diff options
| author | dkf <donal.k.fellows@manchester.ac.uk> | 2019-12-29 13:23:47 (GMT) |
|---|---|---|
| committer | dkf <donal.k.fellows@manchester.ac.uk> | 2019-12-29 13:23:47 (GMT) |
| commit | a7a226fc4988c02841c106b4f1a8fd7af2c5a0c2 (patch) | |
| tree | c783d1388a92e98acf68463339f574ad304125b5 /generic/tclOOScript.h | |
| parent | 76c3874ad8500c1db1360a8a80ae1f8040f32448 (diff) | |
| download | tcl-a7a226fc4988c02841c106b4f1a8fd7af2c5a0c2.zip tcl-a7a226fc4988c02841c106b4f1a8fd7af2c5a0c2.tar.gz tcl-a7a226fc4988c02841c106b4f1a8fd7af2c5a0c2.tar.bz2 | |
Property definitions now work on instances.
Diffstat (limited to 'generic/tclOOScript.h')
| -rw-r--r-- | generic/tclOOScript.h | 81 |
1 files changed, 49 insertions, 32 deletions
diff --git a/generic/tclOOScript.h b/generic/tclOOScript.h index b9223ee..8d8dd2a 100644 --- a/generic/tclOOScript.h +++ b/generic/tclOOScript.h @@ -29,7 +29,7 @@ static const char *tclOOSetupScript = "::namespace eval ::oo {\n" "\t::namespace path {}\n" "\tnamespace eval Helpers {\n" -"\t\t::namespace path {}\n" +"\t\tnamespace path {}\n" "\t\tproc callback {method args} {\n" "\t\t\tlist [uplevel 1 {::namespace which my}] $method {*}$args\n" "\t\t}\n" @@ -248,7 +248,7 @@ static const char *tclOOSetupScript = "\t\tsuperclass class\n" "\t\tunexport create createWithNamespace new\n" "\t}\n" -"\tnamespace eval configuresupport {\n" +"\t::namespace eval configuresupport {\n" "\t\tproc PropertyImpl {readslot writeslot args} {\n" "\t\t\tfor {set i 0} {$i < [llength $args]} {incr i} {\n" "\t\t\t\tset prop [lindex $args $i]\n" @@ -316,48 +316,66 @@ static const char *tclOOSetupScript = "\t\t\t}\n" "\t\t}\n" "\t\tnamespace eval configurableclass {\n" -"\t\t\tproc property args {\n" -"\t\t\t\ttailcall ::oo::configuresupport::PropertyImpl \\\n" +"\t\t\t::proc property args {\n" +"\t\t\t\t::tailcall ::oo::configuresupport::PropertyImpl \\\n" "\t\t\t\t\t::oo::configuresupport::readableproperties \\\n" "\t\t\t\t\t::oo::configuresupport::writableproperties {*}$args\n" "\t\t\t}\n" -"\t\t\tnamespace path ::oo::define\n" +"\t\t\t::namespace path ::oo::define\n" +"\t\t\t::namespace export property\n" "\t\t}\n" "\t\tnamespace eval configurableobject {\n" -"\t\t\tproc property args {\n" -"\t\t\t\ttailcall ::oo::configuresupport::PropertyImpl \\\n" +"\t\t\t::proc property args {\n" +"\t\t\t\t::tailcall ::oo::configuresupport::PropertyImpl \\\n" "\t\t\t\t\t::oo::configuresupport::objreadableproperties \\\n" "\t\t\t\t\t::oo::configuresupport::objwritableproperties {*}$args\n" "\t\t\t}\n" -"\t\t\tnamespace path ::oo::objdefine\n" +"\t\t\t::namespace path ::oo::objdefine\n" +"\t\t\t::namespace export property\n" "\t\t}\n" -"\t}\n" -"\tclass create configuresupport::configurable {\n" -"\t\tprivate method Configure:Match {prop kind} {\n" -"\t\t\tset props [info object property [self] -all $kind]\n" -"\t\t\t::tcl::prefix match -message \"property\" $props $prop\n" +"\t\tproc ReadAll {object my} {\n" +"\t\t\tset result {}\n" +"\t\t\tforeach prop [info object property $object -all -readable] {\n" +"\t\t\t\tdict set result $prop [$my <ReadProp$prop>]\n" +"\t\t\t}\n" +"\t\t\treturn $result\n" "\t\t}\n" -"\t\tmethod configure args {\n" -"\t\t\tif {[llength $args] == 0} {\n" -"\t\t\t\tset result {}\n" -"\t\t\t\tforeach prop [info object property [self] -all -readable] {\n" -"\t\t\t\t\tdict set result $prop [my <ReadProp$prop>]\n" +"\t\tproc Match {object propertyName kind} {\n" +"\t\t\tset props [info object property $object -all $kind]\n" +"\t\t\t::tcl::prefix match -message \"property\" $props $propertyName\n" +"\t\t}\n" +"\t\tproc ReadOne {object my propertyName} {\n" +"\t\t\tset prop [Match $object $propertyName -readable]\n" +"\t\t\treturn [$my <ReadProp$prop>]\n" +"\t\t}\n" +"\t\tproc WriteMany {object my setterMap} {\n" +"\t\t\tforeach {prop value} $setterMap {\n" +"\t\t\t\tset prop [Match $object $prop -writable]\n" +"\t\t\t\t$my <WriteProp$prop> $value\n" +"\t\t\t}\n" +"\t\t\treturn\n" +"\t\t}\n" +"\t\t::oo::class create configurable {\n" +"\t\t\tprivate variable my\n" +"\t\t\tmethod configure args {\n" +"\t\t\t\t::if {![::info exists my]} {\n" +"\t\t\t\t\t::set my [::namespace which my]\n" "\t\t\t\t}\n" -"\t\t\t\treturn $result\n" -"\t\t\t} elseif {[llength $args] == 1} {\n" -"\t\t\t\tset prop [my Configure:Match [lindex $args 0] -readable]\n" -"\t\t\t\treturn [my <ReadProp$prop>]\n" -"\t\t\t} elseif {[llength $args] % 2 == 0} {\n" -"\t\t\t\tforeach {prop value} $args {\n" -"\t\t\t\t\tset prop [my Configure:Match $prop -writable]\n" -"\t\t\t\t\tmy <WriteProp$prop> $value\n" +"\t\t\t\t::if {[::llength $args] == 0} {\n" +"\t\t\t\t\t::oo::configuresupport::ReadAll [self] $my\n" +"\t\t\t\t} elseif {[::llength $args] == 1} {\n" +"\t\t\t\t\t::oo::configuresupport::ReadOne [self] $my \\\n" +"\t\t\t\t\t\t[::lindex $args 0]\n" +"\t\t\t\t} elseif {[::llength $args] % 2 == 0} {\n" +"\t\t\t\t\t::oo::configuresupport::WriteMany [self] $my $args\n" +"\t\t\t\t} else {\n" +"\t\t\t\t\t::return -code error -errorcode {TCL WRONGARGS} \\\n" +"\t\t\t\t\t\t[::format {wrong # args: should be \"%s\"} \\\n" +"\t\t\t\t\t\t\t\"[self] configure \?-option value ...\?\"]\n" "\t\t\t\t}\n" -"\t\t\t\treturn\n" -"\t\t\t} else {\n" -"\t\t\t\treturn -code error -errorcode {TCL WRONGARGS} \\\n" -"\t\t\t\t\t[format \"wrong # args: should be \\\"%s\\\"\" \\\n" -"\t\t\t\t\t\t \"[self] configure \?-option value ...\?\"]\n" "\t\t\t}\n" +"\t\t\tdefinitionnamespace -instance configurableobject\n" +"\t\t\tdefinitionnamespace -class configurableclass\n" "\t\t}\n" "\t}\n" "\tclass create configurable {\n" @@ -367,7 +385,6 @@ static const char *tclOOSetupScript = "\t\t\tnext $definitionScript\n" "\t\t}\n" "\t\tdefinitionnamespace -class configuresupport::configurableclass\n" -"\t\tdefinitionnamespace -instance configuresupport::configurableobject\n" "\t}\n" "}\n" /* !END!: Do not edit above this line. */ |
