PageRenderTime 787ms CodeModel.GetById 77ms app.highlight 57ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1.3.35/Lib/tcl/wish.i

#
Swig | 149 lines | 74 code | 27 blank | 48 comment | 0 complexity | 71bb9bd9c1cd3ad77162cbca1040545d MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1/* -----------------------------------------------------------------------------
  2 * See the LICENSE file for information on copyright, usage and redistribution
  3 * of SWIG, and the README file for authors - http://www.swig.org/release.html.
  4 *
  5 * wish.i
  6 *
  7 * SWIG File for making wish
  8 * ----------------------------------------------------------------------------- */
  9
 10#ifdef AUTODOC
 11%subsection "wish.i"
 12%text %{
 13This module provides the Tk_AppInit() function needed to build a 
 14new version of the wish executable.   Like tclsh.i, this file should
 15not be used with dynamic loading.  To make an interface file work with
 16both static and dynamic loading, put something like this in your
 17interface file :
 18
 19     #ifdef STATIC
 20     %include <wish.i>
 21     #endif
 22
 23A startup file may be specified by defining the symbol SWIG_RcFileName
 24as follows (this should be included in a code-block) :
 25
 26     #define SWIG_RcFileName    "~/.mywishrc"
 27%}
 28#endif
 29
 30%{
 31
 32
 33/* Initialization code for wish */
 34
 35#include <tk.h>
 36
 37#ifndef SWIG_RcFileName
 38char *SWIG_RcFileName = "~/.wishrc";
 39#endif
 40
 41#ifdef MAC_TCL
 42extern int	MacintoshInit _ANSI_ARGS_((void));
 43extern int	SetupMainInterp _ANSI_ARGS_((Tcl_Interp *interp));
 44#endif
 45
 46/*
 47 *----------------------------------------------------------------------
 48 *
 49 * Tcl_AppInit --
 50 *
 51 *	This procedure performs application-specific initialization.
 52 *	Most applications, especially those that incorporate additional
 53 *	packages, will have their own version of this procedure.
 54 *
 55 * Results:
 56 *	Returns a standard Tcl completion code, and leaves an error
 57 *	message in interp->result if an error occurs.
 58 *
 59 * Side effects:
 60 *	Depends on the startup script.
 61 *
 62 *----------------------------------------------------------------------
 63 */
 64
 65int Tcl_AppInit(Tcl_Interp *interp)
 66{
 67#ifndef MAC_TCL
 68    Tk_Window main;
 69    main = Tk_MainWindow(interp);
 70#endif
 71    /*
 72     * Call the init procedures for included packages.  Each call should
 73     * look like this:
 74     *
 75     * if (Mod_Init(interp) == TCL_ERROR) {
 76     *     return TCL_ERROR;
 77     * }
 78     *
 79     * where "Mod" is the name of the module.
 80     */
 81
 82    if (Tcl_Init(interp) == TCL_ERROR) {
 83	return TCL_ERROR;
 84    }
 85
 86    if (Tk_Init(interp) == TCL_ERROR) {
 87	return TCL_ERROR;
 88    }
 89
 90    /*
 91     * Call Tcl_CreateCommand for application-specific commands, if
 92     * they weren't already created by the init procedures called above.
 93     */
 94
 95    if (SWIG_init(interp) == TCL_ERROR) {
 96      return TCL_ERROR;
 97    }
 98    
 99#ifdef MAC_TCL
100    SetupMainInterp(interp);
101#endif
102        
103    /*
104     * Specify a user-specific startup file to invoke if the application
105     * is run interactively.  Typically the startup file is "~/.apprc"
106     * where "app" is the name of the application.  If this line is deleted
107     * then no user-specific startup file will be run under any conditions.
108     */
109
110#if TCL_MAJOR_VERSION >= 8 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 5
111   Tcl_SetVar(interp, (char *) "tcl_rcFileName",SWIG_RcFileName,TCL_GLOBAL_ONLY);
112#else
113   tcl_RcFileName = SWIG_RcFileName;
114#endif
115
116/* For Macintosh might also want this */
117
118#ifdef MAC_TCL
119#ifdef SWIG_RcRsrcName
120    Tcl_SetVar(interp, (char *) "tcl_rcRsrcName",SWIG_RcRsrcName,TCL_GLOBAL_ONLY);
121#endif
122#endif
123    return TCL_OK;
124}
125
126#if TK_MAJOR_VERSION >= 4
127int main(int argc, char **argv) {
128
129#ifdef MAC_TCL
130  char *newArgv[2];
131  if (MacintoshInit() != TCL_OK) {
132      Tcl_Exit(1);
133  }
134  argc = 1;
135  newArgv[0] = "Wish";
136  newArgv[1] = NULL;
137  argv = newArgv;
138#endif
139  Tk_Main(argc, argv, Tcl_AppInit);
140  return(0);
141}
142#else
143extern int main();
144#endif
145
146%}
147
148
149