Index: TODO =================================================================== diff -u -rf1b65a9694a721be01a9a2acaff5ee093456b2bd -r110b3365dd642ce09d4b4392591ea0e5b19f6d60 --- TODO (.../TODO) (revision f1b65a9694a721be01a9a2acaff5ee093456b2bd) +++ TODO (.../TODO) (revision 110b3365dd642ce09d4b4392591ea0e5b19f6d60) @@ -1850,6 +1850,11 @@ - gentclApi.tcl: added optimizer rule for single argument of type tclobj - improved speed of CompiledLocalsLookup slightly +- added an experimental code for setting parent namespace path as + default for child-objects. At the time when an object namespace is + created, the namespace path of the parent object is copied to the + child as default value. + TODO: - "-returns" Index: generic/nsf.c =================================================================== diff -u -rf1b65a9694a721be01a9a2acaff5ee093456b2bd -r110b3365dd642ce09d4b4392591ea0e5b19f6d60 --- generic/nsf.c (.../nsf.c) (revision f1b65a9694a721be01a9a2acaff5ee093456b2bd) +++ generic/nsf.c (.../nsf.c) (revision 110b3365dd642ce09d4b4392591ea0e5b19f6d60) @@ -2250,8 +2250,9 @@ int new; #if defined(VAR_RESOLVER_TRACE) + int flags = var ? ((Var*)var)->flags : 0; fprintf(stderr,"CompiledColonVarFetch var '%s' var %p flags = %.4x dead? %.4x\n", - ObjStr(resVarInfo->nameObj), var, flags, flags&VAR_DEAD_HASH); + ObjStr(resVarInfo->nameObj), var, flags, flags&VAR_DEAD_HASH); #endif /* @@ -2582,6 +2583,8 @@ CallFrame *varFramePtr; int frameFlags; + /*fprintf(stderr, "InterpColonCmdResolver %s flags %.6x\n", cmdName, flags);*/ + if (!FOR_COLON_RESOLVER(cmdName) || flags & TCL_GLOBAL_ONLY) { /* ordinary names and global lookups are not for us */ return TCL_CONTINUE; @@ -2633,13 +2636,36 @@ if (!object->nsPtr) { MakeObjNamespace(interp, object); } - /* This puts a per-object namespace resolver into position upon + /* + * This puts a per-object namespace resolver into position upon * acquiring the namespace. Works for object-scoped commands/procs * and object-only ones (set, unset, ...) */ Tcl_SetNamespaceResolvers(object->nsPtr, /*(Tcl_ResolveCmdProc*)NsColonCmdResolver*/ NULL, NsColonVarResolver, /*(Tcl_ResolveCompiledVarProc*)NsCompiledColonVarResolver*/NULL); +#if 1 + /* + * In case there is a namespace path set for the parent namespace, + * apply this as well to the object namespace to avoid surprises + * with "namespace path nx". + */ + { Namespace *parentNsPtr = Tcl_Namespace_parentPtr(object->nsPtr); + int i, pathLength = Tcl_Namespace_commandPathLength(parentNsPtr); + + if (pathLength>0) { + Namespace **pathArray = (Namespace **)ckalloc(sizeof(Namespace *) * pathLength); + NamespacePathEntry *tmpPathArray = Tcl_Namespace_commandPathArray(parentNsPtr); + + for (i=0; i<pathLength; i++) { + pathArray[i] = tmpPathArray[i].nsPtr; + } + TclSetNsPath((Namespace *)object->nsPtr, pathLength, (Tcl_Namespace **)pathArray); + ckfree((char*)pathArray); + } + } +#endif + return object->nsPtr; } Index: generic/nsfAccessInt.h =================================================================== diff -u -r404ad6bfcb313983a0cc54d3323751008bca991b -r110b3365dd642ce09d4b4392591ea0e5b19f6d60 --- generic/nsfAccessInt.h (.../nsfAccessInt.h) (revision 404ad6bfcb313983a0cc54d3323751008bca991b) +++ generic/nsfAccessInt.h (.../nsfAccessInt.h) (revision 110b3365dd642ce09d4b4392591ea0e5b19f6d60) @@ -24,7 +24,11 @@ #define Tcl_Namespace_childTablePtr(nsPtr) &((Namespace *)nsPtr)->childTable #define Tcl_Namespace_activationCount(nsPtr) ((Namespace *)nsPtr)->activationCount #define Tcl_Namespace_deleteProc(nsPtr) ((Namespace *)nsPtr)->deleteProc +#define Tcl_Namespace_parentPtr(nsPtr) ((Namespace *)nsPtr)->parentPtr +#define Tcl_Namespace_commandPathLength(nsPtr) ((Namespace *)nsPtr)->commandPathLength +#define Tcl_Namespace_commandPathArray(nsPtr) ((Namespace *)nsPtr)->commandPathArray + #define Tcl_Command_refCount(cmd) ((Command *)cmd)->refCount #define Tcl_Command_cmdEpoch(cmd) ((Command *)cmd)->cmdEpoch #define Tcl_Command_flags(cmd) ((Command *)cmd)->flags Fisheye: Tag 110b3365dd642ce09d4b4392591ea0e5b19f6d60 refers to a dead (removed) revision in file `xotcl.m4'. Fisheye: No comparison available. Pass `N' to diff?