4 * This file contains internal definitions for the C-implemented part of a
7 * Copyright (c) 2007 by Arnulf P. Wiedemann
9 * See the file "license.terms" for information on usage and redistribution of
10 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
21 * Used to tag functions that are only to be visible within the module being
22 * built and not outside it (where this is supported by the linker).
27 # define MODULE_SCOPE extern "C"
29 # define MODULE_SCOPE extern
37 #include "itclMigrate2TclCore.h"
38 #include "itclTclIntStubsFcn.h"
41 * Utility macros: STRINGIFY takes an argument and wraps it in "" (double
46 # define STRINGIFY(x) STRINGIFY1(x)
47 # define STRINGIFY1(x) #x
51 * Since the Tcl/Tk distribution doesn't perform any asserts,
52 * dynamic loading can fail to find the __assert function.
53 * As a workaround, we'll include our own.
59 #define assert(EX) ((void)0)
61 #define assert(EX) (void)((EX) || (Itcl_Assert(STRINGIFY(EX), __FILE__, __LINE__), 0))
64 #define ITCL_INTERP_DATA "itcl_data"
65 #define ITCL_TK_VERSION "8.6"
68 * Convenience macros for iterating through hash tables. FOREACH_HASH_DECLS
69 * sets up the declarations needed for the main macro, FOREACH_HASH, which
70 * does the actual iteration. FOREACH_HASH_VALUE is a restricted version that
71 * only iterates over values.
74 #define FOREACH_HASH_DECLS \
75 Tcl_HashEntry *hPtr;Tcl_HashSearch search
76 #define FOREACH_HASH(key,val,tablePtr) \
77 for(hPtr=Tcl_FirstHashEntry((tablePtr),&search); hPtr!=NULL ? \
78 ((key)=(void *)Tcl_GetHashKey((tablePtr),hPtr),\
79 (val)=Tcl_GetHashValue(hPtr),1):0; hPtr=Tcl_NextHashEntry(&search))
80 #define FOREACH_HASH_VALUE(val,tablePtr) \
81 for(hPtr=Tcl_FirstHashEntry((tablePtr),&search); hPtr!=NULL ? \
82 ((val)=Tcl_GetHashValue(hPtr),1):0;hPtr=Tcl_NextHashEntry(&search))
85 * What sort of size of things we like to allocate.
90 #define ITCL_VARIABLES_NAMESPACE "::itcl::internal::variables"
91 #define ITCL_COMMANDS_NAMESPACE "::itcl::internal::commands"
93 #ifdef ITCL_PRESERVE_DEBUG
94 #define ITCL_PRESERVE_BUCKET_SIZE 50
95 #define ITCL_PRESERVE_INCR 1
96 #define ITCL_PRESERVE_DECR -1
97 #define ITCL_PRESERVE_DELETED 0
99 typedef struct ItclPreserveInfoEntry {
102 const char * fileName;
103 } ItclPreserveInfoEntry;
105 typedef struct ItclPreserveInfo {
107 ClientData clientData;
110 ItclPreserveInfoEntry *entries;
116 typedef struct ItclFoundation {
117 Itcl_Stack methodCallStack;
118 Tcl_Command dispatchCommand;
121 typedef struct ItclArgList {
122 struct ItclArgList *nextPtr; /* pointer to next argument */
123 Tcl_Obj *namePtr; /* name of the argument */
124 Tcl_Obj *defaultValuePtr; /* default value or NULL if none */
128 * Common info for managing all known objects.
129 * Each interpreter has one of these data structures stored as
130 * clientData in the "itcl" namespace. It is also accessible
131 * as associated data via the key ITCL_INTERP_DATA.
135 struct ItclMemberFunc;
137 struct ItclDelegatedOption;
138 struct ItclDelegatedFunction;
140 typedef struct ItclObjectInfo {
141 Tcl_Interp *interp; /* interpreter that manages this info */
142 Tcl_HashTable objects; /* list of all known objects key is
144 Tcl_HashTable objectCmds; /* list of known objects using accessCmd */
145 Tcl_HashTable objectNames; /* list of known objects using namePtr */
146 Tcl_HashTable classes; /* list of all known classes,
148 Tcl_HashTable nameClasses; /* maps from fullNamePtr to iclsPtr */
149 Tcl_HashTable namespaceClasses; /* maps from nsPtr to iclsPtr */
150 Tcl_HashTable procMethods; /* maps from procPtr to mFunc */
151 Tcl_HashTable instances; /* maps from instanceNumber to ioPtr */
152 Tcl_HashTable objectInstances; /* maps from ioPtr to instanceNumber */
153 Tcl_HashTable unused; /* Obsolete field */
154 Tcl_HashTable classTypes; /* maps from class type i.e. "widget"
155 * to define value i.e. ITCL_WIDGET */
156 int protection; /* protection level currently in effect */
157 int useOldResolvers; /* whether to use the "old" style
158 * resolvers or the CallFrame resolvers */
159 Itcl_Stack clsStack; /* stack of class definitions currently
161 Itcl_Stack contextStack; /* stack of call contexts */
162 Itcl_Stack constructorStack; /* stack of constructor calls */
163 struct ItclObject *currIoPtr; /* object currently being constructed
164 * set only during calling of constructors
166 Tcl_ObjectMetadataType *class_meta_type;
167 /* type for getting the Itcl class info
168 * from a TclOO Tcl_Object */
169 Tcl_ObjectMetadataType *object_meta_type;
170 /* type for getting the Itcl object info
171 * from a TclOO Tcl_Object */
172 Tcl_Object clazzObjectPtr; /* the root object of Itcl */
173 Tcl_Class clazzClassPtr; /* the root class of Itcl */
174 struct EnsembleInfo *ensembleInfo;
175 struct ItclClass *currContextIclsPtr;
176 /* context class for delegated option
178 int currClassFlags; /* flags for the class just in creation */
179 int buildingWidget; /* set if in construction of a widget */
180 int unparsedObjc; /* number options not parsed by
181 ItclExtendedConfigure/-Cget function */
182 Tcl_Obj **unparsedObjv; /* options not parsed by
183 ItclExtendedConfigure/-Cget function */
184 int functionFlags; /* used for creating of ItclMemberCode */
185 int numInstances; /* used for having a unique key for objects
186 * for use in mytypemethod etc. */
187 struct ItclDelegatedOption *currIdoPtr;
188 /* the current delegated option info */
189 int inOptionHandling; /* used to indicate for type/widget ...
190 * that there is an option processing
191 * and methods are allowed to be called */
192 /* these are the Tcl_Obj Ptrs for the clazz unknown procedure */
193 /* need to store them to be able to free them at the end */
194 int itclWidgetInitted; /* set to 1 if itclWidget.tcl has already
197 int itclHullCmdsInitted; /* set to 1 if itclHullCmds.tcl has already
200 Tcl_Obj *unknownNamePtr;
201 Tcl_Obj *unknownArgumentPtr;
202 Tcl_Obj *unknownBodyPtr;
203 Tcl_Obj *infoVarsPtr;
204 Tcl_Obj *infoVars2Ptr;
205 Tcl_Obj *infoVars3Ptr;
206 Tcl_Obj *infoVars4Ptr;
207 Tcl_Obj *typeDestructorArgumentPtr;
208 struct ItclObject *lastIoPtr; /* last object constructed */
211 typedef struct EnsembleInfo {
212 Tcl_HashTable ensembles; /* list of all known ensembles */
213 Tcl_HashTable subEnsembles; /* list of all known subensembles */
215 Tcl_Namespace *ensembleNsPtr;
218 * Representation for each [incr Tcl] class.
220 #define ITCL_CLASS 0x1
221 #define ITCL_TYPE 0x2
222 #define ITCL_WIDGET 0x4
223 #define ITCL_WIDGETADAPTOR 0x8
224 #define ITCL_ECLASS 0x10
225 #define ITCL_NWIDGET 0x20
226 #define ITCL_WIDGET_FRAME 0x40
227 #define ITCL_WIDGET_LABEL_FRAME 0x80
228 #define ITCL_WIDGET_TOPLEVEL 0x100
229 #define ITCL_WIDGET_TTK_FRAME 0x200
230 #define ITCL_WIDGET_TTK_LABEL_FRAME 0x400
231 #define ITCL_WIDGET_TTK_TOPLEVEL 0x800
232 #define ITCL_CLASS_IS_DELETED 0x1000
233 #define ITCL_CLASS_IS_DESTROYED 0x2000
234 #define ITCL_CLASS_NS_IS_DESTROYED 0x4000
235 #define ITCL_CLASS_IS_RENAMED 0x8000
236 #define ITCL_CLASS_IS_FREED 0x10000
237 #define ITCL_CLASS_DERIVED_RELEASED 0x20000
238 #define ITCL_CLASS_NS_TEARDOWN 0x40000
239 #define ITCL_CLASS_NO_VARNS_DELETE 0x80000
240 #define ITCL_CLASS_SHOULD_VARNS_DELETE 0x100000
241 #define ITCL_CLASS_CONSTRUCT_ERROR 0x200000
242 #define ITCL_CLASS_DESTRUCTOR_CALLED 0x400000
245 typedef struct ItclClass {
246 Tcl_Obj *namePtr; /* class name */
247 Tcl_Obj *fullNamePtr; /* fully qualified class name */
248 Tcl_Interp *interp; /* interpreter that manages this info */
249 Tcl_Namespace *nsPtr; /* namespace representing class scope */
250 Tcl_Command accessCmd; /* access command for creating instances */
251 Tcl_Command thisCmd; /* needed for deletion of class */
253 struct ItclObjectInfo *infoPtr;
254 /* info about all known objects
255 * and other stuff like stacks */
256 Itcl_List bases; /* list of base classes */
257 Itcl_List derived; /* list of all derived classes */
258 Tcl_HashTable heritage; /* table of all base classes. Look up
259 * by pointer to class definition. This
260 * provides fast lookup for inheritance
262 Tcl_Obj *initCode; /* initialization code for new objs */
263 Tcl_HashTable variables; /* definitions for all data members
264 in this class. Look up simple string
265 names and get back ItclVariable* ptrs */
266 Tcl_HashTable options; /* definitions for all option members
267 in this class. Look up simple string
268 names and get back ItclOption* ptrs */
269 Tcl_HashTable components; /* definitions for all component members
270 in this class. Look up simple string
271 names and get back ItclComponent* ptrs */
272 Tcl_HashTable functions; /* definitions for all member functions
273 in this class. Look up simple string
274 names and get back ItclMemberFunc* ptrs */
275 Tcl_HashTable delegatedOptions; /* definitions for all delegated options
276 in this class. Look up simple string
278 ItclDelegatedOption * ptrs */
279 Tcl_HashTable delegatedFunctions; /* definitions for all delegated methods
280 or procs in this class. Look up simple
281 string names and get back
282 ItclDelegatedFunction * ptrs */
283 Tcl_HashTable methodVariables; /* definitions for all methodvariable members
284 in this class. Look up simple string
286 ItclMethodVariable* ptrs */
287 int numInstanceVars; /* number of instance vars in variables
289 Tcl_HashTable classCommons; /* used for storing variable namespace
290 * string for Tcl_Resolve */
291 Tcl_HashTable resolveVars; /* all possible names for variables in
292 * this class (e.g., x, foo::x, etc.) */
293 Tcl_HashTable resolveCmds; /* all possible names for functions in
294 * this class (e.g., x, foo::x, etc.) */
295 Tcl_HashTable contextCache; /* cache for function contexts */
296 struct ItclMemberFunc *constructor;
297 /* the class constructor or NULL */
298 struct ItclMemberFunc *destructor;
299 /* the class destructor or NULL */
300 struct ItclMemberFunc *constructorInit;
301 /* the class constructor init code or NULL */
302 Tcl_Resolve *resolvePtr;
303 Tcl_Obj *widgetClassPtr; /* class name for widget if class is a
305 Tcl_Obj *hullTypePtr; /* hulltype name for widget if class is a
307 Tcl_Object oPtr; /* TclOO class object */
308 Tcl_Class clsPtr; /* TclOO class */
309 int numCommons; /* number of commons in this class */
310 int numVariables; /* number of variables in this class */
311 int numOptions; /* number of options in this class */
312 int unique; /* unique number for #auto generation */
313 int flags; /* maintains class status */
314 int callRefCount; /* prevent deleting of class if refcount>1 */
315 Tcl_Obj *typeConstructorPtr; /* initialization for types */
316 int destructorHasBeenCalled; /* prevent multiple invocations of destrcutor */
319 typedef struct ItclHierIter {
320 ItclClass *current; /* current position in hierarchy */
321 Itcl_Stack stack; /* stack used for traversal */
324 #define ITCL_OBJECT_IS_DELETED 0x01
325 #define ITCL_OBJECT_IS_DESTRUCTED 0x02
326 #define ITCL_OBJECT_IS_DESTROYED 0x04
327 #define ITCL_OBJECT_IS_RENAMED 0x08
328 #define ITCL_OBJECT_CLASS_DESTRUCTED 0x10
329 #define ITCL_TCLOO_OBJECT_IS_DELETED 0x20
330 #define ITCL_OBJECT_DESTRUCT_ERROR 0x40
331 #define ITCL_OBJECT_SHOULD_VARNS_DELETE 0x80
334 * Representation for each [incr Tcl] object.
336 typedef struct ItclObject {
337 ItclClass *iclsPtr; /* most-specific class */
338 Tcl_Command accessCmd; /* object access command */
340 Tcl_HashTable* constructed; /* temp storage used during construction */
341 Tcl_HashTable* destructed; /* temp storage used during destruction */
342 Tcl_HashTable objectVariables;
343 /* used for storing Tcl_Var entries for
344 * variable resolving, key is ivPtr of
345 * variable, value is varPtr */
346 Tcl_HashTable objectOptions; /* definitions for all option members
347 in this object. Look up option namePtr
348 names and get back ItclOption* ptrs */
349 Tcl_HashTable objectComponents; /* definitions for all component members
350 in this object. Look up component namePtr
351 names and get back ItclComponent* ptrs */
352 Tcl_HashTable objectMethodVariables;
353 /* definitions for all methodvariable members
354 in this object. Look up methodvariable
355 namePtr names and get back
356 ItclMethodVariable* ptrs */
357 Tcl_HashTable objectDelegatedOptions;
358 /* definitions for all delegated option
359 members in this object. Look up option
360 namePtr names and get back
362 Tcl_HashTable objectDelegatedFunctions;
363 /* definitions for all delegated function
364 members in this object. Look up function
365 namePtr names and get back
366 ItclMemberFunc * ptrs */
367 Tcl_HashTable contextCache; /* cache for function contexts */
369 Tcl_Obj *origNamePtr; /* the original name before any rename */
370 Tcl_Obj *createNamePtr; /* the temp name before any rename
371 * mostly used for widgetadaptor
372 * because that hijackes the name
373 * often when installing the hull */
375 ItclObjectInfo *infoPtr;
376 Tcl_Obj *varNsNamePtr;
377 Tcl_Object oPtr; /* the TclOO object */
378 Tcl_Resolve *resolvePtr;
380 int callRefCount; /* prevent deleting of object if refcount > 1 */
381 Tcl_Obj *hullWindowNamePtr; /* the window path name for the hull
382 * (before renaming in installhull) */
383 int destructorHasBeenCalled; /* is set when the destructor is called
384 * to avoid callin destructor twice */
385 int noComponentTrace; /* don't call component traces if
386 * setting components in DelegationInstall */
387 int hadConstructorError; /* needed for multiple calls of CallItclObjectCmd */
390 #define ITCL_IGNORE_ERRS 0x002 /* useful for construction/destruction */
392 typedef struct ItclResolveInfo {
398 #define ITCL_RESOLVE_CLASS 0x01
399 #define ITCL_RESOLVE_OBJECT 0x02
402 * Implementation for any code body in an [incr Tcl] class.
404 typedef struct ItclMemberCode {
405 int flags; /* flags describing implementation */
406 int argcount; /* number of args in arglist */
407 int maxargcount; /* max number of args in arglist */
408 Tcl_Obj *usagePtr; /* usage string for error messages */
409 Tcl_Obj *argumentPtr; /* the function arguments */
410 Tcl_Obj *bodyPtr; /* the function body */
411 ItclArgList *argListPtr; /* the parsed arguments */
413 Tcl_CmdProc *argCmd; /* (argc,argv) C implementation */
414 Tcl_ObjCmdProc *objCmd; /* (objc,objv) C implementation */
416 ClientData clientData; /* client data for C implementations */
420 * Flag bits for ItclMemberCode:
422 #define ITCL_IMPLEMENT_NONE 0x001 /* no implementation */
423 #define ITCL_IMPLEMENT_TCL 0x002 /* Tcl implementation */
424 #define ITCL_IMPLEMENT_ARGCMD 0x004 /* (argc,argv) C implementation */
425 #define ITCL_IMPLEMENT_OBJCMD 0x008 /* (objc,objv) C implementation */
426 #define ITCL_IMPLEMENT_C 0x00c /* either kind of C implementation */
428 #define Itcl_IsMemberCodeImplemented(mcode) \
429 (((mcode)->flags & ITCL_IMPLEMENT_NONE) == 0)
432 * Flag bits for ItclMember: functions and variables
434 #define ITCL_COMMON 0x010 /* non-zero => is a "proc" or common
438 * Flag bits for ItclMember: functions
440 #define ITCL_CONSTRUCTOR 0x020 /* non-zero => is a constructor */
441 #define ITCL_DESTRUCTOR 0x040 /* non-zero => is a destructor */
442 #define ITCL_ARG_SPEC 0x080 /* non-zero => has an argument spec */
443 #define ITCL_BODY_SPEC 0x100 /* non-zero => has an body spec */
444 #define ITCL_CONINIT 0x200 /* non-zero => is a constructor
446 #define ITCL_BUILTIN 0x400 /* non-zero => built-in method */
447 #define ITCL_COMPONENT 0x800 /* non-zero => component */
448 #define ITCL_TYPE_METHOD 0x1000 /* non-zero => typemethod */
449 #define ITCL_METHOD 0x2000 /* non-zero => method */
452 * Flag bits for ItclMember: variables
454 #define ITCL_THIS_VAR 0x20 /* non-zero => built-in "this" variable */
455 #define ITCL_OPTIONS_VAR 0x40 /* non-zero => built-in "itcl_options"
457 #define ITCL_TYPE_VAR 0x80 /* non-zero => built-in "type" variable */
458 /* no longer used ??? */
459 #define ITCL_SELF_VAR 0x100 /* non-zero => built-in "self" variable */
460 #define ITCL_SELFNS_VAR 0x200 /* non-zero => built-in "selfns"
462 #define ITCL_WIN_VAR 0x400 /* non-zero => built-in "win" variable */
463 #define ITCL_COMPONENT_VAR 0x800 /* non-zero => component variable */
464 #define ITCL_HULL_VAR 0x1000 /* non-zero => built-in "itcl_hull"
466 #define ITCL_OPTION_READONLY 0x2000 /* non-zero => readonly */
467 #define ITCL_VARIABLE 0x4000 /* non-zero => normal variable */
468 #define ITCL_TYPE_VARIABLE 0x8000 /* non-zero => typevariable */
469 #define ITCL_OPTION_INITTED 0x10000 /* non-zero => option has been initialized */
470 #define ITCL_OPTION_COMP_VAR 0x20000 /* variable to collect option components of extendedclass */
473 * Instance components.
476 typedef struct ItclComponent {
477 Tcl_Obj *namePtr; /* member name */
478 struct ItclVariable *ivPtr; /* variable for this component */
481 Tcl_HashTable keptOptions; /* table of options to keep */
484 #define ITCL_COMPONENT_INHERIT 0x01
485 #define ITCL_COMPONENT_PUBLIC 0x02
487 typedef struct ItclDelegatedFunction {
489 ItclComponent *icPtr;
492 Tcl_HashTable exceptions;
494 } ItclDelegatedFunction;
497 * Representation of member functions in an [incr Tcl] class.
499 typedef struct ItclMemberFunc {
500 Tcl_Obj* namePtr; /* member name */
501 Tcl_Obj* fullNamePtr; /* member name with "class::" qualifier */
502 ItclClass* iclsPtr; /* class containing this member */
503 int protection; /* protection level */
504 int flags; /* flags describing member (see above) */
505 ItclObjectInfo *infoPtr;
506 ItclMemberCode *codePtr; /* code associated with member */
507 Tcl_Command accessCmd; /* Tcl command installed for this function */
508 int argcount; /* number of args in arglist */
509 int maxargcount; /* max number of args in arglist */
510 Tcl_Obj *usagePtr; /* usage string for error messages */
511 Tcl_Obj *argumentPtr; /* the function arguments */
512 Tcl_Obj *builtinArgumentPtr; /* the function arguments for builtin functions */
513 Tcl_Obj *origArgsPtr; /* the argument string of the original definition */
514 Tcl_Obj *bodyPtr; /* the function body */
515 ItclArgList *argListPtr; /* the parsed arguments */
516 ItclClass *declaringClassPtr; /* the class which declared the method/proc */
517 ClientData tmPtr; /* TclOO methodPtr */
518 ItclDelegatedFunction *idmPtr;
519 /* if the function is delegated != NULL */
523 * Instance variables.
525 typedef struct ItclVariable {
526 Tcl_Obj *namePtr; /* member name */
527 Tcl_Obj *fullNamePtr; /* member name with "class::" qualifier */
528 ItclClass *iclsPtr; /* class containing this member */
529 ItclObjectInfo *infoPtr;
530 ItclMemberCode *codePtr; /* code associated with member */
531 Tcl_Obj *init; /* initial value */
532 Tcl_Obj *arrayInitPtr; /* initial value if variable should be array */
533 int protection; /* protection level */
534 int flags; /* flags describing member (see below) */
535 int initted; /* is set when first time initted, to check
536 * for example itcl_hull var, which can be only
537 * initialized once */
543 typedef struct ItclDelegatedOption {
545 Tcl_Obj *resourceNamePtr;
546 Tcl_Obj *classNamePtr;
547 struct ItclOption *ioptPtr; /* the option name or null for "*" */
548 ItclComponent *icPtr; /* the component where the delegation goes
551 Tcl_HashTable exceptions; /* exceptions from delegation */
552 } ItclDelegatedOption;
557 typedef struct ItclOption {
558 /* within a class hierarchy there must be only
559 * one option with the same name !! */
560 Tcl_Obj *namePtr; /* member name */
561 Tcl_Obj *fullNamePtr; /* member name with "class::" qualifier */
562 Tcl_Obj *resourceNamePtr;
563 Tcl_Obj *classNamePtr;
564 ItclClass *iclsPtr; /* class containing this member */
565 int protection; /* protection level */
566 int flags; /* flags describing member (see below) */
567 ItclMemberCode *codePtr; /* code associated with member */
568 Tcl_Obj *defaultValuePtr; /* initial value */
569 Tcl_Obj *cgetMethodPtr;
570 Tcl_Obj *cgetMethodVarPtr;
571 Tcl_Obj *configureMethodPtr;
572 Tcl_Obj *configureMethodVarPtr;
573 Tcl_Obj *validateMethodPtr;
574 Tcl_Obj *validateMethodVarPtr;
575 ItclDelegatedOption *idoPtr;
576 /* if the option is delegated != NULL */
580 * Instance methodvariables.
582 typedef struct ItclMethodVariable {
583 Tcl_Obj *namePtr; /* member name */
584 Tcl_Obj *fullNamePtr; /* member name with "class::" qualifier */
585 ItclClass *iclsPtr; /* class containing this member */
586 int protection; /* protection level */
587 int flags; /* flags describing member (see below) */
588 Tcl_Obj *defaultValuePtr;
589 Tcl_Obj *callbackPtr;
590 } ItclMethodVariable;
592 typedef struct IctlVarTraceInfo {
599 #define ITCL_TRACE_CLASS 0x01
600 #define ITCL_TRACE_OBJECT 0x02
602 #define VAR_TYPE_VARIABLE 1
603 #define VAR_TYPE_COMMON 2
605 typedef struct ItclClassVarInfo {
609 Tcl_Namespace *nsPtr;
610 Tcl_Namespace *declaringNsPtr;
613 #define CMD_TYPE_METHOD 1
614 #define CMD_TYPE_PROC 2
616 typedef struct ItclClassCmdInfo {
620 Tcl_Namespace *nsPtr;
621 Tcl_Namespace *declaringNsPtr;
625 * Instance variable lookup entry.
627 typedef struct ItclVarLookup {
628 ItclVariable* ivPtr; /* variable definition */
629 int usage; /* number of uses for this record */
630 int accessible; /* non-zero => accessible from class with
631 * this lookup record in its resolveVars */
632 char *leastQualName; /* simplist name for this variable, with
633 * the fewest qualifiers. This string is
634 * taken from the resolveVars table, so
635 * it shouldn't be freed. */
637 ItclClassVarInfo *classVarInfoPtr;
642 * Instance command lookup entry.
644 typedef struct ItclCmdLookup {
645 ItclMemberFunc* imPtr; /* function definition */
647 ItclClassCmdInfo *classCmdInfoPtr;
651 typedef struct ItclCallContext {
653 Tcl_Namespace *nsPtr;
655 ItclMemberFunc *imPtr;
660 * The macro below is used to modify a "char" value (e.g. by casting
661 * it to an unsigned character) so that it can be used safely with
662 * macros such as isspace.
665 #define UCHAR(c) ((unsigned char) (c))
667 * Macros used to cast between pointers and integers (e.g. when storing an int
668 * in ClientData), on 64-bit architectures they avoid gcc warning about "cast
669 * to/from pointer from/to integer of different size".
672 #if !defined(INT2PTR) && !defined(PTR2INT)
673 # if defined(HAVE_INTPTR_T) || defined(intptr_t)
674 # define INT2PTR(p) ((void*)(intptr_t)(p))
675 # define PTR2INT(p) ((int)(intptr_t)(p))
677 # define INT2PTR(p) ((void*)(p))
678 # define PTR2INT(p) ((int)(p))
683 MODULE_SCOPE int _itcl_debug_level;
684 MODULE_SCOPE void ItclShowArgs(int level, const char *str, int objc,
685 Tcl_Obj * const* objv);
687 #define ItclShowArgs(a,b,c,d)
690 MODULE_SCOPE Tcl_ObjCmdProc ItclCallCCommand;
691 MODULE_SCOPE Tcl_ObjCmdProc ItclObjectUnknownCommand;
692 MODULE_SCOPE int ItclCheckCallProc(ClientData clientData, Tcl_Interp *interp,
693 Tcl_ObjectContext contextPtr, Tcl_CallFrame *framePtr, int *isFinished);
695 MODULE_SCOPE ItclFoundation *ItclGetFoundation(Tcl_Interp *interp);
696 MODULE_SCOPE Tcl_ObjCmdProc ItclClassCommandDispatcher;
697 MODULE_SCOPE Tcl_Command Itcl_CmdAliasProc(Tcl_Interp *interp,
698 Tcl_Namespace *nsPtr, const char *cmdName, ClientData clientData);
699 MODULE_SCOPE Tcl_Var Itcl_VarAliasProc(Tcl_Interp *interp,
700 Tcl_Namespace *nsPtr, const char *VarName, ClientData clientData);
701 MODULE_SCOPE int ItclIsClass(Tcl_Interp *interp, Tcl_Command cmd);
702 MODULE_SCOPE int ItclCheckCallMethod(ClientData clientData, Tcl_Interp *interp,
703 Tcl_ObjectContext contextPtr, Tcl_CallFrame *framePtr, int *isFinished);
704 MODULE_SCOPE int ItclAfterCallMethod(ClientData clientData, Tcl_Interp *interp,
705 Tcl_ObjectContext contextPtr, Tcl_Namespace *nsPtr, int result);
706 MODULE_SCOPE void ItclReportObjectUsage(Tcl_Interp *interp,
707 ItclObject *contextIoPtr, Tcl_Namespace *callerNsPtr,
708 Tcl_Namespace *contextNsPtr);
709 MODULE_SCOPE void ItclGetInfoUsage(Tcl_Interp *interp, Tcl_Obj *objPtr,
710 ItclObjectInfo *infoPtr);
711 MODULE_SCOPE int ItclMapMethodNameProc(Tcl_Interp *interp, Tcl_Object oPtr,
712 Tcl_Class *startClsPtr, Tcl_Obj *methodObj);
713 MODULE_SCOPE int ItclCreateArgList(Tcl_Interp *interp, const char *str,
714 int *argcPtr, int *maxArgcPtr, Tcl_Obj **usagePtr,
715 ItclArgList **arglistPtrPtr, ItclMemberFunc *imPtr,
716 const char *commandName);
717 MODULE_SCOPE int ItclObjectCmd(ClientData clientData, Tcl_Interp *interp,
718 Tcl_Object oPtr, Tcl_Class clsPtr, int objc, Tcl_Obj *const *objv);
719 MODULE_SCOPE int ItclCreateObject (Tcl_Interp *interp, const char* name,
720 ItclClass *iclsPtr, int objc, Tcl_Obj *const objv[]);
721 MODULE_SCOPE void ItclDeleteObjectVariablesNamespace(Tcl_Interp *interp,
723 MODULE_SCOPE void ItclDeleteClassVariablesNamespace(Tcl_Interp *interp,
725 MODULE_SCOPE int ItclInfoInit(Tcl_Interp *interp);
726 MODULE_SCOPE char * ItclTraceUnsetVar(ClientData clientData, Tcl_Interp *interp,
727 const char *name1, const char *name2, int flags);
729 struct Tcl_ResolvedVarInfo;
730 MODULE_SCOPE int Itcl_ClassCmdResolver(Tcl_Interp *interp, const char* name,
731 Tcl_Namespace *nsPtr, int flags, Tcl_Command *rPtr);
732 MODULE_SCOPE int Itcl_ClassVarResolver(Tcl_Interp *interp, const char* name,
733 Tcl_Namespace *nsPtr, int flags, Tcl_Var *rPtr);
734 MODULE_SCOPE int Itcl_ClassCompiledVarResolver(Tcl_Interp *interp,
735 const char* name, int length, Tcl_Namespace *nsPtr,
736 struct Tcl_ResolvedVarInfo **rPtr);
737 MODULE_SCOPE int Itcl_ClassCmdResolver2(Tcl_Interp *interp, const char* name,
738 Tcl_Namespace *nsPtr, int flags, Tcl_Command *rPtr);
739 MODULE_SCOPE int Itcl_ClassVarResolver2(Tcl_Interp *interp, const char* name,
740 Tcl_Namespace *nsPtr, int flags, Tcl_Var *rPtr);
741 MODULE_SCOPE int Itcl_ClassCompiledVarResolver2(Tcl_Interp *interp,
742 const char* name, int length, Tcl_Namespace *nsPtr,
743 struct Tcl_ResolvedVarInfo **rPtr);
744 MODULE_SCOPE int ItclSetParserResolver(Tcl_Namespace *nsPtr);
745 MODULE_SCOPE void ItclProcErrorProc(Tcl_Interp *interp, Tcl_Obj *procNameObj);
746 MODULE_SCOPE int Itcl_CreateOption (Tcl_Interp *interp, ItclClass *iclsPtr,
747 ItclOption *ioptPtr);
748 MODULE_SCOPE int Itcl_CreateMethodVariable (Tcl_Interp *interp,
749 ItclClass *iclsPtr, Tcl_Obj *name, Tcl_Obj *defaultPtr,
750 Tcl_Obj *callbackPtr, ItclMethodVariable **imvPtr);
751 MODULE_SCOPE int DelegationInstall(Tcl_Interp *interp, ItclObject *ioPtr,
753 MODULE_SCOPE const char* ItclGetInstanceVar(Tcl_Interp *interp,
754 const char *name, const char *name2, ItclObject *contextIoPtr,
755 ItclClass *contextIclsPtr);
756 MODULE_SCOPE const char* ItclGetCommonInstanceVar(Tcl_Interp *interp,
757 const char *name, const char *name2, ItclObject *contextIoPtr,
758 ItclClass *contextIclsPtr);
759 MODULE_SCOPE int ItclCreateMethod(Tcl_Interp* interp, ItclClass *iclsPtr,
760 Tcl_Obj *namePtr, const char* arglist, const char* body,
761 ItclMemberFunc **imPtrPtr);
762 MODULE_SCOPE int Itcl_WidgetParseInit(Tcl_Interp *interp,
763 ItclObjectInfo *infoPtr);
764 MODULE_SCOPE void ItclDeleteObjectMetadata(ClientData clientData);
765 MODULE_SCOPE void ItclDeleteClassMetadata(ClientData clientData);
766 MODULE_SCOPE void ItclDeleteArgList(ItclArgList *arglistPtr);
767 MODULE_SCOPE int Itcl_ClassOptionCmd(ClientData clientData, Tcl_Interp *interp,
768 int objc, Tcl_Obj *const objv[]);
769 MODULE_SCOPE int DelegatedOptionsInstall(Tcl_Interp *interp,
771 MODULE_SCOPE int Itcl_HandleDelegateOptionCmd(Tcl_Interp *interp,
772 ItclObject *ioPtr, ItclClass *iclsPtr, ItclDelegatedOption **idoPtrPtr,
773 int objc, Tcl_Obj *const objv[]);
774 MODULE_SCOPE int Itcl_HandleDelegateMethodCmd(Tcl_Interp *interp,
775 ItclObject *ioPtr, ItclClass *iclsPtr,
776 ItclDelegatedFunction **idmPtrPtr, int objc, Tcl_Obj *const objv[]);
777 MODULE_SCOPE int DelegateFunction(Tcl_Interp *interp, ItclObject *ioPtr,
778 ItclClass *iclsPtr, Tcl_Obj *componentNamePtr,
779 ItclDelegatedFunction *idmPtr);
780 MODULE_SCOPE int ItclInitObjectMethodVariables(Tcl_Interp *interp,
781 ItclObject *ioPtr, ItclClass *iclsPtr, const char *name);
782 MODULE_SCOPE int InitTclOOFunctionPointers(Tcl_Interp *interp);
783 MODULE_SCOPE ItclOption* ItclNewOption(Tcl_Interp *interp, ItclObject *ioPtr,
784 ItclClass *iclsPtr, Tcl_Obj *namePtr, const char *resourceName,
785 const char *className, char *init, ItclMemberCode *mCodePtr);
786 MODULE_SCOPE int ItclParseOption(ItclObjectInfo *infoPtr, Tcl_Interp *interp,
787 int objc, Tcl_Obj *const objv[], ItclClass *iclsPtr,
788 ItclObject *ioPtr, ItclOption **ioptPtrPtr);
789 MODULE_SCOPE void ItclDestroyClassNamesp(ClientData cdata);
790 MODULE_SCOPE int ExpandDelegateAs(Tcl_Interp *interp, ItclObject *ioPtr,
791 ItclClass *iclsPtr, ItclDelegatedFunction *idmPtr,
792 const char *funcName, Tcl_Obj *listPtr);
793 MODULE_SCOPE int ItclCheckForInitializedComponents(Tcl_Interp *interp,
794 ItclClass *iclsPtr, ItclObject *ioPtr);
795 MODULE_SCOPE int ItclCreateDelegatedFunction(Tcl_Interp *interp,
796 ItclClass *iclsPtr, Tcl_Obj *methodNamePtr, ItclComponent *icPtr,
797 Tcl_Obj *targetPtr, Tcl_Obj *usingPtr, Tcl_Obj *exceptionsPtr,
798 ItclDelegatedFunction **idmPtrPtr);
799 MODULE_SCOPE void ItclDeleteDelegatedOption(char *cdata);
800 MODULE_SCOPE void Itcl_FinishList();
801 MODULE_SCOPE void ItclDeleteDelegatedFunction(ItclDelegatedFunction *idmPtr);
802 MODULE_SCOPE void ItclFinishEnsemble(ItclObjectInfo *infoPtr);
803 MODULE_SCOPE int Itcl_EnsembleDeleteCmd(ClientData clientData,
804 Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
805 MODULE_SCOPE int ItclAddClassesDictInfo(Tcl_Interp *interp, ItclClass *iclsPtr);
806 MODULE_SCOPE int ItclDeleteClassesDictInfo(Tcl_Interp *interp,
808 MODULE_SCOPE int ItclAddObjectsDictInfo(Tcl_Interp *interp, ItclObject *ioPtr);
809 MODULE_SCOPE int ItclDeleteObjectsDictInfo(Tcl_Interp *interp,
811 MODULE_SCOPE int ItclAddOptionDictInfo(Tcl_Interp *interp, ItclClass *iclsPtr,
812 ItclOption *ioptPtr);
813 MODULE_SCOPE int ItclAddDelegatedOptionDictInfo(Tcl_Interp *interp,
814 ItclClass *iclsPtr, ItclDelegatedOption *idoPtr);
815 MODULE_SCOPE int ItclAddClassComponentDictInfo(Tcl_Interp *interp,
816 ItclClass *iclsPtr, ItclComponent *icPtr);
817 MODULE_SCOPE int ItclAddClassVariableDictInfo(Tcl_Interp *interp,
818 ItclClass *iclsPtr, ItclVariable *ivPtr);
819 MODULE_SCOPE int ItclAddClassFunctionDictInfo(Tcl_Interp *interp,
820 ItclClass *iclsPtr, ItclMemberFunc *imPtr);
821 MODULE_SCOPE int ItclAddClassDelegatedFunctionDictInfo(Tcl_Interp *interp,
822 ItclClass *iclsPtr, ItclDelegatedFunction *idmPtr);
823 MODULE_SCOPE ItclClass * GetClassFromClassName(Tcl_Interp *interp,
824 const char *className, ItclClass *iclsPtr);
825 MODULE_SCOPE int ItclClassCreateObject(ClientData clientData, Tcl_Interp *interp,
826 int objc, Tcl_Obj *const objv[]);
827 MODULE_SCOPE Tcl_ObjCmdProc Itcl_BiMyProcCmd;
828 MODULE_SCOPE Tcl_ObjCmdProc Itcl_BiInstallComponentCmd;
829 MODULE_SCOPE Tcl_ObjCmdProc Itcl_BiCallInstanceCmd;
830 MODULE_SCOPE Tcl_ObjCmdProc Itcl_BiGetInstanceVarCmd;
831 MODULE_SCOPE Tcl_ObjCmdProc Itcl_BiMyTypeMethodCmd;
832 MODULE_SCOPE Tcl_ObjCmdProc Itcl_BiMyMethodCmd;
833 MODULE_SCOPE Tcl_ObjCmdProc Itcl_BiMyTypeVarCmd;
834 MODULE_SCOPE Tcl_ObjCmdProc Itcl_BiMyVarCmd;
835 MODULE_SCOPE Tcl_ObjCmdProc Itcl_BiItclHullCmd;
836 MODULE_SCOPE Tcl_ObjCmdProc Itcl_ThisCmd;
837 MODULE_SCOPE Tcl_ObjCmdProc Itcl_ExtendedClassCmd;
838 MODULE_SCOPE Tcl_ObjCmdProc Itcl_TypeClassCmd;
839 MODULE_SCOPE Tcl_ObjCmdProc Itcl_AddObjectOptionCmd;
840 MODULE_SCOPE Tcl_ObjCmdProc Itcl_AddDelegatedOptionCmd;
841 MODULE_SCOPE Tcl_ObjCmdProc Itcl_AddDelegatedFunctionCmd;
842 MODULE_SCOPE Tcl_ObjCmdProc Itcl_SetComponentCmd;
843 MODULE_SCOPE Tcl_ObjCmdProc Itcl_ClassHullTypeCmd;
844 MODULE_SCOPE Tcl_ObjCmdProc Itcl_ClassWidgetClassCmd;
846 #include "itcl2TclOO.h"
847 #ifdef NEW_PROTO_RESOLVER
848 #include "itclVarsAndCmds.h"
852 * Include all the private API, generated from itcl.decls.
855 #include "itclIntDecls.h"