1/*
2 * ------------------------------------------------------------------------
3 *      PACKAGE:  [incr Tcl]
4 *  DESCRIPTION:  Object-Oriented Extensions to Tcl
5 *
6 *  [incr Tcl] provides object-oriented extensions to Tcl, much as
7 *  C++ provides object-oriented extensions to C.  It provides a means
8 *  of encapsulating related procedures together with their shared data
9 *  in a local namespace that is hidden from the outside world.  It
10 *  promotes code re-use through inheritance.  More than anything else,
11 *  it encourages better organization of Tcl applications through the
12 *  object-oriented paradigm, leading to code that is easier to
13 *  understand and maintain.
14 *
15 *  ADDING [incr Tcl] TO A Tcl-BASED APPLICATION:
16 *
17 *    To add [incr Tcl] facilities to a Tcl application, modify the
18 *    Tcl_AppInit() routine as follows:
19 *
20 *    1) Include this header file near the top of the file containing
21 *       Tcl_AppInit():
22 *
23 *         #include "itcl.h"
24 *
25 *    2) Within the body of Tcl_AppInit(), add the following lines:
26 *
27 *         if (Itcl_Init(interp) == TCL_ERROR) {
28 *             return TCL_ERROR;
29 *         }
30 *
31 *    3) Link your application with libitcl.a
32 *
33 *    NOTE:  An example file "tclAppInit.c" containing the changes shown
34 *           above is included in this distribution.
35 *
36 * ========================================================================
37 *  AUTHOR:  Michael J. McLennan
38 *           Bell Labs Innovations for Lucent Technologies
39 *           mmclennan@lucent.com
40 *           http://www.tcltk.com/itcl
41 *
42 *     RCS:  $Id: itcl.h,v 1.31 2007/05/24 22:15:41 hobbs Exp $
43 * ========================================================================
44 *           Copyright (c) 1993-1998  Lucent Technologies, Inc.
45 * ------------------------------------------------------------------------
46 * See the file "license.terms" for information on usage and redistribution
47 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
48 */
49#ifndef ITCL_H
50#define ITCL_H
51
52#include "tcl.h"
53
54#ifndef TCL_ALPHA_RELEASE
55#   define TCL_ALPHA_RELEASE	0
56#endif
57#ifndef TCL_BETA_RELEASE
58#   define TCL_BETA_RELEASE	1
59#endif
60#ifndef TCL_FINAL_RELEASE
61#   define TCL_FINAL_RELEASE	2
62#endif
63
64
65#define ITCL_MAJOR_VERSION	3
66#define ITCL_MINOR_VERSION	4
67#define ITCL_RELEASE_LEVEL	TCL_FINAL_RELEASE
68#define ITCL_RELEASE_SERIAL	0
69
70#define ITCL_VERSION		"3.4"
71#define ITCL_PATCH_LEVEL	"3.4.0"
72
73/*
74 * A special definition used to allow this header file to be included
75 * in resource files so that they can get obtain version information from
76 * this file.  Resource compilers don't like all the C stuff, like typedefs
77 * and procedure declarations, that occur below.
78 */
79
80#ifndef RC_INVOKED
81
82#undef TCL_STORAGE_CLASS
83#ifdef BUILD_itcl
84#   define TCL_STORAGE_CLASS DLLEXPORT
85#else
86#   ifdef USE_ITCL_STUBS
87#	define TCL_STORAGE_CLASS
88#   else
89#	define TCL_STORAGE_CLASS DLLIMPORT
90#   endif
91#endif
92
93/*
94 * Fix the Borland bug that's in the EXTERN macro from tcl.h.
95 */
96#ifndef TCL_EXTERN
97#   undef DLLIMPORT
98#   undef DLLEXPORT
99#   ifdef __cplusplus
100#	define TCL_EXTERNC extern "C"
101#   else
102#	define TCL_EXTERNC extern
103#   endif
104#   if defined(STATIC_BUILD)
105#	define DLLIMPORT
106#	define DLLEXPORT
107#	define TCL_EXTERN(RTYPE) TCL_EXTERNC RTYPE
108#   elif (defined(__WIN32__) && ( \
109	    defined(_MSC_VER) || (__BORLANDC__ >= 0x0550) || \
110	    defined(__LCC__) || defined(__WATCOMC__) || \
111	    (defined(__GNUC__) && defined(__declspec)) \
112	)) || (defined(MAC_TCL) && FUNCTION_DECLSPEC)
113#	define DLLIMPORT __declspec(dllimport)
114#	define DLLEXPORT __declspec(dllexport)
115#	define TCL_EXTERN(RTYPE) TCL_EXTERNC TCL_STORAGE_CLASS RTYPE
116#   elif defined(__BORLANDC__)
117#	define DLLIMPORT __import
118#	define DLLEXPORT __export
119	/* Pre-5.5 Borland requires the attributes be placed after the */
120	/* return type instead. */
121#	define TCL_EXTERN(RTYPE) TCL_EXTERNC RTYPE TCL_STORAGE_CLASS
122#   else
123#	define DLLIMPORT
124#	define DLLEXPORT
125#	define TCL_EXTERN(RTYPE) TCL_EXTERNC TCL_STORAGE_CLASS RTYPE
126#   endif
127#endif
128
129
130/*
131 * Starting from the 8.4 core, Tcl API is CONST'ified.  Our API is always
132 * CONST, but we need to build with Tcl when it isn't CONST and fake it
133 * when needed with <= 8.3
134 *
135 * http://wiki.tcl.tk/3669
136 */
137
138#ifndef CONST84
139#   define CONST84
140#endif
141
142
143/*
144 * Protection levels:
145 *
146 * ITCL_PUBLIC    - accessible from any namespace
147 * ITCL_PROTECTED - accessible from namespace that imports in "protected" mode
148 * ITCL_PRIVATE   - accessible only within the namespace that contains it
149 */
150#define ITCL_PUBLIC           1
151#define ITCL_PROTECTED        2
152#define ITCL_PRIVATE          3
153#define ITCL_DEFAULT_PROTECT  4
154
155
156/*
157 *  Generic stack.
158 */
159typedef struct Itcl_Stack {
160    ClientData *values;          /* values on stack */
161    int len;                     /* number of values on stack */
162    int max;                     /* maximum size of stack */
163    ClientData space[5];         /* initial space for stack data */
164} Itcl_Stack;
165
166#define Itcl_GetStackSize(stackPtr) ((stackPtr)->len)
167
168/*
169 *  Generic linked list.
170 */
171struct Itcl_List;
172typedef struct Itcl_ListElem {
173    struct Itcl_List* owner;     /* list containing this element */
174    ClientData value;            /* value associated with this element */
175    struct Itcl_ListElem *prev;  /* previous element in linked list */
176    struct Itcl_ListElem *next;  /* next element in linked list */
177} Itcl_ListElem;
178
179typedef struct Itcl_List {
180    int validate;                /* validation stamp */
181    int num;                     /* number of elements */
182    struct Itcl_ListElem *head;  /* previous element in linked list */
183    struct Itcl_ListElem *tail;  /* next element in linked list */
184} Itcl_List;
185
186#define Itcl_FirstListElem(listPtr) ((listPtr)->head)
187#define Itcl_LastListElem(listPtr)  ((listPtr)->tail)
188#define Itcl_NextListElem(elemPtr)  ((elemPtr)->next)
189#define Itcl_PrevListElem(elemPtr)  ((elemPtr)->prev)
190#define Itcl_GetListLength(listPtr) ((listPtr)->num)
191#define Itcl_GetListValue(elemPtr)  ((elemPtr)->value)
192
193/*
194 *  Token representing the state of an interpreter.
195 */
196typedef struct Itcl_InterpState_ *Itcl_InterpState;
197
198
199/*
200 * Include the public function declarations that are accessible via
201 * the stubs table.
202 */
203
204#include "itclDecls.h"
205
206
207/*
208 * Itcl_InitStubs is used by extensions like Itk that can be linked
209 * against the itcl stubs library.  If we are not using stubs
210 * then this reduces to package require.
211 */
212
213#ifdef USE_ITCL_STUBS
214
215TCL_EXTERNC CONST char *
216	Itcl_InitStubs _ANSI_ARGS_((Tcl_Interp *interp,
217			    CONST char *version, int exact));
218#else
219#define Itcl_InitStubs(interp, version, exact) \
220      Tcl_PkgRequire(interp, "Itcl", version, exact)
221#endif
222
223/*
224 * Public functions that are not accessible via the stubs table.
225 */
226
227
228#endif /* RC_INVOKED */
229
230#undef TCL_STORAGE_CLASS
231#define TCL_STORAGE_CLASS DLLIMPORT
232
233#endif /* ITCL_H */
234