jpayne@69: /* jpayne@69: * itcl.h -- jpayne@69: * jpayne@69: * This file contains definitions for the C-implemeted part of a Itcl jpayne@69: * this version of [incr Tcl] (Itcl) is a completely new implementation jpayne@69: * based on TclOO extension of Tcl 8.5 jpayne@69: * It tries to provide the same interfaces as the original implementation jpayne@69: * of Michael J. McLennan jpayne@69: * Some small pieces of code are taken from that implementation jpayne@69: * jpayne@69: * Copyright (c) 2007 by Arnulf P. Wiedemann jpayne@69: * jpayne@69: * See the file "license.terms" for information on usage and redistribution of jpayne@69: * this file, and for a DISCLAIMER OF ALL WARRANTIES. jpayne@69: */ jpayne@69: jpayne@69: /* jpayne@69: * ------------------------------------------------------------------------ jpayne@69: * PACKAGE: [incr Tcl] jpayne@69: * DESCRIPTION: Object-Oriented Extensions to Tcl jpayne@69: * jpayne@69: * [incr Tcl] provides object-oriented extensions to Tcl, much as jpayne@69: * C++ provides object-oriented extensions to C. It provides a means jpayne@69: * of encapsulating related procedures together with their shared data jpayne@69: * in a local namespace that is hidden from the outside world. It jpayne@69: * promotes code re-use through inheritance. More than anything else, jpayne@69: * it encourages better organization of Tcl applications through the jpayne@69: * object-oriented paradigm, leading to code that is easier to jpayne@69: * understand and maintain. jpayne@69: * jpayne@69: * ADDING [incr Tcl] TO A Tcl-BASED APPLICATION: jpayne@69: * jpayne@69: * To add [incr Tcl] facilities to a Tcl application, modify the jpayne@69: * Tcl_AppInit() routine as follows: jpayne@69: * jpayne@69: * 1) Include this header file near the top of the file containing jpayne@69: * Tcl_AppInit(): jpayne@69: * jpayne@69: * #include "itcl.h" jpayne@69: * jpayne@69: * 2) Within the body of Tcl_AppInit(), add the following lines: jpayne@69: * jpayne@69: * if (Itcl_Init(interp) == TCL_ERROR) { jpayne@69: * return TCL_ERROR; jpayne@69: * } jpayne@69: * jpayne@69: * 3) Link your application with libitcl.a jpayne@69: * jpayne@69: * NOTE: An example file "tclAppInit.c" containing the changes shown jpayne@69: * above is included in this distribution. jpayne@69: * jpayne@69: *--------------------------------------------------------------------- jpayne@69: */ jpayne@69: jpayne@69: #ifndef ITCL_H_INCLUDED jpayne@69: #define ITCL_H_INCLUDED jpayne@69: jpayne@69: #include jpayne@69: jpayne@69: #if (TCL_MAJOR_VERSION == 8) && defined(TCL_MINOR_VERSION) && (TCL_MINOR_VERSION < 6) jpayne@69: # error Itcl 4 build requires tcl.h from Tcl 8.6 or later jpayne@69: #endif jpayne@69: jpayne@69: /* jpayne@69: * For C++ compilers, use extern "C" jpayne@69: */ jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: #ifndef TCL_ALPHA_RELEASE jpayne@69: # define TCL_ALPHA_RELEASE 0 jpayne@69: #endif jpayne@69: #ifndef TCL_BETA_RELEASE jpayne@69: # define TCL_BETA_RELEASE 1 jpayne@69: #endif jpayne@69: #ifndef TCL_FINAL_RELEASE jpayne@69: # define TCL_FINAL_RELEASE 2 jpayne@69: #endif jpayne@69: jpayne@69: #define ITCL_MAJOR_VERSION 4 jpayne@69: #define ITCL_MINOR_VERSION 2 jpayne@69: #define ITCL_RELEASE_LEVEL TCL_FINAL_RELEASE jpayne@69: #define ITCL_RELEASE_SERIAL 3 jpayne@69: jpayne@69: #define ITCL_VERSION "4.2" jpayne@69: #define ITCL_PATCH_LEVEL "4.2.3" jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * A special definition used to allow this header file to be included from jpayne@69: * windows resource files so that they can obtain version information. jpayne@69: * RC_INVOKED is defined by default by the windows RC tool. jpayne@69: * jpayne@69: * Resource compilers don't like all the C stuff, like typedefs and function jpayne@69: * declarations, that occur below, so block them out. jpayne@69: */ jpayne@69: jpayne@69: #ifndef RC_INVOKED jpayne@69: jpayne@69: #define ITCL_NAMESPACE "::itcl" jpayne@69: jpayne@69: #ifndef ITCLAPI jpayne@69: # if defined(BUILD_itcl) jpayne@69: # define ITCLAPI MODULE_SCOPE jpayne@69: # else jpayne@69: # define ITCLAPI extern jpayne@69: # undef USE_ITCL_STUBS jpayne@69: # define USE_ITCL_STUBS 1 jpayne@69: # endif jpayne@69: #endif jpayne@69: jpayne@69: #if defined(BUILD_itcl) && !defined(STATIC_BUILD) jpayne@69: # define ITCL_EXTERN extern DLLEXPORT jpayne@69: #else jpayne@69: # define ITCL_EXTERN extern jpayne@69: #endif jpayne@69: jpayne@69: ITCL_EXTERN int Itcl_Init(Tcl_Interp *interp); jpayne@69: ITCL_EXTERN int Itcl_SafeInit(Tcl_Interp *interp); jpayne@69: jpayne@69: /* jpayne@69: * Protection levels: jpayne@69: * jpayne@69: * ITCL_PUBLIC - accessible from any namespace jpayne@69: * ITCL_PROTECTED - accessible from namespace that imports in "protected" mode jpayne@69: * ITCL_PRIVATE - accessible only within the namespace that contains it jpayne@69: */ jpayne@69: #define ITCL_PUBLIC 1 jpayne@69: #define ITCL_PROTECTED 2 jpayne@69: #define ITCL_PRIVATE 3 jpayne@69: #define ITCL_DEFAULT_PROTECT 4 jpayne@69: jpayne@69: #if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 7) && !defined(Tcl_Size) jpayne@69: # define Tcl_Size int jpayne@69: #endif jpayne@69: jpayne@69: /* jpayne@69: * Generic stack. jpayne@69: */ jpayne@69: typedef struct Itcl_Stack { jpayne@69: void **values; /* values on stack */ jpayne@69: Tcl_Size len; /* number of values on stack */ jpayne@69: Tcl_Size max; /* maximum size of stack */ jpayne@69: void *space[5]; /* initial space for stack data */ jpayne@69: } Itcl_Stack; jpayne@69: jpayne@69: #define Itcl_GetStackSize(stackPtr) ((stackPtr)->len) jpayne@69: jpayne@69: /* jpayne@69: * Generic linked list. jpayne@69: */ jpayne@69: struct Itcl_List; jpayne@69: typedef struct Itcl_ListElem { jpayne@69: struct Itcl_List* owner; /* list containing this element */ jpayne@69: void *value; /* value associated with this element */ jpayne@69: struct Itcl_ListElem *prev; /* previous element in linked list */ jpayne@69: struct Itcl_ListElem *next; /* next element in linked list */ jpayne@69: } Itcl_ListElem; jpayne@69: jpayne@69: typedef struct Itcl_List { jpayne@69: int validate; /* validation stamp */ jpayne@69: Tcl_Size num; /* number of elements */ jpayne@69: struct Itcl_ListElem *head; /* previous element in linked list */ jpayne@69: struct Itcl_ListElem *tail; /* next element in linked list */ jpayne@69: } Itcl_List; jpayne@69: jpayne@69: #define Itcl_FirstListElem(listPtr) ((listPtr)->head) jpayne@69: #define Itcl_LastListElem(listPtr) ((listPtr)->tail) jpayne@69: #define Itcl_NextListElem(elemPtr) ((elemPtr)->next) jpayne@69: #define Itcl_PrevListElem(elemPtr) ((elemPtr)->prev) jpayne@69: #define Itcl_GetListLength(listPtr) ((listPtr)->num) jpayne@69: #define Itcl_GetListValue(elemPtr) ((elemPtr)->value) jpayne@69: jpayne@69: /* jpayne@69: * Token representing the state of an interpreter. jpayne@69: */ jpayne@69: typedef struct Itcl_InterpState_ *Itcl_InterpState; jpayne@69: jpayne@69: jpayne@69: /* jpayne@69: * Include all the public API, generated from itcl.decls. jpayne@69: */ jpayne@69: jpayne@69: #include "itclDecls.h" jpayne@69: jpayne@69: #endif /* RC_INVOKED */ jpayne@69: jpayne@69: /* jpayne@69: * end block for C++ jpayne@69: */ jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #endif /* ITCL_H_INCLUDED */