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