summaryrefslogtreecommitdiffstats
path: root/generic/tclResolve.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclResolve.c')
-rw-r--r--generic/tclResolve.c129
1 files changed, 70 insertions, 59 deletions
diff --git a/generic/tclResolve.c b/generic/tclResolve.c
index e9c7cc5..974737e 100644
--- a/generic/tclResolve.c
+++ b/generic/tclResolve.c
@@ -10,8 +10,6 @@
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id: tclResolve.c,v 1.7 2005/07/23 00:04:31 dkf Exp $
*/
#include "tclInt.h"
@@ -20,7 +18,7 @@
* Declarations for functions local to this file:
*/
-static void BumpCmdRefEpochs _ANSI_ARGS_((Namespace *nsPtr));
+static void BumpCmdRefEpochs(Namespace *nsPtr);
/*
*----------------------------------------------------------------------
@@ -54,20 +52,20 @@ static void BumpCmdRefEpochs _ANSI_ARGS_((Namespace *nsPtr));
*/
void
-Tcl_AddInterpResolvers(interp, name, cmdProc, varProc, compiledVarProc)
- Tcl_Interp *interp; /* Interpreter whose name resolution
- * rules are being modified. */
- CONST char *name; /* Name of this resolution scheme. */
- Tcl_ResolveCmdProc *cmdProc; /* New function for command
- * resolution. */
- Tcl_ResolveVarProc *varProc; /* Function for variable resolution at
- * runtime. */
- Tcl_ResolveCompiledVarProc *compiledVarProc;
- /* Function for variable resolution at
- * compile time. */
+Tcl_AddInterpResolvers(
+ Tcl_Interp *interp, /* Interpreter whose name resolution rules are
+ * being modified. */
+ const char *name, /* Name of this resolution scheme. */
+ Tcl_ResolveCmdProc *cmdProc,/* New function for command resolution. */
+ Tcl_ResolveVarProc *varProc,/* Function for variable resolution at
+ * runtime. */
+ Tcl_ResolveCompiledVarProc *compiledVarProc)
+ /* Function for variable resolution at compile
+ * time. */
{
Interp *iPtr = (Interp *) interp;
ResolverScheme *resPtr;
+ unsigned len;
/*
* Since we're adding a new name resolution scheme, we must force all code
@@ -103,9 +101,10 @@ Tcl_AddInterpResolvers(interp, name, cmdProc, varProc, compiledVarProc)
* list, so that it overrides existing schemes.
*/
- resPtr = (ResolverScheme *) ckalloc(sizeof(ResolverScheme));
- resPtr->name = (char *) ckalloc((unsigned)(strlen(name) + 1));
- strcpy(resPtr->name, name);
+ resPtr = ckalloc(sizeof(ResolverScheme));
+ len = strlen(name) + 1;
+ resPtr->name = ckalloc(len);
+ memcpy(resPtr->name, name, len);
resPtr->cmdResProc = cmdProc;
resPtr->varResProc = varProc;
resPtr->compiledVarResProc = compiledVarProc;
@@ -134,12 +133,13 @@ Tcl_AddInterpResolvers(interp, name, cmdProc, varProc, compiledVarProc)
*/
int
-Tcl_GetInterpResolvers(interp, name, resInfoPtr)
- Tcl_Interp *interp; /* Interpreter whose name resolution
- * rules are being queried. */
- CONST char *name; /* Look for a scheme with this name. */
- Tcl_ResolverInfo *resInfoPtr; /* Returns pointers to the functions,
- * if found */
+Tcl_GetInterpResolvers(
+ Tcl_Interp *interp, /* Interpreter whose name resolution rules are
+ * being queried. */
+ const char *name, /* Look for a scheme with this name. */
+ Tcl_ResolverInfo *resInfoPtr)
+ /* Returns pointers to the functions, if
+ * found */
{
Interp *iPtr = (Interp *) interp;
ResolverScheme *resPtr;
@@ -185,10 +185,10 @@ Tcl_GetInterpResolvers(interp, name, resInfoPtr)
*/
int
-Tcl_RemoveInterpResolvers(interp, name)
- Tcl_Interp *interp; /* Interpreter whose name resolution
- * rules are being modified. */
- CONST char *name; /* Name of the scheme to be removed. */
+Tcl_RemoveInterpResolvers(
+ Tcl_Interp *interp, /* Interpreter whose name resolution rules are
+ * being modified. */
+ const char *name) /* Name of the scheme to be removed. */
{
Interp *iPtr = (Interp *) interp;
ResolverScheme **prevPtrPtr, *resPtr;
@@ -226,7 +226,7 @@ Tcl_RemoveInterpResolvers(interp, name)
*prevPtrPtr = resPtr->nextPtr;
ckfree(resPtr->name);
- ckfree((char *) resPtr);
+ ckfree(resPtr);
return 1;
}
@@ -254,19 +254,31 @@ Tcl_RemoveInterpResolvers(interp, name)
*/
static void
-BumpCmdRefEpochs(nsPtr)
- Namespace *nsPtr; /* Namespace being modified. */
+BumpCmdRefEpochs(
+ Namespace *nsPtr) /* Namespace being modified. */
{
Tcl_HashEntry *entry;
Tcl_HashSearch search;
nsPtr->cmdRefEpoch++;
+#ifndef BREAK_NAMESPACE_COMPAT
for (entry = Tcl_FirstHashEntry(&nsPtr->childTable, &search);
entry != NULL; entry = Tcl_NextHashEntry(&search)) {
- Namespace *childNsPtr = (Namespace *) Tcl_GetHashValue(entry);
+ Namespace *childNsPtr = Tcl_GetHashValue(entry);
+
BumpCmdRefEpochs(childNsPtr);
}
+#else
+ if (nsPtr->childTablePtr != NULL) {
+ for (entry = Tcl_FirstHashEntry(nsPtr->childTablePtr, &search);
+ entry != NULL; entry = Tcl_NextHashEntry(&search)) {
+ Namespace *childNsPtr = Tcl_GetHashValue(entry);
+
+ BumpCmdRefEpochs(childNsPtr);
+ }
+ }
+#endif
TclInvalidateNsPath(nsPtr);
}
@@ -282,24 +294,23 @@ BumpCmdRefEpochs(nsPtr)
*
* Command resolution is handled by a function of the following type:
*
- * typedef int (*Tcl_ResolveCmdProc)(Tcl_Interp *interp,
- * CONST char *name, Tcl_Namespace *context,
+ * typedef int (Tcl_ResolveCmdProc)(Tcl_Interp *interp,
+ * const char *name, Tcl_Namespace *context,
* int flags, Tcl_Command *rPtr);
*
* Whenever a command is executed or Tcl_FindCommand is invoked within
- * the namespace, this function is called to resolve the command name.
- * If this function is able to resolve the name, it should return the
- * status code TCL_OK, along with the corresponding Tcl_Command in the
- * rPtr argument. Otherwise, the function can return TCL_CONTINUE, and
- * the command will be treated under the usual name resolution rules.
- * Or, it can return TCL_ERROR, and the command will be considered
- * invalid.
+ * the namespace, this function is called to resolve the command name. If
+ * this function is able to resolve the name, it should return the status
+ * code TCL_OK, along with the corresponding Tcl_Command in the rPtr
+ * argument. Otherwise, the function can return TCL_CONTINUE, and the
+ * command will be treated under the usual name resolution rules. Or, it
+ * can return TCL_ERROR, and the command will be considered invalid.
*
* Variable resolution is handled by two functions. The first is called
* whenever a variable needs to be resolved at compile time:
*
- * typedef int (*Tcl_ResolveCompiledVarProc)(Tcl_Interp *interp,
- * CONST char *name, Tcl_Namespace *context,
+ * typedef int (Tcl_ResolveCompiledVarProc)(Tcl_Interp *interp,
+ * const char *name, Tcl_Namespace *context,
* Tcl_ResolvedVarInfo *rPtr);
*
* If this function is able to resolve the name, it should return the
@@ -314,8 +325,8 @@ BumpCmdRefEpochs(nsPtr)
* the variable may be requested via Tcl_FindNamespaceVar.) This function
* has the following type:
*
- * typedef int (*Tcl_ResolveVarProc)(Tcl_Interp *interp,
- * CONST char *name, Tcl_Namespace *context,
+ * typedef int (Tcl_ResolveVarProc)(Tcl_Interp *interp,
+ * const char *name, Tcl_Namespace *context,
* int flags, Tcl_Var *rPtr);
*
* This function is quite similar to the compile-time version. It returns
@@ -335,15 +346,15 @@ BumpCmdRefEpochs(nsPtr)
*/
void
-Tcl_SetNamespaceResolvers(namespacePtr, cmdProc, varProc, compiledVarProc)
- Tcl_Namespace *namespacePtr; /* Namespace whose resolution rules
- * are being modified. */
- Tcl_ResolveCmdProc *cmdProc; /* Function for command resolution */
- Tcl_ResolveVarProc *varProc; /* Function for variable resolution at
- * run-time */
- Tcl_ResolveCompiledVarProc *compiledVarProc;
- /* Function for variable resolution at
- * compile time. */
+Tcl_SetNamespaceResolvers(
+ Tcl_Namespace *namespacePtr,/* Namespace whose resolution rules are being
+ * modified. */
+ Tcl_ResolveCmdProc *cmdProc,/* Function for command resolution */
+ Tcl_ResolveVarProc *varProc,/* Function for variable resolution at
+ * run-time */
+ Tcl_ResolveCompiledVarProc *compiledVarProc)
+ /* Function for variable resolution at compile
+ * time. */
{
Namespace *nsPtr = (Namespace *) namespacePtr;
@@ -384,12 +395,12 @@ Tcl_SetNamespaceResolvers(namespacePtr, cmdProc, varProc, compiledVarProc)
*/
int
-Tcl_GetNamespaceResolvers(namespacePtr, resInfoPtr)
- Tcl_Namespace *namespacePtr; /* Namespace whose resolution rules
- * are being modified. */
- Tcl_ResolverInfo *resInfoPtr; /* Returns: pointers for all name
- * resolution functions assigned to
- * this namespace. */
+Tcl_GetNamespaceResolvers(
+ Tcl_Namespace *namespacePtr,/* Namespace whose resolution rules are being
+ * modified. */
+ Tcl_ResolverInfo *resInfoPtr)
+ /* Returns: pointers for all name resolution
+ * functions assigned to this namespace. */
{
Namespace *nsPtr = (Namespace *) namespacePtr;