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
11 * Copyright (c) 2007 by Arnulf P. Wiedemann
13 * See the file "license.terms" for information on usage and redistribution of
14 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
18 * ------------------------------------------------------------------------
20 * DESCRIPTION: Object-Oriented Extensions to Tcl
22 * [incr Tcl] provides object-oriented extensions to Tcl, much as
23 * C++ provides object-oriented extensions to C. It provides a means
24 * of encapsulating related procedures together with their shared data
25 * in a local namespace that is hidden from the outside world. It
26 * promotes code re-use through inheritance. More than anything else,
27 * it encourages better organization of Tcl applications through the
28 * object-oriented paradigm, leading to code that is easier to
29 * understand and maintain.
31 * ADDING [incr Tcl] TO A Tcl-BASED APPLICATION:
33 * To add [incr Tcl] facilities to a Tcl application, modify the
34 * Tcl_AppInit() routine as follows:
36 * 1) Include this header file near the top of the file containing
41 * 2) Within the body of Tcl_AppInit(), add the following lines:
43 * if (Itcl_Init(interp) == TCL_ERROR) {
47 * 3) Link your application with libitcl.a
49 * NOTE: An example file "tclAppInit.c" containing the changes shown
50 * above is included in this distribution.
52 *---------------------------------------------------------------------
55 #ifndef ITCL_H_INCLUDED
56 #define ITCL_H_INCLUDED
60 #if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 6)
61 # error Itcl 4 build requires tcl.h from Tcl 8.6 or later
65 * For C++ compilers, use extern "C"
72 #ifndef TCL_ALPHA_RELEASE
73 # define TCL_ALPHA_RELEASE 0
75 #ifndef TCL_BETA_RELEASE
76 # define TCL_BETA_RELEASE 1
78 #ifndef TCL_FINAL_RELEASE
79 # define TCL_FINAL_RELEASE 2
82 #define ITCL_MAJOR_VERSION 4
83 #define ITCL_MINOR_VERSION 0
84 #define ITCL_RELEASE_LEVEL TCL_FINAL_RELEASE
85 #define ITCL_RELEASE_SERIAL 3
87 #define ITCL_VERSION "4.0"
88 #define ITCL_PATCH_LEVEL "4.0.3"
92 * A special definition used to allow this header file to be included from
93 * windows resource files so that they can obtain version information.
94 * RC_INVOKED is defined by default by the windows RC tool.
96 * Resource compilers don't like all the C stuff, like typedefs and function
97 * declarations, that occur below, so block them out.
102 #define ITCL_NAMESPACE "::itcl"
105 # if defined(BUILD_itcl)
106 # define ITCLAPI MODULE_SCOPE
108 # define ITCLAPI extern
109 # undef USE_ITCL_STUBS
110 # define USE_ITCL_STUBS 1
114 #if defined(BUILD_itcl) && !defined(STATIC_BUILD)
115 # define ITCL_EXTERN extern DLLEXPORT
117 # define ITCL_EXTERN extern
120 ITCL_EXTERN int Itcl_Init(Tcl_Interp *interp);
121 ITCL_EXTERN int Itcl_SafeInit(Tcl_Interp *interp);
126 * ITCL_PUBLIC - accessible from any namespace
127 * ITCL_PROTECTED - accessible from namespace that imports in "protected" mode
128 * ITCL_PRIVATE - accessible only within the namespace that contains it
130 #define ITCL_PUBLIC 1
131 #define ITCL_PROTECTED 2
132 #define ITCL_PRIVATE 3
133 #define ITCL_DEFAULT_PROTECT 4
138 typedef struct Itcl_Stack {
139 ClientData *values; /* values on stack */
140 int len; /* number of values on stack */
141 int max; /* maximum size of stack */
142 ClientData space[5]; /* initial space for stack data */
145 #define Itcl_GetStackSize(stackPtr) ((stackPtr)->len)
148 * Generic linked list.
151 typedef struct Itcl_ListElem {
152 struct Itcl_List* owner; /* list containing this element */
153 ClientData value; /* value associated with this element */
154 struct Itcl_ListElem *prev; /* previous element in linked list */
155 struct Itcl_ListElem *next; /* next element in linked list */
158 typedef struct Itcl_List {
159 int validate; /* validation stamp */
160 int num; /* number of elements */
161 struct Itcl_ListElem *head; /* previous element in linked list */
162 struct Itcl_ListElem *tail; /* next element in linked list */
165 #define Itcl_FirstListElem(listPtr) ((listPtr)->head)
166 #define Itcl_LastListElem(listPtr) ((listPtr)->tail)
167 #define Itcl_NextListElem(elemPtr) ((elemPtr)->next)
168 #define Itcl_PrevListElem(elemPtr) ((elemPtr)->prev)
169 #define Itcl_GetListLength(listPtr) ((listPtr)->num)
170 #define Itcl_GetListValue(elemPtr) ((elemPtr)->value)
173 * Token representing the state of an interpreter.
175 typedef struct Itcl_InterpState_ *Itcl_InterpState;
179 * Include all the public API, generated from itcl.decls.
182 #include "itclDecls.h"
184 #ifdef ITCL_PRESERVE_DEBUG
185 #undef Itcl_PreserveData
186 #undef Itcl_ReleaseData
187 void ItclDbgPreserveData(ClientData cdata, int line, const char *file);
188 void ItclDbgReleaseData(ClientData cdata, int line, const char *file);
189 #define Itcl_PreserveData(addr) ItclDbgPreserveData(addr, __LINE__, __FILE__)
190 #define Itcl_ReleaseData(addr) ItclDbgReleaseData(addr, __LINE__, __FILE__)
193 #endif /* RC_INVOKED */
203 #endif /* ITCL_H_INCLUDED */