Changeset 989 for trunk/base
- Timestamp:
- Oct 8, 2002, 12:25:52 AM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/base/src/port1.0/portutil.tcl
r960 r989 931 931 set depspec_vtbl(test) depspec_test 932 932 set depspec_vtbl(run) depspec_run 933 set depspec_vtbl(get) depspec_get 934 set depspec_vtbl(set) depspec_set 935 set depspec_vtbl(has) depspec_has 936 set depspec_vtbl(append) depspec_append 933 937 934 938 # constructor for abstract depspec class … … 953 957 } 954 958 955 # is the only proc to get access to the object's data 956 # so the get/set routines are defined here. this lets 957 # the virtual members get a real "this" object. 959 proc depspec_get {this prop} { 960 set data [$this _data] 961 global $data 962 if {[eval info exists ${data}($prop)]} { 963 eval return $${data}($prop) 964 } else { 965 return "" 966 } 967 } 968 969 proc depspec_set {this prop args} { 970 set data [$this _data] 971 global $data 972 eval set ${data}($prop) $args 973 } 974 975 proc depspec_has {this prop} { 976 set data [$this _data] 977 global $data 978 eval return \[info exists ${data}($prop)\] 979 } 980 981 proc depspec_append {this prop args} { 982 set data [$this _data] 983 global $data 984 set vals [join $args " "] 985 eval lappend ${data}($prop) $vals 986 } 987 988 # is the only proc to get direct access to the object's data 989 # so the _data accessor has to be defined here. all other 990 # methods are looked up in the virtual function table, 991 # and are called with {$this $args}. 958 992 proc depspec_dispatch {this data method args} { 959 993 global $data 960 switch $method { 961 get { 962 set prop [lindex $args 0] 963 if {[eval info exists ${data}($prop)]} { 964 eval return $${data}($prop) 965 } else { 966 return "" 967 } 968 } 969 set { 970 set prop [lindex $args 0] 971 eval "set ${data}($prop) [lrange $args 1 end]" 972 } 973 has { 974 set prop [lindex $args 0] 975 return [info exists ${data}($prop)] 976 } 977 append { 978 set prop [lindex $args 0] 979 set vals [join [lrange $args 1 end] " "] 980 eval "lappend ${data}($prop) $vals" 981 } 982 default { 983 eval set vtbl $${data}(_vtbl) 984 global $vtbl 985 if {[info exists ${vtbl}($method)]} { 994 if {$method == "_data"} { return $data } 995 eval set vtbl $${data}(_vtbl) 996 global $vtbl 997 if {[info exists ${vtbl}($method)]} { 986 998 eval set function $${vtbl}($method) 987 999 eval "return \[$function $this $args\]" 988 1000 } else { 989 1001 ui_error "unknown method: $method" 990 } 991 } 992 } 1002 } 993 1003 return "" 994 1004 }
Note: See TracChangeset
for help on using the changeset viewer.