PageRenderTime 25ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Lib/tcl/wish.i

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