tkStubLib.c
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:3k
源码类别:

通讯编程

开发平台:

Visual C++

  1. /* 
  2.  * tkStubLib.c --
  3.  *
  4.  * Stub object that will be statically linked into extensions that wish
  5.  * to access Tk.
  6.  *
  7.  * Copyright (c) 1998 Paul Duffin.
  8.  * Copyright (c) 1998-1999 by Scriptics Corporation.
  9.  *
  10.  * See the file "license.terms" for information on usage and redistribution
  11.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12.  *
  13.  * RCS: @(#) $Id: tkStubLib.c,v 1.8 2002/08/31 06:12:27 das Exp $
  14.  */
  15. /*
  16.  * We need to ensure that we use the stub macros so that this file contains
  17.  * no references to any of the stub functions.  This will make it possible
  18.  * to build an extension that references Tk_InitStubs but doesn't end up
  19.  * including the rest of the stub functions.
  20.  */
  21. #ifndef USE_TCL_STUBS
  22. #define USE_TCL_STUBS
  23. #endif
  24. #undef USE_TCL_STUB_PROCS
  25. #ifndef USE_TK_STUBS
  26. #define USE_TK_STUBS
  27. #endif
  28. #undef USE_TK_STUB_PROCS
  29. #include "tkPort.h"
  30. #include "tkInt.h"
  31. #ifdef __WIN32__
  32. #include "tkWinInt.h"
  33. #endif
  34. #ifdef MAC_TCL
  35. #include "tkMacInt.h"
  36. #endif
  37. #ifdef MAC_OSX_TK
  38. #include "tkMacOSXInt.h"
  39. #endif
  40. #include "tkDecls.h"
  41. #include "tkIntDecls.h"
  42. #include "tkPlatDecls.h"
  43. #include "tkIntPlatDecls.h"
  44. #include "tkIntXlibDecls.h"
  45. /*
  46.  * Ensure that Tk_InitStubs is built as an exported symbol.  The other stub
  47.  * functions should be built as non-exported symbols.
  48.  */
  49. #undef TCL_STORAGE_CLASS
  50. #define TCL_STORAGE_CLASS DLLEXPORT
  51. TkStubs *tkStubsPtr;
  52. TkPlatStubs *tkPlatStubsPtr;
  53. TkIntStubs *tkIntStubsPtr;
  54. TkIntPlatStubs *tkIntPlatStubsPtr;
  55. TkIntXlibStubs *tkIntXlibStubsPtr;
  56. /*
  57.  *----------------------------------------------------------------------
  58.  *
  59.  * Tk_InitStubs --
  60.  *
  61.  * Checks that the correct version of Tk is loaded and that it
  62.  * supports stubs. It then initialises the stub table pointers.
  63.  *
  64.  * Results:
  65.  * The actual version of Tk that satisfies the request, or
  66.  * NULL to indicate that an error occurred.
  67.  *
  68.  * Side effects:
  69.  * Sets the stub table pointers.
  70.  *
  71.  *----------------------------------------------------------------------
  72.  */
  73. #ifdef Tk_InitStubs
  74. #undef Tk_InitStubs
  75. #endif
  76. CONST char *
  77. Tk_InitStubs(interp, version, exact)
  78.     Tcl_Interp *interp;
  79.     char *version;
  80.     int exact;
  81. {
  82.     CONST char *actualVersion;
  83.     actualVersion = Tcl_PkgRequireEx(interp, "Tk", version, exact,
  84. (ClientData *) &tkStubsPtr);
  85.     if (!actualVersion) {
  86. return NULL;
  87.     }
  88.     if (!tkStubsPtr) {
  89. Tcl_SetResult(interp,
  90. "This implementation of Tk does not support stubs",
  91. TCL_STATIC);
  92. return NULL;
  93.     }
  94.     
  95.     tkPlatStubsPtr = tkStubsPtr->hooks->tkPlatStubs;
  96.     tkIntStubsPtr = tkStubsPtr->hooks->tkIntStubs;
  97.     tkIntPlatStubsPtr = tkStubsPtr->hooks->tkIntPlatStubs;
  98.     tkIntXlibStubsPtr = tkStubsPtr->hooks->tkIntXlibStubs;
  99.     
  100.     return actualVersion;
  101. }