summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoye <joye>2013-09-09 18:02:24 (GMT)
committerjoye <joye>2013-09-09 18:02:24 (GMT)
commit3e01959a5ca8307048f628dba0e425f7f24ca4e9 (patch)
tree93dba380a1ca3cdca82fc300335b3d791a9f7347
parent5298de48587db6cf3307fb166d2c0b5b3e033dad (diff)
downloadblt-3e01959a5ca8307048f628dba0e425f7f24ca4e9.zip
blt-3e01959a5ca8307048f628dba0e425f7f24ca4e9.tar.gz
blt-3e01959a5ca8307048f628dba0e425f7f24ca4e9.tar.bz2
*** empty log message ***
-rw-r--r--src/bltNsUtil.C136
-rw-r--r--src/bltNsUtil.h9
-rw-r--r--src/bltVector.C8
3 files changed, 62 insertions, 91 deletions
diff --git a/src/bltNsUtil.C b/src/bltNsUtil.C
index c4340d6..1ed06c4 100644
--- a/src/bltNsUtil.C
+++ b/src/bltNsUtil.C
@@ -26,63 +26,22 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#define TIME_WITH_SYS_TIME 0
+#define HAVE_SYS_TIME_H 1
+#define STDC_HEADERS 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_UNISTD_H 1
+#include <tclPort.h>
+#include <tclInt.h>
+
+#define FOOBAR
#include "bltInt.h"
-#include "bltNsUtil.h"
+#undef FOOBAR
-/*
- * A Command structure exists for each command in a namespace. The Tcl_Command
- * opaque type actually refers to these structures.
- */
-
-typedef struct CompileProc CompileProc;
-typedef struct ImportRef ImportRef;
-typedef struct CommandTrace CommandTrace;
-
-typedef struct {
- Tcl_HashEntry *hPtr; /* Pointer to the hash table entry that refers
- * to this command. The hash table is either a
- * namespace's command table or an
- * interpreter's hidden command table. This
- * pointer is used to get a command's name
- * from its Tcl_Command handle. NULL means
- * that the hash table entry has been removed
- * already (this can happen if deleteProc
- * causes the command to be deleted or
- * recreated). */
- Tcl_Namespace *nsPtr; /* Points to the namespace containing this
- * command. */
- int refCount; /* 1 if in command hashtable plus 1 for each
- * reference from a CmdName TCL object
- * representing a command's name in a ByteCode
- * instruction sequence. This structure can be
- * freed when refCount becomes zero. */
- int cmdEpoch; /* Incremented to invalidate any references
- * that point to this command when it is
- * renamed, deleted, hidden, or exposed. */
- CompileProc *compileProc; /* Procedure called to compile command. NULL
- * if no compile proc exists for command. */
- Tcl_ObjCmdProc *objProc; /* Object-based command procedure. */
- ClientData objClientData; /* Arbitrary value passed to object proc. */
- Tcl_CmdProc *proc; /* String-based command procedure. */
- ClientData clientData; /* Arbitrary value passed to string proc. */
- Tcl_CmdDeleteProc *deleteProc;
- /* Procedure invoked when deleting command
- * to, e.g., free all client data. */
- ClientData deleteData; /* Arbitrary value passed to deleteProc. */
- int flags; /* Means that the command is in the process of
- * being deleted (its deleteProc is currently
- * executing). Other attempts to delete the
- * command should be ignored. */
- ImportRef *importRefPtr; /* List of each imported Command created in
- * another namespace when this command is
- * imported. These imported commands redirect
- * invocations back to this command. The list
- * is used to remove all those imported
- * commands when deleting this "real"
- * command. */
- CommandTrace *tracePtr; /* First in list of all traces set for this
- * command. */
-} Command;
+#include "bltNsUtil.h"
/*ARGSUSED*/
Tcl_Namespace *
@@ -93,27 +52,6 @@ Blt_GetCommandNamespace(Tcl_Command cmdToken)
return (Tcl_Namespace *)cmdPtr->nsPtr;
}
-Tcl_CallFrame *
-Blt_EnterNamespace(Tcl_Interp *interp, Tcl_Namespace *nsPtr)
-{
- Tcl_CallFrame *framePtr;
-
- framePtr = malloc(sizeof(Tcl_CallFrame));
- if (Tcl_PushCallFrame(interp, framePtr, (Tcl_Namespace *)nsPtr, 0)
- != TCL_OK) {
- free(framePtr);
- return NULL;
- }
- return framePtr;
-}
-
-void
-Blt_LeaveNamespace(Tcl_Interp *interp, Tcl_CallFrame *framePtr)
-{
- Tcl_PopCallFrame(interp);
- free(framePtr);
-}
-
int
Blt_ParseObjectName(Tcl_Interp *interp, const char *path,
Blt_ObjectName *namePtr, unsigned int flags)
@@ -172,3 +110,49 @@ Blt_MakeQualifiedName(Blt_ObjectName *namePtr, Tcl_DString *resultPtr)
return Tcl_DStringValue(resultPtr);
}
+static INLINE Tcl_Namespace *
+NamespaceOfVariable(Var *varPtr)
+{
+ if (varPtr->flags & VAR_IN_HASHTABLE) {
+ VarInHash *vhashPtr = (VarInHash *)varPtr;
+ TclVarHashTable *vtablePtr;
+
+ vtablePtr = (TclVarHashTable *)vhashPtr->entry.tablePtr;
+ return vtablePtr->nsPtr;
+ }
+ return NULL;
+}
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * Blt_GetVariableNamespace --
+ *
+ * Returns the namespace context of the variable. If NULL, this
+ * indicates that the variable is local to the call frame.
+ *
+ * Results:
+ * Returns the context of the namespace in an opaque type.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+Tcl_Namespace *
+Blt_GetVariableNamespace(Tcl_Interp *interp, const char *path)
+{
+ Blt_ObjectName objName;
+
+ if (!Blt_ParseObjectName(interp, path, &objName, BLT_NO_DEFAULT_NS)) {
+ return NULL;
+ }
+ if (objName.nsPtr == NULL) {
+ Var *varPtr;
+
+ varPtr = (Var *)Tcl_FindNamespaceVar(interp, (char *)path,
+ (Tcl_Namespace *)NULL, TCL_GLOBAL_ONLY);
+ if (varPtr != NULL) {
+ return NamespaceOfVariable(varPtr);
+ }
+ }
+ return objName.nsPtr;
+}
diff --git a/src/bltNsUtil.h b/src/bltNsUtil.h
index 82eebc0..63f8ae3 100644
--- a/src/bltNsUtil.h
+++ b/src/bltNsUtil.h
@@ -29,10 +29,6 @@
#ifndef BLT_NS_UTIL_H
#define BLT_NS_UTIL_H 1
-#ifndef TCL_NAMESPACE_ONLY
-#define TCL_NAMESPACE_ONLY TCL_GLOBAL_ONLY
-#endif
-
#define NS_SEARCH_NONE (0)
#define NS_SEARCH_CURRENT (1<<0)
#define NS_SEARCH_GLOBAL (1<<1)
@@ -54,11 +50,6 @@ extern Tcl_Namespace *Blt_GetVariableNamespace(Tcl_Interp *interp,
extern Tcl_Namespace *Blt_GetCommandNamespace(Tcl_Command cmdToken);
-extern Tcl_CallFrame *Blt_EnterNamespace(Tcl_Interp *interp,
- Tcl_Namespace *nsPtr);
-
-extern void Blt_LeaveNamespace(Tcl_Interp *interp, Tcl_CallFrame *framePtr);
-
extern int Blt_ParseObjectName(Tcl_Interp *interp, const char *name,
Blt_ObjectName *objNamePtr, unsigned int flags);
diff --git a/src/bltVector.C b/src/bltVector.C
index 3bcb63a..41131eb 100644
--- a/src/bltVector.C
+++ b/src/bltVector.C
@@ -51,10 +51,6 @@
#include "bltNsUtil.h"
#include "bltSwitch.h"
-#ifndef TCL_NAMESPACE_ONLY
-#define TCL_NAMESPACE_ONLY TCL_GLOBAL_ONLY
-#endif
-
#define DEF_ARRAY_SIZE 64
#define TRACE_ALL (TCL_TRACE_WRITES | TCL_TRACE_READS | TCL_TRACE_UNSETS)
@@ -709,7 +705,7 @@ UnmapVariable(Vector *vPtr)
if (vPtr->arrayName != NULL) {
free((void*)(vPtr->arrayName));
- vPtr->arrayName = NULL;
+ vPtr->arrayName = NULL;
}
}
@@ -769,7 +765,7 @@ Blt_Vec_MapVariable(
vPtr->varFlags = 0;
if (objName.nsPtr != NULL) { /* Global or namespace variable. */
newPath = Blt_MakeQualifiedName(&objName, &dString);
- vPtr->varFlags |= (TCL_NAMESPACE_ONLY | TCL_GLOBAL_ONLY);
+ vPtr->varFlags |= (TCL_GLOBAL_ONLY);
} else { /* Local variable. */
newPath = (char *)objName.name;
}