Index: TODO =================================================================== diff -u -r6c5a4270b7d010efabb4cb89a890006b059a5f7e -r4c9e3b2b545a49698aa2284cc8dc5d5bb2719703 --- TODO (.../TODO) (revision 6c5a4270b7d010efabb4cb89a890006b059a5f7e) +++ TODO (.../TODO) (revision 4c9e3b2b545a49698aa2284cc8dc5d5bb2719703) @@ -4208,12 +4208,15 @@ XOTcl 2 - don't blindly register all object/class methods for XOTcl +nsf.c: +- fix potential bad interaction between per-object mixins and + per-class caching of object-parameters + ======================================================================== TODO: - regression tests for "/obj/ info lookup parameter ...." -- check potential mis-cachings due to per-object/per-class mixins, - when object-parameters are e.g. manually invalidated. -- do we need NSF_CONFIGURE, NSF_INITIALIZE, NSF_ASSIGN +- handling of "required" in reconfigure (see + parameter-object-mixin-dependency in parameters.test) - check noconfig - "/obj/ configure" returns values which can't be read via "/obj/ cget" (but altered properly via "configure"). Index: generic/nsf.c =================================================================== diff -u -r5d1617640ad71fd52b069f81cfcadbe4cbb6f2a2 -r4c9e3b2b545a49698aa2284cc8dc5d5bb2719703 --- generic/nsf.c (.../nsf.c) (revision 5d1617640ad71fd52b069f81cfcadbe4cbb6f2a2) +++ generic/nsf.c (.../nsf.c) (revision 4c9e3b2b545a49698aa2284cc8dc5d5bb2719703) @@ -21583,9 +21583,13 @@ NsfClass *class; assert(object); - if (object->flags & NSF_HAS_PER_OBJECT_SLOTS) { - assert(object->flags & NSF_INIT_CALLED); - assert(object->nsPtr != NULL); + if ((object->flags & NSF_HAS_PER_OBJECT_SLOTS) + || (object->opt && object->opt->objMixins) + ) { + /* + * We have object-specific parameters. Do not use the per-class cache, + * and do not save the results in the per-class cache + */ /*fprintf(stderr, "per-object configure obj %s flags %.6x\n", ObjectName(object), object->flags);*/ class = NULL; Index: tests/parameters.test =================================================================== diff -u -r5d1617640ad71fd52b069f81cfcadbe4cbb6f2a2 -r4c9e3b2b545a49698aa2284cc8dc5d5bb2719703 --- tests/parameters.test (.../parameters.test) (revision 5d1617640ad71fd52b069f81cfcadbe4cbb6f2a2) +++ tests/parameters.test (.../parameters.test) (revision 4c9e3b2b545a49698aa2284cc8dc5d5bb2719703) @@ -1831,19 +1831,73 @@ } # -# Test incfluence of mixins on objectparameters +# Test interactions between per-object-mixins and objectparameters +# (case without per-object property) # nx::Test case parameter-object-mixin-dependency { nx::Class create C { :property a1 + :create c1 + } + nx::Class create D -superclass C + nx::Class create M {:property b1:required} + + ? {c1 eval :__objectparameter} "-a1 -volatile:alias,noarg -properties:alias,method=::nx::internal::addProperties -noinit:alias,method=::nsf::methods::object::noinit,noarg -mixin:mixinreg,alias,0..n -class:class,alias,method=::nsf::methods::object::class -filter:filterreg,alias,0..n __initcmd:initcmd,optional,noleadingdash" + + c1 mixin M + + ? {c1 info precedence} "::M ::C ::nx::Object" + + ? {c1 eval :__objectparameter} "-b1:required -a1 -volatile:alias,noarg -properties:alias,method=::nx::internal::addProperties -noinit:alias,method=::nsf::methods::object::noinit,noarg -mixin:mixinreg,alias,0..n -class:class,alias,method=::nsf::methods::object::class -filter:filterreg,alias,0..n __initcmd:initcmd,optional,noleadingdash" + + # + # Invalidate the object parameter and expect that the per-class + # mixin does not harm + # + ::nsf::invalidateobjectparameter C + + # + # We have now "-b1:required" in the object parameters. + # + # TODO: Actually we should enforce it. We could check, if the + # associate variable is already set, but this does not work for + # aliases.... we could track, if the slot is already initialized for + # this object. This can be a potentially huge table containing + # potentially all objects (relation slots). Maybe keep the table + # just for "required" parameters? or look for an approach based on + # epoch counting? + # + ? {c1 configure -a1 x} "" + + # + # The object parameter based on the per-object-mixin must not be + # stored in the class based cache. Therefore, creating a new object + # must not require b1 + + ? {C create c2} ::c2 + + # + # the same should hold for subcles + # + ? {D create d1} ::d1 + + +} + + +# +# Test interactions between per-object-mixins and objectparameters +# (case with per-object property) +# +nx::Test case parameter-object-mixin-dependency-object-property { + nx::Class create C { + :property a1 :create c1 { :property a2 } } - - nx::Class create M { - :property b1:required - } + nx::Class create D -superclass C + nx::Class create M {:property b1:required} c1 mixin M @@ -1869,10 +1923,11 @@ # should not require b1 ? {C create c2} ::c2 - + } + # # Test integer, wideinteger and bignums #