Home | History | Annotate | Download | only in tcl
      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   size_t 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 /* Create fast method lookup tables */
     71 
     72 SWIGINTERN void
     73 SWIG_Tcl_InstallMethodLookupTables(void) {
     74   size_t i;
     75 
     76   for (i = 0; i < swig_module.size; ++i) {
     77     swig_type_info *type = swig_module.type_initial[i];
     78     if (type->clientdata) {
     79       swig_class* klass = (swig_class*) type->clientdata;
     80       swig_method* meth;
     81       Tcl_InitHashTable(&(klass->hashtable), TCL_STRING_KEYS);
     82       for (meth = klass->methods; meth && meth->name; ++meth) {
     83         int newEntry;
     84         Tcl_HashEntry* hashentry = Tcl_CreateHashEntry(&(klass->hashtable), meth->name, &newEntry);
     85         Tcl_SetHashValue(hashentry, (ClientData)meth->method);
     86       }
     87     }
     88   }
     89 }
     90 
     91 #ifdef __cplusplus
     92 }
     93 #endif
     94 
     95 /* -----------------------------------------------------------------------------*
     96  *  Partial Init method
     97  * -----------------------------------------------------------------------------*/
     98 
     99 SWIGEXPORT int SWIG_init(Tcl_Interp *interp) {
    100   size_t i;
    101   if (interp == 0) return TCL_ERROR;
    102 #ifdef USE_TCL_STUBS
    103   /* (char*) cast is required to avoid compiler warning/error for Tcl < 8.4. */
    104   if (Tcl_InitStubs(interp, (char*)SWIG_TCL_STUBS_VERSION, 0) == NULL) {
    105     return TCL_ERROR;
    106   }
    107 #endif
    108 #ifdef USE_TK_STUBS
    109   /* (char*) cast is required to avoid compiler warning/error. */
    110   if (Tk_InitStubs(interp, (char*)SWIG_TCL_STUBS_VERSION, 0) == NULL) {
    111     return TCL_ERROR;
    112   }
    113 #endif
    114 
    115   Tcl_PkgProvide(interp, (char*)SWIG_name, (char*)SWIG_version);
    116 
    117 #ifdef SWIG_namespace
    118   Tcl_Eval(interp, "namespace eval " SWIG_namespace " { }");
    119 #endif
    120 
    121   SWIG_InitializeModule((void *) interp);
    122   SWIG_PropagateClientData();
    123 
    124   for (i = 0; swig_commands[i].name; i++) {
    125     Tcl_CreateObjCommand(interp, (char *) swig_commands[i].name, (swig_wrapper_func) swig_commands[i].wrapper,
    126 			 swig_commands[i].clientdata, NULL);
    127   }
    128   for (i = 0; swig_variables[i].name; i++) {
    129     Tcl_SetVar(interp, (char *) swig_variables[i].name, (char *) "", TCL_GLOBAL_ONLY);
    130     Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_READS | TCL_GLOBAL_ONLY,
    131 		 (Tcl_VarTraceProc *) swig_variables[i].get, (ClientData) swig_variables[i].addr);
    132     Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_WRITES | TCL_GLOBAL_ONLY,
    133 		 (Tcl_VarTraceProc *) swig_variables[i].set, (ClientData) swig_variables[i].addr);
    134   }
    135 
    136   SWIG_Tcl_InstallConstants(interp, swig_constants);
    137   SWIG_Tcl_InstallMethodLookupTables();
    138 
    139 %}
    140 
    141 /* Note: the initialization function is closed after all code is generated */
    142