Index: TODO =================================================================== diff -u -r75bdefce85cff349831dbca1900153fca956574c -rf1cd1537386ab1fdfabccaadae215990e376ae9d --- TODO (.../TODO) (revision 75bdefce85cff349831dbca1900153fca956574c) +++ TODO (.../TODO) (revision f1cd1537386ab1fdfabccaadae215990e376ae9d) @@ -1214,6 +1214,11 @@ - adoped emulation layer in xotcl2 accordingly - added two tests for "info has mixin" in regression test +- removed "objectproperty .... type" +- renamed isSubType() to IsSubType() +- adoped emulation layer in xotcl2 accordingly +- added two tests for "info has type" in regression test + TODO: - rename ObjectInfo2 & ClassInfo2 - check "my" vs. "nsf::dispatch" in xotcl2.tcl Index: generic/gentclAPI.decls =================================================================== diff -u -r75bdefce85cff349831dbca1900153fca956574c -rf1cd1537386ab1fdfabccaadae215990e376ae9d --- generic/gentclAPI.decls (.../gentclAPI.decls) (revision 75bdefce85cff349831dbca1900153fca956574c) +++ generic/gentclAPI.decls (.../gentclAPI.decls) (revision f1cd1537386ab1fdfabccaadae215990e376ae9d) @@ -127,8 +127,7 @@ } xotclCmd objectproperty XOTclObjectpropertyCmd { {-argName "object" -required 1 -type tclobj} - {-argName "objectkind" -type "type|object|class|baseclass|metaclass"} - {-argName "value" -required 0 -type tclobj} + {-argName "objectkind" -type "object|class|baseclass|metaclass"} } xotclCmd parametercheck XOTclParametercheckCmd { {-argName "-nocomplain"} Index: generic/tclAPI.h =================================================================== diff -u -r75bdefce85cff349831dbca1900153fca956574c -rf1cd1537386ab1fdfabccaadae215990e376ae9d --- generic/tclAPI.h (.../tclAPI.h) (revision 75bdefce85cff349831dbca1900153fca956574c) +++ generic/tclAPI.h (.../tclAPI.h) (revision f1cd1537386ab1fdfabccaadae215990e376ae9d) @@ -101,13 +101,13 @@ static int convertToObjectkind(Tcl_Interp *interp, Tcl_Obj *objPtr, XOTclParam CONST *pPtr, ClientData *clientData, Tcl_Obj **outObjPtr) { int index, result; - static CONST char *opts[] = {"type", "object", "class", "baseclass", "metaclass", NULL}; + static CONST char *opts[] = {"object", "class", "baseclass", "metaclass", NULL}; result = Tcl_GetIndexFromObj(interp, objPtr, opts, "objectkind", 0, &index); *clientData = (ClientData) INT2PTR(index + 1); *outObjPtr = objPtr; return result; } -enum ObjectkindIdx {ObjectkindNULL, ObjectkindTypeIdx, ObjectkindObjectIdx, ObjectkindClassIdx, ObjectkindBaseclassIdx, ObjectkindMetaclassIdx}; +enum ObjectkindIdx {ObjectkindNULL, ObjectkindObjectIdx, ObjectkindClassIdx, ObjectkindBaseclassIdx, ObjectkindMetaclassIdx}; static int convertToRelationtype(Tcl_Interp *interp, Tcl_Obj *objPtr, XOTclParam CONST *pPtr, ClientData *clientData, Tcl_Obj **outObjPtr) { @@ -298,7 +298,7 @@ static int XOTclMyCmd(Tcl_Interp *interp, int withLocal, Tcl_Obj *method, int nobjc, Tcl_Obj *CONST nobjv[]); static int XOTclNSCopyCmds(Tcl_Interp *interp, Tcl_Obj *fromNs, Tcl_Obj *toNs); static int XOTclNSCopyVars(Tcl_Interp *interp, Tcl_Obj *fromNs, Tcl_Obj *toNs); -static int XOTclObjectpropertyCmd(Tcl_Interp *interp, Tcl_Obj *object, int objectkind, Tcl_Obj *value); +static int XOTclObjectpropertyCmd(Tcl_Interp *interp, Tcl_Obj *object, int objectkind); static int XOTclParametercheckCmd(Tcl_Interp *interp, int withNocomplain, Tcl_Obj *param, Tcl_Obj *value); static int XOTclQualifyObjCmd(Tcl_Interp *interp, Tcl_Obj *name); static int XOTclRelationCmd(Tcl_Interp *interp, XOTclObject *object, int relationtype, Tcl_Obj *value); @@ -1842,10 +1842,9 @@ } else { Tcl_Obj *object = (Tcl_Obj *)pc.clientData[0]; int objectkind = (int )PTR2INT(pc.clientData[1]); - Tcl_Obj *value = (Tcl_Obj *)pc.clientData[2]; parseContextRelease(&pc); - return XOTclObjectpropertyCmd(interp, object, objectkind, value); + return XOTclObjectpropertyCmd(interp, object, objectkind); } } @@ -2252,10 +2251,9 @@ {"fromNs", 1, 0, convertToTclobj}, {"toNs", 1, 0, convertToTclobj}} }, -{"::nsf::objectproperty", XOTclObjectpropertyCmdStub, 3, { +{"::nsf::objectproperty", XOTclObjectpropertyCmdStub, 2, { {"object", 1, 0, convertToTclobj}, - {"objectkind", 0, 0, convertToObjectkind}, - {"value", 0, 0, convertToTclobj}} + {"objectkind", 0, 0, convertToObjectkind}} }, {"::nsf::parametercheck", XOTclParametercheckCmdStub, 3, { {"-nocomplain", 0, 0, convertToString}, Index: generic/xotcl.c =================================================================== diff -u -r75bdefce85cff349831dbca1900153fca956574c -rf1cd1537386ab1fdfabccaadae215990e376ae9d --- generic/xotcl.c (.../xotcl.c) (revision 75bdefce85cff349831dbca1900153fca956574c) +++ generic/xotcl.c (.../xotcl.c) (revision f1cd1537386ab1fdfabccaadae215990e376ae9d) @@ -201,8 +201,9 @@ static void GuardDel(XOTclCmdList *filterCL); static int IsMetaClass(Tcl_Interp *interp, XOTclClass *cl, int withMixins); +static int IsSubType(XOTclClass *subcl, XOTclClass *cl); static int HasMixin(Tcl_Interp *interp, XOTclObject *object, XOTclClass *cl); -static int isSubType(XOTclClass *subcl, XOTclClass *cl); + static XOTclClass *DefaultSuperClass(Tcl_Interp *interp, XOTclClass *cl, XOTclClass *mcl, int isMeta); XOTCLINLINE static void CscInit(XOTclCallStackContent *cscPtr, XOTclObject *object, XOTclClass *cl, @@ -6462,7 +6463,7 @@ return TCL_OK; if ((GetClassFromObj(interp, pPtr->converterArg, &cl, NULL) == TCL_OK) - && isSubType(object->cl, cl)) { + && IsSubType(object->cl, cl)) { return TCL_OK; } @@ -8609,7 +8610,7 @@ } static int -isSubType(XOTclClass *subcl, XOTclClass *cl) { +IsSubType(XOTclClass *subcl, XOTclClass *cl) { XOTclClasses *t; int success = 1; assert(cl && subcl); @@ -11548,7 +11549,7 @@ if (arg== NULL) return XOTclObjErrArgCnt(interp, NULL, NULL, "type "); success = (GetObjectFromObj(interp, valueObj, &object) == TCL_OK) && (GetClassFromObj(interp, arg, &typeClass, NULL) == TCL_OK) - && isSubType(object->cl, typeClass); + && IsSubType(object->cl, typeClass); Tcl_SetIntObj(Tcl_GetObjResult(interp), success); @@ -11563,7 +11564,7 @@ } if (success && withType) { success = (GetClassFromObj(interp, withType, &typeClass, NULL) == TCL_OK) - && isSubType(object->cl, typeClass); + && IsSubType(object->cl, typeClass); } Tcl_SetIntObj(Tcl_GetObjResult(interp), success); @@ -12085,48 +12086,32 @@ /* xotclCmd objectproperty XOTclObjectpropertyCmd { {-argName "object" -required 1 -type tclobj} - {-argName "objectkind" -type "type|object|class|baseclass|metaclass"} - {-argName "value" -required 0 -type tclobj} + {-argName "objectkind" -type "object|class|baseclass|metaclass"} } */ -static int XOTclObjectpropertyCmd(Tcl_Interp *interp, Tcl_Obj *obj, int objectkind, Tcl_Obj *valueObj) { +static int XOTclObjectpropertyCmd(Tcl_Interp *interp, Tcl_Obj *obj, int objectkind) { int success = TCL_ERROR; XOTclObject *object; XOTclClass *cl; /* fprintf(stderr, "XOTclObjectpropertyCmd\n");*/ switch (objectkind) { - case ObjectkindTypeIdx: - if (valueObj == NULL) return XOTclObjErrArgCnt(interp, NULL, NULL, " type "); - if (GetObjectFromObj(interp, obj, &object) != TCL_OK) { - return XOTclObjErrType(interp, obj, "object", "object"); - } - if (GetClassFromObj(interp, valueObj, &cl, NULL) != TCL_OK) { - return XOTclObjErrType(interp, valueObj, "class", "type"); - } - success = isSubType(object->cl, cl); - break; - case ObjectkindObjectIdx: - if (valueObj != NULL) return XOTclObjErrArgCnt(interp, NULL, NULL, " object"); success = (GetObjectFromObj(interp, obj, &object) == TCL_OK); break; case ObjectkindClassIdx: - if (valueObj != NULL) return XOTclObjErrArgCnt(interp, NULL, NULL, " class"); success = (GetObjectFromObj(interp, obj, &object) == TCL_OK) && XOTclObjectIsClass(object); break; case ObjectkindMetaclassIdx: - if (valueObj != NULL) return XOTclObjErrArgCnt(interp, NULL, NULL, " metaclass"); success = (GetObjectFromObj(interp, obj, &object) == TCL_OK) && XOTclObjectIsClass(object) && IsMetaClass(interp, (XOTclClass*)object, 1); break; case ObjectkindBaseclassIdx: - if (valueObj != NULL) return XOTclObjErrArgCnt(interp, NULL, NULL, " baseclass"); success = (GetObjectFromObj(interp, obj, &object) == TCL_OK) && XOTclObjectIsClass(object) && IsBaseClass((XOTclClass*)object); @@ -14109,7 +14094,7 @@ */ static int XOTclObjInfoHasTypeMethod(Tcl_Interp *interp, XOTclObject *object, XOTclClass *typeClass) { - Tcl_SetBooleanObj(Tcl_GetObjResult(interp), isSubType(object->cl, typeClass)); + Tcl_SetBooleanObj(Tcl_GetObjResult(interp), IsSubType(object->cl, typeClass)); return TCL_OK; } @@ -14221,7 +14206,7 @@ slotObjects = computeSlotObjects(interp, object, pattern /* not used */, 1); for (pl=slotObjects; pl; pl = pl->nextPtr) { - /*if (slotClass && !isSubType(pl->obj->cl, slotClass)) continue;*/ + /*if (slotClass && !IsSubType(pl->obj->cl, slotClass)) continue;*/ Tcl_ListObjAppendElement(interp, list, pl->obj->cmdName); } Index: library/nx/nx.tcl =================================================================== diff -u -r75bdefce85cff349831dbca1900153fca956574c -rf1cd1537386ab1fdfabccaadae215990e376ae9d --- library/nx/nx.tcl (.../nx.tcl) (revision 75bdefce85cff349831dbca1900153fca956574c) +++ library/nx/nx.tcl (.../nx.tcl) (revision f1cd1537386ab1fdfabccaadae215990e376ae9d) @@ -846,7 +846,7 @@ :alias "info has mixin" ::nsf::cmd::ObjectInfo2::hasmixin :alias "info has namespace" ::nsf::cmd::ObjectInfo2::hasnamespace :alias "info has type" ::nsf::cmd::ObjectInfo2::hastype - :method "info is" {kind {value ""}} {::nsf::objectproperty [::nsf::current object] $kind {*}$value} + :method "info is" {kind} {::nsf::objectproperty [::nsf::current object] $kind} :alias "info methods" ::nsf::cmd::ObjectInfo2::methods :alias "info mixin guard" ::nsf::cmd::ObjectInfo2::mixinguard :alias "info mixin classes" ::nsf::cmd::ObjectInfo2::mixinclasses @@ -855,8 +855,7 @@ :method "info slotobjects" {} { set result [list] foreach slot [::nsf::dispatch [::nsf::current object] ::nsf::cmd::ObjectInfo2::slotobjects] { - puts stderr "check $slot [::nsf::objectproperty $slot type ::nx::Slot]" - if {![::nsf::objectproperty $slot type ::nx::Slot]} continue + if {![::nsf::dispatch $slot ::nsf::cmd::ObjectInfo2::hastype ::nx::Slot]} continue lappend result $slot } return $result @@ -1330,14 +1329,14 @@ proc ::nsf::parametersFromSlots {obj} { set parameterdefinitions [list] foreach slot [::nsf::dispatch $obj ::nsf::cmd::ObjectInfo2::slotobjects] { - # TODO: the following line is just for the somehwat dummy "info slot" - if {![::nsf::objectproperty $slot type ::nx::Slot]} continue + # TODO: the following line is just for the somehwat dummy "...::slot::__info" + if {![::nsf::dispatch $slot ::nsf::cmd::ObjectInfo2::hastype ::nx::Slot]} continue # Skip some slots for xotcl; # TODO: maybe different parameterFromSlots for xotcl? if {[::nsf::objectproperty ::xotcl::Object class] - && [::nsf::objectproperty $obj type ::xotcl::Object] && + && [::nsf::dispatch $obj ::nsf::cmd::ObjectInfo2::hastype ::xotcl::Object] && ([$slot name] eq "mixin" || [$slot name] eq "filter") - } continue + } continue array set "" [$slot toParameterSyntax] lappend parameterdefinitions -$(oparam) } Index: library/serialize/serializer.tcl =================================================================== diff -u -r02ec0d2caa6701949f29171520a462564299a611 -rf1cd1537386ab1fdfabccaadae215990e376ae9d --- library/serialize/serializer.tcl (.../serializer.tcl) (revision 02ec0d2caa6701949f29171520a462564299a611) +++ library/serialize/serializer.tcl (.../serializer.tcl) (revision f1cd1537386ab1fdfabccaadae215990e376ae9d) @@ -467,7 +467,7 @@ :method registerSerializer {s instances} { # Communicate responsibility to serializer object $s foreach i $instances { - if {![::nsf::objectproperty $i type ${:rootClass}]} continue + if {![::nsf::dispatch $i ::nsf::cmd::ObjectInfo2::hastype ${:rootClass}]} continue $s setObjectSystemSerializer $i [::nsf::current object] } } @@ -496,12 +496,16 @@ foreach {o p m} $k break if {![::nsf::objectproperty $o object]} { puts stderr "Warning: $o is not an object" - } elseif {[::nsf::objectproperty $o type ${:rootClass}]} {set :exportMethods($k) 1} + } elseif {[::nsf::dispatch $o ::nsf::cmd::ObjectInfo2::hastype ${:rootClass}]} { + set :exportMethods($k) 1 + } } foreach o [Serializer exportedObjects] { if {![::nsf::objectproperty $o object]} { puts stderr "Warning: $o is not an object" - } elseif {[::nsf::objectproperty $o type ${:rootClass}]} {set :exportObjects($o) 1} + } elseif {[nsf::dispatch $o ::nsf::cmd::ObjectInfo2::hastype ${:rootClass}]} { + set :exportObjects($o) 1 + } } foreach p [array names :ignorePattern] {Serializer addPattern $p} } @@ -512,7 +516,7 @@ ############################### :method classify {o} { - if {[::nsf::objectproperty $o type ${:rootMetaClass}]} \ + if {[::nsf::dispatch $o ::nsf::cmd::ObjectInfo2::hastype ${:rootMetaClass}]} \ {return Class} {return Object} } @@ -672,7 +676,7 @@ [:frameWorkCmd ::nsf::relation $o object-mixin] \ [:frameWorkCmd ::nsf::assertion $o object-invar] - if {[::nsf::objectproperty $o type ::nx::Slot]} { + if {[$o info has type ::nx::Slot]} { # Slots needs to be initialized to ensure # __invalidateobjectparameter to be called append cmd [list $o eval :init] \n Index: tests/forwardtest.tcl =================================================================== diff -u -r6166d76909482a0a4c1296cb959462d71c688922 -rf1cd1537386ab1fdfabccaadae215990e376ae9d --- tests/forwardtest.tcl (.../forwardtest.tcl) (revision 6166d76909482a0a4c1296cb959462d71c688922) +++ tests/forwardtest.tcl (.../forwardtest.tcl) (revision f1cd1537386ab1fdfabccaadae215990e376ae9d) @@ -372,18 +372,18 @@ C create c1 ? {c1 expr {[current]}} ::c1 - ? {c1 expr {[current] == "::c1"}} 1 + ? {c1 expr {[current] eq "::c1"}} 1 ? {c1 expr {[:xx]}} ::c1 ? {c1 expr {[:info class]}} ::C - ? {c1 expr {[:info is type C]}} 1 - ? {c1 expr {[:info is type ::C]}} 1 + ? {c1 expr {[:info has type C]}} 1 + ? {c1 expr {[:info has type ::C]}} 1 ? {C t ::c1 {[current]}} ::c1 - ? {C t ::c1 {[current] == "::c1"}} 1 + ? {C t ::c1 {[current] eq "::c1"}} 1 ? {C t ::c1 {[:xx]}} ::c1 ? {C t ::c1 {[:info class]}} ::C - ? {C t ::c1 {[:info is type C]}} 1 - ? {C t ::c1 {[:info is type ::C]}} 1 + ? {C t ::c1 {[:info has type C]}} 1 + ? {C t ::c1 {[:info has type ::C]}} 1 Object method expr {} {} Index: tests/parameters.tcl =================================================================== diff -u -r75bdefce85cff349831dbca1900153fca956574c -rf1cd1537386ab1fdfabccaadae215990e376ae9d --- tests/parameters.tcl (.../parameters.tcl) (revision 75bdefce85cff349831dbca1900153fca956574c) +++ tests/parameters.tcl (.../parameters.tcl) (revision f1cd1537386ab1fdfabccaadae215990e376ae9d) @@ -35,7 +35,9 @@ ? {::nsf::objectproperty o1 object} 1 ? {::nsf::objectproperty o1000 object} 0 - ? {::nsf::objectproperty c1 type C} 1 + #? {::nsf::objectproperty c1 type C} 1 + ? {c1 info has type C} 1 + ? {c1 info has type C1} {expected class but got "C1" for parameter class} ? {::nsf::is c1 object -type C} 1 #? {::nsf::is c1 object -hasmixin M -type C} 1