diff options
Diffstat (limited to 'generic/tclInt.h')
-rw-r--r-- | generic/tclInt.h | 103 |
1 files changed, 11 insertions, 92 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h index ee86099..15877f8 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4251,109 +4251,28 @@ MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit; */ #define NRE_ENABLE_ASSERTS 1 -#define NRE_STACK_DEBUG 0 -#define NRE_STACK_SIZE 100 +#if NRE_ENABLE_ASSERTS +#include <assert.h> +#define NRE_ASSERT(expr) assert((expr)) +#else +#define NRE_ASSERT(expr) +#endif -/* - * This is the main data struct for representing NR commands. It is designed - * to fit in sizeof(Tcl_Obj) in order to exploit the fastest memory allocator - * available. - */ - -#define TOP_CB(iPtr) (((Interp *)(iPtr))->execEnvPtr->callbackPtr) - -/* - * Inline versions of Tcl_NRAddCallback and friends - */ - -#define TclNRAddCallback(interp,postProcPtr,data0,data1,data2,data3) \ - do { \ - NRE_callback *cbPtr; \ - ALLOC_CB(interp, cbPtr); \ - INIT_CB(cbPtr, postProcPtr,data0,data1,data2,data3); \ - } while (0) - -#define INIT_CB(cbPtr, postProcPtr,data0,data1,data2,data3) \ - do { \ - cbPtr->procPtr = (postProcPtr); \ - cbPtr->data[0] = (ClientData)(data0); \ - cbPtr->data[1] = (ClientData)(data1); \ - cbPtr->data[2] = (ClientData)(data2); \ - cbPtr->data[3] = (ClientData)(data3); \ - } while (0) - -#if NRE_STACK_DEBUG - -typedef struct NRE_callback { - Tcl_NRPostProc *procPtr; - ClientData data[4]; - struct NRE_callback *nextPtr; -} NRE_callback; - -#define POP_CB(interp, cbPtr) \ - do { \ - cbPtr = TOP_CB(interp); \ - TOP_CB(interp) = cbPtr->nextPtr; \ - } while (0) - -#define ALLOC_CB(interp, cbPtr) \ - do { \ - cbPtr = ckalloc(sizeof(NRE_callback)); \ - cbPtr->nextPtr = TOP_CB(interp); \ - TOP_CB(interp) = cbPtr; \ - } while (0) - -#define FREE_CB(interp, ptr) \ - ckfree((char *) (ptr)) +void TclNRSetRoot(Tcl_Interp *interp); -#define NEXT_CB(ptr) (ptr)->nextPtr +/* NOTE: this just needed by tclOOBasic.c for a legit operation that deserves + * a better API */ -#else /* not debugging the NRE stack */ +#ifdef USE_TOP_CB +#define TOP_CB(iPtr) (((Interp *)(iPtr))->execEnvPtr->callbackPtr) typedef struct NRE_callback { Tcl_NRPostProc *procPtr; ClientData data[4]; - struct NRE_callback *nextPtr; } NRE_callback; - -typedef struct NRE_stack { - struct NRE_callback items[NRE_STACK_SIZE]; - struct NRE_stack *next; -} NRE_stack; - -#define POP_CB(interp, cbPtr) \ - (cbPtr) = TOP_CB(interp)-- - -#define ALLOC_CB(interp, cbPtr) \ - do { \ - ExecEnv *eePtr = ((Interp *) interp)->execEnvPtr; \ - NRE_stack *this = eePtr->NRStack; \ - \ - if (eePtr->callbackPtr && \ - (eePtr->callbackPtr < &this->items[NRE_STACK_SIZE-1])) { \ - (cbPtr) = ++eePtr->callbackPtr; \ - } else { \ - (cbPtr) = TclNewCallback(interp); \ - } \ - } while (0) - -#define FREE_CB(interp, cbPtr) - -#define NEXT_CB(ptr) TclNextCallback(ptr) - -MODULE_SCOPE NRE_callback *TclNewCallback(Tcl_Interp *interp); -MODULE_SCOPE NRE_callback *TclPopCallback(Tcl_Interp *interp); -MODULE_SCOPE NRE_callback *TclNextCallback(NRE_callback *ptr); -MODULE_SCOPE Tcl_NRPostProc TclNRStackBottom; - #endif -#if NRE_ENABLE_ASSERTS -#define NRE_ASSERT(expr) assert((expr)) -#else -#define NRE_ASSERT(expr) -#endif /* GET OUT OF THE ALLOCATOR BIZ! */ #define TclpAlloc(size) malloc(size) |