- Timestamp:
- Feb 22, 2006 9:33:10 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/core/RpLibrary.h
r200 r205 78 78 std::string nodeComp(); 79 79 std::string nodePath(); 80 81 int isvalid(); 80 82 81 83 void result(); -
trunk/src/core/RpLibrary.cc
r200 r205 990 990 } 991 991 992 /**********************************************************************/ 993 // METHOD: isvalid() 994 /// Returns true if the library is a valid Rappture Object with a document root 995 /** 996 */ 997 998 int 999 RpLibrary::isvalid () 1000 { 1001 if (!this->root) { 1002 // library doesn't exist, return false; 1003 return 0; 1004 } 1005 1006 return 1; 1007 } 1008 992 1009 /* 993 1010 * ---------------------------------------------------------------------- -
trunk/src/tcl/library/Makefile.in
r204 r205 11 11 #======================================================================== 12 12 13 lib_BINARIES=$(Rappture Ext_LIB_FILE)13 lib_BINARIES=$(RapptureLibrary_LIB_FILE) 14 14 BINARIES=$(lib_BINARIES) 15 15 … … 19 19 #======================================================================== 20 20 21 Rappture Ext_SOURCES = \21 RapptureLibrary_SOURCES = \ 22 22 src/RpLibraryTclInterface.cc 23 SOURCES = $(Rappture Ext_SOURCES)23 SOURCES = $(RapptureLibrary_SOURCES) 24 24 25 25 #======================================================================== … … 30 30 #======================================================================== 31 31 32 Rappture Ext_OBJECTS = \32 RapptureLibrary_OBJECTS = \ 33 33 RpLibraryTclInterface.$(OBJEXT) 34 OBJECTS = $(Rappture Ext_OBJECTS)35 36 #======================================================================== 37 # The substitution of "Rappture Ext_LIB_FILE" into the variable name below34 OBJECTS = $(RapptureLibrary_OBJECTS) 35 36 #======================================================================== 37 # The substitution of "RapptureLibrary_LIB_FILE" into the variable name below 38 38 # let's us refer to the objects for the library without knowing the name 39 39 # of the library in advance. It also lets us use the "$@" variable in … … 42 42 #======================================================================== 43 43 44 Rappture Ext_LIB_FILE = @RapptureExt_LIB_FILE@45 $(Rappture Ext_LIB_FILE)_OBJECTS = $(RapptureExt_OBJECTS)44 RapptureLibrary_LIB_FILE = @RapptureLibrary_LIB_FILE@ 45 $(RapptureLibrary_LIB_FILE)_OBJECTS = $(RapptureLibrary_OBJECTS) 46 46 47 47 #======================================================================== … … 228 228 # above. 229 229 # 230 # $(Rappture Ext_LIB_FILE) should be listed as part of the BINARIES variable230 # $(RapptureLibrary_LIB_FILE) should be listed as part of the BINARIES variable 231 231 # at the top of the Makefile. That will ensure that this target is built 232 232 # when you run "make binaries". … … 236 236 #======================================================================== 237 237 238 $(Rappture Ext_LIB_FILE): $(RapptureExt_OBJECTS)239 -rm -f $(Rappture Ext_LIB_FILE)238 $(RapptureLibrary_LIB_FILE): $(RapptureLibrary_OBJECTS) 239 -rm -f $(RapptureLibrary_LIB_FILE) 240 240 @MAKE_LIB@ -lrappture 241 $(RANLIB) $(Rappture Ext_LIB_FILE) -lrappture241 $(RANLIB) $(RapptureLibrary_LIB_FILE) -lrappture 242 242 243 243 #======================================================================== … … 320 320 else :; fi; \ 321 321 done 322 $(mkinstalldirs) $(pkglibdir)/scripts323 @for i in $(srcdir)/scripts/*.tcl; do \324 echo "Installing $$i" ; \325 $(INSTALL_DATA) $$i $(DESTDIR)$(pkglibdir)/scripts ; \326 done;327 $(TCLSH_PROG) $(srcdir)/cf/mkindex.tcl $(DESTDIR)$(pkglibdir)/scripts328 $(mkinstalldirs) $(pkglibdir)/scripts/images329 @for i in $(srcdir)/scripts/images/*.gif; do \330 echo "Installing $$i" ; \331 $(INSTALL_DATA) $$i $(DESTDIR)$(pkglibdir)/scripts/images ; \332 done;333 322 $(INSTALL_DATA) pkgIndex.tcl $(DESTDIR)$(pkglibdir)/pkgIndex.tcl 334 323 $(INSTALL_DATA) init.tcl $(DESTDIR)$(pkglibdir)/init.tcl -
trunk/src/tcl/library/README
r204 r205 1 1 to compile: 2 2 ./configure CC=g++ --prefix=/opt/rappture --with-tcl=/opt/rappture/lib --with-tclinclude=/opt/rappture/include 3 make 3 make all install 4 4 5 5 within tclsh 6 package require BLT 7 load libRapptureExt1.0.so 8 6 package require RapptureLibrary -
trunk/src/tcl/library/configure
r204 r205 273 273 274 274 ac_unique_file="src/RpLibraryTclInterface.cc" 275 ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA SET_MAKE RANLIB ac_ct_RANLIB build build_cpu build_vendor build_os host host_cpu host_vendor host_os CYGPATH TCL_INCLUDES TCL_BIN_DIR TCL_SRC_DIR TCL_LIB_FILE TCL_LIBS TCL_DEFS TCL_SHLIB_LD_LIBS TCL_EXTRA_CFLAGS TCL_LD_FLAGS TCL_STUB_LIB_FILE TCL_LIB_SPEC TCL_BUILD_LIB_SPEC TCL_STUB_LIB_SPEC TCL_BUILD_STUB_LIB_SPEC CLEANFILES CC CFLAGS ac_ct_CC CFLAGS_DEBUG CFLAGS_OPTIMIZE STLIB_LD SHLIB_LD SHLIB_CFLAGS SHLIB_LDFLAGS TCL_DBGX CFLAGS_DEFAULT LDFLAGS_DEFAULT MAKE_LIB MAKE_SHARED_LIB MAKE_STATIC_LIB Rappture Ext_LIB_FILE SHLIB_LD_LIBS TCLSH_PROG PACKAGE VERSION PATCHLEVEL EXACT_VERSION NODOT_VERSION LIBOBJS LTLIBOBJS'275 ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA SET_MAKE RANLIB ac_ct_RANLIB build build_cpu build_vendor build_os host host_cpu host_vendor host_os CYGPATH TCL_INCLUDES TCL_BIN_DIR TCL_SRC_DIR TCL_LIB_FILE TCL_LIBS TCL_DEFS TCL_SHLIB_LD_LIBS TCL_EXTRA_CFLAGS TCL_LD_FLAGS TCL_STUB_LIB_FILE TCL_LIB_SPEC TCL_BUILD_LIB_SPEC TCL_STUB_LIB_SPEC TCL_BUILD_STUB_LIB_SPEC CLEANFILES CC CFLAGS ac_ct_CC CFLAGS_DEBUG CFLAGS_OPTIMIZE STLIB_LD SHLIB_LD SHLIB_CFLAGS SHLIB_LDFLAGS TCL_DBGX CFLAGS_DEFAULT LDFLAGS_DEFAULT MAKE_LIB MAKE_SHARED_LIB MAKE_STATIC_LIB RapptureLibrary_LIB_FILE SHLIB_LD_LIBS TCLSH_PROG PACKAGE VERSION PATCHLEVEL EXACT_VERSION NODOT_VERSION LIBOBJS LTLIBOBJS' 276 276 ac_subst_files='' 277 277 … … 1304 1304 #-------------------------------------------------------------------- 1305 1305 1306 PACKAGE=Rappture Ext1306 PACKAGE=RapptureLibrary 1307 1307 1308 1308 MAJOR_VERSION=1 … … 4281 4281 s,@MAKE_SHARED_LIB@,$MAKE_SHARED_LIB,;t t 4282 4282 s,@MAKE_STATIC_LIB@,$MAKE_STATIC_LIB,;t t 4283 s,@Rappture Ext_LIB_FILE@,$RapptureExt_LIB_FILE,;t t4283 s,@RapptureLibrary_LIB_FILE@,$RapptureLibrary_LIB_FILE,;t t 4284 4284 s,@SHLIB_LD_LIBS@,$SHLIB_LD_LIBS,;t t 4285 4285 s,@TCLSH_PROG@,$TCLSH_PROG,;t t -
trunk/src/tcl/library/configure.in
r204 r205 24 24 #-------------------------------------------------------------------- 25 25 26 PACKAGE=Rappture Ext26 PACKAGE=RapptureLibrary 27 27 28 28 MAJOR_VERSION=1 … … 316 316 #-------------------------------------------------------------------- 317 317 318 AC_SUBST(Rappture Ext_LIB_FILE)318 AC_SUBST(RapptureLibrary_LIB_FILE) 319 319 AC_SUBST(SHLIB_LD_LIBS) 320 320 -
trunk/src/tcl/library/init.tcl.in
r204 r205 1 1 # ---------------------------------------------------------------------- 2 # Rappture GUI - scripts and C extensions required for Rappture GUI2 # RapptureLibrary - Tcl extensions to C++ core Rappture Library 3 3 # ---------------------------------------------------------------------- 4 4 # This file initializes the package when it is loaded by "package … … 6 6 # for other scripts. 7 7 # ====================================================================== 8 # AUTHOR: Michael McLennan, Purdue University9 # Copyright (c) 200 4-2006 Purdue Research Foundation8 # AUTHOR: Derrick Kearney, Purdue University 9 # Copyright (c) 2005-2006 Purdue Research Foundation 10 10 # 11 11 # See the file "license.terms" for information on usage and 12 12 # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. 13 13 # ====================================================================== 14 proc Rappture GUI_init {} {14 proc RapptureLibrary_init {} { 15 15 global auto_path 16 16 global rappture_library … … 19 19 20 20 set dir [file dirname [info script]] 21 22 set rappture_library [file join $dir scripts]23 lappend auto_path $rappture_library21 22 # set rappture_library [file join $dir scripts] 23 # lappend auto_path $rappture_library 24 24 25 25 set suffix [info sharedlibextension] 26 set library [file join $dir .. libRappture GUI@VERSION@${suffix}]27 load $library RapptureGUI26 set library [file join $dir .. libRapptureLibrary@VERSION@${suffix}] 27 load $library 28 28 29 29 namespace eval Rappture { 30 31 30 variable version @EXACT_VERSION@ 31 variable patchlevel @PATCHLEVEL@ 32 32 } 33 33 34 package provide Rappture GUI@VERSION@35 rename Rappture GUI_init ""34 package provide RapptureLibrary @VERSION@ 35 rename RapptureLibrary_init "" 36 36 } 37 Rappture GUI_init37 RapptureLibrary_init -
trunk/src/tcl/library/pkgIndex.tcl.in
r204 r205 1 # this file identifies Rappture GUIas a Tcl package2 package ifneeded Rappture GUI@VERSION@ [list source [file join $dir init.tcl]]1 # this file identifies RapptureLibrary as a Tcl package 2 package ifneeded RapptureLibrary @VERSION@ [list source [file join $dir init.tcl]] -
trunk/src/tcl/library/src/RpLibraryTclInterface.cc
r204 r205 16 16 */ 17 17 #include <tcl.h> 18 #include <stdexcept> 19 // #include <typeinfo.h> 18 20 #include "core/RpLibrary.h" 19 21 … … 24 26 #include "bltInt.h" 25 27 26 EXTERN int Rappture ext_Init _ANSI_ARGS_((Tcl_Interp * interp));28 EXTERN int Rappturelibrary_Init _ANSI_ARGS_((Tcl_Interp * interp)); 27 29 28 30 static int RpLibraryCmd _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp, … … 32 34 int argc, const char* argv[] )); 33 35 36 static int RpTclLibChild _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp, 37 int argc, const char *argv[] )); 38 static int RpTclLibCopy _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp, 39 int argc, const char *argv[] )); 34 40 static int RpTclLibElem _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp, 35 41 int argc, const char *argv[] )); 42 static int RpTclLibGet _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp, 43 int argc, const char *argv[] )); 36 44 static int RpTclLibParent _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp, 37 45 int argc, const char *argv[] )); 38 static int RpTclLibChild _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp,39 int argc, const char *argv[] ));40 static int RpTclLibGet _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp,41 int argc, const char *argv[] ));42 46 static int RpTclLibPut _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp, 43 47 int argc, const char *argv[] )); 44 static int RpTclLibCopy _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp,45 int argc, const char *argv[] ));46 48 static int RpTclLibRemove _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp, 49 int argc, const char *argv[] )); 50 static int RpTclLibResult _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp, 47 51 int argc, const char *argv[] )); 48 52 static int RpTclLibXml _ANSI_ARGS_(( ClientData cdata, Tcl_Interp *interp, … … 52 56 static std::string rpLib2command _ANSI_ARGS_(( Tcl_Interp *interp, 53 57 RpLibrary* newRpLibObj )); 54 static int print_library_howto _ANSI_ARGS_((const char** argv));55 static int print_libcmds_howto _ANSI_ARGS_((const char** argv));56 58 57 59 // member function, function pointer mainly used in 'element' implementation … … 68 70 {"put", 2, (Blt_Op)RpTclLibPut, 2, 8, 69 71 "?-append yes? ?-id num? ?<path>? <string>",}, 70 {"remove", 1, (Blt_Op)RpTclLibRemove, 2, 3, "?<path>?",}, 72 {"remove", 3, (Blt_Op)RpTclLibRemove, 2, 3, "?<path>?",}, 73 {"result", 3, (Blt_Op)RpTclLibResult, 2, 2, "",}, 71 74 {"xml", 1, (Blt_Op)RpTclLibXml, 2, 2, "",}, 72 75 }; … … 88 91 89 92 int 90 Rappture ext_Init(Tcl_Interp *interp)91 { 92 93 Tcl_CreateCommand(interp, "::Rappture::library _test",93 Rappturelibrary_Init(Tcl_Interp *interp) 94 { 95 96 Tcl_CreateCommand(interp, "::Rappture::library", 94 97 RpLibraryCmd, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); 95 98 96 99 return TCL_OK; 97 100 } 101 102 /* 103 * 104 * USAGE: library <file> 105 * USAGE: library standard 106 * USAGE: library isvalid <object> 107 * 108 */ 98 109 99 110 int … … 104 115 { 105 116 RpLibrary *rpptr = NULL; 106 std::string libName = "";; 117 RpLibrary *testObj = NULL; 118 std::string libName = ""; 119 int noerr = 0; 120 Tcl_CmdInfo* infoPtr = NULL; // pointer to the command info 121 122 if ( (argc > 2) && (strncmp(argv[1],"isvalid",7) == 0) ) { 123 if (argc != 3) { 124 std::cout << "wrong # args: should be \"" << argv[0] 125 << " isvalid object\"" << std::endl; 126 return TCL_ERROR; 127 } 128 129 libName = std::string(argv[2]); 130 std::cout << "argv[2] = " << argv[2] << std::endl; 131 std::cout << "interp = " << interp << std::endl; 132 noerr = Tcl_GetCommandInfo(interp, libName.c_str(), infoPtr); 133 std::cout << "interp = " << interp << std::endl; 134 if (noerr && infoPtr) { 135 testObj = (RpLibrary*) (infoPtr->clientData); 136 // if ( (testObj) && (typeid(RpLibrary) == typeid(testObj)) ) { 137 if (testObj) { 138 // return testObj->isvalid(); 139 // need a way to try this and catch any errors 140 try { 141 testObj->isvalid(); 142 return 1; // return true 143 } 144 catch (const std::exception& e) { 145 return 0; // return false 146 } 147 } 148 else { 149 return 0; // return false 150 } 151 } 152 else { 153 return 0; // return false 154 } 155 } 107 156 108 157 if (argc != 2) { 109 print_library_howto(argv); 110 return TCL_ERROR; 111 } 112 158 std::cout << "usage: " << argv[0] << " <xmlfile>" << std::endl; 159 return TCL_ERROR; 160 } 161 162 // create a new command 113 163 rpptr = new RpLibrary(argv[1]); 114 164 … … 144 194 145 195 if (argc < 2) { 146 print_libcmds_howto(argv);196 std::cout <<"usage: "<< argv[0] <<" <command> <arg-list>"<< std::endl; 147 197 return TCL_ERROR; 148 198 } … … 158 208 } 159 209 160 int print_library_howto (const char **argv) 161 { 162 std::cout << "usage: " << argv[0] << " <xmlfile>" << std::endl; 163 return TCL_OK; 164 } 165 166 int print_libcmds_howto (const char **argv) 167 { 168 std::cout << "usage: " << argv[0] << " <command> <arg-list>" << std::endl; 169 170 return TCL_OK; 171 } 172 173 int 174 RpTclLibElem ( ClientData cdata, 210 int 211 RpTclLibChild ( ClientData cdata, 175 212 Tcl_Interp *interp, 176 213 int argc, … … 178 215 { 179 216 std::string path = ""; // path of where to place data inside xml tree 217 std::string type = ""; // type of nodes to be returned 180 218 std::string retStr = ""; // path of where to place data inside xml tree 181 219 int nextarg = 2; // start parsing using the '2'th argument 182 int opt_argc = 1; // max number of optional parameters220 int opt_argc = 2; // max number of optional parameters 183 221 int argsLeft = 0; // temp variable for calculation 184 222 … … 225 263 } 226 264 } 265 else if (strncmp(argv[nextarg],"-type",5) == 0) { 266 nextarg++; 267 type = std::string(argv[nextarg]); 268 nextarg++; 269 } 227 270 else { 228 271 Tcl_AppendResult(interp, "bad option \"", argv[nextarg], … … 243 286 } 244 287 245 // call the rappture library element function 246 node = ((RpLibrary*) cdata)->element(path); 247 if (node) { 248 249 // clear any previous result in the interpreter 250 Tcl_ResetResult(interp); 251 252 if (asProc) { 253 // evaluate the "-as" flag on the returned node 254 retStr = (node->*asProc)(); 255 } 256 else { 257 // create a new command for the new rappture object 258 retStr = rpLib2command(interp, node); 259 } 260 // store the new result string in the interpreter 261 Tcl_AppendResult(interp, retStr.c_str(), (char*)NULL); 262 } 263 264 265 return TCL_OK; 266 } 267 268 int 269 RpTclLibParent ( ClientData cdata, 270 Tcl_Interp *interp, 271 int argc, 272 const char *argv[] ) 273 { 274 288 // call the rappture library children function 289 while ( (node = ((RpLibrary*) cdata)->children(path,node,type)) ) { 290 if (node) { 291 292 // clear any previous result in the interpreter 293 // Tcl_ResetResult(interp); 294 295 if (asProc) { 296 // evaluate the "-as" flag on the returned node 297 retStr = (node->*asProc)(); 298 } 299 else { 300 // create a new command for the new rappture object 301 retStr = rpLib2command(interp, node); 302 } 303 304 // store the new result string in the interpreter 305 Tcl_AppendElement(interp,retStr.c_str()); 306 } 307 } 308 309 return TCL_OK; 310 } 311 312 int 313 RpTclLibCopy ( ClientData cdata, 314 Tcl_Interp *interp, 315 int argc, 316 const char *argv[] ) 317 { 318 std::string fromPath = ""; // path of where to copy data from 319 std::string toPath = ""; // path of where to copy data to 320 std::string from = ""; // string that should == "from" 321 std::string fromObjStr = ""; // string that represents the 322 // string name of the object 323 RpLibrary* fromObj = NULL; 324 int nextarg = 2; // start parsing using the '2'th argument 325 int argsLeft = 0; // temp variable for calculation 326 int noerr = 0; // err flag for Tcl_GetCommandInfo 327 Tcl_CmdInfo* infoPtr = NULL; // pointer to the command info 328 329 toPath = std::string(argv[nextarg++]); 330 from = std::string(argv[nextarg++]); 331 332 argsLeft = (argc-nextarg); 333 if (argsLeft == 2) { 334 fromObjStr = std::string(argv[nextarg++]); 335 noerr = Tcl_GetCommandInfo(interp, fromObjStr.c_str(), infoPtr); 336 if (noerr && infoPtr) { 337 fromObj = (RpLibrary*) (infoPtr->clientData); 338 } 339 fromObj = NULL; // gotta figure out how to get the actual lib here 340 fromPath = std::string(argv[nextarg++]); 341 } 342 else if (argsLeft == 1) { 343 fromPath = std::string(argv[nextarg++]); 344 } 345 else { 346 Tcl_AppendResult(interp, 347 "wrong # args: should be \"copy path from ?xmlobj? path\"", 348 (char*)NULL); 349 return TCL_ERROR; 350 } 351 352 if (from != "from") { 353 Tcl_AppendResult(interp, 354 "bad syntax: should be \"copy path from ?xmlobj? path\"", 355 (char*)NULL); 356 return TCL_ERROR; 357 } 358 359 // call the rappture library copy function 360 ((RpLibrary*) cdata)->copy(toPath, fromPath, fromObj); 361 362 // clear any previous result in the interpreter 363 // store the new result in the interpreter 364 Tcl_ResetResult(interp); 365 Tcl_AppendResult(interp, "", (char*)NULL); 366 367 return TCL_OK; 368 } 369 370 int 371 RpTclLibElem ( ClientData cdata, 372 Tcl_Interp *interp, 373 int argc, 374 const char *argv[] ) 375 { 275 376 std::string path = ""; // path of where to place data inside xml tree 276 377 std::string retStr = ""; // path of where to place data inside xml tree … … 339 440 } 340 441 341 // call the rappture library parent function342 node = ((RpLibrary*) cdata)-> parent(path);442 // call the rappture library element function 443 node = ((RpLibrary*) cdata)->element(path); 343 444 if (node) { 344 445 … … 356 457 // store the new result string in the interpreter 357 458 Tcl_AppendResult(interp, retStr.c_str(), (char*)NULL); 358 359 } 360 361 362 return TCL_OK; 363 } 364 365 int 366 RpTclLibChild ( ClientData cdata, 367 Tcl_Interp *interp, 368 int argc, 369 const char *argv[] ) 370 { 459 } 460 461 462 return TCL_OK; 463 } 464 465 int 466 RpTclLibGet ( ClientData cdata, 467 Tcl_Interp *interp, 468 int argc, 469 const char *argv[] ) 470 { 471 472 std::string retStr = ""; // return value of rappture get fxn 473 std::string path = ""; 474 475 if (argc > 2) { 476 path = std::string(argv[2]); 477 } 478 479 // call the Rappture Library Get Function 480 retStr = ((RpLibrary*) cdata)->getString(path); 481 482 // clear any previous result in the interpreter 483 // store the new result in the interpreter 484 Tcl_ResetResult(interp); 485 Tcl_AppendResult(interp, retStr.c_str(), (char*)NULL); 486 487 return TCL_OK; 488 } 489 490 int 491 RpTclLibParent ( ClientData cdata, 492 Tcl_Interp *interp, 493 int argc, 494 const char *argv[] ) 495 { 496 371 497 std::string path = ""; // path of where to place data inside xml tree 372 std::string type = ""; // type of nodes to be returned373 498 std::string retStr = ""; // path of where to place data inside xml tree 374 499 int nextarg = 2; // start parsing using the '2'th argument 375 int opt_argc = 2; // max number of optional parameters500 int opt_argc = 1; // max number of optional parameters 376 501 int argsLeft = 0; // temp variable for calculation 377 502 … … 418 543 } 419 544 } 420 else if (strncmp(argv[nextarg],"-type",5) == 0) {421 nextarg++;422 type = std::string(argv[nextarg]);423 nextarg++;424 }425 545 else { 426 546 Tcl_AppendResult(interp, "bad option \"", argv[nextarg], … … 441 561 } 442 562 443 // call the rappture library children function 444 while ( (node = ((RpLibrary*) cdata)->children(path,node,type)) ) { 445 if (node) { 446 447 // clear any previous result in the interpreter 448 // Tcl_ResetResult(interp); 449 450 if (asProc) { 451 // evaluate the "-as" flag on the returned node 452 retStr = (node->*asProc)(); 453 } 454 else { 455 // create a new command for the new rappture object 456 retStr = rpLib2command(interp, node); 457 } 458 459 // store the new result string in the interpreter 460 Tcl_AppendElement(interp,retStr.c_str()); 461 } 462 } 463 464 return TCL_OK; 465 } 466 467 int 468 RpTclLibGet ( ClientData cdata, 469 Tcl_Interp *interp, 470 int argc, 471 const char *argv[] ) 472 { 473 474 std::string retStr = ""; // return value of rappture get fxn 475 std::string path = ""; 476 477 if (argc > 2) { 478 path = std::string(argv[2]); 479 } 480 481 // call the Rappture Library Get Function 482 retStr = ((RpLibrary*) cdata)->getString(path); 483 484 // clear any previous result in the interpreter 485 // store the new result in the interpreter 486 Tcl_ResetResult(interp); 487 Tcl_AppendResult(interp, retStr.c_str(), (char*)NULL); 563 // call the rappture library parent function 564 node = ((RpLibrary*) cdata)->parent(path); 565 if (node) { 566 567 // clear any previous result in the interpreter 568 Tcl_ResetResult(interp); 569 570 if (asProc) { 571 // evaluate the "-as" flag on the returned node 572 retStr = (node->*asProc)(); 573 } 574 else { 575 // create a new command for the new rappture object 576 retStr = rpLib2command(interp, node); 577 } 578 // store the new result string in the interpreter 579 Tcl_AppendResult(interp, retStr.c_str(), (char*)NULL); 580 581 } 582 488 583 489 584 return TCL_OK; … … 552 647 553 648 int 554 RpTclLibCopy ( ClientData cdata, 555 Tcl_Interp *interp, 556 int argc, 557 const char *argv[] ) 558 { 559 std::string fromPath = ""; // path of where to copy data from 560 std::string toPath = ""; // path of where to copy data to 561 std::string from = ""; // string that should == "from" 562 std::string fromObjStr = ""; // string that represents the 563 // string name of the object 564 RpLibrary* fromObj = NULL; 565 int nextarg = 2; // start parsing using the '2'th argument 566 int argsLeft = 0; // temp variable for calculation 567 568 toPath = std::string(argv[nextarg++]); 569 from = std::string(argv[nextarg++]); 570 571 argsLeft = (argc-nextarg); 572 if (argsLeft == 2) { 573 fromObjStr = std::string(argv[nextarg++]); 574 fromObj = NULL; // gotta figure out how to get the actual lib here 575 fromPath = std::string(argv[nextarg++]); 576 } 577 else if (argsLeft == 1) { 578 fromPath = std::string(argv[nextarg++]); 649 RpTclLibRemove ( ClientData cdata, 650 Tcl_Interp *interp, 651 int argc, 652 const char *argv[] ) 653 { 654 655 std::string path = std::string(""); // path of where to copy data from 656 int nextarg = 2; 657 658 659 if (argc == 2) { 660 path = std::string(""); 661 } 662 else if (argc == 3) { 663 path = std::string(argv[nextarg]); 579 664 } 580 665 else { 581 666 Tcl_AppendResult(interp, 582 "wrong # args: should be \" copy path from ?xmlobj? path\"",667 "wrong # args: should be \"remove ?path?\"", 583 668 (char*)NULL); 584 669 return TCL_ERROR; 585 670 } 586 671 587 if (from != "from") { 588 Tcl_AppendResult(interp, 589 "bad syntax: should be \"copy path from ?xmlobj? path\"", 590 (char*)NULL); 591 return TCL_ERROR; 592 } 593 594 595 596 // call the rappture library put function 597 ((RpLibrary*) cdata)->copy(toPath, fromPath,fromObj); 672 // call the rappture library remove function 673 ((RpLibrary*) cdata)->remove(path); 598 674 599 675 // clear any previous result in the interpreter … … 606 682 607 683 int 608 RpTclLibRemove ( ClientData cdata, 609 Tcl_Interp *interp, 610 int argc, 611 const char *argv[] ) 612 { 613 614 std::string path = std::string(""); // path of where to copy data from 615 int nextarg = 2; 616 617 618 if (argc == 2) { 619 path = std::string(""); 620 } 621 else if (argc == 3) { 622 path = std::string(argv[nextarg]); 684 RpTclLibResult ( ClientData cdata, 685 Tcl_Interp *interp, 686 int argc, 687 const char *argv[] ) 688 { 689 if (argc == 1) { 690 // call the rappture library result function 691 ((RpLibrary*) cdata)->result(); 623 692 } 624 693 else { 625 694 Tcl_AppendResult(interp, 626 "wrong # args: should be \"re move ?path?\"",695 "wrong # args: should be \"result \"", 627 696 (char*)NULL); 628 697 return TCL_ERROR; 629 698 } 630 699 631 // call the rappture library put function632 ((RpLibrary*) cdata)->remove(path);633 700 634 701 // clear any previous result in the interpreter … … 649 716 std::string retStr = ""; // return value of rappture get fxn 650 717 651 // call the Rappture Library GetFunction718 // call the Rappture Library xml Function 652 719 retStr = ((RpLibrary*) cdata)->xml(); 653 720 -
trunk/src/tcl/library/tcl_test.tcl
r204 r205 1 package require BLT 2 load libRapptureExt1.0.so 1 package require RapptureLibrary 3 2 4 Rappture::library _test"rplib_test.xml"3 Rappture::library "rplib_test.xml" 5 4 6 5 puts [library0 get input.(max).current] … … 70 69 puts "Printing XML" 71 70 puts [library0 xml] 71 72 puts "opening new library" 73 set libObj1 [Rappture::library "rplib_test.xml"] 74 set libObj2 [Rappture::library "rplib_test.xml"] 75 puts "libObj1 = " 76 puts $libObj1 77 78 puts "COPYING BETWEEN LIBS" 79 $libObj1 copy "input.test" from libObj2 "input.(max)" 80 puts [$libObj1 xml] 81 82 #puts [$libObj xml] 83 puts "isvalid test1: " 84 # puts [Rappture::library isvalid $libObj1] 85 puts "isvalid test2: " 86 # puts [Rappture::library isvalid library0]
Note: See TracChangeset
for help on using the changeset viewer.