From 99739721baa29cdde991b9de8c58558930f808f6 Mon Sep 17 00:00:00 2001 From: Dave Beazley Date: Sun, 9 Nov 2003 03:51:12 +0000 Subject: [PATCH] SafeInit function added. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5283 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Source/Modules/tcl8.cxx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/SWIG/Source/Modules/tcl8.cxx b/SWIG/Source/Modules/tcl8.cxx index 3f203ce61..5d774f917 100644 --- a/SWIG/Source/Modules/tcl8.cxx +++ b/SWIG/Source/Modules/tcl8.cxx @@ -32,6 +32,7 @@ static const char *usage = (char*)"\ Tcl 8 Options (available with -tcl)\n\ -itcl - Enable ITcl support\n\ -ldflags - Print runtime libraries to link with\n\ + -nosafe - Leave out SafeInit module function.\n\ -prefix - Set a prefix to be prepended to all names\n\ -namespace - Build module into a Tcl 8 namespace\n\ -pkgversion - Set package version\n\n"; @@ -55,6 +56,7 @@ static String *class_name = 0; static int have_attributes; static int have_methods; +static int nosafe = 0; static File *f_header = 0; static File *f_wrappers = 0; @@ -112,6 +114,9 @@ public: } else if (strcmp(argv[i],"-itcl") == 0) { itcl = 1; Swig_mark_arg(i); + } else if (strcmp(argv[i],"-nosafe") == 0) { + nosafe = 1; + Swig_mark_arg(i); } else if (strcmp(argv[i],"-help") == 0) { fputs(usage,stderr); } else if (strcmp (argv[i], "-ldflags") == 0) { @@ -234,13 +239,19 @@ public: /* Close the init function and quit */ Printf(f_init,"return TCL_OK;\n}\n"); - + + if (!nosafe) { + Printf(f_init,"SWIGEXPORT(int) %(title)s_SafeInit(Tcl_Interp *interp) {\n", module ); + Printf(f_init," return SWIG_init(interp);\n"); + Printf(f_init,"}\n"); + } + if (itcl) { Printv(f_shadow, f_shadow_stubs, "\n",NIL); Close(f_shadow); Delete(f_shadow); } - + /* Close all of the files */ Printv(f_runtime, f_header, f_wrappers,NIL); Wrapper_pretty_print(f_init,f_runtime);