import source from 1.3.40
[external/swig.git] / Lib / tcl / tclinit.swg
1 /* ------------------------------------------------------------
2  * The start of the Tcl initialization function 
3  * ------------------------------------------------------------ */
4
5 %insert(init) "swiginit.swg"
6
7 /* This initialization code exports the module initialization function */
8
9 %header %{
10
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 #ifdef MAC_TCL
15 #pragma export on
16 #endif
17 SWIGEXPORT int SWIG_init(Tcl_Interp *);
18 #ifdef MAC_TCL
19 #pragma export off
20 #endif
21 #ifdef __cplusplus
22 }
23 #endif
24
25 /* Compatibility version for TCL stubs */
26 #ifndef SWIG_TCL_STUBS_VERSION
27 #define SWIG_TCL_STUBS_VERSION "8.1"
28 #endif
29
30 %}
31
32 %init %{
33 #ifdef __cplusplus
34 extern "C" {   
35 #endif
36
37 /* -----------------------------------------------------------------------------
38  * constants/methods manipulation
39  * ----------------------------------------------------------------------------- */
40
41 /* Install Constants */
42
43 SWIGINTERN void
44 SWIG_Tcl_InstallConstants(Tcl_Interp *interp, swig_const_info constants[]) {
45   int i;
46   Tcl_Obj *obj;
47
48   if (!swigconstTableinit) {
49     Tcl_InitHashTable(&swigconstTable, TCL_STRING_KEYS);
50     swigconstTableinit = 1;
51   }
52   for (i = 0; constants[i].type; i++) {
53     switch(constants[i].type) {
54     case SWIG_TCL_POINTER:
55       obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
56       break;
57     case SWIG_TCL_BINARY:
58       obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
59       break;
60     default:
61       obj = 0;
62       break;
63     }
64     if (obj) {
65       SWIG_Tcl_SetConstantObj(interp, constants[i].name, obj);
66     }
67   }
68 }
69
70 #ifdef __cplusplus
71 }
72 #endif
73
74 /* -----------------------------------------------------------------------------*
75  *  Partial Init method
76  * -----------------------------------------------------------------------------*/
77
78 SWIGEXPORT int SWIG_init(Tcl_Interp *interp) {
79   int i;
80   if (interp == 0) return TCL_ERROR;
81 #ifdef USE_TCL_STUBS
82   /* (char*) cast is required to avoid compiler warning/error for Tcl < 8.4. */
83   if (Tcl_InitStubs(interp, (char*)SWIG_TCL_STUBS_VERSION, 0) == NULL) {
84     return TCL_ERROR;
85   }
86 #endif  
87 #ifdef USE_TK_STUBS
88   /* (char*) cast is required to avoid compiler warning/error. */
89   if (Tk_InitStubs(interp, (char*)SWIG_TCL_STUBS_VERSION, 0) == NULL) {
90     return TCL_ERROR;
91   }
92 #endif
93
94   Tcl_PkgProvide(interp, (char*)SWIG_name, (char*)SWIG_version);
95   
96 #ifdef SWIG_namespace
97   Tcl_Eval(interp, "namespace eval " SWIG_namespace " { }");
98 #endif
99   
100   SWIG_InitializeModule((void *) interp);
101   SWIG_PropagateClientData();
102   
103   for (i = 0; swig_commands[i].name; i++) {
104     Tcl_CreateObjCommand(interp, (char *) swig_commands[i].name, (swig_wrapper_func) swig_commands[i].wrapper,
105                          swig_commands[i].clientdata, NULL);
106   }
107   for (i = 0; swig_variables[i].name; i++) {
108     Tcl_SetVar(interp, (char *) swig_variables[i].name, (char *) "", TCL_GLOBAL_ONLY);
109     Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_READS | TCL_GLOBAL_ONLY, 
110                  (Tcl_VarTraceProc *) swig_variables[i].get, (ClientData) swig_variables[i].addr);
111     Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_WRITES | TCL_GLOBAL_ONLY, 
112                  (Tcl_VarTraceProc *) swig_variables[i].set, (ClientData) swig_variables[i].addr);
113   }
114
115   SWIG_Tcl_InstallConstants(interp, swig_constants);
116
117 %}
118
119 /* Note: the initialization function is closed after all code is generated */