PageRenderTime 15ms CodeModel.GetById 12ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Lib/tcl/tclsh.i

#
Swig | 85 lines | 54 code | 19 blank | 12 comment | 0 complexity | 3c4be5103bdc8bda224661a04981017c MD5 | raw file
 1/* -----------------------------------------------------------------------------
 2 * tclsh.i
 3 *
 4 * SWIG File for building new tclsh program
 5 * ----------------------------------------------------------------------------- */
 6
 7#ifdef AUTODOC
 8%subsection "tclsh.i"
 9%text %{
10This module provides the Tcl_AppInit() function needed to build a 
11new version of the tclsh executable.   This file should not be used
12when using dynamic loading.   To make an interface file work with
13both static and dynamic loading, put something like this in your
14interface 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
32char *SWIG_RcFileName = "~/.myapprc";
33#endif
34
35
36#ifdef MAC_TCL
37extern int		MacintoshInit _ANSI_ARGS_((void));
38#endif
39
40int 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
62int 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
81extern int main();
82#endif
83
84%}
85