Index: generic/xotcl.c =================================================================== diff -u -r15b6823910520e77bfa8c2cf4ea78289af91c28c -r32967f9cd85ab5b73e80781c150240d9c23ee7b0 --- generic/xotcl.c (.../xotcl.c) (revision 15b6823910520e77bfa8c2cf4ea78289af91c28c) +++ generic/xotcl.c (.../xotcl.c) (revision 32967f9cd85ab5b73e80781c150240d9c23ee7b0) @@ -1655,6 +1655,12 @@ */ Tcl_Obj * XOTclMethodObj(Tcl_Interp *interp, XOTclObject *object, int methodIdx) { XOTclObjectSystem *osPtr = GetObjectSystem(object); + /* + fprintf(stderr, "XOTclMethodObj object %s os %p idx %d %s methodObj %p\n", + objectName(object), osPtr, methodIdx, + XOTcl_SytemMethodOpts[methodIdx]+1, + osPtr->methods[methodIdx]); + */ return osPtr->methods[methodIdx]; } @@ -6356,7 +6362,7 @@ if (unknown) { Tcl_Obj *unknownObj = XOTclMethodObj(interp, object, XO_o_unknown_idx); - if (/*XOTclObjectIsClass(object) &&*/ (flags & XOTCL_CM_NO_UNKNOWN)) { + if (unknownObj == NULL || (flags & XOTCL_CM_NO_UNKNOWN)) { result = XOTclVarErrMsg(interp, objectName(object), ": unable to dispatch method '", methodName, "'", (char *) NULL); @@ -8520,7 +8526,7 @@ memset(cl, 0, sizeof(XOTclClass)); MEM_COUNT_ALLOC("XOTclObject/XOTclClass", cl); - /* pass object system fram meta class */ + /* pass object system from meta class */ if (class) { cl->osPtr = class->osPtr; } @@ -12937,6 +12943,8 @@ DECR_REF_COUNT(rawConfArgs); } } else { + parsedParamPtr->paramDefs = NULL; + parsedParamPtr->possibleUnknowns = 0; result = TCL_OK; } } @@ -13555,7 +13563,7 @@ * create a new object from scratch */ - /*fprintf(stderr, " **** 0 class '%s' wants to alloc '%s'\n", className(cl), name);*/ + /*fprintf(stderr, " **** 0 class '%s' wants to alloc '%s'\n", className(cl), nameString);*/ if (!NSCheckColons(nameString, 0)) { return XOTclVarErrMsg(interp, "Cannot allocate object -- illegal name '", nameString, "'", (char *) NULL); @@ -13652,16 +13660,24 @@ );*/ /* don't allow to - - recreate an object as a class, and to - - recreate a class as an object + - recreate an object as a class, + - recreate a class as an object, and to + - recreate an object in a different obejct system In these clases, we use destroy + create instead of recrate. */ - if (newObject && (IsMetaClass(interp, cl, 1) == IsMetaClass(interp, newObject->cl, 1))) { - /*fprintf(stderr, "%%%% recreate, call recreate method ... %s, objc=%d\n", - ObjStr(nameObj), objc+1);*/ + if (newObject + && (IsMetaClass(interp, cl, 1) == IsMetaClass(interp, newObject->cl, 1)) + && GetObjectSystem(newObject) == cl->osPtr) { + /*fprintf(stderr, "%%%% recreate, call recreate method ... %s, objc=%d oldOs %p != newOs %p EQ %d\n", + ObjStr(nameObj), objc+1, + GetObjectSystem(newObject), cl->osPtr, + GetObjectSystem(newObject) != cl->osPtr + ); + */ + /* call recreate --> initialization */ if (CallDirectly(interp, &cl->object, XO_c_recreate_idx, &methodObj)) { result = RecreateObject(interp, cl, newObject, objc, nobjv); @@ -13683,7 +13699,7 @@ * alloc */ - /*fprintf(stderr, "alloc ... %s\n", ObjStr(nameObj);*/ + /*fprintf(stderr, "alloc ... %s\n", ObjStr(nameObj));*/ if (CallDirectly(interp, &cl->object, XO_c_alloc_idx, &methodObj)) { result = XOTclCAllocMethod(interp, cl, nameObj); } else { Index: library/lib/metadataAnalyzer.xotcl =================================================================== diff -u -ra6087540279fa5a9110728605795620ecd43e10e -r32967f9cd85ab5b73e80781c150240d9c23ee7b0 --- library/lib/metadataAnalyzer.xotcl (.../metadataAnalyzer.xotcl) (revision a6087540279fa5a9110728605795620ecd43e10e) +++ library/lib/metadataAnalyzer.xotcl (.../metadataAnalyzer.xotcl) (revision 32967f9cd85ab5b73e80781c150240d9c23ee7b0) @@ -492,7 +492,7 @@ @ AnalyzerCmd @ { description {Recreate @ with metadata analyis funtionality.} } - AnalyzerCmd create @ + AnalyzerCmd create ::xotcl::@ namespace export \ MetadataToken FileToken ConstraintToken PackageToken ObjToken \ Index: library/lib/staticMetadata.xotcl =================================================================== diff -u -ra6087540279fa5a9110728605795620ecd43e10e -r32967f9cd85ab5b73e80781c150240d9c23ee7b0 --- library/lib/staticMetadata.xotcl (.../staticMetadata.xotcl) (revision a6087540279fa5a9110728605795620ecd43e10e) +++ library/lib/staticMetadata.xotcl (.../staticMetadata.xotcl) (revision 32967f9cd85ab5b73e80781c150240d9c23ee7b0) @@ -1,9 +1,9 @@ +package require XOTcl package require xotcl::metadataAnalyzer package provide xotcl::staticMetadataAnalyzer 0.84 -package require XOTcl namespace eval ::xotcl::staticMetadataAnalyzer { - namespace import ::xotcl::* + ::xotcl::use xotcl1 @ @File { description { @@ -64,7 +64,7 @@ StaticMetadataAnalyzer instproc analyzeFile name { my set cmd "" - set t [FileToken create [my autoname t]] + set t [FileToken create [my autoname t]] $t set name $name my set fileToken $t Index: library/lib/xodoc.xotcl =================================================================== diff -u -r217d826e64107056ae97176552cae3c776991b9e -r32967f9cd85ab5b73e80781c150240d9c23ee7b0 --- library/lib/xodoc.xotcl (.../xodoc.xotcl) (revision 217d826e64107056ae97176552cae3c776991b9e) +++ library/lib/xodoc.xotcl (.../xodoc.xotcl) (revision 32967f9cd85ab5b73e80781c150240d9c23ee7b0) @@ -1,13 +1,11 @@ # $Id: xodoc.xotcl,v 1.7 2006/09/27 08:12:40 neumann Exp $ package require XOTcl -package require xotcl1 package provide xotcl::xodoc 0.84 package require xotcl::staticMetadataAnalyzer package require xotcl::htmllib -#package require xotcl::trace namespace eval ::xotcl::xodoc { - namespace import ::xotcl::* + ::xotcl::use xotcl1 @ @File { description { Index: tests/object-system.xotcl =================================================================== diff -u -r44736fc4e8b7b220f25afc685739f79c263b7d99 -r32967f9cd85ab5b73e80781c150240d9c23ee7b0 --- tests/object-system.xotcl (.../object-system.xotcl) (revision 44736fc4e8b7b220f25afc685739f79c263b7d99) +++ tests/object-system.xotcl (.../object-system.xotcl) (revision 32967f9cd85ab5b73e80781c150240d9c23ee7b0) @@ -122,4 +122,52 @@ ? {catch {::xotcl::dispatch ::o -objscope ::xxx x}} 1 "cmd dispatch with unknown command" o destroy +puts stderr ===MINI-OBJECTSYSTEM +# test object system +# create a minimal object system without internally dipatched methods +::xotcl::createobjectsystem ::object ::class + +? {::xotcl::objectproperty ::object object} 1 +? {::xotcl::objectproperty ::object class} 1 +? {::xotcl::objectproperty ::object metaclass} 0 +? {::xotcl::relation ::object class} ::class +? {::xotcl::relation ::object superclass} "" + +? {::xotcl::objectproperty ::class object} 1 +? {::xotcl::objectproperty ::class class} 1 +? {::xotcl::objectproperty ::class metaclass} 1 +? {::xotcl::relation ::class class} ::class +? {::xotcl::relation ::class superclass} ::object + +# define non-standard methos to create/destroy objects and classes +::xotcl::alias ::class + ::xotcl::cmd::Class::create +::xotcl::alias ::object - ::xotcl::cmd::Object::destroy + +# create a class named C +::class + C + +? {::xotcl::objectproperty ::C object} 1 +? {::xotcl::objectproperty ::C class} 1 +? {::xotcl::objectproperty ::C metaclass} 0 +? {::xotcl::relation ::C class} ::class +? {::xotcl::relation ::C superclass} ::object + +# create an instance of C +C + c1 + +? {::xotcl::objectproperty ::c1 object} 1 +? {::xotcl::objectproperty ::c1 class} 0 +? {::xotcl::objectproperty ::c1 metaclass} 0 +? {::xotcl::relation ::c1 class} ::C + +# destroy instance and class +c1 - + +? {::xotcl::objectproperty ::c1 object} 0 +? {::xotcl::objectproperty ::C class} 1 + +C - + +? {::xotcl::objectproperty ::C class} 0 + puts stderr ===EXIT