PageRenderTime 253ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1-3-26/SWIG/Lib/tcl/swigtcl8.swg

#
Unknown | 786 lines | 722 code | 64 blank | 0 comment | 0 complexity | 94d10d0ad7d7e4df156fe5bda97fc004 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /*
  2. * $Header$
  3. *
  4. * swigtcl8.swg
  5. */
  6. #include <tcl.h>
  7. #include <errno.h>
  8. #include <stdlib.h>
  9. #include <stdarg.h>
  10. #include <ctype.h>
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. /* Constant table */
  15. #define SWIG_TCL_INT 1
  16. #define SWIG_TCL_FLOAT 2
  17. #define SWIG_TCL_STRING 3
  18. #define SWIG_TCL_POINTER 4
  19. #define SWIG_TCL_BINARY 5
  20. /* Flags for pointer conversion */
  21. #define SWIG_POINTER_EXCEPTION 0x1
  22. #define SWIG_POINTER_DISOWN 0x2
  23. /* Swig fail macro */
  24. #define SWIG_fail goto fail
  25. /* Constant information structure */
  26. typedef struct swig_const_info {
  27. int type;
  28. char *name;
  29. long lvalue;
  30. double dvalue;
  31. void *pvalue;
  32. swig_type_info **ptype;
  33. } swig_const_info;
  34. typedef int (*swig_wrapper)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []);
  35. typedef int (*swig_wrapper_func)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []);
  36. typedef char *(*swig_variable_func)(ClientData, Tcl_Interp *, char *, char *, int);
  37. typedef void (*swig_delete_func)(ClientData);
  38. typedef struct swig_method {
  39. const char *name;
  40. swig_wrapper method;
  41. } swig_method;
  42. typedef struct swig_attribute {
  43. const char *name;
  44. swig_wrapper getmethod;
  45. swig_wrapper setmethod;
  46. } swig_attribute;
  47. typedef struct swig_class {
  48. const char *name;
  49. swig_type_info **type;
  50. swig_wrapper constructor;
  51. void (*destructor)(void *);
  52. swig_method *methods;
  53. swig_attribute *attributes;
  54. struct swig_class **bases;
  55. char **base_names;
  56. swig_module_info *module;
  57. } swig_class;
  58. typedef struct swig_instance {
  59. Tcl_Obj *thisptr;
  60. void *thisvalue;
  61. swig_class *classptr;
  62. int destroy;
  63. Tcl_Command cmdtok;
  64. } swig_instance;
  65. #define SWIG_NewPointerObj(ptr, type, flags) \
  66. SWIG_Tcl_NewPointerObj(ptr, type, flags)
  67. #define SWIG_ConvertPtr(oc, ptr, ty, flags) \
  68. SWIG_Tcl_ConvertPtr(interp, oc, ptr, ty, flags)
  69. #define SWIG_ConvertPtrFromString(c, ptr, ty, flags) \
  70. SWIG_Tcl_ConvertPtrFromString(interp, c, ptr, ty, flags)
  71. #define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) \
  72. SWIG_Tcl_ConvertPacked(interp, obj, ptr, sz, ty, flags)
  73. #define SWIG_MakePtr(c, ptr, ty, flags) \
  74. SWIG_Tcl_MakePtr(c, ptr, ty, flags)
  75. #define SWIG_NewPackedObj(ptr, sz, type, flags) \
  76. SWIG_Tcl_NewPackedObj(ptr, sz, type, flags)
  77. #define SWIG_GetArgs SWIG_Tcl_GetArgs
  78. #define SWIG_PointerTypeFromString(c) \
  79. SWIG_Tcl_PointerTypeFromString(c)
  80. #define SWIG_Acquire(ptr) \
  81. SWIG_Tcl_Acquire(ptr)
  82. #define SWIG_Disown(ptr) \
  83. SWIG_Tcl_Disown(ptr)
  84. #define SWIG_Thisown(ptr) \
  85. SWIG_Tcl_Thisown(ptr)
  86. #define SWIG_InstallConstants(interp, constants) \
  87. SWIG_Tcl_InstallConstants(interp, constants)
  88. #define SWIG_GetConstant(key) \
  89. SWIG_Tcl_GetConstant(key)
  90. #define SWIG_NewInstanceObj(thisvalue, type, flags) \
  91. SWIG_Tcl_NewInstanceObj(interp, thisvalue, type, flags)
  92. #define SWIG_ObjectConstructor SWIG_Tcl_ObjectConstructor
  93. #define SWIG_MethodCommand SWIG_Tcl_MethodCommand
  94. #define SWIG_ObjectDelete SWIG_Tcl_ObjectDelete
  95. /* Runtime API */
  96. #define SWIG_GetModule(clientdata) SWIG_Tcl_GetModule((Tcl_Interp *) (clientdata))
  97. #define SWIG_SetModule(clientdata, pointer) SWIG_Tcl_SetModule((Tcl_Interp *) (clientdata), pointer)
  98. #define SWIG_MODULE_CLIENTDATA_TYPE Tcl_Interp *
  99. /* Object support */
  100. static Tcl_HashTable swigobjectTable;
  101. static int swigobjectTableinit = 0;
  102. /* Acquire ownership of a pointer */
  103. static void
  104. SWIG_Tcl_Acquire(void *ptr) {
  105. Tcl_HashEntry *entryPtr;
  106. int newobj;
  107. if (!swigobjectTableinit) {
  108. Tcl_InitHashTable(&swigobjectTable, TCL_ONE_WORD_KEYS);
  109. swigobjectTableinit = 1;
  110. }
  111. entryPtr = Tcl_CreateHashEntry(&swigobjectTable, (char *) ptr, &newobj);
  112. }
  113. /* Disown a pointer. Returns 1 if we owned it to begin with */
  114. static int
  115. SWIG_Tcl_Disown(void *ptr) {
  116. Tcl_HashEntry *entryPtr;
  117. if (!swigobjectTableinit) return 0;
  118. entryPtr = Tcl_FindHashEntry(&swigobjectTable, (char *) ptr);
  119. if (entryPtr) {
  120. Tcl_DeleteHashEntry(entryPtr);
  121. return 1;
  122. }
  123. return 0;
  124. }
  125. static int
  126. SWIG_Tcl_Thisown(void *ptr) {
  127. if (!swigobjectTableinit) return 0;
  128. if (Tcl_FindHashEntry(&swigobjectTable, (char *) ptr)) {
  129. return 1;
  130. }
  131. return 0;
  132. }
  133. /* Convert a pointer value */
  134. static int
  135. SWIG_Tcl_ConvertPtrFromString(Tcl_Interp *interp, const char *c, void **ptr, swig_type_info *ty, int flags) {
  136. swig_cast_info *tc;
  137. /* Pointer values must start with leading underscore */
  138. while (*c != '_') {
  139. *ptr = (void *) 0;
  140. if (strcmp(c,"NULL") == 0) return TCL_OK;
  141. /* Hmmm. It could be an object name. */
  142. if (Tcl_VarEval(interp,c," cget -this", (char *) NULL) == TCL_OK) {
  143. Tcl_Obj *result = Tcl_GetObjResult(interp);
  144. c = Tcl_GetStringFromObj(result, NULL);
  145. continue;
  146. }
  147. Tcl_ResetResult(interp);
  148. if (flags & SWIG_POINTER_EXCEPTION)
  149. Tcl_SetResult(interp, (char *) "Type error. Expected a pointer", TCL_STATIC);
  150. return TCL_ERROR;
  151. }
  152. c++;
  153. c = SWIG_UnpackData(c,ptr,sizeof(void *));
  154. if (ty) {
  155. tc = SWIG_TypeCheck(c,ty);
  156. if ((!tc) && (flags & SWIG_POINTER_EXCEPTION)) {
  157. Tcl_SetResult(interp, (char *) "Type error. Expected ", TCL_STATIC);
  158. Tcl_AppendElement(interp, (char *) ty->name);
  159. return TCL_ERROR;
  160. } else if (!tc) {
  161. Tcl_ResetResult(interp);
  162. return TCL_ERROR;
  163. }
  164. if (flags & SWIG_POINTER_DISOWN) {
  165. SWIG_Disown((void *) *ptr);
  166. }
  167. *ptr = SWIG_TypeCast(tc,(void *) *ptr);
  168. }
  169. return TCL_OK;
  170. }
  171. /* Convert a pointer value */
  172. static SWIGINLINE int
  173. SWIG_Tcl_ConvertPtr(Tcl_Interp *interp, Tcl_Obj *oc, void **ptr, swig_type_info *ty, int flags) {
  174. return SWIG_Tcl_ConvertPtrFromString(interp, Tcl_GetStringFromObj(oc,NULL), ptr, ty, flags);
  175. }
  176. /* Convert a pointer value */
  177. static char *
  178. SWIG_Tcl_PointerTypeFromString(char *c) {
  179. char d;
  180. /* Pointer values must start with leading underscore. NULL has no type */
  181. if (*c != '_') {
  182. return 0;
  183. }
  184. c++;
  185. /* Extract hex value from pointer */
  186. while ((d = *c)) {
  187. if (!(((d >= '0') && (d <= '9')) || ((d >= 'a') && (d <= 'f')))) break;
  188. c++;
  189. }
  190. return c;
  191. }
  192. /* Convert a packed value value */
  193. static int
  194. SWIG_Tcl_ConvertPacked(Tcl_Interp *interp, Tcl_Obj *obj, void *ptr, int sz, swig_type_info *ty, int flags) {
  195. swig_cast_info *tc;
  196. const char *c;
  197. if (!obj) goto type_error;
  198. c = Tcl_GetStringFromObj(obj,NULL);
  199. /* Pointer values must start with leading underscore */
  200. if (*c != '_') goto type_error;
  201. c++;
  202. c = SWIG_UnpackData(c,ptr,sz);
  203. if (ty) {
  204. tc = SWIG_TypeCheck(c,ty);
  205. if (!tc) goto type_error;
  206. }
  207. return TCL_OK;
  208. type_error:
  209. if (flags) {
  210. if (ty) {
  211. Tcl_SetResult(interp, (char *) "Type error. Expected ", TCL_STATIC);
  212. Tcl_AppendElement(interp, (char *) ty->name);
  213. return TCL_ERROR;
  214. } else {
  215. Tcl_SetResult(interp, (char *) "Expected packed data.", TCL_STATIC);
  216. return TCL_ERROR;
  217. }
  218. }
  219. return TCL_ERROR;
  220. }
  221. /* Take a pointer and convert it to a string */
  222. static void
  223. SWIG_Tcl_MakePtr(char *c, void *ptr, swig_type_info *ty, int flags) {
  224. if (ptr) {
  225. *(c++) = '_';
  226. c = SWIG_PackData(c,&ptr,sizeof(void *));
  227. strcpy(c,ty->name);
  228. } else {
  229. strcpy(c,(char *)"NULL");
  230. }
  231. flags = 0;
  232. }
  233. /* Create a new pointer object */
  234. static SWIGINLINE Tcl_Obj *
  235. SWIG_Tcl_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
  236. Tcl_Obj *robj;
  237. char result[512];
  238. SWIG_MakePtr(result,ptr,type,flags);
  239. robj = Tcl_NewStringObj(result,-1);
  240. return robj;
  241. }
  242. static Tcl_Obj *
  243. SWIG_Tcl_NewPackedObj(void *ptr, int sz, swig_type_info *type, int flags) {
  244. char result[1024];
  245. char *r = result;
  246. if ((2*sz + 1 + strlen(type->name)) > 1000) return 0;
  247. *(r++) = '_';
  248. r = SWIG_PackData(r,ptr,sz);
  249. strcpy(r,type->name);
  250. flags = 0;
  251. return Tcl_NewStringObj(result,-1);
  252. }
  253. static Tcl_HashTable swigconstTable;
  254. static int swigconstTableinit = 0;
  255. /* Install Constants */
  256. static void
  257. SWIG_Tcl_InstallConstants(Tcl_Interp *interp, swig_const_info constants[]) {
  258. int i;
  259. Tcl_Obj *obj;
  260. Tcl_HashEntry *entryPtr;
  261. int newobj;
  262. if (!swigconstTableinit) {
  263. Tcl_InitHashTable(&swigconstTable, TCL_STRING_KEYS);
  264. swigconstTableinit = 1;
  265. }
  266. for (i = 0; constants[i].type; i++) {
  267. switch(constants[i].type) {
  268. case SWIG_TCL_INT:
  269. obj = Tcl_NewIntObj(constants[i].lvalue);
  270. break;
  271. case SWIG_TCL_FLOAT:
  272. obj = Tcl_NewDoubleObj(constants[i].dvalue);
  273. break;
  274. case SWIG_TCL_STRING:
  275. obj = Tcl_NewStringObj((char *) constants[i].pvalue,-1);
  276. break;
  277. case SWIG_TCL_POINTER:
  278. obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
  279. break;
  280. case SWIG_TCL_BINARY:
  281. obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype),0);
  282. break;
  283. default:
  284. obj = 0;
  285. break;
  286. }
  287. if (obj) {
  288. Tcl_ObjSetVar2(interp,Tcl_NewStringObj(constants[i].name,-1), NULL, obj, TCL_GLOBAL_ONLY);
  289. entryPtr = Tcl_CreateHashEntry(&swigconstTable, constants[i].name, &newobj);
  290. Tcl_SetHashValue(entryPtr, (ClientData) obj);
  291. }
  292. }
  293. }
  294. static Tcl_Obj *
  295. SWIG_Tcl_GetConstant(const char *key) {
  296. Tcl_HashEntry *entryPtr;
  297. if (!swigconstTableinit) return 0;
  298. entryPtr = Tcl_FindHashEntry(&swigconstTable, key);
  299. if (entryPtr) {
  300. return (Tcl_Obj *) Tcl_GetHashValue(entryPtr);
  301. }
  302. return 0;
  303. }
  304. /* Get arguments */
  305. static int
  306. SWIG_Tcl_GetArgs(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], const char *fmt, ...) {
  307. int argno = 0, opt = 0;
  308. long tempi;
  309. double tempd;
  310. const char *c;
  311. va_list ap;
  312. void *vptr;
  313. Tcl_Obj *obj = 0;
  314. swig_type_info *ty;
  315. va_start(ap,fmt);
  316. for (c = fmt; (*c && (*c != ':') && (*c != ';')); c++,argno++) {
  317. if (*c == '|') {
  318. opt = 1;
  319. c++;
  320. }
  321. if (argno >= (objc-1)) {
  322. if (!opt) {
  323. Tcl_SetResult(interp, (char *) "Wrong # args. ", TCL_STATIC);
  324. goto argerror;
  325. } else {
  326. va_end(ap);
  327. return TCL_OK;
  328. }
  329. }
  330. vptr = va_arg(ap,void *);
  331. if (vptr) {
  332. if (isupper(*c)) {
  333. obj = SWIG_GetConstant(Tcl_GetStringFromObj(objv[argno+1],0));
  334. if (!obj) obj = objv[argno+1];
  335. } else {
  336. obj = objv[argno+1];
  337. }
  338. switch(*c) {
  339. case 'i': case 'I':
  340. case 'l': case 'L':
  341. case 'h': case 'H':
  342. case 'b': case 'B':
  343. if (Tcl_GetLongFromObj(interp,obj,&tempi) != TCL_OK) goto argerror;
  344. if ((*c == 'i') || (*c == 'I')) *((int *)vptr) = (int)tempi;
  345. else if ((*c == 'l') || (*c == 'L')) *((long *)vptr) = (long)tempi;
  346. else if ((*c == 'h') || (*c == 'H')) *((short*)vptr) = (short)tempi;
  347. else if ((*c == 'b') || (*c == 'B')) *((unsigned char *)vptr) = (unsigned char)tempi;
  348. break;
  349. case 'f': case 'F':
  350. case 'd': case 'D':
  351. if (Tcl_GetDoubleFromObj(interp,obj,&tempd) != TCL_OK) goto argerror;
  352. if ((*c == 'f') || (*c == 'F')) *((float *) vptr) = (float)tempd;
  353. else if ((*c == 'd') || (*c == 'D')) *((double*) vptr) = tempd;
  354. break;
  355. case 's': case 'S':
  356. if (*(c+1) == '#') {
  357. int *vlptr = (int *) va_arg(ap, void *);
  358. *((char **) vptr) = Tcl_GetStringFromObj(obj, vlptr);
  359. c++;
  360. } else {
  361. *((char **)vptr) = Tcl_GetStringFromObj(obj,NULL);
  362. }
  363. break;
  364. case 'c': case 'C':
  365. *((char *)vptr) = *(Tcl_GetStringFromObj(obj,NULL));
  366. break;
  367. case 'p': case 'P':
  368. ty = (swig_type_info *) va_arg(ap, void *);
  369. if (SWIG_Tcl_ConvertPtr(interp, obj, (void **) vptr, ty, SWIG_POINTER_EXCEPTION) == TCL_ERROR) goto argerror;
  370. break;
  371. case 'o': case 'O':
  372. *((Tcl_Obj **)vptr) = objv[argno+1];
  373. break;
  374. default:
  375. break;
  376. }
  377. }
  378. }
  379. if ((*c != ';') && ((objc-1) > argno)) {
  380. Tcl_SetResult(interp, (char *) "Wrong # args.", TCL_STATIC);
  381. goto argerror;
  382. }
  383. va_end(ap);
  384. return TCL_OK;
  385. argerror:
  386. {
  387. char temp[32];
  388. sprintf(temp,"%d", argno+1);
  389. c = strchr(fmt,':');
  390. if (!c) c = strchr(fmt,';');
  391. if (!c) c = (char *)"";
  392. Tcl_AppendResult(interp,c," argument ", temp, NULL);
  393. va_end(ap);
  394. return TCL_ERROR;
  395. }
  396. }
  397. static void
  398. SWIG_Tcl_ObjectDelete(ClientData clientData) {
  399. swig_instance *si = (swig_instance *) clientData;
  400. if ((si) && (si->destroy) && (SWIG_Disown(si->thisvalue))) {
  401. if (si->classptr->destructor) {
  402. (si->classptr->destructor)(si->thisvalue);
  403. }
  404. }
  405. Tcl_DecrRefCount(si->thisptr);
  406. free(si);
  407. }
  408. /* Function to invoke object methods given an instance */
  409. static int
  410. SWIG_Tcl_MethodCommand(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST _objv[]) {
  411. char *method, *attrname;
  412. swig_instance *inst = (swig_instance *) clientData;
  413. swig_method *meth;
  414. swig_attribute *attr;
  415. Tcl_Obj *oldarg;
  416. Tcl_Obj **objv;
  417. int rcode;
  418. swig_class *cls;
  419. swig_class *cls_stack[64];
  420. int cls_stack_bi[64];
  421. int cls_stack_top = 0;
  422. int numconf = 2;
  423. int bi;
  424. objv = (Tcl_Obj **) _objv;
  425. if (objc < 2) {
  426. Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC);
  427. return TCL_ERROR;
  428. }
  429. method = Tcl_GetStringFromObj(objv[1],NULL);
  430. if (strcmp(method,"-acquire") == 0) {
  431. inst->destroy = 1;
  432. SWIG_Acquire(inst->thisvalue);
  433. return TCL_OK;
  434. }
  435. if (strcmp(method,"-disown") == 0) {
  436. if (inst->destroy) {
  437. SWIG_Disown(inst->thisvalue);
  438. }
  439. inst->destroy = 0;
  440. return TCL_OK;
  441. }
  442. if (strcmp(method,"-delete") == 0) {
  443. Tcl_DeleteCommandFromToken(interp,inst->cmdtok);
  444. return TCL_OK;
  445. }
  446. cls_stack[cls_stack_top] = inst->classptr;
  447. cls_stack_bi[cls_stack_top] = -1;
  448. cls = inst->classptr;
  449. while (1) {
  450. bi = cls_stack_bi[cls_stack_top];
  451. cls = cls_stack[cls_stack_top];
  452. if (bi != -1) {
  453. if (!cls->bases[bi] && cls->base_names[bi]) {
  454. /* lookup and cache the base class */
  455. swig_type_info *info = SWIG_TypeQueryModule(cls->module, cls->module, cls->base_names[bi]);
  456. if (info) cls->bases[bi] = (swig_class *) info->clientdata;
  457. }
  458. cls = cls->bases[bi];
  459. if (cls) {
  460. cls_stack_bi[cls_stack_top]++;
  461. cls_stack_top++;
  462. cls_stack[cls_stack_top] = cls;
  463. cls_stack_bi[cls_stack_top] = -1;
  464. continue;
  465. }
  466. }
  467. if (!cls) {
  468. cls_stack_top--;
  469. if (cls_stack_top < 0) break;
  470. else continue;
  471. }
  472. cls_stack_bi[cls_stack_top]++;
  473. meth = cls->methods;
  474. /* Check for methods */
  475. while (meth && meth->name) {
  476. if (strcmp(meth->name,method) == 0) {
  477. oldarg = objv[1];
  478. objv[1] = inst->thisptr;
  479. Tcl_IncrRefCount(inst->thisptr);
  480. rcode = (*meth->method)(clientData,interp,objc,objv);
  481. objv[1] = oldarg;
  482. Tcl_DecrRefCount(inst->thisptr);
  483. return rcode;
  484. }
  485. meth++;
  486. }
  487. /* Check class methods for a match */
  488. if (strcmp(method,"cget") == 0) {
  489. if (objc < 3) {
  490. Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC);
  491. return TCL_ERROR;
  492. }
  493. attrname = Tcl_GetStringFromObj(objv[2],NULL);
  494. attr = cls->attributes;
  495. while (attr && attr->name) {
  496. if ((strcmp(attr->name, attrname) == 0) && (attr->getmethod)) {
  497. oldarg = objv[1];
  498. objv[1] = inst->thisptr;
  499. Tcl_IncrRefCount(inst->thisptr);
  500. rcode = (*attr->getmethod)(clientData,interp,2, objv);
  501. objv[1] = oldarg;
  502. Tcl_DecrRefCount(inst->thisptr);
  503. return rcode;
  504. }
  505. attr++;
  506. }
  507. if (strcmp(attrname, "-this") == 0) {
  508. Tcl_SetObjResult(interp, Tcl_DuplicateObj(inst->thisptr));
  509. return TCL_OK;
  510. }
  511. if (strcmp(attrname, "-thisown") == 0) {
  512. if (SWIG_Thisown(inst->thisvalue)) {
  513. Tcl_SetResult(interp,(char*)"1",TCL_STATIC);
  514. } else {
  515. Tcl_SetResult(interp,(char*)"0",TCL_STATIC);
  516. }
  517. return TCL_OK;
  518. }
  519. } else if (strcmp(method, "configure") == 0) {
  520. int i;
  521. if (objc < 4) {
  522. Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC);
  523. return TCL_ERROR;
  524. }
  525. i = 2;
  526. while (i < objc) {
  527. attrname = Tcl_GetStringFromObj(objv[i],NULL);
  528. attr = cls->attributes;
  529. while (attr && attr->name) {
  530. if ((strcmp(attr->name, attrname) == 0) && (attr->setmethod)) {
  531. oldarg = objv[i];
  532. objv[i] = inst->thisptr;
  533. Tcl_IncrRefCount(inst->thisptr);
  534. rcode = (*attr->setmethod)(clientData,interp,3, &objv[i-1]);
  535. objv[i] = oldarg;
  536. Tcl_DecrRefCount(inst->thisptr);
  537. if (rcode != TCL_OK) return rcode;
  538. numconf += 2;
  539. }
  540. attr++;
  541. }
  542. i+=2;
  543. }
  544. }
  545. }
  546. if (strcmp(method,"configure") == 0) {
  547. if (numconf >= objc) {
  548. return TCL_OK;
  549. } else {
  550. Tcl_SetResult(interp,(char *) "Invalid attribute name.", TCL_STATIC);
  551. return TCL_ERROR;
  552. }
  553. }
  554. if (strcmp(method,"cget") == 0) {
  555. Tcl_SetResult(interp,(char *) "Invalid attribute name.", TCL_STATIC);
  556. return TCL_ERROR;
  557. }
  558. Tcl_SetResult(interp, (char *) "Invalid method. Must be one of: configure cget -acquire -disown -delete", TCL_STATIC);
  559. cls = inst->classptr;
  560. bi = 0;
  561. while (cls) {
  562. meth = cls->methods;
  563. while (meth && meth->name) {
  564. char *cr = (char *) Tcl_GetStringResult(interp);
  565. int meth_len = strlen(meth->name);
  566. char* where = strchr(cr,':');
  567. while(where) {
  568. where = strstr(where, meth->name);
  569. if(where) {
  570. if(where[-1] == ' ' && (where[meth_len] == ' ' || where[meth_len]==0)) {
  571. break;
  572. } else {
  573. where++;
  574. }
  575. }
  576. }
  577. if (!where)
  578. Tcl_AppendElement(interp, (char *) meth->name);
  579. meth++;
  580. }
  581. cls = inst->classptr->bases[bi++];
  582. }
  583. return TCL_ERROR;
  584. }
  585. /* Function to create objects */
  586. static int
  587. SWIG_Tcl_ObjectConstructor(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
  588. Tcl_Obj *newObj = 0;
  589. void *thisvalue = 0;
  590. swig_instance *newinst = 0;
  591. swig_class *classptr = (swig_class *) clientData;
  592. swig_wrapper cons = 0;
  593. char *name = 0;
  594. int firstarg = 0;
  595. int thisarg = 0;
  596. int destroy = 1;
  597. if (!classptr) {
  598. Tcl_SetResult(interp, (char *) "swig: internal runtime error. No class object defined.", TCL_STATIC);
  599. return TCL_ERROR;
  600. }
  601. cons = classptr->constructor;
  602. if (objc > 1) {
  603. char *s = Tcl_GetStringFromObj(objv[1],NULL);
  604. if (strcmp(s,"-this") == 0) {
  605. thisarg = 2;
  606. cons = 0;
  607. } else if (strcmp(s,"-args") == 0) {
  608. firstarg = 1;
  609. } else if (objc == 2) {
  610. firstarg = 1;
  611. name = s;
  612. } else if (objc >= 3) {
  613. char *s1;
  614. name = s;
  615. s1 = Tcl_GetStringFromObj(objv[2],NULL);
  616. if (strcmp(s1,"-this") == 0) {
  617. thisarg = 3;
  618. cons = 0;
  619. } else {
  620. firstarg = 1;
  621. }
  622. }
  623. }
  624. if (cons) {
  625. int result;
  626. result = (*cons)(0, interp, objc-firstarg, &objv[firstarg]);
  627. if (result != TCL_OK) {
  628. return result;
  629. }
  630. newObj = Tcl_DuplicateObj(Tcl_GetObjResult(interp));
  631. if (!name) name = Tcl_GetStringFromObj(newObj,NULL);
  632. } else if (thisarg > 0) {
  633. if (thisarg < objc) {
  634. destroy = 0;
  635. newObj = Tcl_DuplicateObj(objv[thisarg]);
  636. if (!name) name = Tcl_GetStringFromObj(newObj,NULL);
  637. } else {
  638. Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC);
  639. return TCL_ERROR;
  640. }
  641. } else {
  642. Tcl_SetResult(interp, (char *) "No constructor available.", TCL_STATIC);
  643. return TCL_ERROR;
  644. }
  645. if (SWIG_Tcl_ConvertPtr(interp,newObj, (void **) &thisvalue, *(classptr->type), SWIG_POINTER_EXCEPTION) == TCL_ERROR) {
  646. Tcl_DecrRefCount(newObj);
  647. return TCL_ERROR;
  648. }
  649. newinst = (swig_instance *) malloc(sizeof(swig_instance));
  650. newinst->thisptr = newObj;
  651. Tcl_IncrRefCount(newObj);
  652. newinst->thisvalue = thisvalue;
  653. newinst->classptr = classptr;
  654. newinst->destroy = destroy;
  655. if (destroy) {
  656. SWIG_Acquire(thisvalue);
  657. }
  658. newinst->cmdtok = Tcl_CreateObjCommand(interp,name, (swig_wrapper) SWIG_MethodCommand, (ClientData) newinst, (swig_delete_func) SWIG_ObjectDelete);
  659. return TCL_OK;
  660. }
  661. /* This function takes the current result and turns it into an object command */
  662. static Tcl_Obj *
  663. SWIG_Tcl_NewInstanceObj(Tcl_Interp *interp, void *thisvalue, swig_type_info *type, int flags) {
  664. Tcl_Obj *robj = SWIG_NewPointerObj(thisvalue, type,0);
  665. /* Check to see if this pointer belongs to a class or not */
  666. if ((type->clientdata) && (interp)) {
  667. Tcl_CmdInfo ci;
  668. char *name;
  669. name = Tcl_GetStringFromObj(robj,NULL);
  670. if (!Tcl_GetCommandInfo(interp,name, &ci) || (flags)) {
  671. swig_instance *newinst = (swig_instance *) malloc(sizeof(swig_instance));
  672. newinst->thisptr = Tcl_DuplicateObj(robj);
  673. Tcl_IncrRefCount(newinst->thisptr);
  674. newinst->thisvalue = thisvalue;
  675. newinst->classptr = (swig_class *) type->clientdata;
  676. newinst->destroy = flags;
  677. newinst->cmdtok = Tcl_CreateObjCommand(interp, Tcl_GetStringFromObj(robj,NULL), (swig_wrapper_func) SWIG_MethodCommand, (ClientData) newinst, (swig_delete_func) SWIG_ObjectDelete);
  678. if (flags) {
  679. SWIG_Acquire(thisvalue);
  680. }
  681. }
  682. }
  683. return robj;
  684. }
  685. /* Structure for command table */
  686. typedef struct {
  687. const char *name;
  688. int (*wrapper)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []);
  689. ClientData clientdata;
  690. } swig_command_info;
  691. /* Structure for variable linking table */
  692. typedef struct {
  693. const char *name;
  694. void *addr;
  695. char * (*get)(ClientData, Tcl_Interp *, char *, char *, int);
  696. char * (*set)(ClientData, Tcl_Interp *, char *, char *, int);
  697. } swig_var_info;
  698. /* Contract support */
  699. #define SWIG_contract_assert(expr, msg) if (!(expr)) { Tcl_SetResult(interp, (char *) msg, TCL_STATIC ); goto fail; } else
  700. static swig_module_info *
  701. SWIG_Tcl_GetModule(Tcl_Interp *interp) {
  702. char *data;
  703. swig_module_info *ret = 0;
  704. /* first check if pointer already created */
  705. data = (char *) Tcl_GetVar(interp, "swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TCL_GLOBAL_ONLY);
  706. if (data) {
  707. SWIG_UnpackData(data, &ret, sizeof(swig_type_info **));
  708. }
  709. return ret;
  710. }
  711. static void
  712. SWIG_Tcl_SetModule(Tcl_Interp *interp, swig_module_info *module) {
  713. char buf[512];
  714. char *data;
  715. /* create a new pointer */
  716. data = SWIG_PackData(buf, &module, sizeof(swig_type_info **));
  717. *data = 0;
  718. Tcl_SetVar(interp, "swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, buf, 0);
  719. }
  720. #ifdef __cplusplus
  721. }
  722. #endif