Index: TODO =================================================================== diff -u -rf1cd1537386ab1fdfabccaadae215990e376ae9d -r39952278bc1e3aa6dda5df7cbe4cffc399f63b98 --- TODO (.../TODO) (revision f1cd1537386ab1fdfabccaadae215990e376ae9d) +++ TODO (.../TODO) (revision 39952278bc1e3aa6dda5df7cbe4cffc399f63b98) @@ -1209,16 +1209,20 @@ - updated interface definitions for info methods, sort these alphabetically - removed "objectproperty .... hasmixin" -- removed "nsd::is ... -hasmixin ...." +- removed "nsf::is ... -hasmixin ...." - removed type-converter "type=hasmixin" - adoped emulation layer in xotcl2 accordingly -- added two tests for "info has mixin" in regression test +- added two tests for "info has mixin" to regression tests - removed "objectproperty .... type" - renamed isSubType() to IsSubType() - adoped emulation layer in xotcl2 accordingly -- added two tests for "info has type" in regression test +- added two tests for "info has type" to regression tests +- removed "nsf::is ... -type ...." +- adoped emulation layer in xotcl2 accordingly +- extended regression test + TODO: - rename ObjectInfo2 & ClassInfo2 - check "my" vs. "nsf::dispatch" in xotcl2.tcl Index: generic/gentclAPI.decls =================================================================== diff -u -rf1cd1537386ab1fdfabccaadae215990e376ae9d -r39952278bc1e3aa6dda5df7cbe4cffc399f63b98 --- generic/gentclAPI.decls (.../gentclAPI.decls) (revision f1cd1537386ab1fdfabccaadae215990e376ae9d) +++ generic/gentclAPI.decls (.../gentclAPI.decls) (revision 39952278bc1e3aa6dda5df7cbe4cffc399f63b98) @@ -90,8 +90,6 @@ xotclCmd is XOTclIsCmd { {-argName "value" -required 1 -type tclobj} {-argName "constraint" -required 1 -type tclobj} - {-argName "-type" -required 0 -nrargs 1 -type tclobj} - {-argName "arg" -required 0 -type tclobj} } xotclCmd method XOTclMethodCmd { {-argName "object" -required 1 -type object} Index: generic/tclAPI.h =================================================================== diff -u -rf1cd1537386ab1fdfabccaadae215990e376ae9d -r39952278bc1e3aa6dda5df7cbe4cffc399f63b98 --- generic/tclAPI.h (.../tclAPI.h) (revision f1cd1537386ab1fdfabccaadae215990e376ae9d) +++ generic/tclAPI.h (.../tclAPI.h) (revision 39952278bc1e3aa6dda5df7cbe4cffc399f63b98) @@ -292,7 +292,7 @@ static int XOTclImportvarCmd(Tcl_Interp *interp, XOTclObject *object, int nobjc, Tcl_Obj *CONST nobjv[]); static int XOTclInterpObjCmd(Tcl_Interp *interp, CONST char *name, int objc, Tcl_Obj *CONST objv[]); static int XOTclInvalidateObjectParameterCmd(Tcl_Interp *interp, XOTclClass *class); -static int XOTclIsCmd(Tcl_Interp *interp, Tcl_Obj *value, Tcl_Obj *constraint, Tcl_Obj *withType, Tcl_Obj *arg); +static int XOTclIsCmd(Tcl_Interp *interp, Tcl_Obj *value, Tcl_Obj *constraint); static int XOTclMethodCmd(Tcl_Interp *interp, XOTclObject *object, int withInner_namespace, int withPer_object, int withPublic, Tcl_Obj *name, Tcl_Obj *args, Tcl_Obj *body, Tcl_Obj *withPrecondition, Tcl_Obj *withPostcondition); static int XOTclMethodPropertyCmd(Tcl_Interp *interp, XOTclObject *object, int withPer_object, Tcl_Obj *methodName, int methodproperty, Tcl_Obj *value); static int XOTclMyCmd(Tcl_Interp *interp, int withLocal, Tcl_Obj *method, int nobjc, Tcl_Obj *CONST nobjv[]); @@ -1716,11 +1716,9 @@ } else { Tcl_Obj *value = (Tcl_Obj *)pc.clientData[0]; Tcl_Obj *constraint = (Tcl_Obj *)pc.clientData[1]; - Tcl_Obj *withType = (Tcl_Obj *)pc.clientData[2]; - Tcl_Obj *arg = (Tcl_Obj *)pc.clientData[3]; parseContextRelease(&pc); - return XOTclIsCmd(interp, value, constraint, withType, arg); + return XOTclIsCmd(interp, value, constraint); } } @@ -2214,11 +2212,9 @@ {"::nsf::invalidateobjectparameter", XOTclInvalidateObjectParameterCmdStub, 1, { {"class", 0, 0, convertToClass}} }, -{"::nsf::is", XOTclIsCmdStub, 4, { +{"::nsf::is", XOTclIsCmdStub, 2, { {"value", 1, 0, convertToTclobj}, - {"constraint", 1, 0, convertToTclobj}, - {"-type", 0, 1, convertToTclobj}, - {"arg", 0, 0, convertToTclobj}} + {"constraint", 1, 0, convertToTclobj}} }, {"::nsf::method", XOTclMethodCmdStub, 9, { {"object", 1, 0, convertToObject}, Index: generic/xotcl.c =================================================================== diff -u -rf1cd1537386ab1fdfabccaadae215990e376ae9d -r39952278bc1e3aa6dda5df7cbe4cffc399f63b98 --- generic/xotcl.c (.../xotcl.c) (revision f1cd1537386ab1fdfabccaadae215990e376ae9d) +++ generic/xotcl.c (.../xotcl.c) (revision 39952278bc1e3aa6dda5df7cbe4cffc399f63b98) @@ -11534,54 +11534,10 @@ xotclCmd is XOTclIsCmd { {-argName "value" -required 1 -type tclobj} {-argName "constraint" -required 1 -type tclobj} - {-argName "-type" -required 0 -nrargs 1 -type tclobj} - {-argName "arg" -required 0 -type tclobj} } */ -static int XOTclIsCmd(Tcl_Interp *interp, Tcl_Obj *valueObj, Tcl_Obj *constraintObj, - Tcl_Obj *withType, Tcl_Obj *arg) { - int result = TCL_OK, success; - CONST char *constraintString = ObjStr(constraintObj); - XOTclObject *object; - XOTclClass *typeClass, *mixinClass; - - if (isTypeString(constraintString)) { - 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); - - Tcl_SetIntObj(Tcl_GetObjResult(interp), success); - - } else if (withType) { - if ((!isObjectString(constraintString) && !isClassString(constraintString)) || arg != NULL) { - return XOTclObjErrArgCnt(interp, NULL, NULL, "object|class ?-type cl?"); - } - if (*constraintString == 'o') { - success = (GetObjectFromObj(interp, valueObj, &object) == TCL_OK); - } else { - success = (GetClassFromObj(interp, valueObj, (XOTclClass **)&object, NULL) == TCL_OK); - } - if (success && withType) { - success = (GetClassFromObj(interp, withType, &typeClass, NULL) == TCL_OK) - && IsSubType(object->cl, typeClass); - } - Tcl_SetIntObj(Tcl_GetObjResult(interp), success); - - } else if (arg != NULL) { - Tcl_Obj *paramObj = Tcl_DuplicateObj(valueObj); - - INCR_REF_COUNT(paramObj); - Tcl_AppendLimitedToObj(paramObj, ",arg=", 5, INT_MAX, NULL); - Tcl_AppendObjToObj(paramObj, arg); - - result = XOTclParametercheckCmd(interp, 1, paramObj, valueObj); - DECR_REF_COUNT(paramObj); - } else { - result = XOTclParametercheckCmd(interp, 1, constraintObj, valueObj); - } - - return result; +static int XOTclIsCmd(Tcl_Interp *interp, Tcl_Obj *valueObj, Tcl_Obj *constraintObj) { + return XOTclParametercheckCmd(interp, 1, constraintObj, valueObj); } /* Index: library/xotcl/library/xotcl2.tcl =================================================================== diff -u -r75bdefce85cff349831dbca1900153fca956574c -r39952278bc1e3aa6dda5df7cbe4cffc399f63b98 --- library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision 75bdefce85cff349831dbca1900153fca956574c) +++ library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision 39952278bc1e3aa6dda5df7cbe4cffc399f63b98) @@ -593,8 +593,13 @@ Object instproc isobject {{object:substdefault "[self]"}} {::nsf::objectproperty $object object} Object instproc isclass {{class:substdefault "[self]"}} {::nsf::objectproperty $class class} Object instproc ismetaclass {{class:substdefault "[self]"}} {::nsf::objectproperty $class metaclass} - Object instproc ismixin {class} {expr {[::nsf::objectproperty $class class] && [my ::nsf::cmd::ObjectInfo2::hasmixin $class]}} - Object instproc istype {class} {::nsf::is [self] type $class} + Object instproc ismixin {class} { + expr {[::nsf::objectproperty $class class] && + [my ::nsf::cmd::ObjectInfo2::hasmixin $class]}} + Object instproc istype {class} { + expr {[::nsf::objectproperty $class class] && + [::nsf::dispatch [self] ::nsf::cmd::ObjectInfo2::hastype $class]} + } # definitin of "contains", based on nx @@ -686,7 +691,7 @@ Object instproc hasclass cl { if {![::nsf::objectproperty $cl class]} {return 0} if {[my ::nsf::cmd::ObjectInfo2::hasmixin $cl]} {return 1} - ::nsf::is [self] type $cl + ::nsf::dispatch [self] ::nsf::cmd::ObjectInfo2::hastype $cl } Object instproc filtersearch {filter} { set handle [::nsf::dispatch [::nsf::current object] \ Index: tests/parameters.tcl =================================================================== diff -u -rf1cd1537386ab1fdfabccaadae215990e376ae9d -r39952278bc1e3aa6dda5df7cbe4cffc399f63b98 --- tests/parameters.tcl (.../parameters.tcl) (revision f1cd1537386ab1fdfabccaadae215990e376ae9d) +++ tests/parameters.tcl (.../parameters.tcl) (revision 39952278bc1e3aa6dda5df7cbe4cffc399f63b98) @@ -29,26 +29,35 @@ ? {::nsf::parametercheck -nocomplain object o1000} 0 ? {::nsf::parametercheck integer 1} 1 ? {::nsf::parametercheck object,type=::C c1} 1 + ? {::nsf::parametercheck object,type=::C o} {expected object but got "o" for parameter value} + ? {::nsf::parametercheck -nocomplain object,type=::C o} 0 + ? {c1 info has mixin ::M} 1 ? {c1 info has mixin ::M1} {expected class but got "::M1" for parameter class} #? {::nsf::parametercheck hasmixin,arg=::M c1} 1 ? {::nsf::objectproperty o1 object} 1 ? {::nsf::objectproperty o1000 object} 0 + #? {::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 + ? {c1 ::nsf::cmd::ObjectInfo2::hastype C} 1 + ? {::nsf::dispatch c1 ::nsf::cmd::ObjectInfo2::hastype C} 1 - ? {::nsf::is c1 object -type C} 1 #? {::nsf::is c1 object -hasmixin M -type C} 1 #? {::nsf::is c1 object -hasmixin M1 -type C} 0 #? {::nsf::is c1 object -hasmixin M -type C0} 0 ? {::nsf::is o1 object} 1 ? {::nsf::is o100 object} 0 ? {::nsf::is 1 integer} 1 - ? {::nsf::is c1 type C} 1 - ? {::nsf::is o type C} 0 - ? {::nsf::is o object -type C} 0 + ? {::nsf::is c1 object,type=::C} 1 + ? {::nsf::is o object,type=::C} 0 + + #? {::nsf::is c1 type C} 1 + #? {::nsf::is o type C} 0 + #? {::nsf::is o object -type C} 0 #? {::nsf::is o object -hasmixin C} 0 #exit ? {::nsf::parametercheck class o1} {expected class but got "o1" for parameter value}