Index: TODO =================================================================== diff -u -rcd7387dce218900697565aeabc0e58afb0294a6a -rc790d82b4b9e44e1d8e2a303e1d4931a91f049d8 --- TODO (.../TODO) (revision cd7387dce218900697565aeabc0e58afb0294a6a) +++ TODO (.../TODO) (revision c790d82b4b9e44e1d8e2a303e1d4931a91f049d8) @@ -5434,10 +5434,20 @@ -class.dealloc {__dealloc ::nsf::methods::class::dealloc 1} - extend regression test + +nsf.c: +- allow abbreaviated nonpos args +- change name of relationslot "superclass" to "superclasses". + (part of a planned change to use plural for setvalued parameters, + "info superclasses" and similar changes for mixins/filters will + probably follow) + ======================================================================== TODO: - +- finish pluaral reform +- maybe introdouce "allowabbrev" flag +- set nodashalnum for int types - shouldn't "info subclass" be named "info subclasses"? >>> Same for "info superclass". If the introspection interface uses Index: generic/nsf.c =================================================================== diff -u -rcd7387dce218900697565aeabc0e58afb0294a6a -rc790d82b4b9e44e1d8e2a303e1d4931a91f049d8 --- generic/nsf.c (.../nsf.c) (revision cd7387dce218900697565aeabc0e58afb0294a6a) +++ generic/nsf.c (.../nsf.c) (revision c790d82b4b9e44e1d8e2a303e1d4931a91f049d8) @@ -11076,6 +11076,67 @@ return paramList; } +/*---------------------------------------------------------------------- + * NsfParamDefsNonposLookup -- + * + * Process a list of ParamDefs look for a nonpos args. If there is no exact + * match, look for an abbreviated match having at least + * NSF_ABBREV_MIN_CHARS leading chars which are identical. + * + * Results: + * Parameter definition or NULL + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ +static Nsf_Param CONST *NsfParamDefsNonposLookup(CONST char *nameString, Nsf_Param CONST *paramsPtr) + nonnull(1) nonnull(2); + +static Nsf_Param CONST * +NsfParamDefsNonposLookup(CONST char *nameString, Nsf_Param CONST *paramsPtr) { + Nsf_Param CONST *paramPtr; + char ch1 = nameString[2]; + int length; + + assert(nameString); + assert(paramsPtr); + /* + * The provided paramsPtr must point to a block starting with a nonpos arg. + */ + assert(paramsPtr->name); + assert(*paramsPtr->name == '-'); + /* + * The provided nameString starts as well with a leading dash. + */ + assert(*nameString == '-'); + + for (paramPtr = paramsPtr; likely(paramPtr->name != NULL) && *paramPtr->name == '-'; paramPtr++) { + if (unlikely(paramPtr->flags & NSF_ARG_NOCONFIG)) continue; + if (ch1 == paramPtr->name[2] + && strcmp(nameString, paramPtr->name) == 0) { + return paramPtr; + } + } + + length = strlen(nameString); + + if (length >= NSF_ABBREV_MIN_CHARS) { + + for (paramPtr = paramsPtr; likely(paramPtr->name != NULL) && *paramPtr->name == '-'; paramPtr++) { + if (unlikely(paramPtr->flags & NSF_ARG_NOCONFIG)) continue; + + if (ch1 == paramPtr->name[2] + && strncmp(nameString, paramPtr->name, length) == 0) { + /* fprintf(stderr, "... <%s> is an abbrev of <%s>\n", nameString, paramPtr->name); */ + return paramPtr; + } + } + } + return NULL; +} + /* *---------------------------------------------------------------------- * NsfProcDeleteProc -- @@ -15399,13 +15460,13 @@ *---------------------------------------------------------------------- */ static int ParameterMethodForwardDispatch(Tcl_Interp *interp, NsfObject *object, - Nsf_Param *paramPtr, Tcl_Obj *newValue, + Nsf_Param CONST *paramPtr, Tcl_Obj *newValue, NsfCallStackContent *cscPtr) nonnull(1) nonnull(2) nonnull(3); static int ParameterMethodForwardDispatch(Tcl_Interp *interp, NsfObject *object, - Nsf_Param *paramPtr, Tcl_Obj *newValue, + Nsf_Param CONST *paramPtr, Tcl_Obj *newValue, NsfCallStackContent *cscPtr) { Tcl_Obj **nobjv, *ov[3], *methodObj, *forwardSpec; ForwardCmdClientData *tcd = NULL; @@ -21200,18 +21261,15 @@ * definition. */ int found = 0; + assert(pPtr == currentParamPtr); - for (; pPtr <= lastParamPtr && *pPtr->name == '-'; pPtr ++) { - /*fprintf(stderr, "comparing '%s' with '%s'\n", argumentString, pPtr->name);*/ - if ((pPtr->flags & NSF_ARG_NOCONFIG) == 0 - && ch1 == pPtr->name[1] - && strcmp(argumentString, pPtr->name) == 0) { - found = 1; - NsfFlagObjSet(interp, argumentObj, paramPtr, serial, - pPtr, NULL, 0); - break; - } - } + if (ch1 != '\0') { + pPtr = NsfParamDefsNonposLookup(argumentString, currentParamPtr); + if (pPtr != NULL) { + found = 1; + NsfFlagObjSet(interp, argumentObj, paramPtr, serial, pPtr, NULL, 0); + } + } /* * We might have found the argument starting with the dash in the @@ -21244,7 +21302,6 @@ strtod(&argumentString[1], &p); if (*p == '\0') { /* argument is numeric */ - //fprintf(stderr,"===== FOUND negative NUMERIC argument <%s>\n", argumentString); nonposArgError = 0; } } @@ -21267,6 +21324,7 @@ } } + //posarg: assert(pPtr); /* * pPtr points to the actual parameter (part of the currentParamPtr block) @@ -27372,9 +27430,9 @@ */ static int NsfOCgetMethod(Tcl_Interp *interp, NsfObject *object, Tcl_Obj *nameObj) { - int result, i, found = 0; + int result, found = 0; NsfParsedParam parsedParam; - Nsf_Param *paramPtr; + Nsf_Param CONST *paramPtr; NsfParamDefs *paramDefs; CallFrame frame, *framePtr = &frame, *uplevelVarFramePtr; char *nameString = ObjStr(nameObj); @@ -27424,17 +27482,22 @@ ParamDefsRefCountIncr(paramDefs); /* - * Iterate over the parameter definitions to lookup the desired - * parameter. Skip positional parameters and those with NOCONFIG settings. + * Does provided value start with a dash? */ - for (i = 1, paramPtr = paramDefs->paramsPtr; paramPtr->name; paramPtr++, i++) { - if (*paramPtr->name != '-' || (paramPtr->flags & NSF_ARG_NOCONFIG)) { - continue; - } - if (strcmp(nameString, paramPtr->name) == 0) { - found = 1; - break; - } + if (*nameString == '-') { + /* + * Skip leading parameters from the definition, which are no nonpos args + * (very unlikely). + */ + for (paramPtr = paramDefs->paramsPtr; + paramPtr->name && *paramPtr->name != '-'; + paramPtr++); + + /* + * Perform the lookup from the next group. + */ + paramPtr = NsfParamDefsNonposLookup(nameString, paramPtr); + found = (paramPtr != NULL); } if (!found) { Index: generic/nsfInt.h =================================================================== diff -u -rcd7387dce218900697565aeabc0e58afb0294a6a -rc790d82b4b9e44e1d8e2a303e1d4931a91f049d8 --- generic/nsfInt.h (.../nsfInt.h) (revision cd7387dce218900697565aeabc0e58afb0294a6a) +++ generic/nsfInt.h (.../nsfInt.h) (revision c790d82b4b9e44e1d8e2a303e1d4931a91f049d8) @@ -264,6 +264,7 @@ # define ISOBJ(o) (o != NULL) #endif +#define NSF_ABBREV_MIN_CHARS 4 /* * This was defined to be inline for anything !sun or __IBMC__ >= 0x0306, * but __hpux should also be checked - switched to only allow in gcc - JH Index: library/nx/nx.tcl =================================================================== diff -u -rcd7387dce218900697565aeabc0e58afb0294a6a -rc790d82b4b9e44e1d8e2a303e1d4931a91f049d8 --- library/nx/nx.tcl (.../nx.tcl) (revision cd7387dce218900697565aeabc0e58afb0294a6a) +++ library/nx/nx.tcl (.../nx.tcl) (revision c790d82b4b9e44e1d8e2a303e1d4931a91f049d8) @@ -1641,7 +1641,7 @@ # # Define "superclass" as a ObjectParameterSlot defined as alias # - ::nx::ObjectParameterSlot create ::nx::Class::slot::superclass \ + ::nx::ObjectParameterSlot create ::nx::Class::slot::superclasses \ -methodname "::nsf::methods::class::superclass" \ -elementtype class \ -multiplicity 1..n \ Index: tests/cget.test =================================================================== diff -u -ra093703e9836fc152fcbbce96d4f880ace6a6170 -rc790d82b4b9e44e1d8e2a303e1d4931a91f049d8 --- tests/cget.test (.../cget.test) (revision a093703e9836fc152fcbbce96d4f880ace6a6170) +++ tests/cget.test (.../cget.test) (revision c790d82b4b9e44e1d8e2a303e1d4931a91f049d8) @@ -142,7 +142,8 @@ # class-level lookup # ? {C info lookup syntax configure} \ - "?-superclass /class .../? ?-mixin /mixinreg .../? ?-filter /filterreg .../? ?-volatile? ?-object-mixin /mixinreg .../? ?-class /class/? ?-object-filter /filterreg .../? ?/__initblock/?" + "?-superclasses /class .../? ?-mixin /mixinreg .../? ?-filter /filterreg .../? ?-volatile? ?-object-mixin /mixinreg .../? ?-class /class/? ?-object-filter /filterreg .../? ?/__initblock/?" + ? {C cget -superclasses} "::nx::Object" ? {C cget -superclass} "::nx::Object" ? {C cget -object-mixin} "" ? {C cget -mixin} "" Index: tests/info-method.test =================================================================== diff -u -r896f9013e125e965474ea7fdbda099ca22b152c2 -rc790d82b4b9e44e1d8e2a303e1d4931a91f049d8 --- tests/info-method.test (.../info-method.test) (revision 896f9013e125e965474ea7fdbda099ca22b152c2) +++ tests/info-method.test (.../info-method.test) (revision c790d82b4b9e44e1d8e2a303e1d4931a91f049d8) @@ -505,10 +505,10 @@ :create d1 } - ? {lsort [D info lookup slots]} "::D::per-object-slot::a2 ::nx::Class::slot::filter ::nx::Class::slot::mixin ::nx::Class::slot::superclass ::nx::Object::slot::__initblock ::nx::Object::slot::class ::nx::Object::slot::object-filter ::nx::Object::slot::object-mixin" + ? {lsort [D info lookup slots]} "::D::per-object-slot::a2 ::nx::Class::slot::filter ::nx::Class::slot::mixin ::nx::Class::slot::superclasses ::nx::Object::slot::__initblock ::nx::Object::slot::class ::nx::Object::slot::object-filter ::nx::Object::slot::object-mixin" - ? {D info lookup slots superclass} "::nx::Class::slot::superclass" - ? {D info lookup slots ::nx::Class::slot::superclass} "::nx::Class::slot::superclass" + ? {D info lookup slots superclasses} "::nx::Class::slot::superclasses" + ? {D info lookup slots ::nx::Class::slot::superclasses} "::nx::Class::slot::superclasses" ? {D info lookup slots a2} "::D::per-object-slot::a2" ? {D info lookup slots ::D::per-object-slot::a2} "::D::per-object-slot::a2" Index: tests/parameters.test =================================================================== diff -u -rcd7387dce218900697565aeabc0e58afb0294a6a -rc790d82b4b9e44e1d8e2a303e1d4931a91f049d8 --- tests/parameters.test (.../parameters.test) (revision cd7387dce218900697565aeabc0e58afb0294a6a) +++ tests/parameters.test (.../parameters.test) (revision c790d82b4b9e44e1d8e2a303e1d4931a91f049d8) @@ -283,7 +283,7 @@ C create c1 ? {C eval :__object_configureparameter} \ - "{-superclass:class,alias,method=::nsf::methods::class::superclass,1..n ::nx::Object} -mixin:mixinreg,slot=::nx::Class::slot::mixin,slotset,method=class-mixin,0..n $::filter $::objectMixin -class:class,alias,method=::nsf::methods::object::class $::objectFilter $::initBlock" + "{-superclasses:class,alias,method=::nsf::methods::class::superclass,1..n ::nx::Object} -mixin:mixinreg,slot=::nx::Class::slot::mixin,slotset,method=class-mixin,0..n $::filter $::objectMixin -class:class,alias,method=::nsf::methods::object::class $::objectFilter $::initBlock" #### TOOD: remove or add #? {c1 eval :__object_configureparameter} \ Index: tests/properties.test =================================================================== diff -u -r15a93252f0d9d8961ded6fd8f9b610a535ddbdb5 -rc790d82b4b9e44e1d8e2a303e1d4931a91f049d8 --- tests/properties.test (.../properties.test) (revision 15a93252f0d9d8961ded6fd8f9b610a535ddbdb5) +++ tests/properties.test (.../properties.test) (revision c790d82b4b9e44e1d8e2a303e1d4931a91f049d8) @@ -764,7 +764,7 @@ ? {c1 cget -a} a1 ? {c1 configure -a a2} "" - ? {C info lookup syntax configure} {?-b /value/? ?-superclass /class .../? ?-mixin /mixinreg .../? ?-filter /filterreg .../? ?-object-mixin /mixinreg .../? ?-class /class/? ?-object-filter /filterreg .../? ?/__initblock/?} + ? {C info lookup syntax configure} {?-b /value/? ?-superclasses /class .../? ?-mixin /mixinreg .../? ?-filter /filterreg .../? ?-object-mixin /mixinreg .../? ?-class /class/? ?-object-filter /filterreg .../? ?/__initblock/?} ? {C cget -b} b1 ? {C configure -b b2} ""