Index: TODO =================================================================== diff -u -r8f2c993e02fe43f23c7e1653d05f6e298c23b2b2 -r8274c68ad85f12b1e4a41a01273079405fa865ef --- TODO (.../TODO) (revision 8f2c993e02fe43f23c7e1653d05f6e298c23b2b2) +++ TODO (.../TODO) (revision 8274c68ad85f12b1e4a41a01273079405fa865ef) @@ -951,9 +951,13 @@ - moved slottest to library/xotcl - added new Makefile target test-xotcl - finished test migration for now - - deactivated __next for now +- iterated through doc.tcl-TODOs +- changed CheckVarName to allow array names like e.g. a(::b) +- extended regression test +- fixed serializer to handle subobjects of explicitely exported objects + TODO: - nameing * .c-code: Index: generic/xotcl.c =================================================================== diff -u -r8f2c993e02fe43f23c7e1653d05f6e298c23b2b2 -r8274c68ad85f12b1e4a41a01273079405fa865ef --- generic/xotcl.c (.../xotcl.c) (revision 8f2c993e02fe43f23c7e1653d05f6e298c23b2b2) +++ generic/xotcl.c (.../xotcl.c) (revision 8274c68ad85f12b1e4a41a01273079405fa865ef) @@ -5050,7 +5050,17 @@ static int CheckVarName(Tcl_Interp *interp, const char *varNameString) { - if (strstr(varNameString, "::") || *varNameString == ':') { + /* + * Check, whether the provided name is save to be used in the + * resolver. We do not want to get interferences with namespace + * resolver and such. In an first attempt, we disallowed occurances + * of "::", but we have to deal as well with e.g. arrayName(::x::y) + * + * TODO: more general and efficient solution to disallow e.g. a::b + * (check for :: until parens) + */ + /*if (strstr(varNameString, "::") || *varNameString == ':') {*/ + if (*varNameString == ':') { return XOTclVarErrMsg(interp, "variable name \"", varNameString, "\" must not contain namespace separator or colon prefix", (char *) NULL); @@ -8537,10 +8547,10 @@ * see Tcl_VariableObjCmd ... */ if (arrayPtr) { - return XOTclVarErrMsg(interp, "can't make instvar ", ObjStr(varName), + return XOTclVarErrMsg(interp, "can't make instance variable ", ObjStr(varName), " on ", objectName(object), - ": variable cannot be an element in an array;", - " use an alias or objeval.", (char *) NULL); + ": Variable cannot be an element in an array;", + " use e.g. an alias.", (char *) NULL); } newName = varName; Index: library/serialize/serializer.tcl =================================================================== diff -u -r183ec0e7c071586238bf5ed90a05dbbda91d4582 -r8274c68ad85f12b1e4a41a01273079405fa865ef --- library/serialize/serializer.tcl (.../serializer.tcl) (revision 183ec0e7c071586238bf5ed90a05dbbda91d4582) +++ library/serialize/serializer.tcl (.../serializer.tcl) (revision 8274c68ad85f12b1e4a41a01273079405fa865ef) @@ -179,7 +179,7 @@ # we export the object tree. set oo $o while {1} { - if {[[self class] exists exportObjects($o)]} { + if {[::nx::core::existsvar [self class] exportObjects($o)]} { return 1 } # we do this for object trees without object-less namespaces @@ -196,7 +196,6 @@ # TODO generalize? set ns_excluded(::ns) 1 - foreach c $set { set ns [namespace qualifiers $c] if {!$all && @@ -478,7 +477,7 @@ # notify serializer object $s set instances [list] foreach i [${:rootClass} info instances -closure] { - if {[:matchesIgnorePattern $i] && ![info exists :exportObjects($i)]} { + if {[:matchesIgnorePattern $i] && ![$s isExportedObject $i]} { continue } $s setObjectSystemSerializer $i [self] Index: tests/varresolutiontest.tcl =================================================================== diff -u -r35c67391973a07983d0b0dfe70706e6a69fbdbfc -r8274c68ad85f12b1e4a41a01273079405fa865ef --- tests/varresolutiontest.tcl (.../varresolutiontest.tcl) (revision 35c67391973a07983d0b0dfe70706e6a69fbdbfc) +++ tests/varresolutiontest.tcl (.../varresolutiontest.tcl) (revision 8274c68ad85f12b1e4a41a01273079405fa865ef) @@ -53,6 +53,8 @@ set ::z 3 set [self]::X 4 set g 1 + set :a(:b) 1 + set :a(::c) 1 } ? {::nx::core::importvar o2 j} \ "importvar cannot import variable 'j' into method scope; not called from a method frame" @@ -63,12 +65,27 @@ o method foo {} {::nx::core::importvar [self] ::a} ? {o foo} "variable name \"::a\" must not contain namespace separator or colon prefix" +o method foo {} {::nx::core::importvar [self] a(:b)} +? {o foo} "can't make instance variable a(:b) on ::o: Variable cannot be an element in an array; use e.g. an alias." + +o method foo {} {::nx::core::importvar [self] {a(:b) ab}} +? {o foo} "" + +o method foo {} {::nx::core::existsvar [self] ::a} +? {o foo} "variable name \"::a\" must not contain namespace separator or colon prefix" + +o method foo {} {::nx::core::existsvar [self] a(:b)} +? {o foo} 1 + +o method foo {} {::nx::core::existsvar [self] a(::c)} +? {o foo} 1 + set ::o::Y 5 ? {info vars ::x} "" ? {info exists ::z} 1 ? {set ::z} 3 -? {lsort [o info vars]} {X Y g i x y} +? {lsort [o info vars]} {X Y a g i x y} ? {o eval {info exists :x}} 1 ? {o eval {info exists :y}} 1 ? {o eval {info exists :z}} 0