Index: generic/gentclAPI.decls =================================================================== diff -u -r9b7f41ce40b2a9d629810bd677681ffa50f5e11c -r6b3921be54ad92034e563a09300ab2e4f49645aa --- generic/gentclAPI.decls (.../gentclAPI.decls) (revision 9b7f41ce40b2a9d629810bd677681ffa50f5e11c) +++ generic/gentclAPI.decls (.../gentclAPI.decls) (revision 6b3921be54ad92034e563a09300ab2e4f49645aa) @@ -119,7 +119,7 @@ } xotclCmd relation XOTclRelationCmd { {-argName "object" -type object} - {-argName "relationtype" -required 1 -type "mixin|instmixin|object-mixin|class-mixin|filter|instfilter|object-filter|class-filter|class|superclass|rootclass"} + {-argName "relationtype" -required 1 -type "object-mixin|class-mixin|object-filter|class-filter|class|superclass|rootclass"} {-argName "value" -required 0 -type tclobj} } xotclCmd self XOTclGetSelfObjCmd { Index: generic/predefined.h =================================================================== diff -u -rbe717fe9ef13e09dcfabf496ca61d75e4c042422 -r6b3921be54ad92034e563a09300ab2e4f49645aa --- generic/predefined.h (.../predefined.h) (revision be717fe9ef13e09dcfabf496ca61d75e4c042422) +++ generic/predefined.h (.../predefined.h) (revision 6b3921be54ad92034e563a09300ab2e4f49645aa) @@ -146,7 +146,8 @@ "foreach slot $slots {\n" "if {[::xotcl::is $obj type ::xotcl::Object] &&\n" "([$slot name] eq \"mixin\" || [$slot name] eq \"filter\")} continue\n" -"set parameterdefinition \"-[namespace tail $slot]\"\n" +"set name [namespace tail $slot]\n" +"set parameterdefinition \"-$name\"\n" "set opts [list]\n" "if {[$slot exists required] && [$slot required]} {\n" "lappend opts required}\n" @@ -158,6 +159,10 @@ "lappend opts substdefault}} elseif {[$slot exists initcmd]} {\n" "set arg [::xotcl::setinstvar $slot initcmd]\n" "lappend opts initcmd}\n" +"if {[$slot exists methodname]} {\n" +"set methodname [::xotcl::setinstvar $slot methodname]\n" +"if {$methodname ne $name} {\n" +"lappend opts arg=$methodname}}\n" "if {[llength $opts] > 0} {\n" "append parameterdefinition :[join $opts ,]}\n" "if {[info exists arg]} {\n" @@ -200,7 +205,7 @@ "$class __invalidateobjectparameter}\n" "createBootstrapAttributeSlots ::xotcl::Slot {\n" "{name \"[namespace tail [::xotcl::self]]\"}\n" -"{methodname \"[namespace tail [::xotcl::self]]\"}\n" +"{methodname}\n" "{domain \"[lindex [regexp -inline {^(.*)::slot::[^:]+$} [::xotcl::self]] 1]\"}\n" "{defaultmethods {get assign}}\n" "{manager \"[::xotcl::self]\"}\n" @@ -238,6 +243,8 @@ "if {${.domain} eq \"\"} {\n" "set .domain [::xotcl::self callingobject]}\n" "if {${.domain} ne \"\"} {\n" +"if {![info exists .methodname]} {\n" +"set .methodname ${.name}}\n" "${.domain} __invalidateobjectparameter\n" "set cl [expr {${.per-object} ? \"Object\" : \"Class\"}]\n" "::xotcl::dispatch ${.domain} ::xotcl::classes::xotcl2::${cl}::forward \\\n" Index: generic/predefined.xotcl =================================================================== diff -u -re61fc14f5c25172a1d1f93bea03be54a772fb4b5 -r6b3921be54ad92034e563a09300ab2e4f49645aa --- generic/predefined.xotcl (.../predefined.xotcl) (revision e61fc14f5c25172a1d1f93bea03be54a772fb4b5) +++ generic/predefined.xotcl (.../predefined.xotcl) (revision 6b3921be54ad92034e563a09300ab2e4f49645aa) @@ -308,9 +308,9 @@ if {[::xotcl::is $obj type ::xotcl::Object] && ([$slot name] eq "mixin" || [$slot name] eq "filter") } continue - set parameterdefinition "-[namespace tail $slot]" + set name [namespace tail $slot] + set parameterdefinition "-$name" set opts [list] - if {[$slot exists required] && [$slot required]} { lappend opts required } @@ -326,6 +326,12 @@ } elseif {[$slot exists initcmd]} { set arg [::xotcl::setinstvar $slot initcmd] lappend opts initcmd + } + if {[$slot exists methodname]} { + set methodname [::xotcl::setinstvar $slot methodname] + if {$methodname ne $name} { + lappend opts arg=$methodname + } } if {[llength $opts] > 0} { append parameterdefinition :[join $opts ,] @@ -411,7 +417,7 @@ ############################################ createBootstrapAttributeSlots ::xotcl::Slot { {name "[namespace tail [::xotcl::self]]"} - {methodname "[namespace tail [::xotcl::self]]"} + {methodname} {domain "[lindex [regexp -inline {^(.*)::slot::[^:]+$} [::xotcl::self]] 1]"} {defaultmethods {get assign}} {manager "[::xotcl::self]"} @@ -470,6 +476,9 @@ set .domain [::xotcl::self callingobject] } if {${.domain} ne ""} { + if {![info exists .methodname]} { + set .methodname ${.name} + } ${.domain} __invalidateobjectparameter set cl [expr {${.per-object} ? "Object" : "Class"}] # since the domain object might be xotcl1 or xotcl2, use dispatch Index: generic/tclAPI.h =================================================================== diff -u -re61fc14f5c25172a1d1f93bea03be54a772fb4b5 -r6b3921be54ad92034e563a09300ab2e4f49645aa --- generic/tclAPI.h (.../tclAPI.h) (revision e61fc14f5c25172a1d1f93bea03be54a772fb4b5) +++ generic/tclAPI.h (.../tclAPI.h) (revision 6b3921be54ad92034e563a09300ab2e4f49645aa) @@ -73,12 +73,12 @@ static int convertToRelationtype(Tcl_Interp *interp, Tcl_Obj *objPtr, XOTclParam CONST *pPtr, ClientData *clientData) { int index, result; - static CONST char *opts[] = {"mixin", "instmixin", "object-mixin", "class-mixin", "filter", "instfilter", "object-filter", "class-filter", "class", "superclass", "rootclass", NULL}; + static CONST char *opts[] = {"object-mixin", "class-mixin", "object-filter", "class-filter", "class", "superclass", "rootclass", NULL}; result = Tcl_GetIndexFromObj(interp, objPtr, opts, "relationtype", 0, &index); *clientData = (ClientData) INT2PTR(index + 1); return result; } -enum RelationtypeIdx {RelationtypeNULL, RelationtypeMixinIdx, RelationtypeInstmixinIdx, RelationtypeObject_mixinIdx, RelationtypeClass_mixinIdx, RelationtypeFilterIdx, RelationtypeInstfilterIdx, RelationtypeObject_filterIdx, RelationtypeClass_filterIdx, RelationtypeClassIdx, RelationtypeSuperclassIdx, RelationtypeRootclassIdx}; +enum RelationtypeIdx {RelationtypeNULL, RelationtypeObject_mixinIdx, RelationtypeClass_mixinIdx, RelationtypeObject_filterIdx, RelationtypeClass_filterIdx, RelationtypeClassIdx, RelationtypeSuperclassIdx, RelationtypeRootclassIdx}; typedef struct { Index: generic/xotcl.c =================================================================== diff -u -r28acb2d7bddbbf6c82e6c516d7706f9429e05e6b -r6b3921be54ad92034e563a09300ab2e4f49645aa --- generic/xotcl.c (.../xotcl.c) (revision 28acb2d7bddbbf6c82e6c516d7706f9429e05e6b) +++ generic/xotcl.c (.../xotcl.c) (revision 6b3921be54ad92034e563a09300ab2e4f49645aa) @@ -5204,6 +5204,7 @@ if (paramPtr->nameObj) {DECR_REF_COUNT(paramPtr->nameObj);} if (paramPtr->defaultValue) {DECR_REF_COUNT(paramPtr->defaultValue);} if (paramPtr->arg) {DECR_REF_COUNT(paramPtr->arg);} + if (paramPtr->converterArg) {DECR_REF_COUNT(paramPtr->converterArg);} } FREE(XOTclParam*, paramsPtr); } @@ -6233,6 +6234,8 @@ } else if (strncmp(option, "noarg", length) == 0) { paramPtr->flags |= XOTCL_ARG_NOARG; paramPtr->nrArgs = 0; + } else if (length >= 5 && strncmp(option, "arg=", 4) == 0) { + paramPtr->converterArg = Tcl_NewStringObj(option+4, length-4); } else if (strncmp(option, "switch", length) == 0) { paramPtr->nrArgs = 0; paramPtr->converter = convertToSwitch; @@ -11455,7 +11458,7 @@ /* xotclCmd relation XOTclRelationCmd { {-argName "object" -type object} - {-argName "relationtype" -required 1 -type "mixin|instmixin|object-mixin|class-mixin|filter|instfilter|object-filter|class-filter|class|superclass|rootclass"} + {-argName "relationtype" -required 1 -type "object-mixin|class-mixin|object-filter|class-filter|class|superclass|rootclass"} {-argName "value" -required 0 -type tclobj} } */ @@ -11473,30 +11476,15 @@ /* set withPer_object according to object- or class- */ switch (relationtype) { - case RelationtypeMixinIdx: - if (XOTclObjectIsClass(object)) { - relationtype = RelationtypeClass_mixinIdx; - } - break; - case RelationtypeFilterIdx: - if (XOTclObjectIsClass(object)) { - relationtype = RelationtypeClass_filterIdx; - } - break; - } - - switch (relationtype) { - case RelationtypeObject_mixinIdx: - case RelationtypeMixinIdx: case RelationtypeObject_filterIdx: - case RelationtypeFilterIdx: + case RelationtypeObject_mixinIdx: if (value == NULL) { objopt = object->opt; switch (relationtype) { case RelationtypeObject_mixinIdx: - case RelationtypeMixinIdx: return objopt ? MixinInfo(interp, objopt->mixins, NULL, 1, NULL) : TCL_OK; + return objopt ? MixinInfo(interp, objopt->mixins, NULL, 1, NULL) : TCL_OK; case RelationtypeObject_filterIdx: - case RelationtypeFilterIdx: return objopt ? FilterInfo(interp, objopt->filters, NULL, 1, 0) : TCL_OK; + return objopt ? FilterInfo(interp, objopt->filters, NULL, 1, 0) : TCL_OK; } } if (Tcl_ListObjGetElements(interp, value, &oc, &ov) != TCL_OK) @@ -11505,9 +11493,7 @@ break; case RelationtypeClass_mixinIdx: - case RelationtypeInstmixinIdx: case RelationtypeClass_filterIdx: - case RelationtypeInstfilterIdx: if (XOTclObjectIsClass(object)) { cl = (XOTclClass *)object; } else { @@ -11517,10 +11503,9 @@ if (value == NULL) { clopt = cl->opt; switch (relationtype) { - case RelationtypeClass_mixinIdx: - case RelationtypeInstmixinIdx: return clopt ? MixinInfo(interp, clopt->instmixins, NULL, 1, NULL) : TCL_OK; + case RelationtypeClass_mixinIdx: return clopt ? MixinInfo(interp, clopt->instmixins, NULL, 1, NULL) : TCL_OK; case RelationtypeClass_filterIdx: - case RelationtypeInstfilterIdx: return objopt ? FilterInfo(interp, clopt->instfilters, NULL, 1, 0) : TCL_OK; + return objopt ? FilterInfo(interp, clopt->instfilters, NULL, 1, 0) : TCL_OK; } } @@ -11578,7 +11563,6 @@ switch (relationtype) { case RelationtypeObject_mixinIdx: - case RelationtypeMixinIdx: { XOTclCmdList *newMixinCmdList = NULL; @@ -11638,7 +11622,6 @@ } case RelationtypeObject_filterIdx: - case RelationtypeFilterIdx: if (objopt->filters) CmdListRemoveList(&objopt->filters, GuardDel); @@ -11651,7 +11634,6 @@ break; case RelationtypeClass_mixinIdx: - case RelationtypeInstmixinIdx: { XOTclCmdList *newMixinCmdList = NULL; @@ -11692,7 +11674,6 @@ } case RelationtypeClass_filterIdx: - case RelationtypeInstfilterIdx: if (clopt->instfilters) CmdListRemoveList(&clopt->instfilters, GuardDel); @@ -12046,7 +12027,8 @@ /* special setter due to relation handling */ if (paramPtr->converter == convertToRelation) { int relIdx; - result = convertToRelationtype(interp, paramPtr->nameObj, paramPtr, (ClientData)&relIdx); + Tcl_Obj *relationObj = paramPtr->converterArg ? paramPtr->converterArg : paramPtr->nameObj; + result = convertToRelationtype(interp, relationObj, paramPtr, (ClientData)&relIdx); if (result == TCL_OK) { result = XOTclRelationCmd(interp, obj, relIdx, newValue); } Index: generic/xotclInt.h =================================================================== diff -u -r28acb2d7bddbbf6c82e6c516d7706f9429e05e6b -r6b3921be54ad92034e563a09300ab2e4f49645aa --- generic/xotclInt.h (.../xotclInt.h) (revision 28acb2d7bddbbf6c82e6c516d7706f9429e05e6b) +++ generic/xotclInt.h (.../xotclInt.h) (revision 6b3921be54ad92034e563a09300ab2e4f49645aa) @@ -462,6 +462,7 @@ int flags; int nrArgs; XOTclTypeConverter *converter; + Tcl_Obj *converterArg; Tcl_Obj *defaultValue; char *type; Tcl_Obj *nameObj; Index: tests/interceptor-slot.xotcl =================================================================== diff -u -rd70c849219212800fa401c2227796b9a63eadcaf -r6b3921be54ad92034e563a09300ab2e4f49645aa --- tests/interceptor-slot.xotcl (.../interceptor-slot.xotcl) (revision d70c849219212800fa401c2227796b9a63eadcaf) +++ tests/interceptor-slot.xotcl (.../interceptor-slot.xotcl) (revision 6b3921be54ad92034e563a09300ab2e4f49645aa) @@ -36,9 +36,9 @@ # per-object mixins ? {c1 info precedence} "::C ::xotcl2::Object" c1 mixin add M -? {::xotcl::relation c1 mixin} ::M +? {::xotcl::relation c1 object-mixin} ::M ? {catch {c1 mixin UNKNOWN}} 1 -? {::xotcl::relation c1 mixin} "::M" +? {::xotcl::relation c1 object-mixin} "::M" # add again the same mixin c1 mixin add M @@ -52,16 +52,6 @@ # # adding, removing per-object mixins for classes through relation -# "mixin" and "-per-object" (deprecated) -# -# ::xotcl::relation C -per-object mixin M -# ? {C info precedence} "::M ::xotcl2::Class ::xotcl2::Object" -# ? {C object info mixin} "::M" -# ::xotcl::relation C -per-object mixin "" -# ? {C info precedence} "::xotcl2::Class ::xotcl2::Object" - -# -# adding, removing per-object mixins for classes through relation # "object-mixin" # ::xotcl::relation C object-mixin M