codekingpro/portable-devtools
114k
1/*2 * itcl.h --3 *4 * This file contains definitions for the C-implemeted part of a Itcl5 * this version of [incr Tcl] (Itcl) is a completely new implementation6 * based on TclOO extension of Tcl 8.57 * It tries to provide the same interfaces as the original implementation8 * of Michael J. McLennan9 * Some small pieces of code are taken from that implementation10 *11 * Copyright (c) 2007 by Arnulf P. Wiedemann12 *13 * See the file "license.terms" for information on usage and redistribution of14 * this file, and for a DISCLAIMER OF ALL WARRANTIES.15 */16 17/*18 * ------------------------------------------------------------------------19 * PACKAGE: [incr Tcl]20 * DESCRIPTION: Object-Oriented Extensions to Tcl21 *22 * [incr Tcl] provides object-oriented extensions to Tcl, much as23 * C++ provides object-oriented extensions to C. It provides a means24 * of encapsulating related procedures together with their shared data25 * in a local namespace that is hidden from the outside world. It26 * promotes code re-use through inheritance. More than anything else,27 * it encourages better organization of Tcl applications through the28 * object-oriented paradigm, leading to code that is easier to29 * understand and maintain.30 *31 * ADDING [incr Tcl] TO A Tcl-BASED APPLICATION:32 *33 * To add [incr Tcl] facilities to a Tcl application, modify the34 * Tcl_AppInit() routine as follows:35 *36 * 1) Include this header file near the top of the file containing37 * Tcl_AppInit():38 *39 * #include "itcl.h"40*41 * 2) Within the body of Tcl_AppInit(), add the following lines:42 *43 * if (Itcl_Init(interp) == TCL_ERROR) {44 * return TCL_ERROR;45 * }46 *47 * 3) Link your application with libitcl.a48 *49 * NOTE: An example file "tclAppInit.c" containing the changes shown50 * above is included in this distribution.51 *52 *---------------------------------------------------------------------53 */54 55#ifndef ITCL_H_INCLUDED56#define ITCL_H_INCLUDED57 58#include <tcl.h>59 60#if (TCL_MAJOR_VERSION == 8) && defined(TCL_MINOR_VERSION) && (TCL_MINOR_VERSION < 6)61# error Itcl 4 build requires tcl.h from Tcl 8.6 or later62#endif63 64/*65 * For C++ compilers, use extern "C"66 */67 68#ifdef __cplusplus69extern "C" {70#endif71 72#ifndef TCL_ALPHA_RELEASE73# define TCL_ALPHA_RELEASE 074#endif75#ifndef TCL_BETA_RELEASE76# define TCL_BETA_RELEASE 177#endif78#ifndef TCL_FINAL_RELEASE79# define TCL_FINAL_RELEASE 280#endif81 82#define ITCL_MAJOR_VERSION 483#define ITCL_MINOR_VERSION 284#define ITCL_RELEASE_LEVEL TCL_FINAL_RELEASE85#define ITCL_RELEASE_SERIAL 386 87#define ITCL_VERSION "4.2"88#define ITCL_PATCH_LEVEL "4.2.3"89 90 91/*92 * A special definition used to allow this header file to be included from93 * windows resource files so that they can obtain version information.94 * RC_INVOKED is defined by default by the windows RC tool.95 *96 * Resource compilers don't like all the C stuff, like typedefs and function97 * declarations, that occur below, so block them out.98 */99 100#ifndef RC_INVOKED101 102#define ITCL_NAMESPACE "::itcl"103 104#ifndef ITCLAPI105# if defined(BUILD_itcl)106# define ITCLAPI MODULE_SCOPE107# else108# define ITCLAPI extern109# undef USE_ITCL_STUBS110# define USE_ITCL_STUBS 1111# endif112#endif113 114#if defined(BUILD_itcl) && !defined(STATIC_BUILD)115# define ITCL_EXTERN extern DLLEXPORT116#else117# define ITCL_EXTERN extern118#endif119 120ITCL_EXTERN int Itcl_Init(Tcl_Interp *interp);121ITCL_EXTERN int Itcl_SafeInit(Tcl_Interp *interp);122 123/*124 * Protection levels:125 *126 * ITCL_PUBLIC - accessible from any namespace127 * ITCL_PROTECTED - accessible from namespace that imports in "protected" mode128 * ITCL_PRIVATE - accessible only within the namespace that contains it129 */130#define ITCL_PUBLIC 1131#define ITCL_PROTECTED 2132#define ITCL_PRIVATE 3133#define ITCL_DEFAULT_PROTECT 4134 135#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 7) && !defined(Tcl_Size)136# define Tcl_Size int137#endif138 139/*140 * Generic stack.141 */142typedef struct Itcl_Stack {143 void **values; /* values on stack */144 Tcl_Size len; /* number of values on stack */145 Tcl_Size max; /* maximum size of stack */146 void *space[5]; /* initial space for stack data */147} Itcl_Stack;148 149#define Itcl_GetStackSize(stackPtr) ((stackPtr)->len)150 151/*152 * Generic linked list.153 */154struct Itcl_List;155typedef struct Itcl_ListElem {156 struct Itcl_List* owner; /* list containing this element */157 void *value; /* value associated with this element */158 struct Itcl_ListElem *prev; /* previous element in linked list */159 struct Itcl_ListElem *next; /* next element in linked list */160} Itcl_ListElem;161 162typedef struct Itcl_List {163 int validate; /* validation stamp */164 Tcl_Size num; /* number of elements */165 struct Itcl_ListElem *head; /* previous element in linked list */166 struct Itcl_ListElem *tail; /* next element in linked list */167} Itcl_List;168 169#define Itcl_FirstListElem(listPtr) ((listPtr)->head)170#define Itcl_LastListElem(listPtr) ((listPtr)->tail)171#define Itcl_NextListElem(elemPtr) ((elemPtr)->next)172#define Itcl_PrevListElem(elemPtr) ((elemPtr)->prev)173#define Itcl_GetListLength(listPtr) ((listPtr)->num)174#define Itcl_GetListValue(elemPtr) ((elemPtr)->value)175 176/*177 * Token representing the state of an interpreter.178 */179typedef struct Itcl_InterpState_ *Itcl_InterpState;180 181182/*183 * Include all the public API, generated from itcl.decls.184 */185 186#include "itclDecls.h"187 188#endif /* RC_INVOKED */189 190/*191 * end block for C++192 */193 194#ifdef __cplusplus195}196#endif197 198#endif /* ITCL_H_INCLUDED */199 