gmlTcl_Wrapper_internals.h

00001 // gml/tcl/wrapper/wrapper/gmlTcl_Wrapper_internals.h --
00002 // 
00003 //    gmlTcl wrapper's internal declarations.
00004 // 
00005 //  Copyright (c) 1996-2003 CLIPS-IMAG
00006 // 
00007 //  See the file "gml_LicenseTerms.txt" for information on usage and redistribution
00008 //  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00009 // 
00010 //  May 16, 2003 (FB)
00011 //    hide wrapper structures, internals.
00012 //
00013 //  Created on September 8, 2002 (FB).
00014 
00015 #ifndef __GMLTCLWRAPPER_INT__
00016 #define __GMLTCLWRAPPER_INT__
00017 
00018 #include "gml/tcl/wrapper/gmlTcl_General.h"
00019 #include "gml/tcl/wrapper/wrapper/gmlTcl_Wrapper.h"
00020 #include "gml/base/gml_List.h"
00021 
00022 
00023 class gmlTclTWrapObject;
00024 class gmlTclTWrapClass;
00025 
00026 extern "C"
00027 int gmlTclWrapBinding_ClassBindUnbindProc  (Tcl_Interp*           interp,
00028                                             gmlTcl_TWrapObject    wrapObj,
00029                                             int                   objc,
00030                                             Tcl_Obj*              objv[],
00031                                             void*                 parsed);
00032 
00033 extern "C"
00034 int gmlTclWrapBinding_ObjectBindUnbindProc (Tcl_Interp*           interp,
00035                                             gmlTcl_TWrapObject    wrapObj,
00036                                             int                   objc,
00037                                             Tcl_Obj*              objv[],
00038                                             void*                 parsed);
00039 
00040 
00041 // gmlTclTWrapEvent --
00042 //
00043 //  An event (either class of object) than script can be bound to.
00044 
00045 class gmlTclTWrapEvent
00046 {
00047 public:
00048 
00049   int           Init       (Tcl_Interp*         interp,
00050                             gmlTclTWrapClass*   wrapClass,
00051                             gml_TBoolean        isAClassEvent,
00052                             char*               eventName);
00053 
00054   void          Dispose    ();
00055   
00056   void          Invoke     (gmlTclTWrapObject*  wrapObj,
00057                             int                 objc,
00058                             Tcl_Obj*            objv[]);
00059 
00060   void          DeleteMyScript
00061                            (char*               script,
00062                             gml_TList*          scriptList);
00063 
00064   void          DeleteAllMyScripts
00065                            (gml_TList*          scriptList);
00066 
00067   static
00068   gmlTclTWrapEvent*
00069                 FindEventInListFromName
00070                            (char*               eventName,
00071                             gml_TList*          eventList);
00072   static
00073   void          DeleteAllEventsInList
00074                            (gml_TList*          eventList);
00075   
00076   static
00077   void          DeleteAllScriptsInList
00078                            (gml_TList*          scriptList);
00079   
00080   char*               fName;
00081   gmlTclTWrapClass*   fClass;
00082   gml_TBoolean        fIsAClassEvent;
00083   Tcl_Interp*         fInterp;
00084   gmlTcl_Uid          fUid;
00085 };
00086 
00087 
00088 
00089 
00090 // gmlTclTWrapClass --
00091 //
00092 //  The base class of gmlTcl class wrappers.
00093 
00094 class gmlTclTWrapClass
00095 {
00096 public:
00097   Tcl_Interp*               fInterp;            /* The interpreter in which the class was registered */
00098   Tcl_Command               fCmd;               /* Token for Tcl command associated with this class */
00099   gmlTcl_TMethodDescr*      fMethodDescrs;      /* Array of description of methods */
00100   gmlTcl_TMethodDescr*      fConstructorDescr;  /* Pointer to constructor method descr (if existing) */
00101   gmlTcl_TMethodDescr*      fDestructorDescr;   /* Pointer to destructor method descr (if existing) */
00102 
00103   gml_TList*                fObjects;           /* List of object instances of this class */
00104   gml_TList*                fSuperClasses;      /* List of superclass, first in list is searched first
00105                                                     (as its ancestors) for methods */
00106   gml_TList*                fSpecializations;   /* List of classes that inherits from this one */
00107 
00108   gml_TList*                fClassEvents;       /* List of class events that can be bound to */
00109   gml_TList*                fObjectEvents;      /* List of object events that can be bound to */
00110   gml_TList*                fBindingScripts;    /* List of scripts bound to this class events */
00111   gmlTcl_TWrapEvent         fEventNewObject;    /* Class event: "creation of an object" */
00112   gmlTcl_TWrapEvent         fEventDeleteObject; /* Class event: "deletion of an object" */
00113   gmlTcl_TWrapEvent         fEventObjDispose;   /* Object event: "object has been disposed" */
00114 
00115   int           Init               (Tcl_Interp*             interp,
00116                                     char*                   className,
00117                                     gmlTcl_TMethodDescr*    methodDescrs);
00118 
00119   void          Dispose            ();
00120 
00121   char*         Name               ()
00122                                     { return Tcl_GetCommandName (fInterp, fCmd); }
00123 
00124   int           Inherit            (Tcl_Interp*             interp,
00125                                     gmlTclTWrapClass*       superClass);
00126 
00127   void          DeInherit          (gmlTclTWrapClass*       superClass);
00128   
00129   int           ObjectFromName     (Tcl_Interp*             interp,
00130                                     char*                   objName,
00131                                     gmlTclTWrapObject**     object);
00132   gmlTclTWrapObject* 
00133                 FindObjectFromName (char* objName);
00134 
00135   gml_TBoolean  IsAncestor         (gmlTclTWrapClass*       superClass);
00136 
00137   int           RegisterNewObject  (Tcl_Interp*             interp,
00138                                     gmlTclTWrapObject*      wrapObj);
00139 
00140   void          DeregisterObject   (gmlTclTWrapObject*      wrapObj);
00141 
00142   int           NewObjectFromCommand
00143                                    (Tcl_Interp*             interp,
00144                                     int                     objc,
00145                                     Tcl_Obj*                objv[]);
00146 
00147   int           NewObjectFromLowLevelObject
00148                                    (Tcl_Interp*             interp,
00149                                     char*                   objName,
00150                                     void*                   object,
00151                                     gmlTclTWrapObject**     ownerRef,
00152                                     gmlTclTWrapObject*      owner);
00153 
00154   int           CallMethod         (gmlTcl_TMethodDescr*    methodDescr,
00155                                     gmlTclTWrapObject*      wrapObj,
00156                                     Tcl_Interp*             interp,
00157                                     int                     objc,
00158                                     Tcl_Obj*                objv[]);
00159 
00160   gmlTcl_TMethodDescr*      
00161                 FindMethodDescr    (char*                   method,
00162                                     gml_TBoolean            searchInherited  = gml_cTrue);
00163 
00164   void          GenerateMethodList (Tcl_Interp*             interp,
00165                                     gml_TBoolean            objectMethods);
00166 
00167   gml_TError    AddMethodNamesToList
00168                                    (gml_TList*              list,
00169                                     gml_TBoolean            objectMethods);
00170 };
00171 
00172 
00173 
00174 // gmlTclTWrapObject --
00175 //
00176 //  The base class of gmlTcl object wrappers.
00177 
00178 class gmlTclTWrapObject
00179 {
00180 public:
00181   gmlTclTWrapClass*         fClass;             /* Points to the object's class class wrapper */
00182   Tcl_Command               fCmd;               /* Token for Tcl command associated with this object */
00183   void*                     fObject;            /* The "real" C / C++ object */
00184   gml_TBoolean              fConstructed;       /* True when the constructor has been called (thus, destructor will
00185                                                     be called on object disposal) */
00186   gmlTclTWrapObject**       fOwnerRef;          /* Adress of this object's owner pointer to this object. Will be set
00187                                                     to point to NULL when this object is deleted. */
00188   gml_TList*                fOwnedRefs;         /* List of reference to wrapper on objects that this object owns */
00189   gml_TList*                fBindingScripts;    /* List of scripts bound to this object events */
00190   
00191   void          Reset      ();
00192 
00193   int           Init       (Tcl_Interp*           interp,
00194                             gmlTclTWrapClass*     classWrap,
00195                             char*                 name);
00196 
00197   int           InitFromCommand
00198                            (Tcl_Interp*           interp,
00199                             gmlTclTWrapClass*     classWrap,
00200                             int                   objc,
00201                             Tcl_Obj*              objv[]);
00202 
00203 
00204   void          Dispose    ();
00205 
00206   char*         Name               ()
00207                                     { return Tcl_GetCommandName (fClass->fInterp, fCmd); }
00208 
00209   int           RegisterOwnedObject
00210                            (Tcl_Interp*           interp,
00211                             gmlTclTWrapObject*    ownedWrap);
00212 };
00213 
00214 
00215 
00216 
00217 
00218 int   gmlTclWrapCheckNameLength (Tcl_Interp* interp, char* errorMsgPrefix, char* name);
00219 
00220 int   gmlTclWrapFindIndexFromString  (char* array, gml_TBlockSize entrySize, char* searched);
00221 char* gmlTclWrapFindEntryFromString  (char* array, gml_TBlockSize entrySize, char* key);
00222 
00223 
00224 #endif
Generated on Tue Jun 12 14:03:27 2007 for gml by Doxygen 1.5.2.