1 |
578 |
markom |
/*
|
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.1.1.1 2002-01-16 10:24:46 markom 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 |
|
|
#define ITCL_VERSION "3.0"
|
55 |
|
|
#define ITCL_PATCH_LEVEL "3.0"
|
56 |
|
|
#define ITCL_MAJOR_VERSION 3
|
57 |
|
|
#define ITCL_MINOR_VERSION 0
|
58 |
|
|
#define ITCL_RELEASE_LEVEL 0
|
59 |
|
|
|
60 |
|
|
/*
|
61 |
|
|
* A special definition used to allow this header file to be included
|
62 |
|
|
* in resource files so that they can get obtain version information from
|
63 |
|
|
* this file. Resource compilers don't like all the C stuff, like typedefs
|
64 |
|
|
* and procedure declarations, that occur below.
|
65 |
|
|
*/
|
66 |
|
|
|
67 |
|
|
#ifndef RESOURCE_INCLUDED
|
68 |
|
|
|
69 |
|
|
#include "tclInt.h"
|
70 |
|
|
|
71 |
|
|
#ifdef BUILD_itcl
|
72 |
|
|
# undef TCL_STORAGE_CLASS
|
73 |
|
|
# define TCL_STORAGE_CLASS DLLEXPORT
|
74 |
|
|
#endif
|
75 |
|
|
|
76 |
|
|
/*
|
77 |
|
|
* Protection levels:
|
78 |
|
|
*
|
79 |
|
|
* ITCL_PUBLIC - accessible from any namespace
|
80 |
|
|
* ITCL_PROTECTED - accessible from namespace that imports in "protected" mode
|
81 |
|
|
* ITCL_PRIVATE - accessible only within the namespace that contains it
|
82 |
|
|
*/
|
83 |
|
|
#define ITCL_PUBLIC 1
|
84 |
|
|
#define ITCL_PROTECTED 2
|
85 |
|
|
#define ITCL_PRIVATE 3
|
86 |
|
|
#define ITCL_DEFAULT_PROTECT 4
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
/*
|
90 |
|
|
* Generic stack.
|
91 |
|
|
*/
|
92 |
|
|
typedef struct Itcl_Stack {
|
93 |
|
|
ClientData *values; /* values on stack */
|
94 |
|
|
int len; /* number of values on stack */
|
95 |
|
|
int max; /* maximum size of stack */
|
96 |
|
|
ClientData space[5]; /* initial space for stack data */
|
97 |
|
|
} Itcl_Stack;
|
98 |
|
|
|
99 |
|
|
#define Itcl_GetStackSize(stackPtr) ((stackPtr)->len)
|
100 |
|
|
|
101 |
|
|
/*
|
102 |
|
|
* Generic linked list.
|
103 |
|
|
*/
|
104 |
|
|
struct Itcl_List;
|
105 |
|
|
typedef struct Itcl_ListElem {
|
106 |
|
|
struct Itcl_List* owner; /* list containing this element */
|
107 |
|
|
ClientData value; /* value associated with this element */
|
108 |
|
|
struct Itcl_ListElem *prev; /* previous element in linked list */
|
109 |
|
|
struct Itcl_ListElem *next; /* next element in linked list */
|
110 |
|
|
} Itcl_ListElem;
|
111 |
|
|
|
112 |
|
|
typedef struct Itcl_List {
|
113 |
|
|
int validate; /* validation stamp */
|
114 |
|
|
int num; /* number of elements */
|
115 |
|
|
struct Itcl_ListElem *head; /* previous element in linked list */
|
116 |
|
|
struct Itcl_ListElem *tail; /* next element in linked list */
|
117 |
|
|
} Itcl_List;
|
118 |
|
|
|
119 |
|
|
#define Itcl_FirstListElem(listPtr) ((listPtr)->head)
|
120 |
|
|
#define Itcl_LastListElem(listPtr) ((listPtr)->tail)
|
121 |
|
|
#define Itcl_NextListElem(elemPtr) ((elemPtr)->next)
|
122 |
|
|
#define Itcl_PrevListElem(elemPtr) ((elemPtr)->prev)
|
123 |
|
|
#define Itcl_GetListLength(listPtr) ((listPtr)->num)
|
124 |
|
|
#define Itcl_GetListValue(elemPtr) ((elemPtr)->value)
|
125 |
|
|
|
126 |
|
|
/*
|
127 |
|
|
* Token representing the state of an interpreter.
|
128 |
|
|
*/
|
129 |
|
|
typedef struct Itcl_InterpState_ *Itcl_InterpState;
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
/*
|
133 |
|
|
* Exported functions
|
134 |
|
|
*/
|
135 |
|
|
EXTERN int Itcl_Init _ANSI_ARGS_((Tcl_Interp *interp));
|
136 |
|
|
EXTERN int Itcl_SafeInit _ANSI_ARGS_((Tcl_Interp *interp));
|
137 |
|
|
|
138 |
|
|
EXTERN int Itcl_RegisterC _ANSI_ARGS_((Tcl_Interp *interp,
|
139 |
|
|
char *name, Tcl_CmdProc *proc, ClientData clientData,
|
140 |
|
|
Tcl_CmdDeleteProc *deleteProc));
|
141 |
|
|
EXTERN int Itcl_RegisterObjC _ANSI_ARGS_((Tcl_Interp *interp,
|
142 |
|
|
char *name, Tcl_ObjCmdProc *proc, ClientData clientData,
|
143 |
|
|
Tcl_CmdDeleteProc *deleteProc));
|
144 |
|
|
EXTERN int Itcl_FindC _ANSI_ARGS_((Tcl_Interp *interp, char *name,
|
145 |
|
|
Tcl_CmdProc **argProcPtr, Tcl_ObjCmdProc **objProcPtr,
|
146 |
|
|
ClientData *cDataPtr));
|
147 |
|
|
|
148 |
|
|
EXTERN void Itcl_InitStack _ANSI_ARGS_((Itcl_Stack *stack));
|
149 |
|
|
EXTERN void Itcl_DeleteStack _ANSI_ARGS_((Itcl_Stack *stack));
|
150 |
|
|
EXTERN void Itcl_PushStack _ANSI_ARGS_((ClientData cdata,
|
151 |
|
|
Itcl_Stack *stack));
|
152 |
|
|
EXTERN ClientData Itcl_PopStack _ANSI_ARGS_((Itcl_Stack *stack));
|
153 |
|
|
EXTERN ClientData Itcl_PeekStack _ANSI_ARGS_((Itcl_Stack *stack));
|
154 |
|
|
EXTERN ClientData Itcl_GetStackValue _ANSI_ARGS_((Itcl_Stack *stack,
|
155 |
|
|
int pos));
|
156 |
|
|
|
157 |
|
|
EXTERN void Itcl_InitList _ANSI_ARGS_((Itcl_List *listPtr));
|
158 |
|
|
EXTERN void Itcl_DeleteList _ANSI_ARGS_((Itcl_List *listPtr));
|
159 |
|
|
EXTERN Itcl_ListElem* Itcl_CreateListElem _ANSI_ARGS_((Itcl_List *listPtr));
|
160 |
|
|
EXTERN Itcl_ListElem* Itcl_DeleteListElem _ANSI_ARGS_((Itcl_ListElem *elemPtr));
|
161 |
|
|
EXTERN Itcl_ListElem* Itcl_InsertList _ANSI_ARGS_((Itcl_List *listPtr,
|
162 |
|
|
ClientData val));
|
163 |
|
|
EXTERN Itcl_ListElem* Itcl_InsertListElem _ANSI_ARGS_((Itcl_ListElem *pos,
|
164 |
|
|
ClientData val));
|
165 |
|
|
EXTERN Itcl_ListElem* Itcl_AppendList _ANSI_ARGS_((Itcl_List *listPtr,
|
166 |
|
|
ClientData val));
|
167 |
|
|
EXTERN Itcl_ListElem* Itcl_AppendListElem _ANSI_ARGS_((Itcl_ListElem *pos,
|
168 |
|
|
ClientData val));
|
169 |
|
|
EXTERN void Itcl_SetListValue _ANSI_ARGS_((Itcl_ListElem *elemPtr,
|
170 |
|
|
ClientData val));
|
171 |
|
|
|
172 |
|
|
EXTERN void Itcl_EventuallyFree _ANSI_ARGS_((ClientData cdata,
|
173 |
|
|
Tcl_FreeProc *fproc));
|
174 |
|
|
EXTERN void Itcl_PreserveData _ANSI_ARGS_((ClientData cdata));
|
175 |
|
|
EXTERN void Itcl_ReleaseData _ANSI_ARGS_((ClientData cdata));
|
176 |
|
|
|
177 |
|
|
EXTERN Itcl_InterpState Itcl_SaveInterpState _ANSI_ARGS_((Tcl_Interp* interp,
|
178 |
|
|
int status));
|
179 |
|
|
EXTERN int Itcl_RestoreInterpState _ANSI_ARGS_((Tcl_Interp* interp,
|
180 |
|
|
Itcl_InterpState state));
|
181 |
|
|
EXTERN void Itcl_DiscardInterpState _ANSI_ARGS_((Itcl_InterpState state));
|
182 |
|
|
|
183 |
|
|
#endif /* RESOURCE_INCLUDED */
|
184 |
|
|
|
185 |
|
|
#undef TCL_STORAGE_CLASS
|
186 |
|
|
#define TCL_STORAGE_CLASS DLLIMPORT
|
187 |
|
|
|
188 |
|
|
#endif /* ITCL_H */
|