PageRenderTime 65ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1.3.35/Source/Modules/tcl8.cxx

#
C++ | 1297 lines | 945 code | 215 blank | 137 comment | 192 complexity | c0c472aad3ff1b074c95fcbad7e2cebb MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* -----------------------------------------------------------------------------
  2. * See the LICENSE file for information on copyright, usage and redistribution
  3. * of SWIG, and the README file for authors - http://www.swig.org/release.html.
  4. *
  5. * tcl8.cxx
  6. *
  7. * Tcl8 language module for SWIG.
  8. * ----------------------------------------------------------------------------- */
  9. char cvsroot_tcl8_cxx[] = "$Id: tcl8.cxx 10270 2008-02-27 15:29:55Z wsfulton $";
  10. #include "swigmod.h"
  11. #include "cparse.h"
  12. static int treduce = SWIG_cparse_template_reduce(0);
  13. static const char *usage = (char *) "\
  14. Tcl 8 Options (available with -tcl)\n\
  15. -itcl - Enable ITcl support\n\
  16. -nosafe - Leave out SafeInit module function.\n\
  17. -prefix <name> - Set a prefix <name> to be prepended to all names\n\
  18. -namespace - Build module into a Tcl 8 namespace\n\
  19. -pkgversion - Set package version\n\n";
  20. static String *cmd_tab = 0; /* Table of command names */
  21. static String *var_tab = 0; /* Table of global variables */
  22. static String *const_tab = 0; /* Constant table */
  23. static String *methods_tab = 0; /* Methods table */
  24. static String *attr_tab = 0; /* Attribute table */
  25. static String *prefix = 0;
  26. static String *module = 0;
  27. static int nspace = 0;
  28. static String *init_name = 0;
  29. static String *ns_name = 0;
  30. static int have_constructor;
  31. static String *constructor_name;
  32. static int have_destructor;
  33. static int have_base_classes;
  34. static String *destructor_action = 0;
  35. static String *version = (String *) "0.0";
  36. static String *class_name = 0;
  37. static int have_attributes;
  38. static int have_methods;
  39. static int nosafe = 0;
  40. static File *f_header = 0;
  41. static File *f_wrappers = 0;
  42. static File *f_init = 0;
  43. static File *f_runtime = 0;
  44. // Itcl support
  45. static int itcl = 0;
  46. static File *f_shadow = 0;
  47. static File *f_shadow_stubs = 0;
  48. static String *constructor = 0;
  49. static String *destructor = 0;
  50. static String *base_classes = 0;
  51. static String *base_class_init = 0;
  52. static String *methods = 0;
  53. static String *imethods = 0;
  54. static String *attributes = 0;
  55. static String *attribute_traces = 0;
  56. static String *iattribute_traces = 0;
  57. class TCL8:public Language {
  58. public:
  59. /* ------------------------------------------------------------
  60. * TCL8::main()
  61. * ------------------------------------------------------------ */
  62. virtual void main(int argc, char *argv[]) {
  63. int cppcast = 1;
  64. SWIG_library_directory("tcl");
  65. for (int i = 1; i < argc; i++) {
  66. if (argv[i]) {
  67. if (strcmp(argv[i], "-prefix") == 0) {
  68. if (argv[i + 1]) {
  69. prefix = NewString(argv[i + 1]);
  70. Swig_mark_arg(i);
  71. Swig_mark_arg(i + 1);
  72. i++;
  73. } else
  74. Swig_arg_error();
  75. } else if (strcmp(argv[i], "-pkgversion") == 0) {
  76. if (argv[i + 1]) {
  77. version = NewString(argv[i + 1]);
  78. Swig_mark_arg(i);
  79. Swig_mark_arg(i + 1);
  80. i++;
  81. }
  82. } else if (strcmp(argv[i], "-namespace") == 0) {
  83. nspace = 1;
  84. Swig_mark_arg(i);
  85. } else if (strcmp(argv[i], "-itcl") == 0) {
  86. itcl = 1;
  87. Swig_mark_arg(i);
  88. } else if (strcmp(argv[i], "-nosafe") == 0) {
  89. nosafe = 1;
  90. Swig_mark_arg(i);
  91. } else if (strcmp(argv[i], "-cppcast") == 0) {
  92. cppcast = 1;
  93. Swig_mark_arg(i);
  94. } else if (strcmp(argv[i], "-nocppcast") == 0) {
  95. cppcast = 0;
  96. Swig_mark_arg(i);
  97. } else if (strcmp(argv[i], "-help") == 0) {
  98. fputs(usage, stdout);
  99. }
  100. }
  101. }
  102. if (cppcast) {
  103. Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0);
  104. }
  105. Preprocessor_define("SWIGTCL 1", 0);
  106. Preprocessor_define("SWIGTCL8 1", 0);
  107. SWIG_typemap_lang("tcl8");
  108. SWIG_config_file("tcl8.swg");
  109. allow_overloading();
  110. }
  111. /* ------------------------------------------------------------
  112. * top()
  113. * ------------------------------------------------------------ */
  114. virtual int top(Node *n) {
  115. /* Initialize all of the output files */
  116. String *outfile = Getattr(n, "outfile");
  117. f_runtime = NewFile(outfile, "w");
  118. if (!f_runtime) {
  119. FileErrorDisplay(outfile);
  120. SWIG_exit(EXIT_FAILURE);
  121. }
  122. f_init = NewString("");
  123. f_header = NewString("");
  124. f_wrappers = NewString("");
  125. /* Register file targets with the SWIG file handler */
  126. Swig_register_filebyname("header", f_header);
  127. Swig_register_filebyname("wrapper", f_wrappers);
  128. Swig_register_filebyname("runtime", f_runtime);
  129. Swig_register_filebyname("init", f_init);
  130. /* Initialize some variables for the object interface */
  131. cmd_tab = NewString("");
  132. var_tab = NewString("");
  133. methods_tab = NewString("");
  134. const_tab = NewString("");
  135. Swig_banner(f_runtime);
  136. /* Set the module name, namespace, and prefix */
  137. module = NewStringf("%(lower)s", Getattr(n, "name"));
  138. init_name = NewStringf("%(title)s_Init", module);
  139. ns_name = prefix ? Copy(prefix) : Copy(module);
  140. if (prefix)
  141. Append(prefix, "_");
  142. /* If shadow classing is enabled, we're going to change the module name to "_module" */
  143. if (itcl) {
  144. String *filen;
  145. filen = NewStringf("%s%s.itcl", Swig_file_dirname(outfile), module);
  146. Insert(module, 0, "_");
  147. if ((f_shadow = NewFile(filen, "w")) == 0) {
  148. FileErrorDisplay(filen);
  149. SWIG_exit(EXIT_FAILURE);
  150. }
  151. f_shadow_stubs = NewString("");
  152. Swig_register_filebyname("shadow", f_shadow);
  153. Swig_register_filebyname("itcl", f_shadow);
  154. Printf(f_shadow, "# This file was automatically generated by SWIG (http://www.swig.org).\n");
  155. Printf(f_shadow, "# Version %s\n", Swig_package_version());
  156. Printf(f_shadow, "#\n");
  157. Printf(f_shadow, "# Don't modify this file, modify the SWIG interface instead.\n");
  158. Printv(f_shadow, "\npackage require Itcl\n\n", NIL);
  159. Delete(filen);
  160. }
  161. /* Generate some macros used throughout code generation */
  162. Printf(f_header, "#define SWIG_init %s\n", init_name);
  163. Printf(f_header, "#define SWIG_name \"%s\"\n", module);
  164. if (nspace) {
  165. Printf(f_header, "#define SWIG_prefix \"%s::\"\n", ns_name);
  166. Printf(f_header, "#define SWIG_namespace \"%s\"\n\n", ns_name);
  167. } else {
  168. Printf(f_header, "#define SWIG_prefix \"%s\"\n", prefix);
  169. }
  170. Printf(f_header, "#define SWIG_version \"%s\"\n", version);
  171. Printf(cmd_tab, "\nstatic swig_command_info swig_commands[] = {\n");
  172. Printf(var_tab, "\nstatic swig_var_info swig_variables[] = {\n");
  173. Printf(const_tab, "\nstatic swig_const_info swig_constants[] = {\n");
  174. Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
  175. /* Start emitting code */
  176. Language::top(n);
  177. /* Done. Close up the module */
  178. Printv(cmd_tab, tab4, "{0, 0, 0}\n", "};\n", NIL);
  179. Printv(var_tab, tab4, "{0,0,0,0}\n", "};\n", NIL);
  180. Printv(const_tab, tab4, "{0,0,0,0,0,0}\n", "};\n", NIL);
  181. Printv(f_wrappers, cmd_tab, var_tab, const_tab, NIL);
  182. /* Dump the pointer equivalency table */
  183. SwigType_emit_type_table(f_runtime, f_wrappers);
  184. Printf(f_wrappers, "#ifdef __cplusplus\n}\n#endif\n");
  185. /* Close the init function and quit */
  186. Printf(f_init, "return TCL_OK;\n}\n");
  187. if (!nosafe) {
  188. Printf(f_init, "SWIGEXPORT int %(title)s_SafeInit(Tcl_Interp *interp) {\n", module);
  189. Printf(f_init, " return SWIG_init(interp);\n");
  190. Printf(f_init, "}\n");
  191. }
  192. if (itcl) {
  193. Printv(f_shadow, f_shadow_stubs, "\n", NIL);
  194. Close(f_shadow);
  195. Delete(f_shadow);
  196. }
  197. /* Close all of the files */
  198. Printv(f_runtime, f_header, f_wrappers, NIL);
  199. Wrapper_pretty_print(f_init, f_runtime);
  200. Delete(f_header);
  201. Delete(f_wrappers);
  202. Delete(f_init);
  203. Close(f_runtime);
  204. return SWIG_OK;
  205. }
  206. /* ------------------------------------------------------------
  207. * functionWrapper()
  208. * ------------------------------------------------------------ */
  209. virtual int functionWrapper(Node *n) {
  210. String *name = Getattr(n, "name"); /* Like to get rid of this */
  211. String *iname = Getattr(n, "sym:name");
  212. SwigType *type = Getattr(n, "type");
  213. ParmList *parms = Getattr(n, "parms");
  214. String *overname = 0;
  215. Parm *p;
  216. int i;
  217. String *tm;
  218. Wrapper *f;
  219. String *incode, *cleanup, *outarg, *argstr, *args;
  220. int num_arguments = 0;
  221. int num_required = 0;
  222. int varargs = 0;
  223. char source[64];
  224. if (Getattr(n, "sym:overloaded")) {
  225. overname = Getattr(n, "sym:overname");
  226. } else {
  227. if (!addSymbol(iname, n))
  228. return SWIG_ERROR;
  229. }
  230. incode = NewString("");
  231. cleanup = NewString("");
  232. outarg = NewString("");
  233. argstr = NewString("\"");
  234. args = NewString("");
  235. f = NewWrapper();
  236. #ifdef SWIG_USE_RESULTOBJ
  237. Wrapper_add_local(f, "resultobj", "Tcl_Obj *resultobj = NULL");
  238. #endif
  239. String *wname = Swig_name_wrapper(iname);
  240. if (overname) {
  241. Append(wname, overname);
  242. }
  243. Setattr(n, "wrap:name", wname);
  244. Printv(f->def, "SWIGINTERN int\n ", wname, "(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {", NIL);
  245. /* Print out variables for storing arguments. */
  246. emit_args(type, parms, f);
  247. /* Attach standard typemaps */
  248. emit_attach_parmmaps(parms, f);
  249. Setattr(n, "wrap:parms", parms);
  250. /* Get number of require and total arguments */
  251. num_arguments = emit_num_arguments(parms);
  252. num_required = emit_num_required(parms);
  253. varargs = emit_isvarargs(parms);
  254. /* Unmarshal parameters */
  255. for (i = 0, p = parms; i < num_arguments; i++) {
  256. /* Skip ignored arguments */
  257. while (checkAttribute(p, "tmap:in:numinputs", "0")) {
  258. p = Getattr(p, "tmap:in:next");
  259. }
  260. SwigType *pt = Getattr(p, "type");
  261. String *ln = Getattr(p, "lname");
  262. /* Produce string representations of the source and target arguments */
  263. sprintf(source, "objv[%d]", i + 1);
  264. if (i == num_required)
  265. Putc('|', argstr);
  266. if ((tm = Getattr(p, "tmap:in"))) {
  267. String *parse = Getattr(p, "tmap:in:parse");
  268. if (!parse) {
  269. Replaceall(tm, "$target", ln);
  270. Replaceall(tm, "$source", source);
  271. Replaceall(tm, "$input", source);
  272. Setattr(p, "emit:input", source);
  273. if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) {
  274. Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN");
  275. } else {
  276. Replaceall(tm, "$disown", "0");
  277. }
  278. Putc('o', argstr);
  279. Printf(args, ",(void *)0");
  280. if (i >= num_required) {
  281. Printf(incode, "if (objc > %d) {\n", i + 1);
  282. }
  283. Printf(incode, "%s\n", tm);
  284. if (i >= num_required) {
  285. Printf(incode, "}\n");
  286. }
  287. } else {
  288. Printf(argstr, "%s", parse);
  289. Printf(args, ",&%s", ln);
  290. if (Strcmp(parse, "p") == 0) {
  291. SwigType *lt = SwigType_ltype(pt);
  292. SwigType_remember(pt);
  293. if (Cmp(lt, "p.void") == 0) {
  294. Printf(args, ",(void *)0");
  295. } else {
  296. Printf(args, ",SWIGTYPE%s", SwigType_manglestr(pt));
  297. }
  298. Delete(lt);
  299. }
  300. }
  301. p = Getattr(p, "tmap:in:next");
  302. continue;
  303. } else {
  304. Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
  305. }
  306. p = nextSibling(p);
  307. }
  308. if (!varargs) {
  309. Putc(':', argstr);
  310. } else {
  311. Putc(';', argstr);
  312. /* If variable length arguments we need to emit the in typemap here */
  313. if (p && (tm = Getattr(p, "tmap:in"))) {
  314. sprintf(source, "objv[%d]", i + 1);
  315. Printf(incode, "if (objc > %d) {\n", i);
  316. Replaceall(tm, "$input", source);
  317. Printv(incode, tm, "\n", NIL);
  318. Printf(incode, "}\n");
  319. }
  320. }
  321. Printf(argstr, "%s\"", usage_string(Char(iname), type, parms));
  322. Printv(f->code, "if (SWIG_GetArgs(interp, objc, objv,", argstr, args, ") == TCL_ERROR) SWIG_fail;\n", NIL);
  323. Printv(f->code, incode, NIL);
  324. /* Insert constraint checking code */
  325. for (p = parms; p;) {
  326. if ((tm = Getattr(p, "tmap:check"))) {
  327. Replaceall(tm, "$target", Getattr(p, "lname"));
  328. Printv(f->code, tm, "\n", NIL);
  329. p = Getattr(p, "tmap:check:next");
  330. } else {
  331. p = nextSibling(p);
  332. }
  333. }
  334. /* Insert cleanup code */
  335. for (i = 0, p = parms; p; i++) {
  336. if (!checkAttribute(p, "tmap:in:numinputs", "0")
  337. && !Getattr(p, "tmap:in:parse") && (tm = Getattr(p, "tmap:freearg"))) {
  338. if (Len(tm) != 0) {
  339. Replaceall(tm, "$source", Getattr(p, "lname"));
  340. Printv(cleanup, tm, "\n", NIL);
  341. }
  342. p = Getattr(p, "tmap:freearg:next");
  343. } else {
  344. p = nextSibling(p);
  345. }
  346. }
  347. /* Insert argument output code */
  348. for (i = 0, p = parms; p; i++) {
  349. if ((tm = Getattr(p, "tmap:argout"))) {
  350. Replaceall(tm, "$source", Getattr(p, "lname"));
  351. #ifdef SWIG_USE_RESULTOBJ
  352. Replaceall(tm, "$target", "resultobj");
  353. Replaceall(tm, "$result", "resultobj");
  354. #else
  355. Replaceall(tm, "$target", "(Tcl_GetObjResult(interp))");
  356. Replaceall(tm, "$result", "(Tcl_GetObjResult(interp))");
  357. #endif
  358. Replaceall(tm, "$arg", Getattr(p, "emit:input"));
  359. Replaceall(tm, "$input", Getattr(p, "emit:input"));
  360. Printv(outarg, tm, "\n", NIL);
  361. p = Getattr(p, "tmap:argout:next");
  362. } else {
  363. p = nextSibling(p);
  364. }
  365. }
  366. /* Now write code to make the function call */
  367. emit_action(n, f);
  368. /* Need to redo all of this code (eventually) */
  369. /* Return value if necessary */
  370. if ((tm = Swig_typemap_lookup_new("out", n, "result", 0))) {
  371. Replaceall(tm, "$source", "result");
  372. #ifdef SWIG_USE_RESULTOBJ
  373. Replaceall(tm, "$target", "resultobj");
  374. Replaceall(tm, "$result", "resultobj");
  375. #else
  376. Replaceall(tm, "$target", "(Tcl_GetObjResult(interp))");
  377. Replaceall(tm, "$result", "(Tcl_GetObjResult(interp))");
  378. #endif
  379. if (GetFlag(n, "feature:new")) {
  380. Replaceall(tm, "$owner", "SWIG_POINTER_OWN");
  381. } else {
  382. Replaceall(tm, "$owner", "0");
  383. }
  384. Printf(f->code, "%s\n", tm);
  385. } else {
  386. Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(type, 0), name);
  387. }
  388. /* Dump output argument code */
  389. Printv(f->code, outarg, NIL);
  390. /* Dump the argument cleanup code */
  391. Printv(f->code, cleanup, NIL);
  392. /* Look for any remaining cleanup */
  393. if (GetFlag(n, "feature:new")) {
  394. if ((tm = Swig_typemap_lookup_new("newfree", n, "result", 0))) {
  395. Replaceall(tm, "$source", "result");
  396. Printf(f->code, "%s\n", tm);
  397. }
  398. }
  399. if ((tm = Swig_typemap_lookup_new("ret", n, "result", 0))) {
  400. Replaceall(tm, "$source", "result");
  401. Printf(f->code, "%s\n", tm);
  402. }
  403. #ifdef SWIG_USE_RESULTOBJ
  404. Printv(f->code, "if (resultobj) Tcl_SetObjResult(interp, resultobj);\n", NIL);
  405. #endif
  406. Printv(f->code, "return TCL_OK;\n", NIL);
  407. Printv(f->code, "fail:\n", cleanup, "return TCL_ERROR;\n", NIL);
  408. Printv(f->code, "}\n", NIL);
  409. /* Substitute the cleanup code */
  410. Replaceall(f->code, "$cleanup", cleanup);
  411. Replaceall(f->code, "$symname", iname);
  412. /* Dump out the function */
  413. Wrapper_print(f, f_wrappers);
  414. if (!Getattr(n, "sym:overloaded")) {
  415. /* Register the function with Tcl */
  416. Printv(cmd_tab, tab4, "{ SWIG_prefix \"", iname, "\", (swig_wrapper_func) ", Swig_name_wrapper(iname), ", NULL},\n", NIL);
  417. } else {
  418. if (!Getattr(n, "sym:nextSibling")) {
  419. /* Emit overloading dispatch function */
  420. int maxargs;
  421. String *dispatch = Swig_overload_dispatch(n, "return %s(clientData, interp, objc, argv - 1);", &maxargs);
  422. /* Generate a dispatch wrapper for all overloaded functions */
  423. Wrapper *df = NewWrapper();
  424. String *dname = Swig_name_wrapper(iname);
  425. Printv(df->def, "SWIGINTERN int\n", dname, "(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {", NIL);
  426. Printf(df->code, "Tcl_Obj *CONST *argv = objv+1;\n");
  427. Printf(df->code, "int argc = objc-1;\n");
  428. Printv(df->code, dispatch, "\n", NIL);
  429. Printf(df->code, "Tcl_SetResult(interp,(char *) \"No matching function for overloaded '%s'\", TCL_STATIC);\n", iname);
  430. Printf(df->code, "return TCL_ERROR;\n");
  431. Printv(df->code, "}\n", NIL);
  432. Wrapper_print(df, f_wrappers);
  433. Printv(cmd_tab, tab4, "{ SWIG_prefix \"", iname, "\", (swig_wrapper_func) ", dname, ", NULL},\n", NIL);
  434. DelWrapper(df);
  435. Delete(dispatch);
  436. Delete(dname);
  437. }
  438. }
  439. Delete(incode);
  440. Delete(cleanup);
  441. Delete(outarg);
  442. Delete(argstr);
  443. Delete(args);
  444. DelWrapper(f);
  445. return SWIG_OK;
  446. }
  447. /* ------------------------------------------------------------
  448. * variableWrapper()
  449. * ------------------------------------------------------------ */
  450. virtual int variableWrapper(Node *n) {
  451. String *name = Getattr(n, "name");
  452. String *iname = Getattr(n, "sym:name");
  453. SwigType *t = Getattr(n, "type");
  454. String *setname = 0;
  455. String *setfname = 0;
  456. Wrapper *setf = 0, *getf = 0;
  457. int readonly = 0;
  458. String *tm;
  459. if (!addSymbol(iname, n))
  460. return SWIG_ERROR;
  461. /* Create a function for getting a variable */
  462. int addfail = 0;
  463. getf = NewWrapper();
  464. String *getname = Swig_name_get(iname);
  465. String *getfname = Swig_name_wrapper(getname);
  466. Setattr(n, "wrap:name", getfname);
  467. Printv(getf->def, "SWIGINTERN const char *", getfname, "(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, char *name1, char *name2, int flags) {", NIL);
  468. Wrapper_add_local(getf, "value", "Tcl_Obj *value = 0");
  469. if ((tm = Swig_typemap_lookup_new("varout", n, name, 0))) {
  470. Replaceall(tm, "$source", name);
  471. Replaceall(tm, "$target", "value");
  472. Replaceall(tm, "$result", "value");
  473. /* Printf(getf->code, "%s\n",tm); */
  474. addfail = emit_action_code(n, getf, tm);
  475. Printf(getf->code, "if (value) {\n");
  476. Printf(getf->code, "Tcl_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n");
  477. Printf(getf->code, "Tcl_DecrRefCount(value);\n");
  478. Printf(getf->code, "}\n");
  479. Printf(getf->code, "return NULL;\n");
  480. if (addfail) {
  481. Append(getf->code, "fail:\n");
  482. Printf(getf->code, "return \"%s\";\n", iname);
  483. }
  484. Printf(getf->code, "}\n");
  485. Wrapper_print(getf, f_wrappers);
  486. } else {
  487. Swig_warning(WARN_TYPEMAP_VAROUT_UNDEF, input_file, line_number, "Unable to read variable of type %s\n", SwigType_str(t, 0));
  488. DelWrapper(getf);
  489. return SWIG_NOWRAP;
  490. }
  491. DelWrapper(getf);
  492. /* Try to create a function setting a variable */
  493. if (is_assignable(n)) {
  494. setf = NewWrapper();
  495. setname = Swig_name_set(iname);
  496. setfname = Swig_name_wrapper(setname);
  497. Setattr(n, "wrap:name", setfname);
  498. if (setf) {
  499. Printv(setf->def, "SWIGINTERN const char *", setfname,
  500. "(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, char *name1, char *name2 SWIGUNUSED, int flags) {", NIL);
  501. Wrapper_add_local(setf, "value", "Tcl_Obj *value = 0");
  502. Wrapper_add_local(setf, "name1o", "Tcl_Obj *name1o = 0");
  503. if ((tm = Swig_typemap_lookup_new("varin", n, name, 0))) {
  504. Replaceall(tm, "$source", "value");
  505. Replaceall(tm, "$target", name);
  506. Replaceall(tm, "$input", "value");
  507. Printf(setf->code, "name1o = Tcl_NewStringObj(name1,-1);\n");
  508. Printf(setf->code, "value = Tcl_ObjGetVar2(interp, name1o, 0, flags);\n");
  509. Printf(setf->code, "Tcl_DecrRefCount(name1o);\n");
  510. Printf(setf->code, "if (!value) SWIG_fail;\n");
  511. /* Printf(setf->code,"%s\n", tm); */
  512. emit_action_code(n, setf, tm);
  513. Printf(setf->code, "return NULL;\n");
  514. Printf(setf->code, "fail:\n");
  515. Printf(setf->code, "return \"%s\";\n", iname);
  516. Printf(setf->code, "}\n");
  517. Wrapper_print(setf, f_wrappers);
  518. } else {
  519. Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0));
  520. readonly = 1;
  521. }
  522. }
  523. DelWrapper(setf);
  524. } else {
  525. readonly = 1;
  526. }
  527. Printv(var_tab, tab4, "{ SWIG_prefix \"", iname, "\", 0, (swig_variable_func) ", getfname, ",", NIL);
  528. if (readonly) {
  529. static int readonlywrap = 0;
  530. if (!readonlywrap) {
  531. Wrapper *ro = NewWrapper();
  532. Printf(ro->def,
  533. "SWIGINTERN const char *swig_readonly(ClientData clientData SWIGUNUSED, Tcl_Interp *interp SWIGUNUSED, char *name1 SWIGUNUSED, char *name2 SWIGUNUSED, int flags SWIGUNUSED) {");
  534. Printv(ro->code, "return \"Variable is read-only\";\n", "}\n", NIL);
  535. Wrapper_print(ro, f_wrappers);
  536. readonlywrap = 1;
  537. DelWrapper(ro);
  538. }
  539. Printf(var_tab, "(swig_variable_func) swig_readonly},\n");
  540. } else {
  541. Printv(var_tab, "(swig_variable_func) ", setfname, "},\n", NIL);
  542. }
  543. Delete(getfname);
  544. Delete(setfname);
  545. Delete(setname);
  546. Delete(getname);
  547. return SWIG_OK;
  548. }
  549. /* ------------------------------------------------------------
  550. * constantWrapper()
  551. * ------------------------------------------------------------ */
  552. virtual int constantWrapper(Node *n) {
  553. String *name = Getattr(n, "name");
  554. String *iname = Getattr(n, "sym:name");
  555. String *nsname = !nspace ? Copy(iname) : NewStringf("%s::%s", ns_name, iname);
  556. SwigType *type = Getattr(n, "type");
  557. String *rawval = Getattr(n, "rawval");
  558. String *value = rawval ? rawval : Getattr(n, "value");
  559. String *tm;
  560. if (!addSymbol(iname, n))
  561. return SWIG_ERROR;
  562. if (nspace)
  563. Setattr(n, "sym:name", nsname);
  564. /* Special hook for member pointer */
  565. if (SwigType_type(type) == T_MPOINTER) {
  566. String *wname = Swig_name_wrapper(iname);
  567. Printf(f_wrappers, "static %s = %s;\n", SwigType_str(type, wname), value);
  568. value = Char(wname);
  569. }
  570. if ((tm = Swig_typemap_lookup_new("consttab", n, name, 0))) {
  571. Replaceall(tm, "$source", value);
  572. Replaceall(tm, "$target", name);
  573. Replaceall(tm, "$value", value);
  574. Replaceall(tm, "$nsname", nsname);
  575. Printf(const_tab, "%s,\n", tm);
  576. } else if ((tm = Swig_typemap_lookup_new("constcode", n, name, 0))) {
  577. Replaceall(tm, "$source", value);
  578. Replaceall(tm, "$target", name);
  579. Replaceall(tm, "$value", value);
  580. Replaceall(tm, "$nsname", nsname);
  581. Printf(f_init, "%s\n", tm);
  582. } else {
  583. Delete(nsname);
  584. Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value.\n");
  585. return SWIG_NOWRAP;
  586. }
  587. Delete(nsname);
  588. return SWIG_OK;
  589. }
  590. /* ------------------------------------------------------------
  591. * nativeWrapper()
  592. * ------------------------------------------------------------ */
  593. virtual int nativeWrapper(Node *n) {
  594. String *name = Getattr(n, "sym:name");
  595. String *funcname = Getattr(n, "wrap:name");
  596. if (!addSymbol(funcname, n))
  597. return SWIG_ERROR;
  598. Printf(f_init, "\t Tcl_CreateObjCommand(interp, SWIG_prefix \"%s\", (swig_wrapper_func) %s, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);\n", name,
  599. funcname);
  600. return SWIG_OK;
  601. }
  602. /* ------------------------------------------------------------
  603. * classHandler()
  604. * ------------------------------------------------------------ */
  605. virtual int classHandler(Node *n) {
  606. static Hash *emitted = NewHash();
  607. String *mangled_classname = 0;
  608. String *real_classname = 0;
  609. have_constructor = 0;
  610. have_destructor = 0;
  611. destructor_action = 0;
  612. if (itcl) {
  613. constructor = NewString("");
  614. destructor = NewString("");
  615. base_classes = NewString("");
  616. base_class_init = NewString("");
  617. methods = NewString("");
  618. imethods = NewString("");
  619. attributes = NewString("");
  620. attribute_traces = NewString("");
  621. iattribute_traces = NewString("");
  622. have_base_classes = 0;
  623. have_methods = 0;
  624. have_attributes = 0;
  625. }
  626. class_name = Getattr(n, "sym:name");
  627. if (!addSymbol(class_name, n))
  628. return SWIG_ERROR;
  629. real_classname = Getattr(n, "name");
  630. mangled_classname = Swig_name_mangle(real_classname);
  631. if (Getattr(emitted, mangled_classname))
  632. return SWIG_NOWRAP;
  633. Setattr(emitted, mangled_classname, "1");
  634. attr_tab = NewString("");
  635. Printf(attr_tab, "static swig_attribute swig_");
  636. Printv(attr_tab, mangled_classname, "_attributes[] = {\n", NIL);
  637. methods_tab = NewStringf("");
  638. Printf(methods_tab, "static swig_method swig_");
  639. Printv(methods_tab, mangled_classname, "_methods[] = {\n", NIL);
  640. /* Generate normal wrappers */
  641. Language::classHandler(n);
  642. SwigType *t = Copy(Getattr(n, "name"));
  643. SwigType_add_pointer(t);
  644. // Catch all: eg. a class with only static functions and/or variables will not have 'remembered'
  645. // SwigType_remember(t);
  646. String *wrap_class = NewStringf("&_wrap_class_%s", mangled_classname);
  647. SwigType_remember_clientdata(t, wrap_class);
  648. // t = Copy(Getattr(n,"classtype"));
  649. // SwigType_add_pointer(t);
  650. String *rt = Copy(Getattr(n, "classtype"));
  651. SwigType_add_pointer(rt);
  652. // Register the class structure with the type checker
  653. /* Printf(f_init,"SWIG_TypeClientData(SWIGTYPE%s, (void *) &_wrap_class_%s);\n", SwigType_manglestr(t), mangled_classname); */
  654. if (have_destructor) {
  655. Printv(f_wrappers, "SWIGINTERN void swig_delete_", class_name, "(void *obj) {\n", NIL);
  656. if (destructor_action) {
  657. Printv(f_wrappers, SwigType_str(rt, "arg1"), " = (", SwigType_str(rt, 0), ") obj;\n", NIL);
  658. Printv(f_wrappers, destructor_action, NIL);
  659. } else {
  660. if (CPlusPlus) {
  661. Printv(f_wrappers, " delete (", SwigType_str(rt, 0), ") obj;\n", NIL);
  662. } else {
  663. Printv(f_wrappers, " free((char *) obj);\n", NIL);
  664. }
  665. }
  666. Printf(f_wrappers, "}\n");
  667. }
  668. Printf(methods_tab, " {0,0}\n};\n");
  669. Printv(f_wrappers, methods_tab, NIL);
  670. Printf(attr_tab, " {0,0,0}\n};\n");
  671. Printv(f_wrappers, attr_tab, NIL);
  672. /* Handle inheritance */
  673. String *base_class = NewString("");
  674. String *base_class_names = NewString("");
  675. if (itcl) {
  676. base_classes = NewString("");
  677. }
  678. List *baselist = Getattr(n, "bases");
  679. if (baselist && Len(baselist)) {
  680. Iterator b;
  681. int index = 0;
  682. b = First(baselist);
  683. while (b.item) {
  684. String *bname = Getattr(b.item, "name");
  685. if ((!bname) || GetFlag(b.item, "feature:ignore") || (!Getattr(b.item, "module"))) {
  686. b = Next(b);
  687. continue;
  688. }
  689. if (itcl) {
  690. have_base_classes = 1;
  691. Printv(base_classes, bname, " ", NIL);
  692. Printv(base_class_init, " ", bname, "Ptr::constructor $ptr\n", NIL);
  693. }
  694. String *bmangle = Swig_name_mangle(bname);
  695. // Printv(f_wrappers,"extern swig_class _wrap_class_", bmangle, ";\n", NIL);
  696. // Printf(base_class,"&_wrap_class_%s",bmangle);
  697. Printf(base_class, "0");
  698. Printf(base_class_names, "\"%s *\",", SwigType_namestr(bname));
  699. /* Put code to register base classes in init function */
  700. //Printf(f_init,"/* Register base : %s */\n", bmangle);
  701. //Printf(f_init,"swig_%s_bases[%d] = (swig_class *) SWIG_TypeQuery(\"%s *\")->clientdata;\n", mangled_classname, index, SwigType_namestr(bname));
  702. b = Next(b);
  703. index++;
  704. Putc(',', base_class);
  705. Delete(bmangle);
  706. }
  707. }
  708. if (itcl) {
  709. String *ptrclass = NewString("");
  710. // First, build the pointer base class
  711. Printv(ptrclass, "itcl::class ", class_name, "Ptr {\n", NIL);
  712. if (have_base_classes)
  713. Printv(ptrclass, " inherit ", base_classes, "\n", NIL);
  714. // Define protected variables for SWIG object pointer
  715. Printv(ptrclass, " protected variable swigobj\n", " protected variable thisown\n", NIL);
  716. // Define public variables
  717. if (have_attributes) {
  718. Printv(ptrclass, attributes, NIL);
  719. // base class swig_getset was being called for complex inheritance trees
  720. if (nspace) {
  721. Printv(ptrclass, " protected method ", class_name, "_swig_getset {var name1 name2 op} {\n", NIL);
  722. Printv(ptrclass,
  723. " switch -exact -- $op {\n",
  724. " r {set $var [", ns_name, "::", class_name, "_[set var]_get $swigobj]}\n",
  725. " w {", ns_name, "::", class_name, "_${var}_set $swigobj [set $var]}\n", " }\n", " }\n", NIL);
  726. } else {
  727. Printv(ptrclass,
  728. " protected method ", class_name, "_swig_getset {var name1 name2 op} {\n",
  729. " switch -exact -- $op {\n",
  730. " r {set $var [", class_name, "_[set var]_get $swigobj]}\n",
  731. " w {", class_name, "_${var}_set $swigobj [set $var]}\n", " }\n", " }\n", NIL);
  732. }
  733. }
  734. // Add the constructor, which may include
  735. // calls to base class class constructors
  736. Printv(ptrclass, " constructor { ptr } {\n", NIL);
  737. if (have_base_classes) {
  738. Printv(ptrclass, base_class_init, NIL);
  739. Printv(ptrclass, " } {\n", NIL);
  740. }
  741. Printv(ptrclass, " set swigobj $ptr\n", " set thisown 0\n", NIL);
  742. if (have_attributes) {
  743. Printv(ptrclass, attribute_traces, NIL);
  744. }
  745. Printv(ptrclass, " }\n", NIL);
  746. // Add destructor
  747. Printv(ptrclass, " destructor {\n",
  748. " set d_func delete_", class_name, "\n",
  749. " if { $thisown && ([info command $d_func] != \"\") } {\n" " $d_func $swigobj\n", " }\n", " }\n", NIL);
  750. // Add methods
  751. if (have_methods) {
  752. Printv(ptrclass, imethods, NIL);
  753. };
  754. // Close out the pointer class
  755. Printv(ptrclass, "}\n\n", NIL);
  756. Printv(f_shadow, ptrclass, NIL);
  757. // pointer class end
  758. // Create the "real" class.
  759. Printv(f_shadow, "itcl::class ", class_name, " {\n", NIL);
  760. Printv(f_shadow, " inherit ", class_name, "Ptr\n", NIL);
  761. // If we have a constructor, then use it.
  762. // If not, then we must have an abstract class without
  763. // any constructor. So we create a class constructor
  764. // which will fail for this class (but not for inherited
  765. // classes). Note that the constructor must fail before
  766. // calling the ptrclass constructor.
  767. if (have_constructor) {
  768. Printv(f_shadow, constructor, NIL);
  769. } else {
  770. Printv(f_shadow, " constructor { } {\n", NIL);
  771. Printv(f_shadow, " # This constructor will fail if called directly\n", NIL);
  772. Printv(f_shadow, " if { [info class] == \"::", class_name, "\" } {\n", NIL);
  773. Printv(f_shadow, " error \"No constructor for class ", class_name, "\"\n", NIL);
  774. Printv(f_shadow, " }\n", NIL);
  775. Printv(f_shadow, " }\n", NIL);
  776. }
  777. Printv(f_shadow, "}\n\n", NIL);
  778. };
  779. Printv(f_wrappers, "static swig_class *swig_", mangled_classname, "_bases[] = {", base_class, "0};\n", NIL);
  780. Printv(f_wrappers, "static const char * swig_", mangled_classname, "_base_names[] = {", base_class_names, "0};\n", NIL);
  781. Delete(base_class);
  782. Delete(base_class_names);
  783. Printv(f_wrappers, "static swig_class _wrap_class_", mangled_classname, " = { \"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL);
  784. if (have_constructor) {
  785. Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(constructor_name)));
  786. Delete(constructor_name);
  787. constructor_name = 0;
  788. } else {
  789. Printf(f_wrappers, "0");
  790. }
  791. if (have_destructor) {
  792. Printv(f_wrappers, ", swig_delete_", class_name, NIL);
  793. } else {
  794. Printf(f_wrappers, ",0");
  795. }
  796. Printv(f_wrappers, ", swig_", mangled_classname, "_methods, swig_", mangled_classname, "_attributes, swig_", mangled_classname, "_bases,",
  797. "swig_", mangled_classname, "_base_names, &swig_module };\n", NIL);
  798. if (!itcl) {
  799. Printv(cmd_tab, tab4, "{ SWIG_prefix \"", class_name, "\", (swig_wrapper_func) SWIG_ObjectConstructor, (ClientData)&_wrap_class_", mangled_classname,
  800. "},\n", NIL);
  801. };
  802. Delete(t);
  803. Delete(mangled_classname);
  804. return SWIG_OK;
  805. }
  806. /* ------------------------------------------------------------
  807. * memberfunctionHandler()
  808. * ------------------------------------------------------------ */
  809. virtual int memberfunctionHandler(Node *n) {
  810. String *name = Getattr(n, "name");
  811. String *iname = GetChar(n, "sym:name");
  812. String *realname, *rname;
  813. Language::memberfunctionHandler(n);
  814. realname = iname ? iname : name;
  815. rname = Swig_name_wrapper(Swig_name_member(class_name, realname));
  816. if (!Getattr(n, "sym:nextSibling")) {
  817. Printv(methods_tab, tab4, "{\"", realname, "\", ", rname, "}, \n", NIL);
  818. }
  819. if (itcl) {
  820. ParmList *l = Getattr(n, "parms");
  821. Parm *p = 0;
  822. String *pname = NewString("");
  823. // Add this member to our class handler function
  824. Printv(imethods, tab2, "method ", realname, " [list ", NIL);
  825. int pnum = 0;
  826. for (p = l; p; p = nextSibling(p)) {
  827. String *pn = Getattr(p, "name");
  828. String *dv = Getattr(p, "value");
  829. SwigType *pt = Getattr(p, "type");
  830. Printv(pname, ",(", pt, ")", NIL);
  831. Clear(pname);
  832. /* Only print an argument if not void */
  833. if (Cmp(pt, "void") != 0) {
  834. if (Len(pn) > 0) {
  835. Printv(pname, pn, NIL);
  836. } else {
  837. Printf(pname, "p%d", pnum);
  838. }
  839. if (Len(dv) > 0) {
  840. String *defval = NewString(dv);
  841. if (nspace) {
  842. Insert(defval, 0, "::");
  843. Insert(defval, 0, ns_name);
  844. }
  845. if (Strncmp(dv, "(", 1) == 0) {
  846. Insert(defval, 0, "$");
  847. Replaceall(defval, "(", "");
  848. Replaceall(defval, ")", "");
  849. }
  850. Printv(imethods, "[list ", pname, " ", defval, "] ", NIL);
  851. } else {
  852. Printv(imethods, pname, " ", NIL);
  853. }
  854. }
  855. ++pnum;
  856. }
  857. Printv(imethods, "] ", NIL);
  858. if (nspace) {
  859. Printv(imethods, "{ ", ns_name, "::", class_name, "_", realname, " $swigobj", NIL);
  860. } else {
  861. Printv(imethods, "{ ", class_name, "_", realname, " $swigobj", NIL);
  862. };
  863. pnum = 0;
  864. for (p = l; p; p = nextSibling(p)) {
  865. String *pn = Getattr(p, "name");
  866. SwigType *pt = Getattr(p, "type");
  867. Clear(pname);
  868. /* Only print an argument if not void */
  869. if (Cmp(pt, "void") != 0) {
  870. if (Len(pn) > 0) {
  871. Printv(pname, pn, NIL);
  872. } else {
  873. Printf(pname, "p%d", pnum);
  874. }
  875. Printv(imethods, " $", pname, NIL);
  876. }
  877. ++pnum;
  878. }
  879. Printv(imethods, " }\n", NIL);
  880. have_methods = 1;
  881. }
  882. Delete(rname);
  883. return SWIG_OK;
  884. }
  885. /* ------------------------------------------------------------
  886. * membervariableHandler()
  887. * ------------------------------------------------------------ */
  888. virtual int membervariableHandler(Node *n) {
  889. String *symname = Getattr(n, "sym:name");
  890. String *rname;
  891. Language::membervariableHandler(n);
  892. Printv(attr_tab, tab4, "{ \"-", symname, "\",", NIL);
  893. rname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname)));
  894. Printv(attr_tab, rname, ", ", NIL);
  895. Delete(rname);
  896. if (!GetFlag(n, "feature:immutable")) {
  897. rname = Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname)));
  898. Printv(attr_tab, rname, "},\n", NIL);
  899. Delete(rname);
  900. } else {
  901. Printf(attr_tab, "0 },\n");
  902. }
  903. if (itcl) {
  904. Printv(attributes, " public variable ", symname, "\n", NIL);
  905. Printv(attribute_traces, " trace variable ", symname, " rw [list ", class_name, "_swig_getset ", symname, "]\n", NIL);
  906. Printv(attribute_traces, " set ", symname, "\n", NIL);
  907. have_attributes = 1;
  908. }
  909. return SWIG_OK;
  910. }
  911. /* ------------------------------------------------------------
  912. * constructorHandler()
  913. * ------------------------------------------------------------ */
  914. virtual int constructorHandler(Node *n) {
  915. Language::constructorHandler(n);
  916. if (itcl) {
  917. String *name = Getattr(n, "name");
  918. String *iname = GetChar(n, "sym:name");
  919. String *realname;
  920. ParmList *l = Getattr(n, "parms");
  921. Parm *p = 0;
  922. String *pname = NewString("");
  923. realname = iname ? iname : name;
  924. if (!have_constructor) {
  925. // Add this member to our class handler function
  926. Printf(constructor, " constructor { ");
  927. // Add parameter list
  928. int pnum = 0;
  929. for (p = l; p; p = nextSibling(p)) {
  930. SwigType *pt = Getattr(p, "type");
  931. String *pn = Getattr(p, "name");
  932. String *dv = Getattr(p, "value");
  933. Clear(pname);
  934. /* Only print an argument if not void */
  935. if (Cmp(pt, "void") != 0) {
  936. if (Len(pn) > 0) {
  937. Printv(pname, pn, NIL);
  938. } else {
  939. Printf(pname, "p%d", pnum);
  940. }
  941. if (Len(dv) > 0) {
  942. Printv(constructor, "{", pname, " {", dv, "} } ", NIL);
  943. } else {
  944. Printv(constructor, pname, " ", NIL);
  945. }
  946. }
  947. ++pnum;
  948. }
  949. Printf(constructor, "} { \n");
  950. // [BRE] 08/17/00 Added test to see if we are instantiating this object
  951. // type, or, if this constructor is being called as part of the itcl
  952. // inheritance hierarchy.
  953. // In the former case, we need to call the C++ constructor, in the
  954. // latter we don't, or we end up with two C++ objects.
  955. // Check to see if we are instantiating a 'realname' or something
  956. // derived from it.
  957. //
  958. Printv(constructor, " if { [string equal -nocase \"", realname, "\" \"[namespace tail [info class]]\" ] } {\n", NIL);
  959. // Call to constructor wrapper and parent Ptr class
  960. // [BRE] add -namespace/-prefix support
  961. if (nspace) {
  962. Printv(constructor, " ", realname, "Ptr::constructor [", ns_name, "::new_", realname, NIL);
  963. } else {
  964. Printv(constructor, " ", realname, "Ptr::constructor [new_", realname, NIL);
  965. }
  966. pnum = 0;
  967. for (p = l; p; p = nextSibling(p)) {
  968. SwigType *pt = Getattr(p, "type");
  969. String *pn = Getattr(p, "name");
  970. Clear(pname);
  971. /* Only print an argument if not void */
  972. if (Cmp(pt, "void") != 0) {
  973. if (Len(pn) > 0) {
  974. Printv(pname, pn, NIL);
  975. } else {
  976. Printf(pname, "p%d", pnum);
  977. }
  978. Printv(constructor, " $", pname, NIL);
  979. }
  980. ++pnum;
  981. }
  982. Printv(constructor, "]\n", " }\n", " } {\n", " set thisown 1\n", " }\n", NIL);
  983. }
  984. }
  985. constructor_name = NewString(Getattr(n, "sym:name"));
  986. have_constructor = 1;
  987. return SWIG_OK;
  988. }
  989. /* ------------------------------------------------------------
  990. * destructorHandler()
  991. * ------------------------------------------------------------ */
  992. virtual int destructorHandler(Node *n) {
  993. Language::destructorHandler(n);
  994. have_destructor = 1;
  995. destructor_action = Getattr(n, "wrap:action");
  996. return SWIG_OK;
  997. }
  998. /* ------------------------------------------------------------
  999. * validIdentifier()
  1000. * ------------------------------------------------------------ */
  1001. virtual int validIdentifier(String *s) {
  1002. if (Strchr(s, ' '))
  1003. return 0;
  1004. return 1;
  1005. }
  1006. /* ------------------------------------------------------------
  1007. * usage_string()
  1008. * ------------------------------------------------------------ */
  1009. char *usage_string(char *iname, SwigType *, ParmList *l) {
  1010. static String *temp = 0;
  1011. Parm *p;
  1012. int i, numopt, pcount;
  1013. if (!temp)
  1014. temp = NewString("");
  1015. Clear(temp);
  1016. if (nspace) {
  1017. Printf(temp, "%s::%s ", ns_name, iname);
  1018. } else {
  1019. Printf(temp, "%s ", iname);
  1020. }
  1021. /* Now go through and print parameters */
  1022. i = 0;
  1023. pcount = emit_num_arguments(l);
  1024. numopt = pcount - emit_num_required(l);
  1025. for (p = l; p; p = nextSibling(p)) {
  1026. SwigType *pt = Getattr(p, "type");
  1027. String *pn = Getattr(p, "name");
  1028. /* Only print an argument if not ignored */
  1029. if (!checkAttribute(p, "tmap:in:numinputs", "0")) {
  1030. if (i >= (pcount - numopt))
  1031. Putc('?', temp);
  1032. if (Len(pn) > 0) {
  1033. Printf(temp, "%s", pn);
  1034. } else {
  1035. Printf(temp, "%s", SwigType_str(pt, 0));
  1036. }
  1037. if (i >= (pcount - numopt))
  1038. Putc('?', temp);
  1039. Putc(' ', temp);
  1040. i++;
  1041. }
  1042. }
  1043. return Char(temp);
  1044. }
  1045. String *runtimeCode() {
  1046. String *s = NewString("");
  1047. String *serrors = Swig_include_sys("tclerrors.swg");
  1048. if (!serrors) {
  1049. Printf(stderr, "*** Unable to open 'tclerrors.swg'\n");
  1050. } else {
  1051. Append(s, serrors);
  1052. Delete(serrors);
  1053. }
  1054. String *sapi = Swig_include_sys("tclapi.swg");
  1055. if (!sapi) {
  1056. Printf(stderr, "*** Unable to open 'tclapi.swg'\n");
  1057. } else {
  1058. Append(s, sapi);
  1059. Delete(sapi);
  1060. }
  1061. String *srun = Swig_include_sys("tclrun.swg");
  1062. if (!srun) {
  1063. Printf(stderr, "*** Unable to open 'tclrun.swg'\n");
  1064. } else {
  1065. Append(s, srun);
  1066. Delete(srun);
  1067. }
  1068. return s;
  1069. }
  1070. String *defaultExternalRuntimeFilename() {
  1071. return NewString("swigtclrun.h");
  1072. }
  1073. };
  1074. /* ----------------------------------------------------------------------
  1075. * swig_tcl() - Instantiate module
  1076. * ---------------------------------------------------------------------- */
  1077. static Language *new_swig_tcl() {
  1078. return new TCL8();
  1079. }
  1080. extern "C" Language *swig_tcl(void) {
  1081. return new_swig_tcl();
  1082. }