summaryrefslogtreecommitdiffstats
path: root/generic/tclOOScript.h
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2018-07-15 15:46:33 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2018-07-15 15:46:33 (GMT)
commit77aceb5c5fa1c705713e90b474e94be2799f233a (patch)
treed4676ccebddac3e1850e6ddd7c427417b12650e4 /generic/tclOOScript.h
parentd0f8889c8f63ea1c95b2d89ad98354657cf2f10f (diff)
downloadtcl-77aceb5c5fa1c705713e90b474e94be2799f233a.zip
tcl-77aceb5c5fa1c705713e90b474e94be2799f233a.tar.gz
tcl-77aceb5c5fa1c705713e90b474e94be2799f233a.tar.bz2
Added more tests and made [initialize] an alternate spelling for [initialise].
Diffstat (limited to 'generic/tclOOScript.h')
-rw-r--r--generic/tclOOScript.h45
1 files changed, 27 insertions, 18 deletions
diff --git a/generic/tclOOScript.h b/generic/tclOOScript.h
index 4b58337..ffdedb8 100644
--- a/generic/tclOOScript.h
+++ b/generic/tclOOScript.h
@@ -73,21 +73,6 @@ static const char *tclOOSetupScript =
" string cat [info object namespace $class] {:: oo ::delegate}\n"
"}\n"
-"proc ::oo::define::classmethod {name {args {}} {body {}}} {\n"
-" # Create the method on the class if the caller gave arguments and body\n"
-" set argc [llength [info level 0]]\n"
-" if {$argc == 3} {\n"
-" return -code error [string cat {wrong # args: should be \"}"
-" [lindex [info level 0] 0] { name ?args body?\"}]\n"
-" }\n"
-" set cls [uplevel 1 self]\n"
-" if {$argc == 4} {\n"
-" ::oo::define [::oo::DelegateName $cls] method $name $args $body\n"
-" }\n"
-" # Make the connection by forwarding\n"
-" tailcall forward $name myclass $name\n"
-"}\n"
-
"proc ::oo::MixinClassDelegates {class} {\n"
" if {![info object isa class $class]} {\n"
" return\n"
@@ -106,9 +91,33 @@ static const char *tclOOSetupScript =
" ::oo::objdefine $class mixin -append $delegate\n"
"}\n"
-"::proc ::oo::define::initialise {body} {\n"
-" set clsns [info object namespace [uplevel 1 self]]\n"
-" tailcall apply [list {} $body $clsns]\n"
+"::namespace eval ::oo::define {"
+" ::proc classmethod {name {args {}} {body {}}} {\n"
+" # Create the method on the class if the caller gave arguments and body\n"
+" ::set argc [::llength [::info level 0]]\n"
+" ::if {$argc == 3} {\n"
+" ::return -code error [::string cat {wrong # args: should be \"}"
+" [::lindex [::info level 0] 0] { name ?args body?\"}]\n"
+" }\n"
+" ::set cls [::uplevel 1 self]\n"
+" ::if {$argc == 4} {\n"
+" ::oo::define [::oo::DelegateName $cls] method $name $args $body\n"
+" }\n"
+" # Make the connection by forwarding\n"
+" ::tailcall forward $name myclass $name\n"
+" }\n"
+
+" ::proc initialise {body} {\n"
+" ::set clsns [::info object namespace [::uplevel 1 self]]\n"
+" ::tailcall apply [::list {} $body $clsns]\n"
+" }\n"
+
+" # Make the initialise command appear with US spelling too\n"
+" ::namespace export initialise\n"
+" ::namespace eval tmp {::namespace import ::oo::define::initialise}\n"
+" ::rename ::oo::define::tmp::initialise initialize\n"
+" ::namespace delete tmp\n"
+" ::namespace export -clear\n"
"}\n"
"::oo::define ::oo::Slot {\n"