Home | History | Annotate | Download | only in tcl
      1 /* -----------------------------------------------------------------------------
      2  * tclsh.i
      3  *
      4  * SWIG File for building new tclsh program
      5  * ----------------------------------------------------------------------------- */
      6 
      7 #ifdef AUTODOC
      8 %subsection "tclsh.i"
      9 %text %{
     10 This module provides the Tcl_AppInit() function needed to build a
     11 new version of the tclsh executable.   This file should not be used
     12 when using dynamic loading.   To make an interface file work with
     13 both static and dynamic loading, put something like this in your
     14 interface file :
     15 
     16      #ifdef STATIC
     17      %include <tclsh.i>
     18      #endif
     19 %}
     20 #endif
     21 
     22 %{
     23 
     24 /* A TCL_AppInit() function that lets you build a new copy
     25  * of tclsh.
     26  *
     27  * The macro SWIG_init contains the name of the initialization
     28  * function in the wrapper file.
     29  */
     30 
     31 #ifndef SWIG_RcFileName
     32 char *SWIG_RcFileName = "~/.myapprc";
     33 #endif
     34 
     35 
     36 #ifdef MAC_TCL
     37 extern int		MacintoshInit _ANSI_ARGS_((void));
     38 #endif
     39 
     40 int Tcl_AppInit(Tcl_Interp *interp){
     41 
     42   if (Tcl_Init(interp) == TCL_ERROR)
     43     return TCL_ERROR;
     44 
     45   /* Now initialize our functions */
     46 
     47   if (SWIG_init(interp) == TCL_ERROR)
     48     return TCL_ERROR;
     49 #if TCL_MAJOR_VERSION > 7 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 5
     50    Tcl_SetVar(interp, (char *) "tcl_rcFileName",SWIG_RcFileName,TCL_GLOBAL_ONLY);
     51 #else
     52    tcl_RcFileName = SWIG_RcFileName;
     53 #endif
     54 #ifdef SWIG_RcRsrcName
     55   Tcl_SetVar(interp, (char *) "tcl_rcRsrcName",SWIG_RcRsrcName,TCL_GLOBAL);
     56 #endif
     57 
     58   return TCL_OK;
     59 }
     60 
     61 #if TCL_MAJOR_VERSION > 7 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 4
     62 int main(int argc, char **argv) {
     63 #ifdef MAC_TCL
     64     char *newArgv[2];
     65 
     66     if (MacintoshInit()  != TCL_OK) {
     67 	Tcl_Exit(1);
     68     }
     69 
     70     argc = 1;
     71     newArgv[0] = "tclsh";
     72     newArgv[1] = NULL;
     73     argv = newArgv;
     74 #endif
     75 
     76   Tcl_Main(argc, argv, Tcl_AppInit);
     77   return(0);
     78 
     79 }
     80 #else
     81 extern int main();
     82 #endif
     83 
     84 %}
     85 
     86