Mercurial > repos > rliterman > csp2
comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/tclOOInt.h @ 69:33d812a61356
planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author | jpayne |
---|---|
date | Tue, 18 Mar 2025 17:55:14 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
67:0e9998148a16 | 69:33d812a61356 |
---|---|
1 /* | |
2 * tclOOInt.h -- | |
3 * | |
4 * This file contains the structure definitions and some of the function | |
5 * declarations for the object-system (NB: not Tcl_Obj, but ::oo). | |
6 * | |
7 * Copyright (c) 2006-2012 by Donal K. Fellows | |
8 * | |
9 * See the file "license.terms" for information on usage and redistribution of | |
10 * this file, and for a DISCLAIMER OF ALL WARRANTIES. | |
11 */ | |
12 | |
13 #ifndef TCL_OO_INTERNAL_H | |
14 #define TCL_OO_INTERNAL_H 1 | |
15 | |
16 #include "tclInt.h" | |
17 #include "tclOO.h" | |
18 | |
19 /* | |
20 * Hack to make things work with Objective C. Note that ObjC isn't really | |
21 * supported, but we don't want to to be actively hostile to it. [Bug 2163447] | |
22 */ | |
23 | |
24 #ifdef __OBJC__ | |
25 #define Class TclOOClass | |
26 #define Object TclOOObject | |
27 #endif /* __OBJC__ */ | |
28 | |
29 /* | |
30 * Forward declarations. | |
31 */ | |
32 | |
33 struct CallChain; | |
34 struct Class; | |
35 struct Foundation; | |
36 struct Object; | |
37 | |
38 /* | |
39 * The data that needs to be stored per method. This record is used to collect | |
40 * information about all sorts of methods, including forwards, constructors | |
41 * and destructors. | |
42 */ | |
43 | |
44 typedef struct Method { | |
45 const Tcl_MethodType *typePtr; | |
46 /* The type of method. If NULL, this is a | |
47 * special flag record which is just used for | |
48 * the setting of the flags field. */ | |
49 int refCount; | |
50 void *clientData; /* Type-specific data. */ | |
51 Tcl_Obj *namePtr; /* Name of the method. */ | |
52 struct Object *declaringObjectPtr; | |
53 /* The object that declares this method, or | |
54 * NULL if it was declared by a class. */ | |
55 struct Class *declaringClassPtr; | |
56 /* The class that declares this method, or | |
57 * NULL if it was declared directly on an | |
58 * object. */ | |
59 int flags; /* Assorted flags. Includes whether this | |
60 * method is public/exported or not. */ | |
61 } Method; | |
62 | |
63 /* | |
64 * Pre- and post-call callbacks, to allow procedure-like methods to be fine | |
65 * tuned in their behaviour. | |
66 */ | |
67 | |
68 typedef int (TclOO_PreCallProc)(void *clientData, Tcl_Interp *interp, | |
69 Tcl_ObjectContext context, Tcl_CallFrame *framePtr, int *isFinished); | |
70 typedef int (TclOO_PostCallProc)(void *clientData, Tcl_Interp *interp, | |
71 Tcl_ObjectContext context, Tcl_Namespace *namespacePtr, int result); | |
72 typedef void (TclOO_PmCDDeleteProc)(void *clientData); | |
73 typedef void *(TclOO_PmCDCloneProc)(void *clientData); | |
74 | |
75 /* | |
76 * Procedure-like methods have the following extra information. | |
77 */ | |
78 | |
79 typedef struct ProcedureMethod { | |
80 int version; /* Version of this structure. Currently must | |
81 * be 0. */ | |
82 Proc *procPtr; /* Core of the implementation of the method; | |
83 * includes the argument definition and the | |
84 * body bytecodes. */ | |
85 int flags; /* Flags to control features. */ | |
86 int refCount; | |
87 void *clientData; | |
88 TclOO_PmCDDeleteProc *deleteClientdataProc; | |
89 TclOO_PmCDCloneProc *cloneClientdataProc; | |
90 ProcErrorProc *errProc; /* Replacement error handler. */ | |
91 TclOO_PreCallProc *preCallProc; | |
92 /* Callback to allow for additional setup | |
93 * before the method executes. */ | |
94 TclOO_PostCallProc *postCallProc; | |
95 /* Callback to allow for additional cleanup | |
96 * after the method executes. */ | |
97 GetFrameInfoValueProc *gfivProc; | |
98 /* Callback to allow for fine tuning of how | |
99 * the method reports itself. */ | |
100 } ProcedureMethod; | |
101 | |
102 #define TCLOO_PROCEDURE_METHOD_VERSION 0 | |
103 | |
104 /* | |
105 * Flags for use in a ProcedureMethod. | |
106 * | |
107 * When the USE_DECLARER_NS flag is set, the method will use the namespace of | |
108 * the object or class that declared it (or the clone of it, if it was from | |
109 * such that the implementation of the method came to the particular use) | |
110 * instead of the namespace of the object on which the method was invoked. | |
111 * This flag must be distinct from all others that are associated with | |
112 * methods. | |
113 */ | |
114 | |
115 #define USE_DECLARER_NS 0x80 | |
116 | |
117 /* | |
118 * Forwarded methods have the following extra information. | |
119 */ | |
120 | |
121 typedef struct ForwardMethod { | |
122 Tcl_Obj *prefixObj; /* The list of values to use to replace the | |
123 * object and method name with. Will be a | |
124 * non-empty list. */ | |
125 } ForwardMethod; | |
126 | |
127 /* | |
128 * Helper definitions that declare a "list" array. The two varieties are | |
129 * either optimized for simplicity (in the case that the whole array is | |
130 * typically assigned at once) or efficiency (in the case that the array is | |
131 * expected to be expanded over time). These lists are designed to be iterated | |
132 * over with the help of the FOREACH macro (see later in this file). | |
133 * | |
134 * The "num" field always counts the number of listType_t elements used in the | |
135 * "list" field. When a "size" field exists, it describes how many elements | |
136 * are present in the list; when absent, exactly "num" elements are present. | |
137 */ | |
138 | |
139 #define LIST_STATIC(listType_t) \ | |
140 struct { int num; listType_t *list; } | |
141 #define LIST_DYNAMIC(listType_t) \ | |
142 struct { int num, size; listType_t *list; } | |
143 | |
144 /* | |
145 * Now, the definition of what an object actually is. | |
146 */ | |
147 | |
148 typedef struct Object { | |
149 struct Foundation *fPtr; /* The basis for the object system. Putting | |
150 * this here allows the avoidance of quite a | |
151 * lot of hash lookups on the critical path | |
152 * for object invocation and creation. */ | |
153 Tcl_Namespace *namespacePtr;/* This object's namespace. */ | |
154 Tcl_Command command; /* Reference to this object's public | |
155 * command. */ | |
156 Tcl_Command myCommand; /* Reference to this object's internal | |
157 * command. */ | |
158 struct Class *selfCls; /* This object's class. */ | |
159 Tcl_HashTable *methodsPtr; /* Object-local Tcl_Obj (method name) to | |
160 * Method* mapping. */ | |
161 LIST_STATIC(struct Class *) mixins; | |
162 /* Classes mixed into this object. */ | |
163 LIST_STATIC(Tcl_Obj *) filters; | |
164 /* List of filter names. */ | |
165 struct Class *classPtr; /* This is non-NULL for all classes, and NULL | |
166 * for everything else. It points to the class | |
167 * structure. */ | |
168 int refCount; /* Number of strong references to this object. | |
169 * Note that there may be many more weak | |
170 * references; this mechanism exists to | |
171 * avoid Tcl_Preserve. */ | |
172 int flags; | |
173 int creationEpoch; /* Unique value to make comparisons of objects | |
174 * easier. */ | |
175 int epoch; /* Per-object epoch, incremented when the way | |
176 * an object should resolve call chains is | |
177 * changed. */ | |
178 Tcl_HashTable *metadataPtr; /* Mapping from pointers to metadata type to | |
179 * the ClientData values that are the values | |
180 * of each piece of attached metadata. This | |
181 * field starts out as NULL and is only | |
182 * allocated if metadata is attached. */ | |
183 Tcl_Obj *cachedNameObj; /* Cache of the name of the object. */ | |
184 Tcl_HashTable *chainCache; /* Place to keep unused contexts. This table | |
185 * is indexed by method name as Tcl_Obj. */ | |
186 Tcl_ObjectMapMethodNameProc *mapMethodNameProc; | |
187 /* Function to allow remapping of method | |
188 * names. For itcl-ng. */ | |
189 LIST_STATIC(Tcl_Obj *) variables; | |
190 } Object; | |
191 | |
192 #define OBJECT_DESTRUCTING 1 /* Indicates that an object is being or has | |
193 * been destroyed */ | |
194 #define DESTRUCTOR_CALLED 2 /* Indicates that evaluation of destructor script for the | |
195 object has began */ | |
196 #define OO_UNUSED_4 4 /* No longer used. */ | |
197 #define ROOT_OBJECT 0x1000 /* Flag to say that this object is the root of | |
198 * the class hierarchy and should be treated | |
199 * specially during teardown. */ | |
200 #define FILTER_HANDLING 0x2000 /* Flag set when the object is processing a | |
201 * filter; when set, filters are *not* | |
202 * processed on the object, preventing nasty | |
203 * recursive filtering problems. */ | |
204 #define USE_CLASS_CACHE 0x4000 /* Flag set to say that the object is a pure | |
205 * instance of the class, and has had nothing | |
206 * added that changes the dispatch chain (i.e. | |
207 * no methods, mixins, or filters. */ | |
208 #define ROOT_CLASS 0x8000 /* Flag to say that this object is the root | |
209 * class of classes, and should be treated | |
210 * specially during teardown (and in a few | |
211 * other spots). */ | |
212 #define FORCE_UNKNOWN 0x10000 /* States that we are *really* looking up the | |
213 * unknown method handler at that point. */ | |
214 #define DONT_DELETE 0x20000 /* Inhibit deletion of this object. */ | |
215 | |
216 /* | |
217 * And the definition of a class. Note that every class also has an associated | |
218 * object, through which it is manipulated. | |
219 */ | |
220 | |
221 typedef struct Class { | |
222 Object *thisPtr; /* Reference to the object associated with | |
223 * this class. */ | |
224 int flags; /* Assorted flags. */ | |
225 LIST_STATIC(struct Class *) superclasses; | |
226 /* List of superclasses, used for generation | |
227 * of method call chains. */ | |
228 LIST_DYNAMIC(struct Class *) subclasses; | |
229 /* List of subclasses, used to ensure deletion | |
230 * of dependent entities happens properly when | |
231 * the class itself is deleted. */ | |
232 LIST_DYNAMIC(Object *) instances; | |
233 /* List of instances, used to ensure deletion | |
234 * of dependent entities happens properly when | |
235 * the class itself is deleted. */ | |
236 LIST_STATIC(Tcl_Obj *) filters; | |
237 /* List of filter names, used for generation | |
238 * of method call chains. */ | |
239 LIST_STATIC(struct Class *) mixins; | |
240 /* List of mixin classes, used for generation | |
241 * of method call chains. */ | |
242 LIST_DYNAMIC(struct Class *) mixinSubs; | |
243 /* List of classes that this class is mixed | |
244 * into, used to ensure deletion of dependent | |
245 * entities happens properly when the class | |
246 * itself is deleted. */ | |
247 Tcl_HashTable classMethods; /* Hash table of all methods. Hash maps from | |
248 * the (Tcl_Obj*) method name to the (Method*) | |
249 * method record. */ | |
250 Method *constructorPtr; /* Method record of the class constructor (if | |
251 * any). */ | |
252 Method *destructorPtr; /* Method record of the class destructor (if | |
253 * any). */ | |
254 Tcl_HashTable *metadataPtr; /* Mapping from pointers to metadata type to | |
255 * the ClientData values that are the values | |
256 * of each piece of attached metadata. This | |
257 * field starts out as NULL and is only | |
258 * allocated if metadata is attached. */ | |
259 struct CallChain *constructorChainPtr; | |
260 struct CallChain *destructorChainPtr; | |
261 Tcl_HashTable *classChainCache; | |
262 /* Places where call chains are stored. For | |
263 * constructors, the class chain is always | |
264 * used. For destructors and ordinary methods, | |
265 * the class chain is only used when the | |
266 * object doesn't override with its own mixins | |
267 * (and filters and method implementations for | |
268 * when getting method chains). */ | |
269 LIST_STATIC(Tcl_Obj *) variables; | |
270 } Class; | |
271 | |
272 /* | |
273 * The foundation of the object system within an interpreter contains | |
274 * references to the key classes and namespaces, together with a few other | |
275 * useful bits and pieces. Probably ought to eventually go in the Interp | |
276 * structure itself. | |
277 */ | |
278 | |
279 typedef struct ThreadLocalData { | |
280 int nsCount; /* Epoch counter is used for keeping | |
281 * the values used in Tcl_Obj internal | |
282 * representations sane. Must be thread-local | |
283 * because Tcl_Objs can cross interpreter | |
284 * boundaries within a thread (objects don't | |
285 * generally cross threads). */ | |
286 } ThreadLocalData; | |
287 | |
288 typedef struct Foundation { | |
289 Tcl_Interp *interp; | |
290 Class *objectCls; /* The root of the object system. */ | |
291 Class *classCls; /* The class of all classes. */ | |
292 Tcl_Namespace *ooNs; /* ::oo namespace. */ | |
293 Tcl_Namespace *defineNs; /* Namespace containing special commands for | |
294 * manipulating objects and classes. The | |
295 * "oo::define" command acts as a special kind | |
296 * of ensemble for this namespace. */ | |
297 Tcl_Namespace *objdefNs; /* Namespace containing special commands for | |
298 * manipulating objects and classes. The | |
299 * "oo::objdefine" command acts as a special | |
300 * kind of ensemble for this namespace. */ | |
301 Tcl_Namespace *helpersNs; /* Namespace containing the commands that are | |
302 * only valid when executing inside a | |
303 * procedural method. */ | |
304 int epoch; /* Used to invalidate method chains when the | |
305 * class structure changes. */ | |
306 ThreadLocalData *tsdPtr; /* Counter so we can allocate a unique | |
307 * namespace to each object. */ | |
308 Tcl_Obj *unknownMethodNameObj; | |
309 /* Shared object containing the name of the | |
310 * unknown method handler method. */ | |
311 Tcl_Obj *constructorName; /* Shared object containing the "name" of a | |
312 * constructor. */ | |
313 Tcl_Obj *destructorName; /* Shared object containing the "name" of a | |
314 * destructor. */ | |
315 Tcl_Obj *clonedName; /* Shared object containing the name of a | |
316 * "<cloned>" pseudo-constructor. */ | |
317 Tcl_Obj *defineName; /* Fully qualified name of oo::define. */ | |
318 } Foundation; | |
319 | |
320 /* | |
321 * A call context structure is built when a method is called. It contains the | |
322 * chain of method implementations that are to be invoked by a particular | |
323 * call, and the process of calling walks the chain, with the [next] command | |
324 * proceeding to the next entry in the chain. | |
325 */ | |
326 | |
327 #define CALL_CHAIN_STATIC_SIZE 4 | |
328 | |
329 struct MInvoke { | |
330 Method *mPtr; /* Reference to the method implementation | |
331 * record. */ | |
332 int isFilter; /* Whether this is a filter invocation. */ | |
333 Class *filterDeclarer; /* What class decided to add the filter; if | |
334 * NULL, it was added by the object. */ | |
335 }; | |
336 | |
337 typedef struct CallChain { | |
338 int objectCreationEpoch; /* The object's creation epoch. Note that the | |
339 * object reference is not stored in the call | |
340 * chain; it is in the call context. */ | |
341 int objectEpoch; /* Local (object structure) epoch counter | |
342 * snapshot. */ | |
343 int epoch; /* Global (class structure) epoch counter | |
344 * snapshot. */ | |
345 int flags; /* Assorted flags, see below. */ | |
346 int refCount; /* Reference count. */ | |
347 int numChain; /* Size of the call chain. */ | |
348 struct MInvoke *chain; /* Array of call chain entries. May point to | |
349 * staticChain if the number of entries is | |
350 * small. */ | |
351 struct MInvoke staticChain[CALL_CHAIN_STATIC_SIZE]; | |
352 } CallChain; | |
353 | |
354 typedef struct CallContext { | |
355 Object *oPtr; /* The object associated with this call. */ | |
356 int index; /* Index into the call chain of the currently | |
357 * executing method implementation. */ | |
358 int skip; /* Current number of arguments to skip; can | |
359 * vary depending on whether it is a direct | |
360 * method call or a continuation via the | |
361 * [next] command. */ | |
362 CallChain *callPtr; /* The actual call chain. */ | |
363 } CallContext; | |
364 | |
365 /* | |
366 * Bits for the 'flags' field of the call chain. | |
367 */ | |
368 | |
369 #define PUBLIC_METHOD 0x01 /* This is a public (exported) method. */ | |
370 #define PRIVATE_METHOD 0x02 /* This is a private (class's direct instances | |
371 * only) method. Supports itcl. */ | |
372 #define OO_UNKNOWN_METHOD 0x04 /* This is an unknown method. */ | |
373 #define CONSTRUCTOR 0x08 /* This is a constructor. */ | |
374 #define DESTRUCTOR 0x10 /* This is a destructor. */ | |
375 | |
376 /* | |
377 * Structure containing definition information about basic class methods. | |
378 */ | |
379 | |
380 typedef struct { | |
381 const char *name; /* Name of the method in question. */ | |
382 int isPublic; /* Whether the method is public by default. */ | |
383 Tcl_MethodType definition; /* How to call the method. */ | |
384 } DeclaredClassMethod; | |
385 | |
386 /* | |
387 *---------------------------------------------------------------- | |
388 * Commands relating to OO support. | |
389 *---------------------------------------------------------------- | |
390 */ | |
391 | |
392 MODULE_SCOPE int TclOOInit(Tcl_Interp *interp); | |
393 MODULE_SCOPE int TclOODefineObjCmd(void *clientData, | |
394 Tcl_Interp *interp, int objc, | |
395 Tcl_Obj *const *objv); | |
396 MODULE_SCOPE int TclOOObjDefObjCmd(void *clientData, | |
397 Tcl_Interp *interp, int objc, | |
398 Tcl_Obj *const *objv); | |
399 MODULE_SCOPE int TclOODefineConstructorObjCmd(void *clientData, | |
400 Tcl_Interp *interp, int objc, | |
401 Tcl_Obj *const *objv); | |
402 MODULE_SCOPE int TclOODefineDeleteMethodObjCmd(void *clientData, | |
403 Tcl_Interp *interp, int objc, | |
404 Tcl_Obj *const *objv); | |
405 MODULE_SCOPE int TclOODefineDestructorObjCmd(void *clientData, | |
406 Tcl_Interp *interp, int objc, | |
407 Tcl_Obj *const *objv); | |
408 MODULE_SCOPE int TclOODefineExportObjCmd(void *clientData, | |
409 Tcl_Interp *interp, int objc, | |
410 Tcl_Obj *const *objv); | |
411 MODULE_SCOPE int TclOODefineForwardObjCmd(void *clientData, | |
412 Tcl_Interp *interp, int objc, | |
413 Tcl_Obj *const *objv); | |
414 MODULE_SCOPE int TclOODefineMethodObjCmd(void *clientData, | |
415 Tcl_Interp *interp, int objc, | |
416 Tcl_Obj *const *objv); | |
417 MODULE_SCOPE int TclOODefineRenameMethodObjCmd(void *clientData, | |
418 Tcl_Interp *interp, int objc, | |
419 Tcl_Obj *const *objv); | |
420 MODULE_SCOPE int TclOODefineUnexportObjCmd(void *clientData, | |
421 Tcl_Interp *interp, int objc, | |
422 Tcl_Obj *const *objv); | |
423 MODULE_SCOPE int TclOODefineClassObjCmd(void *clientData, | |
424 Tcl_Interp *interp, int objc, | |
425 Tcl_Obj *const *objv); | |
426 MODULE_SCOPE int TclOODefineSelfObjCmd(void *clientData, | |
427 Tcl_Interp *interp, int objc, | |
428 Tcl_Obj *const *objv); | |
429 MODULE_SCOPE int TclOOUnknownDefinition(void *clientData, | |
430 Tcl_Interp *interp, int objc, | |
431 Tcl_Obj *const *objv); | |
432 MODULE_SCOPE int TclOOCopyObjectCmd(void *clientData, | |
433 Tcl_Interp *interp, int objc, | |
434 Tcl_Obj *const *objv); | |
435 MODULE_SCOPE int TclOONextObjCmd(void *clientData, | |
436 Tcl_Interp *interp, int objc, | |
437 Tcl_Obj *const *objv); | |
438 MODULE_SCOPE int TclOONextToObjCmd(void *clientData, | |
439 Tcl_Interp *interp, int objc, | |
440 Tcl_Obj *const *objv); | |
441 MODULE_SCOPE int TclOOSelfObjCmd(void *clientData, | |
442 Tcl_Interp *interp, int objc, | |
443 Tcl_Obj *const *objv); | |
444 | |
445 /* | |
446 * Method implementations (in tclOOBasic.c). | |
447 */ | |
448 | |
449 MODULE_SCOPE int TclOO_Class_Constructor(void *clientData, | |
450 Tcl_Interp *interp, Tcl_ObjectContext context, | |
451 int objc, Tcl_Obj *const *objv); | |
452 MODULE_SCOPE int TclOO_Class_Create(void *clientData, | |
453 Tcl_Interp *interp, Tcl_ObjectContext context, | |
454 int objc, Tcl_Obj *const *objv); | |
455 MODULE_SCOPE int TclOO_Class_CreateNs(void *clientData, | |
456 Tcl_Interp *interp, Tcl_ObjectContext context, | |
457 int objc, Tcl_Obj *const *objv); | |
458 MODULE_SCOPE int TclOO_Class_New(void *clientData, | |
459 Tcl_Interp *interp, Tcl_ObjectContext context, | |
460 int objc, Tcl_Obj *const *objv); | |
461 MODULE_SCOPE int TclOO_Object_Destroy(void *clientData, | |
462 Tcl_Interp *interp, Tcl_ObjectContext context, | |
463 int objc, Tcl_Obj *const *objv); | |
464 MODULE_SCOPE int TclOO_Object_Eval(void *clientData, | |
465 Tcl_Interp *interp, Tcl_ObjectContext context, | |
466 int objc, Tcl_Obj *const *objv); | |
467 MODULE_SCOPE int TclOO_Object_LinkVar(void *clientData, | |
468 Tcl_Interp *interp, Tcl_ObjectContext context, | |
469 int objc, Tcl_Obj *const *objv); | |
470 MODULE_SCOPE int TclOO_Object_Unknown(void *clientData, | |
471 Tcl_Interp *interp, Tcl_ObjectContext context, | |
472 int objc, Tcl_Obj *const *objv); | |
473 MODULE_SCOPE int TclOO_Object_VarName(void *clientData, | |
474 Tcl_Interp *interp, Tcl_ObjectContext context, | |
475 int objc, Tcl_Obj *const *objv); | |
476 | |
477 /* | |
478 * Private definitions, some of which perhaps ought to be exposed properly or | |
479 * maybe just put in the internal stubs table. | |
480 */ | |
481 | |
482 MODULE_SCOPE void TclOOAddToInstances(Object *oPtr, Class *clsPtr); | |
483 MODULE_SCOPE void TclOOAddToMixinSubs(Class *subPtr, Class *mixinPtr); | |
484 MODULE_SCOPE void TclOOAddToSubclasses(Class *subPtr, Class *superPtr); | |
485 MODULE_SCOPE Class * TclOOAllocClass(Tcl_Interp *interp, | |
486 Object *useThisObj); | |
487 MODULE_SCOPE int TclNRNewObjectInstance(Tcl_Interp *interp, | |
488 Tcl_Class cls, const char *nameStr, | |
489 const char *nsNameStr, int objc, | |
490 Tcl_Obj *const *objv, int skip, | |
491 Tcl_Object *objectPtr); | |
492 MODULE_SCOPE Object * TclNewObjectInstanceCommon(Tcl_Interp *interp, | |
493 Class *classPtr, | |
494 const char *nameStr, | |
495 const char *nsNameStr); | |
496 MODULE_SCOPE int TclOODecrRefCount(Object *oPtr); | |
497 MODULE_SCOPE int TclOOObjectDestroyed(Object *oPtr); | |
498 MODULE_SCOPE int TclOODefineSlots(Foundation *fPtr); | |
499 MODULE_SCOPE void TclOODeleteChain(CallChain *callPtr); | |
500 MODULE_SCOPE void TclOODeleteChainCache(Tcl_HashTable *tablePtr); | |
501 MODULE_SCOPE void TclOODeleteContext(CallContext *contextPtr); | |
502 MODULE_SCOPE void TclOODeleteDescendants(Tcl_Interp *interp, | |
503 Object *oPtr); | |
504 MODULE_SCOPE void TclOODelMethodRef(Method *method); | |
505 MODULE_SCOPE CallContext *TclOOGetCallContext(Object *oPtr, | |
506 Tcl_Obj *methodNameObj, int flags, | |
507 Tcl_Obj *cacheInThisObj); | |
508 MODULE_SCOPE CallChain *TclOOGetStereotypeCallChain(Class *clsPtr, | |
509 Tcl_Obj *methodNameObj, int flags); | |
510 MODULE_SCOPE Foundation *TclOOGetFoundation(Tcl_Interp *interp); | |
511 MODULE_SCOPE Tcl_Obj * TclOOGetFwdFromMethod(Method *mPtr); | |
512 MODULE_SCOPE Proc * TclOOGetProcFromMethod(Method *mPtr); | |
513 MODULE_SCOPE Tcl_Obj * TclOOGetMethodBody(Method *mPtr); | |
514 MODULE_SCOPE int TclOOGetSortedClassMethodList(Class *clsPtr, | |
515 int flags, const char ***stringsPtr); | |
516 MODULE_SCOPE int TclOOGetSortedMethodList(Object *oPtr, int flags, | |
517 const char ***stringsPtr); | |
518 MODULE_SCOPE int TclOOInit(Tcl_Interp *interp); | |
519 MODULE_SCOPE void TclOOInitInfo(Tcl_Interp *interp); | |
520 MODULE_SCOPE int TclOOInvokeContext(void *clientData, | |
521 Tcl_Interp *interp, int objc, | |
522 Tcl_Obj *const objv[]); | |
523 MODULE_SCOPE int TclNRObjectContextInvokeNext(Tcl_Interp *interp, | |
524 Tcl_ObjectContext context, int objc, | |
525 Tcl_Obj *const *objv, int skip); | |
526 MODULE_SCOPE void TclOONewBasicMethod(Tcl_Interp *interp, Class *clsPtr, | |
527 const DeclaredClassMethod *dcm); | |
528 MODULE_SCOPE Tcl_Obj * TclOOObjectName(Tcl_Interp *interp, Object *oPtr); | |
529 MODULE_SCOPE void TclOOReleaseClassContents(Tcl_Interp *interp, | |
530 Object *oPtr); | |
531 MODULE_SCOPE int TclOORemoveFromInstances(Object *oPtr, Class *clsPtr); | |
532 MODULE_SCOPE int TclOORemoveFromMixins(Class *mixinPtr, Object *oPtr); | |
533 MODULE_SCOPE int TclOORemoveFromMixinSubs(Class *subPtr, | |
534 Class *mixinPtr); | |
535 MODULE_SCOPE int TclOORemoveFromSubclasses(Class *subPtr, | |
536 Class *superPtr); | |
537 MODULE_SCOPE Tcl_Obj * TclOORenderCallChain(Tcl_Interp *interp, | |
538 CallChain *callPtr); | |
539 MODULE_SCOPE void TclOOStashContext(Tcl_Obj *objPtr, | |
540 CallContext *contextPtr); | |
541 MODULE_SCOPE void TclOOSetupVariableResolver(Tcl_Namespace *nsPtr); | |
542 | |
543 /* | |
544 * Include all the private API, generated from tclOO.decls. | |
545 */ | |
546 | |
547 #include "tclOOIntDecls.h" | |
548 | |
549 /* | |
550 * Alternatives to Tcl_Preserve/Tcl_EventuallyFree/Tcl_Release. | |
551 */ | |
552 | |
553 #define AddRef(ptr) ((ptr)->refCount++) | |
554 | |
555 /* | |
556 * A convenience macro for iterating through the lists used in the internal | |
557 * memory management of objects. | |
558 * REQUIRES DECLARATION: int i; | |
559 */ | |
560 | |
561 #define FOREACH(var,ary) \ | |
562 for(i=0 ; i<(ary).num; i++) if ((ary).list[i] == NULL) { \ | |
563 continue; \ | |
564 } else if ((var) = (ary).list[i], 1) | |
565 | |
566 /* | |
567 * Convenience macros for iterating through hash tables. FOREACH_HASH_DECLS | |
568 * sets up the declarations needed for the main macro, FOREACH_HASH, which | |
569 * does the actual iteration. FOREACH_HASH_VALUE is a restricted version that | |
570 * only iterates over values. | |
571 */ | |
572 | |
573 #define FOREACH_HASH_DECLS \ | |
574 Tcl_HashEntry *hPtr;Tcl_HashSearch search | |
575 #define FOREACH_HASH(key,val,tablePtr) \ | |
576 for(hPtr=Tcl_FirstHashEntry((tablePtr),&search); hPtr!=NULL ? \ | |
577 ((key)=(void *)Tcl_GetHashKey((tablePtr),hPtr),\ | |
578 (val)=Tcl_GetHashValue(hPtr),1):0; hPtr=Tcl_NextHashEntry(&search)) | |
579 #define FOREACH_HASH_VALUE(val,tablePtr) \ | |
580 for(hPtr=Tcl_FirstHashEntry((tablePtr),&search); hPtr!=NULL ? \ | |
581 ((val)=Tcl_GetHashValue(hPtr),1):0;hPtr=Tcl_NextHashEntry(&search)) | |
582 | |
583 /* | |
584 * Convenience macro for duplicating a list. Needs no external declaration, | |
585 * but all arguments are used multiple times and so must have no side effects. | |
586 */ | |
587 | |
588 #undef DUPLICATE /* prevent possible conflict with definition in WINAPI nb30.h */ | |
589 #define DUPLICATE(target,source,type) \ | |
590 do { \ | |
591 size_t len = sizeof(type) * ((target).num=(source).num);\ | |
592 if (len != 0) { \ | |
593 memcpy(((target).list=(type*)ckalloc(len)), (source).list, len); \ | |
594 } else { \ | |
595 (target).list = NULL; \ | |
596 } \ | |
597 } while(0) | |
598 | |
599 #endif /* TCL_OO_INTERNAL_H */ | |
600 | |
601 /* | |
602 * Local Variables: | |
603 * mode: c | |
604 * c-basic-offset: 4 | |
605 * fill-column: 78 | |
606 * End: | |
607 */ |