OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/hostdependX86LINUX64.git] / util / X86LINUX64 / include / itcl.h
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  * ------------------------------------------------------------------------
19  *      PACKAGE:  [incr Tcl]
20  *  DESCRIPTION:  Object-Oriented Extensions to Tcl
21  *
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.
30  *
31  *  ADDING [incr Tcl] TO A Tcl-BASED APPLICATION:
32  *
33  *    To add [incr Tcl] facilities to a Tcl application, modify the
34  *    Tcl_AppInit() routine as follows:
35  *
36  *    1) Include this header file near the top of the file containing
37  *       Tcl_AppInit():
38  *
39  *         #include "itcl.h"
40 *
41  *    2) Within the body of Tcl_AppInit(), add the following lines:
42  *
43  *         if (Itcl_Init(interp) == TCL_ERROR) {
44  *             return TCL_ERROR;
45  *         }
46  *
47  *    3) Link your application with libitcl.a
48  *
49  *    NOTE:  An example file "tclAppInit.c" containing the changes shown
50  *           above is included in this distribution.
51  *
52  *---------------------------------------------------------------------
53  */
54
55 #ifndef ITCL_H_INCLUDED
56 #define ITCL_H_INCLUDED
57
58 #include <tcl.h>
59
60 #if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 6)
61 #    error Itcl 4 build requires tcl.h from Tcl 8.6 or later
62 #endif
63
64 /*
65  * For C++ compilers, use extern "C"
66  */
67
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71
72 #ifndef TCL_ALPHA_RELEASE
73 #   define TCL_ALPHA_RELEASE    0
74 #endif
75 #ifndef TCL_BETA_RELEASE
76 #   define TCL_BETA_RELEASE     1
77 #endif
78 #ifndef TCL_FINAL_RELEASE
79 #   define TCL_FINAL_RELEASE    2
80 #endif
81
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
86
87 #define ITCL_VERSION            "4.0"
88 #define ITCL_PATCH_LEVEL        "4.0.3"
89
90
91 /*
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.
95  *
96  * Resource compilers don't like all the C stuff, like typedefs and function
97  * declarations, that occur below, so block them out.
98  */
99
100 #ifndef RC_INVOKED
101
102 #define ITCL_NAMESPACE          "::itcl"
103
104 #ifndef ITCLAPI
105 #   if defined(BUILD_itcl)
106 #       define ITCLAPI MODULE_SCOPE
107 #   else
108 #       define ITCLAPI extern
109 #       undef USE_ITCL_STUBS
110 #       define USE_ITCL_STUBS 1
111 #   endif
112 #endif
113
114 #if defined(BUILD_itcl) && !defined(STATIC_BUILD)
115 #   define ITCL_EXTERN extern DLLEXPORT
116 #else
117 #   define ITCL_EXTERN extern
118 #endif
119
120 ITCL_EXTERN int Itcl_Init(Tcl_Interp *interp);
121 ITCL_EXTERN int Itcl_SafeInit(Tcl_Interp *interp);
122
123 /*
124  * Protection levels:
125  *
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
129  */
130 #define ITCL_PUBLIC           1
131 #define ITCL_PROTECTED        2
132 #define ITCL_PRIVATE          3
133 #define ITCL_DEFAULT_PROTECT  4
134
135 /*
136  *  Generic stack.
137  */
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 */
143 } Itcl_Stack;
144
145 #define Itcl_GetStackSize(stackPtr) ((stackPtr)->len)
146
147 /*
148  *  Generic linked list.
149  */
150 struct Itcl_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 */
156 } Itcl_ListElem;
157
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 */
163 } Itcl_List;
164
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)
171
172 /*
173  *  Token representing the state of an interpreter.
174  */
175 typedef struct Itcl_InterpState_ *Itcl_InterpState;
176
177 \f
178 /*
179  * Include all the public API, generated from itcl.decls.
180  */
181
182 #include "itclDecls.h"
183
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__)
191 #endif
192
193 #endif /* RC_INVOKED */
194
195 /*
196  * end block for C++
197  */
198
199 #ifdef __cplusplus
200 }
201 #endif
202
203 #endif /* ITCL_H_INCLUDED */