itcl.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * itcl.h --
  3. *
  4. * This file contains definitions for the C-implemeted part of a Itcl
  5. * this version of [incr Tcl] (Itcl) is a completely new implementation
  6. * based on TclOO extension of Tcl 8.5
  7. * It tries to provide the same interfaces as the original implementation
  8. * of Michael J. McLennan
  9. * Some small pieces of code are taken from that implementation
  10. *
  11. * Copyright (c) 2007 by Arnulf P. Wiedemann
  12. *
  13. * See the file "license.terms" for information on usage and redistribution of
  14. * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  15. */
  16. /*
  17. * ------------------------------------------------------------------------
  18. * PACKAGE: [incr Tcl]
  19. * DESCRIPTION: Object-Oriented Extensions to Tcl
  20. *
  21. * [incr Tcl] provides object-oriented extensions to Tcl, much as
  22. * C++ provides object-oriented extensions to C. It provides a means
  23. * of encapsulating related procedures together with their shared data
  24. * in a local namespace that is hidden from the outside world. It
  25. * promotes code re-use through inheritance. More than anything else,
  26. * it encourages better organization of Tcl applications through the
  27. * object-oriented paradigm, leading to code that is easier to
  28. * understand and maintain.
  29. *
  30. * ADDING [incr Tcl] TO A Tcl-BASED APPLICATION:
  31. *
  32. * To add [incr Tcl] facilities to a Tcl application, modify the
  33. * Tcl_AppInit() routine as follows:
  34. *
  35. * 1) Include this header file near the top of the file containing
  36. * Tcl_AppInit():
  37. *
  38. * #include "itcl.h"
  39. *
  40. * 2) Within the body of Tcl_AppInit(), add the following lines:
  41. *
  42. * if (Itcl_Init(interp) == TCL_ERROR) {
  43. * return TCL_ERROR;
  44. * }
  45. *
  46. * 3) Link your application with libitcl.a
  47. *
  48. * NOTE: An example file "tclAppInit.c" containing the changes shown
  49. * above is included in this distribution.
  50. *
  51. *---------------------------------------------------------------------
  52. */
  53. #ifndef ITCL_H_INCLUDED
  54. #define ITCL_H_INCLUDED
  55. #include <tcl.h>
  56. #if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 6)
  57. # error Itcl 4 build requires tcl.h from Tcl 8.6 or later
  58. #endif
  59. /*
  60. * For C++ compilers, use extern "C"
  61. */
  62. #ifdef __cplusplus
  63. extern "C" {
  64. #endif
  65. #ifndef TCL_ALPHA_RELEASE
  66. # define TCL_ALPHA_RELEASE 0
  67. #endif
  68. #ifndef TCL_BETA_RELEASE
  69. # define TCL_BETA_RELEASE 1
  70. #endif
  71. #ifndef TCL_FINAL_RELEASE
  72. # define TCL_FINAL_RELEASE 2
  73. #endif
  74. #define ITCL_MAJOR_VERSION 4
  75. #define ITCL_MINOR_VERSION 2
  76. #define ITCL_RELEASE_LEVEL TCL_FINAL_RELEASE
  77. #define ITCL_RELEASE_SERIAL 2
  78. #define ITCL_VERSION "4.2"
  79. #define ITCL_PATCH_LEVEL "4.2.2"
  80. /*
  81. * A special definition used to allow this header file to be included from
  82. * windows resource files so that they can obtain version information.
  83. * RC_INVOKED is defined by default by the windows RC tool.
  84. *
  85. * Resource compilers don't like all the C stuff, like typedefs and function
  86. * declarations, that occur below, so block them out.
  87. */
  88. #ifndef RC_INVOKED
  89. #define ITCL_NAMESPACE "::itcl"
  90. #ifndef ITCLAPI
  91. # if defined(BUILD_itcl)
  92. # define ITCLAPI MODULE_SCOPE
  93. # else
  94. # define ITCLAPI extern
  95. # undef USE_ITCL_STUBS
  96. # define USE_ITCL_STUBS 1
  97. # endif
  98. #endif
  99. #if defined(BUILD_itcl) && !defined(STATIC_BUILD)
  100. # define ITCL_EXTERN extern DLLEXPORT
  101. #else
  102. # define ITCL_EXTERN extern
  103. #endif
  104. ITCL_EXTERN int Itcl_Init(Tcl_Interp *interp);
  105. ITCL_EXTERN int Itcl_SafeInit(Tcl_Interp *interp);
  106. /*
  107. * Protection levels:
  108. *
  109. * ITCL_PUBLIC - accessible from any namespace
  110. * ITCL_PROTECTED - accessible from namespace that imports in "protected" mode
  111. * ITCL_PRIVATE - accessible only within the namespace that contains it
  112. */
  113. #define ITCL_PUBLIC 1
  114. #define ITCL_PROTECTED 2
  115. #define ITCL_PRIVATE 3
  116. #define ITCL_DEFAULT_PROTECT 4
  117. /*
  118. * Generic stack.
  119. */
  120. typedef struct Itcl_Stack {
  121. ClientData *values; /* values on stack */
  122. int len; /* number of values on stack */
  123. int max; /* maximum size of stack */
  124. ClientData space[5]; /* initial space for stack data */
  125. } Itcl_Stack;
  126. #define Itcl_GetStackSize(stackPtr) ((stackPtr)->len)
  127. /*
  128. * Generic linked list.
  129. */
  130. struct Itcl_List;
  131. typedef struct Itcl_ListElem {
  132. struct Itcl_List* owner; /* list containing this element */
  133. ClientData value; /* value associated with this element */
  134. struct Itcl_ListElem *prev; /* previous element in linked list */
  135. struct Itcl_ListElem *next; /* next element in linked list */
  136. } Itcl_ListElem;
  137. typedef struct Itcl_List {
  138. int validate; /* validation stamp */
  139. int num; /* number of elements */
  140. struct Itcl_ListElem *head; /* previous element in linked list */
  141. struct Itcl_ListElem *tail; /* next element in linked list */
  142. } Itcl_List;
  143. #define Itcl_FirstListElem(listPtr) ((listPtr)->head)
  144. #define Itcl_LastListElem(listPtr) ((listPtr)->tail)
  145. #define Itcl_NextListElem(elemPtr) ((elemPtr)->next)
  146. #define Itcl_PrevListElem(elemPtr) ((elemPtr)->prev)
  147. #define Itcl_GetListLength(listPtr) ((listPtr)->num)
  148. #define Itcl_GetListValue(elemPtr) ((elemPtr)->value)
  149. /*
  150. * Token representing the state of an interpreter.
  151. */
  152. typedef struct Itcl_InterpState_ *Itcl_InterpState;
  153. /*
  154. * Include all the public API, generated from itcl.decls.
  155. */
  156. #include "itclDecls.h"
  157. #endif /* RC_INVOKED */
  158. /*
  159. * end block for C++
  160. */
  161. #ifdef __cplusplus
  162. }
  163. #endif
  164. #endif /* ITCL_H_INCLUDED */