No registered users in community xowiki
in last 10 minutes
in last 10 minutes
[Xotcl] Help: Meta-class and derived Classes
From: Sheik Yussuff <sheik_at_carib-link.net>
Date: Sat, 21 Jul 2001 23:41:17 -0300
Class A is a derived class of meta-class Consultation.
In the filter conFilter I would like to obtain
the class of the object that received the message "m"
when invoking the command: [a m 123]. That is, the
class of the original receiver of method "m".
(Please see code below).
Thanks for any help.
Regards
sheik
.........................................................
#Code:
Class Consultation -superclass Class
Consultation instproc conFilter args {
set method [self calledproc]
#The following is of course not correct!
#[self class] evaluates to Consultation;
#I need it to evaluate to A. Help!!
if {[[self class] info instprocs $method] == ""} {
if { [[self] exists delegate] } {
return [eval [[self] set delegate] $method $args]
}
}
next
}
Consultation instproc init args {
[self] instproc setDelegate {d} {
[self] set delegate $d
}
next
[self] filterappend [self class]::conFilter
}
Consultation A -parameter delegate
A instproc m {x} {
puts "[self] [self class] [self proc] $x"
return [next]
}
Class B
B instproc m {x} {
puts "[self] [self class] [self proc] $x"
return [next]
}
A a
B b
a setDelegate b
# send message m to object a
puts "result = [a m 123]"
Date: Sat, 21 Jul 2001 23:41:17 -0300
Class A is a derived class of meta-class Consultation.
In the filter conFilter I would like to obtain
the class of the object that received the message "m"
when invoking the command: [a m 123]. That is, the
class of the original receiver of method "m".
(Please see code below).
Thanks for any help.
Regards
sheik
.........................................................
#Code:
Class Consultation -superclass Class
Consultation instproc conFilter args {
set method [self calledproc]
#The following is of course not correct!
#[self class] evaluates to Consultation;
#I need it to evaluate to A. Help!!
if {[[self class] info instprocs $method] == ""} {
if { [[self] exists delegate] } {
return [eval [[self] set delegate] $method $args]
}
}
next
}
Consultation instproc init args {
[self] instproc setDelegate {d} {
[self] set delegate $d
}
next
[self] filterappend [self class]::conFilter
}
Consultation A -parameter delegate
A instproc m {x} {
puts "[self] [self class] [self proc] $x"
return [next]
}
Class B
B instproc m {x} {
puts "[self] [self class] [self proc] $x"
return [next]
}
A a
B b
a setDelegate b
# send message m to object a
puts "result = [a m 123]"