1 /*
2  * Macros to abstract access to Tcl internals where possible.
3  * This file is part of the Next Scripting Framework
4  *
5  * Copyright (C) 2010-2014 Gustaf Neumann
6  *
7  * Vienna University of Economics and Business
8  * Institute of Information Systems and New Media
9  * A-1020, Welthandelsplatz 1
10  * Vienna, Austria
11  *
12  * This work is licensed under the MIT License https://www.opensource.org/licenses/MIT
13  *
14  * Copyright:
15  *
16  * Permission is hereby granted, free of charge, to any person obtaining a
17  * copy of this software and associated documentation files (the "Software"),
18  * to deal in the Software without restriction, including without limitation
19  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
20  * and/or sell copies of the Software, and to permit persons to whom the
21  * Software is furnished to do so, subject to the following conditions:
22  *
23  * The above copyright notice and this permission notice shall be included in
24  * all copies or substantial portions of the Software.
25  *
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
31  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
32  * DEALINGS IN THE SOFTWARE.
33  *
34  */
35 #define Tcl_Interp_numLevels(interp)       ((Interp *)(interp))->numLevels
36 #define Tcl_Interp_framePtr(interp)        ((Tcl_CallFrame *)((Interp *)(interp))->framePtr)
37 #define Tcl_Interp_varFramePtr(interp)     (((Interp *)(interp))->varFramePtr)
38 #define Tcl_Interp_cmdFramePtr(interp)     (((Interp *)(interp))->cmdFramePtr)
39 #define Tcl_Interp_globalNsPtr(interp)     ((Tcl_Namespace *)((Interp *)(interp))->globalNsPtr)
40 #define Tcl_Interp_flags(interp)           ((Interp *)(interp))->flags
41 #define Tcl_Interp_threadId(interp)        ((Interp *)(interp))->threadId
42 
43 #define Tcl_CallFrame_callerPtr(cf)       ((Tcl_CallFrame*)((CallFrame *)(cf))->callerPtr)
44 #define Tcl_CallFrame_procPtr(cf)         ((CallFrame *)(cf))->procPtr
45 #define Tcl_CallFrame_varTablePtr(cf)     ((CallFrame *)(cf))->varTablePtr
46 #define Tcl_CallFrame_level(cf)           ((CallFrame *)(cf))->level
47 #define Tcl_CallFrame_isProcCallFrame(cf) ((CallFrame *)(cf))->isProcCallFrame
48 #define Tcl_CallFrame_compiledLocals(cf)  ((CallFrame *)(cf))->compiledLocals
49 #define Tcl_CallFrame_numCompiledLocals(cf)  ((CallFrame *)(cf))->numCompiledLocals
50 #define Tcl_CallFrame_callerVarPtr(cf)    ((Tcl_CallFrame*)((CallFrame *)(cf))->callerVarPtr)
51 #define Tcl_CallFrame_objc(cf)            ((CallFrame *)(cf))->objc
52 #define Tcl_CallFrame_objv(cf)            ((CallFrame *)(cf))->objv
53 #define Tcl_CallFrame_clientData(cf)      ((CallFrame *)(cf))->clientData
54 #define Tcl_CallFrame_nsPtr(cf)           ((Tcl_Namespace *)((CallFrame *)(cf))->nsPtr)
55 
56 #define Tcl_Namespace_cmdTablePtr(nsPtr) &((Namespace *)(nsPtr))->cmdTable
57 #define Tcl_Namespace_varTablePtr(nsPtr) &((Namespace *)(nsPtr))->varTable
58 #define Tcl_Namespace_childTablePtr(nsPtr) &((Namespace *)(nsPtr))->childTable
59 #define Tcl_Namespace_activationCount(nsPtr) ((Namespace *)(nsPtr))->activationCount
60 #define Tcl_Namespace_deleteProc(nsPtr)  ((Namespace *)(nsPtr))->deleteProc
61 #define Tcl_Namespace_parentPtr(nsPtr)   ((Namespace *)(nsPtr))->parentPtr
62 #define Tcl_Namespace_commandPathLength(nsPtr) ((Namespace *)(nsPtr))->commandPathLength
63 #define Tcl_Namespace_commandPathArray(nsPtr)  ((Namespace *)(nsPtr))->commandPathArray
64 #define Tcl_Namespace_refCount(nsPtr)  ((Namespace *)(nsPtr))->refCount
65 #define Tcl_Namespace_flags(nsPtr)  ((Namespace *)(nsPtr))->flags
66 
67 
68 #define Tcl_Command_refCount(cmd)      ((Command *)(cmd))->refCount
69 #define Tcl_Command_cmdEpoch(cmd)      ((Command *)(cmd))->cmdEpoch
70 #define Tcl_Command_flags(cmd)         ((Command *)(cmd))->flags
71 /* the following items could be obtained from
72    Tcl_GetCommandInfoFromToken(cmd, infoPtr) */
73 #define Tcl_Command_nsPtr(cmd)         ((Tcl_Namespace*)(((Command *)(cmd))->nsPtr))
74 #define Tcl_Command_objProc(cmd)       ((Command *)(cmd))->objProc
75 #if defined(NRE)
76 # define Tcl_Command_nreProc(cmd)       ((Command *)(cmd))->nreProc
77 #endif
78 #define Tcl_Command_objClientData(cmd) ((Command *)(cmd))->objClientData
79 #define Tcl_Command_proc(cmd)          ((Command *)(cmd))->proc
80 #define Tcl_Command_clientData(cmd)    ((Command *)(cmd))->clientData
81 #define Tcl_Command_deleteProc(cmd)    ((Command *)(cmd))->deleteProc
82 #define Tcl_Command_deleteData(cmd)    ((Command *)(cmd))->deleteData
83 
84 /*
85  * Var Reform Compatibility support.
86  *
87  *   Definitions for accessing Tcl variable structures after varreform
88  *   in Tcl 8.5.
89  */
90 
91 #define TclIsCompiledLocalArgument(compiledLocalPtr)  ((compiledLocalPtr)->flags & VAR_ARGUMENT)
92 #define TclIsCompiledLocalTemporary(compiledLocalPtr) ((compiledLocalPtr)->flags & VAR_TEMPORARY)
93 
94 #define TclVarHashGetValue(hPtr)	((Var *) ((char *)(hPtr) - TclOffset(VarInHash, entry)))
95 #define TclVarHashGetKey(varPtr)	(((VarInHash *)(varPtr))->entry.key.objPtr)
96 #define TclVarHashTablePtr(varTablePtr)		&(varTablePtr)->table
97 #define TclVarValue(type, varPtr, field)	(type *)(varPtr)->value.field
98 
99 #if !defined(Tcl_HashSize)
100 # define Tcl_HashSize(tablePtr) ((tablePtr)->numEntries)
101 #endif
102 
103 
104 
105 
106