Index: generic/predefined.h =================================================================== diff -u -r670151ba40e8da27625ed679f2d3ff58d1763239 -r4a91216d0624226fb9a64de97feccc84cc79df79 --- generic/predefined.h (.../predefined.h) (revision 670151ba40e8da27625ed679f2d3ff58d1763239) +++ generic/predefined.h (.../predefined.h) (revision 4a91216d0624226fb9a64de97feccc84cc79df79) @@ -453,6 +453,8 @@ "set setterParam ${:name}}\n" "::xotcl::setter ${:domain} {*}$perObject $setterParam}}\n" "::xotcl::Attribute mixin add ::xotcl::Attribute::Optimizer\n" +"::xotcl2::Object method attribute {spec {-slotclass ::xotcl::Attribute} {initblock \"\"}} {\n" +"$slotclass createFromParameterSyntax [self] -initblock $initblock {*}$spec}\n" "::xotcl2::Class public method parameter arglist {\n" "foreach arg $arglist {\n" "::xotcl::Attribute createFromParameterSyntax [self] {*}$arg}\n" @@ -470,15 +472,15 @@ "if {![::xotcl::is $value metaclass]} {\n" "error \"expected metaclass but got \\\"$value\\\" for parameter $name\"}\n" "return $value}}\n" -"::xotcl2::Class create ::xotcl::ScopedNew -superclass ::xotcl2::Class -parameter {\n" -"{withclass ::xotcl2::Object}\n" -"container}\n" -"::xotcl::ScopedNew protected method init {} {\n" +"::xotcl2::Class create ::xotcl::ScopedNew -superclass ::xotcl2::Class {\n" +":attribute {withclass ::xotcl2::Object}\n" +":attribute container\n" +":protected method init {} {\n" ":public method new {-childof args} {\n" "::xotcl::importvar [::xotcl::self class] {container object} withclass\n" "if {![::xotcl::is $object object]} {\n" "$withclass create $object}\n" -"eval ::xotcl::next -childof $object $args}}\n" +"eval ::xotcl::next -childof $object $args}}}\n" "::xotcl2::Object public method contains {\n" "{-withnew:boolean true}\n" "-object\n" @@ -498,10 +500,10 @@ "namespace eval $object $cmds}}\n" "::xotcl2::Class forward slots %self contains \\\n" "-object {%::xotcl::dispatch [::xotcl::self] -objscope ::subst [::xotcl::self]::slot}\n" -"::xotcl2::Class create ::xotcl::CopyHandler -parameter {\n" -"{targetList \"\"}\n" -"{dest \"\"}\n" -"objLength} {\n" +"::xotcl2::Class create ::xotcl::CopyHandler {\n" +":attribute {targetList \"\"}\n" +":attribute {dest \"\"}\n" +":attribute objLength\n" ":method makeTargetList {t} {\n" "lappend :targetList $t\n" "if {[::xotcl::is $t object]} {\n" Index: generic/predefined.xotcl =================================================================== diff -u -r670151ba40e8da27625ed679f2d3ff58d1763239 -r4a91216d0624226fb9a64de97feccc84cc79df79 --- generic/predefined.xotcl (.../predefined.xotcl) (revision 670151ba40e8da27625ed679f2d3ff58d1763239) +++ generic/predefined.xotcl (.../predefined.xotcl) (revision 4a91216d0624226fb9a64de97feccc84cc79df79) @@ -476,6 +476,7 @@ } ${:domain} __invalidateobjectparameter set cl [expr {${:per-object} ? "Object" : "Class"}] + #puts stderr "Slot [self] init, forwarder on ${:domain}" ::xotcl::forward ${:domain} ${:name} \ ${:manager} \ [list %1 [${:manager} defaultmethods]] %self \ @@ -851,6 +852,12 @@ # register the optimizer per default ::xotcl::Attribute mixin add ::xotcl::Attribute::Optimizer + ############################################ + # Define method "attribute" for convenience + ############################################ + ::xotcl2::Object method attribute {spec {-slotclass ::xotcl::Attribute} {initblock ""}} { + $slotclass createFromParameterSyntax [self] -initblock $initblock {*}$spec + } ############################################ # Define method "parameter" for backward @@ -906,17 +913,19 @@ # (without syntactic overhead). ################################################################## -::xotcl2::Class create ::xotcl::ScopedNew -superclass ::xotcl2::Class -parameter { - {withclass ::xotcl2::Object} - container -} -::xotcl::ScopedNew protected method init {} { - :public method new {-childof args} { - ::xotcl::importvar [::xotcl::self class] {container object} withclass - if {![::xotcl::is $object object]} { - $withclass create $object +::xotcl2::Class create ::xotcl::ScopedNew -superclass ::xotcl2::Class { + + :attribute {withclass ::xotcl2::Object} + :attribute container + + :protected method init {} { + :public method new {-childof args} { + ::xotcl::importvar [::xotcl::self class] {container object} withclass + if {![::xotcl::is $object object]} { + $withclass create $object + } + eval ::xotcl::next -childof $object $args } - eval ::xotcl::next -childof $object $args } } @@ -956,12 +965,12 @@ # copy/move implementation ################################################################## -::xotcl2::Class create ::xotcl::CopyHandler -parameter { - {targetList ""} - {dest ""} - objLength -} { +::xotcl2::Class create ::xotcl::CopyHandler { + :attribute {targetList ""} + :attribute {dest ""} + :attribute objLength + :method makeTargetList {t} { lappend :targetList $t # if it is an object without namespace, it is a leaf