itcl.h

Go to the documentation of this file.
00001 /*
00002  * ------------------------------------------------------------------------
00003  *      PACKAGE:  [incr Tcl]
00004  *  DESCRIPTION:  Object-Oriented Extensions to Tcl
00005  *
00006  *  [incr Tcl] provides object-oriented extensions to Tcl, much as
00007  *  C++ provides object-oriented extensions to C.  It provides a means
00008  *  of encapsulating related procedures together with their shared data
00009  *  in a local namespace that is hidden from the outside world.  It
00010  *  promotes code re-use through inheritance.  More than anything else,
00011  *  it encourages better organization of Tcl applications through the
00012  *  object-oriented paradigm, leading to code that is easier to
00013  *  understand and maintain.
00014  *  
00015  *  ADDING [incr Tcl] TO A Tcl-BASED APPLICATION:
00016  *
00017  *    To add [incr Tcl] facilities to a Tcl application, modify the
00018  *    Tcl_AppInit() routine as follows:
00019  *
00020  *    1) Include this header file near the top of the file containing
00021  *       Tcl_AppInit():
00022  *
00023  *         #include "itcl.h"
00024  *
00025  *    2) Within the body of Tcl_AppInit(), add the following lines:
00026  *
00027  *         if (Itcl_Init(interp) == TCL_ERROR) {
00028  *             return TCL_ERROR;
00029  *         }
00030  * 
00031  *    3) Link your application with libitcl.a
00032  *
00033  *    NOTE:  An example file "tclAppInit.c" containing the changes shown
00034  *           above is included in this distribution.
00035  *  
00036  * ========================================================================
00037  *  AUTHOR:  Michael J. McLennan
00038  *           Bell Labs Innovations for Lucent Technologies
00039  *           mmclennan@lucent.com
00040  *           http://www.tcltk.com/itcl
00041  *
00042  *     RCS:  $Id: itcl.h,v 14.1 2004/11/16 19:42:10 morrison Exp $
00043  * ========================================================================
00044  *           Copyright (c) 1993-1998  Lucent Technologies, Inc.
00045  * ------------------------------------------------------------------------
00046  * See the file "license.terms" for information on usage and redistribution
00047  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00048  */
00049 #ifndef ITCL_H
00050 #define ITCL_H
00051 
00052 #include "tcl.h"
00053 
00054 #ifndef TCL_ALPHA_RELEASE
00055 #   define TCL_ALPHA_RELEASE    0
00056 #endif
00057 #ifndef TCL_BETA_RELEASE
00058 #   define TCL_BETA_RELEASE     1
00059 #endif
00060 #ifndef TCL_FINAL_RELEASE
00061 #   define TCL_FINAL_RELEASE    2
00062 #endif
00063 
00064 
00065 #define ITCL_MAJOR_VERSION      3
00066 #define ITCL_MINOR_VERSION      3
00067 #define ITCL_RELEASE_LEVEL      TCL_BETA_RELEASE
00068 #define ITCL_RELEASE_SERIAL     1
00069 
00070 #define ITCL_VERSION            "3.3"
00071 #define ITCL_PATCH_LEVEL        "3.3b1"
00072 
00073 /* 
00074  * A special definition used to allow this header file to be included 
00075  * in resource files so that they can get obtain version information from
00076  * this file.  Resource compilers don't like all the C stuff, like typedefs
00077  * and procedure declarations, that occur below.
00078  */
00079 
00080 #ifndef RC_INVOKED
00081 
00082 #undef TCL_STORAGE_CLASS
00083 #ifdef BUILD_itcl
00084 #   define TCL_STORAGE_CLASS DLLEXPORT
00085 #else
00086 #   ifdef USE_ITCL_STUBS
00087 #       define TCL_STORAGE_CLASS
00088 #   else
00089 #       define TCL_STORAGE_CLASS DLLIMPORT
00090 #   endif
00091 #endif
00092 
00093 /*
00094  * Fix the Borland bug that's in the EXTERN macro from tcl.h.
00095  */
00096 #ifndef TCL_EXTERN
00097 #   undef DLLIMPORT
00098 #   undef DLLEXPORT
00099 #   ifdef __cplusplus
00100 #       define TCL_EXTERNC extern "C"
00101 #   else
00102 #       define TCL_EXTERNC extern
00103 #   endif
00104 #   if defined(STATIC_BUILD)
00105 #       define DLLIMPORT
00106 #       define DLLEXPORT
00107 #       define TCL_EXTERN(RTYPE) TCL_EXTERNC RTYPE
00108 #   elif (defined(__WIN32__) && ( \
00109             defined(_MSC_VER) || (__BORLANDC__ >= 0x0550) || \
00110             defined(__LCC__) || defined(__WATCOMC__) || \
00111             (defined(__GNUC__) && defined(__declspec)) \
00112         )) || (defined(MAC_TCL) && FUNCTION_DECLSPEC)
00113 #       define DLLIMPORT __declspec(dllimport)
00114 #       define DLLEXPORT __declspec(dllexport)
00115 #       define TCL_EXTERN(RTYPE) TCL_EXTERNC TCL_STORAGE_CLASS RTYPE
00116 #   elif defined(__BORLANDC__)
00117 #       define DLLIMPORT __import
00118 #       define DLLEXPORT __export
00119         /* Pre-5.5 Borland requires the attributes be placed after the */
00120         /* return type instead. */
00121 #       define TCL_EXTERN(RTYPE) TCL_EXTERNC RTYPE TCL_STORAGE_CLASS
00122 #   else
00123 #       define DLLIMPORT
00124 #       define DLLEXPORT
00125 #       define TCL_EXTERN(RTYPE) TCL_EXTERNC TCL_STORAGE_CLASS RTYPE
00126 #   endif
00127 #endif
00128 
00129 
00130 /*
00131  * Starting from the 8.4 core, Tcl API is CONST'ified.  Our API is always
00132  * CONST, but we need to build with Tcl when it isn't CONST and fake it
00133  * when needed with <= 8.3
00134  *
00135  * http://wiki.tcl.tk/3669
00136  */
00137 
00138 #ifndef CONST84
00139 #   define CONST84
00140 #endif
00141 
00142 
00143 /*
00144  * Protection levels:
00145  *
00146  * ITCL_PUBLIC    - accessible from any namespace
00147  * ITCL_PROTECTED - accessible from namespace that imports in "protected" mode
00148  * ITCL_PRIVATE   - accessible only within the namespace that contains it
00149  */
00150 #define ITCL_PUBLIC           1
00151 #define ITCL_PROTECTED        2
00152 #define ITCL_PRIVATE          3
00153 #define ITCL_DEFAULT_PROTECT  4
00154 
00155 
00156 /*
00157  *  Generic stack.
00158  */
00159 typedef struct Itcl_Stack {
00160     ClientData *values;          /* values on stack */
00161     int len;                     /* number of values on stack */
00162     int max;                     /* maximum size of stack */
00163     ClientData space[5];         /* initial space for stack data */
00164 } Itcl_Stack;
00165 
00166 #define Itcl_GetStackSize(stackPtr) ((stackPtr)->len)
00167 
00168 /*
00169  *  Generic linked list.
00170  */
00171 struct Itcl_List;
00172 typedef struct Itcl_ListElem {
00173     struct Itcl_List* owner;     /* list containing this element */
00174     ClientData value;            /* value associated with this element */
00175     struct Itcl_ListElem *prev;  /* previous element in linked list */
00176     struct Itcl_ListElem *next;  /* next element in linked list */
00177 } Itcl_ListElem;
00178 
00179 typedef struct Itcl_List {
00180     int validate;                /* validation stamp */
00181     int num;                     /* number of elements */
00182     struct Itcl_ListElem *head;  /* previous element in linked list */
00183     struct Itcl_ListElem *tail;  /* next element in linked list */
00184 } Itcl_List;
00185 
00186 #define Itcl_FirstListElem(listPtr) ((listPtr)->head)
00187 #define Itcl_LastListElem(listPtr)  ((listPtr)->tail)
00188 #define Itcl_NextListElem(elemPtr)  ((elemPtr)->next)
00189 #define Itcl_PrevListElem(elemPtr)  ((elemPtr)->prev)
00190 #define Itcl_GetListLength(listPtr) ((listPtr)->num)
00191 #define Itcl_GetListValue(elemPtr)  ((elemPtr)->value)
00192 
00193 /*
00194  *  Token representing the state of an interpreter.
00195  */
00196 typedef struct Itcl_InterpState_ *Itcl_InterpState;
00197 
00198 
00199 /*
00200  * Include the public function declarations that are accessible via
00201  * the stubs table.
00202  */
00203 
00204 #include "itclDecls.h"
00205 
00206 
00207 /*
00208  * Itcl_InitStubs is used by extensions like Itk that can be linked
00209  * against the itcl stubs library.  If we are not using stubs
00210  * then this reduces to package require.
00211  */
00212 
00213 #ifdef USE_ITCL_STUBS
00214 
00215 TCL_EXTERNC CONST char *
00216         Itcl_InitStubs _ANSI_ARGS_((Tcl_Interp *interp,
00217                             CONST char *version, int exact));
00218 #else
00219 #define Itcl_InitStubs(interp, version, exact) \
00220       Tcl_PkgRequire(interp, "Itcl", version, exact)
00221 #endif
00222 
00223 /*
00224  * Public functions that are not accessible via the stubs table.
00225  */
00226 
00227 
00228 #endif /* RC_INVOKED */
00229 
00230 #undef TCL_STORAGE_CLASS
00231 #define TCL_STORAGE_CLASS DLLIMPORT
00232 
00233 #endif /* ITCL_H */
00234 
00235 /*
00236  * Local Variables:
00237  * mode: C
00238  * tab-width: 8
00239  * c-basic-offset: 4
00240  * indent-tabs-mode: t
00241  * End:
00242  * ex: shiftwidth=4 tabstop=8
00243  */

Generated on Mon Sep 18 01:24:40 2006 for BRL-CAD by  doxygen 1.4.6