Clone
Gustaf Neumann <neumann@wu-wien.ac.at>
committed
on 05 Mar 11
- serializer: catch for object-level alias apparently not needed anymore (search for ns_cache_flush) - silence compilation when compiled w… Show more
- serializer: catch for object-level alias apparently   not needed anymore (search for ns_cache_flush) - silence compilation when compiled without dtrace

Show less

library/nx/nx.tcl (+9 -4)
200 200         # It would be much easier, to do a
201 201         #
202 202         #    return [:object-$what {*}$args]
203 203         #
204 204         # here. However, since we removed "object-mixin" and friends
205 205         # from the registered methods, we have to emulate the work of
206 206         # the forwarder.
207 207         #
208 208         switch [llength $args] {
209 209           0 {return [::nsf::relation [::nsf::self] object-$what]}
210 210           1 {return [::nsf::relation [::nsf::self] object-$what {*}$args]}
211 211           default {return [::nx::Object::slot::$what [lindex $args 0] \
212 212                                [::nsf::self] object-$what \
213 213                                {*}[lrange $args 1 end]]
214 214           }
215 215         }
216 216       }
217 217       if {$what in [list "filterguard" "mixinguard"]} {
218 218         return [::nsf::dispatch [::nsf::self] ::nsf::methods::object::$what {*}$args]
219 219       }
  220       error "'$what' not allowed to be modified by 'class-object'"
220 221     }
221 222     # define unknown handler for class
222 223     :method unknown {m args} {
223 224       error "Method '$m' unknown for [::nsf::self].\
224 225         Consider '[::nsf::self] create $m $args' instead of '[::nsf::self] $m $args'"
225 226     }
226 227     # protected is not yet defined
227 228     ::nsf::method::property [::nsf::self] unknown call-protected true
228 229   }
229 230
  231   # Well, class-object is not a method defining method either, but a modifier
  232   array set ::nsf::methodDefiningMethod {method 1 alias 1 attribute 1 forward 1 class-object 1}
230 233
231 234   Object eval {
232 235
233 236     # method modifier "public"
234 237     :method public {args} {
235         set p [lsearch -regexp $args {^(method|alias|attribute|forward)$}]
236         if {$p == -1} {error "$args is not a method defining method"}
  238       if {![info exists ::nsf::methodDefiningMethod([lindex $args 0])]} {
  239         error "'[lindex $args 0]' is not a method defining method"
  240       }
237 241       set r [::nsf::dispatch [::nsf::current object] {*}$args]
238 242       if {$r ne ""} {::nsf::method::property [::nsf::self] $r call-protected false}
239 243       return $r
240 244     }
241 245
242 246     # method modifier "protected"
243 247     :method protected {args} {
244         set p [lsearch -regexp $args {^(method|alias|attribute|forward)$}]
245         if {$p == -1} {error "$args is not a method defining command"}
  248       if {![info exists ::nsf::methodDefiningMethod([lindex $args 0])]} {
  249         error "'[lindex $args 0]' is not a method defining method"
  250       }
246 251       set r [{*}:$args]
247 252       if {$r ne ""} {::nsf::method::property [::nsf::self] $r call-protected true}
248 253       return $r
249 254     }
250 255   }
251 256
252 257   Object eval {
253 258
254 259     # Default unknown-handler for Object
255 260     #
256 261     # Actually, we do not need this unknown handler, but we could
257 262     # define it as follows:
258 263     #
259 264     # :protected method unknown {m args} {
260 265     #   error "[::nsf::self]: unable to dispatch method '$m'"
261 266     # }
262 267    
263 268     # "init" must exist on Object. per default it is empty.
264 269     :protected method init args {}
265 270