Index: TODO =================================================================== diff -u -r172b35a1009234b4cf2900f5e3c01d257b4cb369 -rd6a22408f08fb02ee6043b2243957922a75fbeef --- TODO (.../TODO) (revision 172b35a1009234b4cf2900f5e3c01d257b4cb369) +++ TODO (.../TODO) (revision d6a22408f08fb02ee6043b2243957922a75fbeef) @@ -2215,7 +2215,13 @@ - extended regression test - next-tutorial: documentation updates +- add explicit reference counting for oacs-style flag value passing +- parameter specs: use "arg=" in object parameter type "method" as + name of a called method to allow to call unregistered methods +- eliminate protected method "noinit" for nx and allow it just as an + object parameter + TODO: - doc: NextScriptingLanguage/index.html: Index: generic/nsf.c =================================================================== diff -u -rcf9e57bf5b9dbb5960ea71fbb22debc89421aa70 -rd6a22408f08fb02ee6043b2243957922a75fbeef --- generic/nsf.c (.../nsf.c) (revision cf9e57bf5b9dbb5960ea71fbb22debc89421aa70) +++ generic/nsf.c (.../nsf.c) (revision d6a22408f08fb02ee6043b2243957922a75fbeef) @@ -8457,7 +8457,7 @@ Tcl_Obj *objv[3]; int result; - if (pPtr->converterArg) { + if (pPtr->converterArg && (pPtr->flags & (NSF_ARG_METHOD)) == 0) { /*fprintf(stderr, "ConvertToTclobj %s (must be %s)\n", ObjStr(objPtr), ObjStr(pPtr->converterArg));*/ objv[1] = pPtr->converterArg; @@ -8802,7 +8802,7 @@ if (*option == '*' || *option == 'n') { if ((paramPtr->flags & (NSF_ARG_INITCMD|NSF_ARG_RELATION|NSF_ARG_METHOD|NSF_ARG_SWITCH)) != 0) { return NsfPrintError(interp, - "multivalued not allowed for \"initcmd\", \"method\", \"relation\" or \"switch\"\n"); + "upper bound of multiplicity of '%c' not allowed for \"initcmd\", \"method\", \"relation\" or \"switch\"\n", *option); } paramPtr->flags |= NSF_ARG_MULTIVALUED; } else if (*option != '1') { @@ -16489,29 +16489,30 @@ NsfCallStackContent csc, *cscPtr = &csc; CallFrame frame2, *framePtr2 = &frame2; - /* The current callframe of configure uses an objframe, such - that setvar etc. are able to access variables like "a" as a - local variable. However, in the init block, we do not like - that behavior, since this should look like like a proc body. - So we push yet another callframe without providing the - varframe. + /* + * The current callframe of configure uses an objframe, such + * that setvar etc. are able to access variables like "a" as a + * local variable. However, in the init block, we do not like + * that behavior, since this should look like like a proc body. + * So we push yet another callframe without providing the + * varframe. + * + * The new frame will have the namespace of the caller to avoid + * the current objframe. Nsf_PushFrameCsc() will establish a + * CMETHOD frame. + */ - The new frame will have the namespace of the caller to avoid - the current objframe. Nsf_PushFrameCsc() will establish - a CMETHOD frame. - */ - Tcl_Interp_varFramePtr(interp) = varFramePtr->callerPtr; cscPtr->flags = 0; - CscInit(cscPtr, object, NULL /*cl*/, NULL/*cmd*/, NSF_CSC_TYPE_PLAIN, 0); + CscInit(cscPtr, object, NULL /*cl*/, NULL /*cmd*/, NSF_CSC_TYPE_PLAIN, 0); Nsf_PushFrameCsc(interp, cscPtr, framePtr2); if (paramPtr->flags & NSF_ARG_INITCMD) { /* cscPtr->cmdPtr = NSFindCommand(interp, "::eval"); */ result = Tcl_EvalObjEx(interp, newValue, TCL_EVAL_DIRECT); } else /* must be NSF_ARG_METHOD */ { - Tcl_Obj *ov[3]; + Tcl_Obj *ov[3], *methodObj; int oc = 0; /* @@ -16520,16 +16521,19 @@ * activelevel ignore it. */ cscPtr->frameType = NSF_CSC_TYPE_INACTIVE; - if (paramPtr->converterArg) { - /* if arg= was given, pass it as first argument */ - ov[0] = paramPtr->converterArg; - oc = 1; - } + + /* + * If arg= was given, use it as method name + */ + methodObj = paramPtr->converterArg ? paramPtr->converterArg : paramPtr->nameObj; + if (paramPtr->nrArgs == 1) { ov[oc] = newValue; oc ++; } - result = NsfCallMethodWithArgs((ClientData) object, interp, paramPtr->nameObj, + /*fprintf(stderr, "call **alias with methodObj %s.%s oc %d\n", + ObjectName(object), ObjStr(methodObj), oc);*/ + result = NsfCallMethodWithArgs((ClientData) object, interp, methodObj, ov[0], oc, &ov[1], NSF_CSC_IMMEDIATE); } /* Index: library/nx/nx.tcl =================================================================== diff -u -r99993215e25c11fa8c1467f4ee5cfd1dc71c250e -rd6a22408f08fb02ee6043b2243957922a75fbeef --- library/nx/nx.tcl (.../nx.tcl) (revision 99993215e25c11fa8c1467f4ee5cfd1dc71c250e) +++ library/nx/nx.tcl (.../nx.tcl) (revision d6a22408f08fb02ee6043b2243957922a75fbeef) @@ -40,7 +40,7 @@ set cmdName [namespace tail $cmd] if {$cmdName in [list "autoname" "cleanup" "exists" \ "filterguard" "instvar" "mixinguard" \ - "requirenamespace"]} continue + "noinit" "requirenamespace"]} continue ::nsf::alias Object $cmdName $cmd } @@ -65,7 +65,7 @@ # set a few aliases as protected # "__next", if defined, should be added as well - foreach cmd [list noinit residualargs uplevel upvar] { + foreach cmd [list residualargs uplevel upvar] { ::nsf::methodproperty Object $cmd call-protected 1 } @@ -938,7 +938,7 @@ lappend parameterdefinitions -attributes:method } lappend parameterdefinitions \ - -noinit:method,noarg \ + -noinit:method,arg=::nsf::methods::object::noinit,noarg \ -volatile:method,noarg \ {*}$lastparameter #puts stderr "*** parameter definition for [::nsf::self]: $parameterdefinitions" Index: tests/parameters.test =================================================================== diff -u -r99993215e25c11fa8c1467f4ee5cfd1dc71c250e -rd6a22408f08fb02ee6043b2243957922a75fbeef --- tests/parameters.test (.../parameters.test) (revision 99993215e25c11fa8c1467f4ee5cfd1dc71c250e) +++ tests/parameters.test (.../parameters.test) (revision d6a22408f08fb02ee6043b2243957922a75fbeef) @@ -249,13 +249,10 @@ C create c1 ? {C eval {:objectparameter}} \ - "-object-mixin:relation,slot=::nx::Class::slot::object-mixin -mixin:relation,arg=class-mixin,slot=::nx::Class::slot::mixin -superclass:relation,slot=::nx::Class::slot::superclass -object-filter:relation,slot=::nx::Class::slot::object-filter -filter:relation,arg=class-filter,slot=::nx::Class::slot::filter -attributes:method -noinit:method,noarg -volatile:method,noarg __initcmd:initcmd,optional" + "-object-mixin:relation,slot=::nx::Class::slot::object-mixin -mixin:relation,arg=class-mixin,slot=::nx::Class::slot::mixin -superclass:relation,slot=::nx::Class::slot::superclass -object-filter:relation,slot=::nx::Class::slot::object-filter -filter:relation,arg=class-filter,slot=::nx::Class::slot::filter -attributes:method -noinit:method,arg=::nsf::methods::object::noinit,noarg -volatile:method,noarg __initcmd:initcmd,optional" - - - ? {c1 eval {:objectparameter}} \ - "-a:slot=::C::slot::a -b:boolean,slot=::C::slot::b {-c:slot=::C::slot::c 1} -mixin:relation,arg=object-mixin,slot=::nx::Object::slot::mixin -filter:relation,arg=object-filter,slot=::nx::Object::slot::filter -noinit:method,noarg -volatile:method,noarg __initcmd:initcmd,optional" + "-a:slot=::C::slot::a -b:boolean,slot=::C::slot::b {-c:slot=::C::slot::c 1} -mixin:relation,arg=object-mixin,slot=::nx::Object::slot::mixin -filter:relation,arg=object-filter,slot=::nx::Object::slot::filter -noinit:method,arg=::nsf::methods::object::noinit,noarg -volatile:method,noarg __initcmd:initcmd,optional" } ####################################################### @@ -268,13 +265,13 @@ c1 class Object ? {c1 eval :objectparameter} \ - "-mixin:relation,arg=object-mixin,slot=::nx::Object::slot::mixin -filter:relation,arg=object-filter,slot=::nx::Object::slot::filter -noinit:method,noarg -volatile:method,noarg __initcmd:initcmd,optional" + "-mixin:relation,arg=object-mixin,slot=::nx::Object::slot::mixin -filter:relation,arg=object-filter,slot=::nx::Object::slot::filter -noinit:method,arg=::nsf::methods::object::noinit,noarg -volatile:method,noarg __initcmd:initcmd,optional" Class create D -superclass C -attributes {d:required} D create d1 -d 100 ? {d1 eval :objectparameter} \ - "-d:required,slot=::D::slot::d -a:slot=::C::slot::a -b:boolean,slot=::C::slot::b {-c:slot=::C::slot::c 1} -mixin:relation,arg=object-mixin,slot=::nx::Object::slot::mixin -filter:relation,arg=object-filter,slot=::nx::Object::slot::filter -noinit:method,noarg -volatile:method,noarg __initcmd:initcmd,optional" + "-d:required,slot=::D::slot::d -a:slot=::C::slot::a -b:boolean,slot=::C::slot::b {-c:slot=::C::slot::c 1} -mixin:relation,arg=object-mixin,slot=::nx::Object::slot::mixin -filter:relation,arg=object-filter,slot=::nx::Object::slot::filter -noinit:method,arg=::nsf::methods::object::noinit,noarg -volatile:method,noarg __initcmd:initcmd,optional" } ####################################################### @@ -290,27 +287,27 @@ Class create M2 -attributes {b2} D mixin M ? {d1 eval :objectparameter} \ - "-b:slot=::M::slot::b -m1:slot=::M::slot::m1 -m2:slot=::M::slot::m2 -d:required,slot=::D::slot::d -a:slot=::C::slot::a {-c:slot=::C::slot::c 1} -mixin:relation,arg=object-mixin,slot=::nx::Object::slot::mixin -filter:relation,arg=object-filter,slot=::nx::Object::slot::filter -noinit:method,noarg -volatile:method,noarg __initcmd:initcmd,optional" \ + "-b:slot=::M::slot::b -m1:slot=::M::slot::m1 -m2:slot=::M::slot::m2 -d:required,slot=::D::slot::d -a:slot=::C::slot::a {-c:slot=::C::slot::c 1} -mixin:relation,arg=object-mixin,slot=::nx::Object::slot::mixin -filter:relation,arg=object-filter,slot=::nx::Object::slot::filter -noinit:method,arg=::nsf::methods::object::noinit,noarg -volatile:method,noarg __initcmd:initcmd,optional" \ "mixin added" M mixin M2 ? {d1 eval :objectparameter} \ - "-b2:slot=::M2::slot::b2 -b:slot=::M::slot::b -m1:slot=::M::slot::m1 -m2:slot=::M::slot::m2 -d:required,slot=::D::slot::d -a:slot=::C::slot::a {-c:slot=::C::slot::c 1} -mixin:relation,arg=object-mixin,slot=::nx::Object::slot::mixin -filter:relation,arg=object-filter,slot=::nx::Object::slot::filter -noinit:method,noarg -volatile:method,noarg __initcmd:initcmd,optional" \ + "-b2:slot=::M2::slot::b2 -b:slot=::M::slot::b -m1:slot=::M::slot::m1 -m2:slot=::M::slot::m2 -d:required,slot=::D::slot::d -a:slot=::C::slot::a {-c:slot=::C::slot::c 1} -mixin:relation,arg=object-mixin,slot=::nx::Object::slot::mixin -filter:relation,arg=object-filter,slot=::nx::Object::slot::filter -noinit:method,arg=::nsf::methods::object::noinit,noarg -volatile:method,noarg __initcmd:initcmd,optional" \ "transitive mixin added" D mixin "" #we should have again the old interface ? {d1 eval :objectparameter} \ - "-d:required,slot=::D::slot::d -a:slot=::C::slot::a -b:boolean,slot=::C::slot::b {-c:slot=::C::slot::c 1} -mixin:relation,arg=object-mixin,slot=::nx::Object::slot::mixin -filter:relation,arg=object-filter,slot=::nx::Object::slot::filter -noinit:method,noarg -volatile:method,noarg __initcmd:initcmd,optional" + "-d:required,slot=::D::slot::d -a:slot=::C::slot::a -b:boolean,slot=::C::slot::b {-c:slot=::C::slot::c 1} -mixin:relation,arg=object-mixin,slot=::nx::Object::slot::mixin -filter:relation,arg=object-filter,slot=::nx::Object::slot::filter -noinit:method,arg=::nsf::methods::object::noinit,noarg -volatile:method,noarg __initcmd:initcmd,optional" C mixin M ? {d1 eval :objectparameter} \ - "-b2:slot=::M2::slot::b2 -b:slot=::M::slot::b -m1:slot=::M::slot::m1 -m2:slot=::M::slot::m2 -d:required,slot=::D::slot::d -a:slot=::C::slot::a {-c:slot=::C::slot::c 1} -mixin:relation,arg=object-mixin,slot=::nx::Object::slot::mixin -filter:relation,arg=object-filter,slot=::nx::Object::slot::filter -noinit:method,noarg -volatile:method,noarg __initcmd:initcmd,optional" \ + "-b2:slot=::M2::slot::b2 -b:slot=::M::slot::b -m1:slot=::M::slot::m1 -m2:slot=::M::slot::m2 -d:required,slot=::D::slot::d -a:slot=::C::slot::a {-c:slot=::C::slot::c 1} -mixin:relation,arg=object-mixin,slot=::nx::Object::slot::mixin -filter:relation,arg=object-filter,slot=::nx::Object::slot::filter -noinit:method,arg=::nsf::methods::object::noinit,noarg -volatile:method,noarg __initcmd:initcmd,optional" \ "mixin added" C mixin "" #we should have again the old interface ? {d1 eval :objectparameter} \ - "-d:required,slot=::D::slot::d -a:slot=::C::slot::a -b:boolean,slot=::C::slot::b {-c:slot=::C::slot::c 1} -mixin:relation,arg=object-mixin,slot=::nx::Object::slot::mixin -filter:relation,arg=object-filter,slot=::nx::Object::slot::filter -noinit:method,noarg -volatile:method,noarg __initcmd:initcmd,optional" + "-d:required,slot=::D::slot::d -a:slot=::C::slot::a -b:boolean,slot=::C::slot::b {-c:slot=::C::slot::c 1} -mixin:relation,arg=object-mixin,slot=::nx::Object::slot::mixin -filter:relation,arg=object-filter,slot=::nx::Object::slot::filter -noinit:method,arg=::nsf::methods::object::noinit,noarg -volatile:method,noarg __initcmd:initcmd,optional" } #######################################################