No registered users in community xowiki
in last 10 minutes
in last 10 minutes
[Xotcl] XOTcl, threading and AOLserver ?
From: Gustaf Neumann <Gustaf.Neumann_at_wu-wien.ac.at>
Date: Thu, 16 Nov 2000 19:31:09 +0100 (CET)
>>>>> "Zoran" == Zoran Vasiljevic <zoran_at_munich.com> writes:
Zoran> Hi !
Zoran> First of all, I'm very excited about XOTcl ! I think
Zoran> you did an excellent job.
Zoran> ...
Zoran> Question 2: <read on>
Zoran> Having nice introspection capabilities built into the
Zoran> XOTcl, I wonder if one can write a Tcl script which
Zoran> runs against the initialized interpreter and builds up
Zoran> a script needed to re-construct all classes and/or object
Zoran> which it finds there (in the interpreter)?
Zoran> Why should one need this ?
Zoran> Well, the AOLserver webserver which we use is a little bit
Zoran> special. It sources initialization files in startup thread/interp
Zoran> and then runs a series of scripts to get the interpreter
Zoran> blue-print. This blue-print (in form of Tcl-code) is then
Zoran> ran against each newly created interpreter. This is to
Zoran> simplify and speed-up of new interpreter(s) initialization.
Zoran> In order to use XOTcl in AOLserver, one should be able to
Zoran> produce such a script programatically.
Zoran> For plain Tcl code, this is no big deal. I think XOTcl would
Zoran> not pose any problem, but nevertheless, it's better to ask.
Zoran> Any comments ?
Hi Zoran,
there are no such problems, it is indeed quite easy to reproduce
a script from Objects and classes. Here is a simple script for
object serialization that you might use as an starting point. Class
serialization works very similar...
best regards
-gustaf
===========================================================================
Object instproc serialize {} {
::set o [self]
if {![Object isobject $o]} { error "$o is not an object" }
::append cmd [list [$o info class] $o] \n
foreach i [$o info procs] {
::append cmd [list $o proc $i [$o info args $i] [$o info body $i]] \n
}
foreach v [$o info vars] {
if {[string match __* $v]} continue ;# internal variables
if {[$o array exists $v]} {
::append cmd [list $o array set $v [$o array get $v]] \n
} else {
::append cmd [list $o set $v [$o set $v]] \n
}
}
::append cmd [list $o mixin [$o info mixin]] \n
foreach child [[self] info children] {
::append cmd [$child serialize] \n
}
return $cmd
}
Object o1
o1 set var1 100
o1 set var2 "hi there"
o1 set price(potato) 10
o1 set price(tomato) 20
o1 proc test {a b} {
puts "a=$a, b=$b"
}
Object o1::x
o1::x set y 100
puts --------------------
puts [o1 serialize]
puts --------------------
===========================================================================
Date: Thu, 16 Nov 2000 19:31:09 +0100 (CET)
>>>>> "Zoran" == Zoran Vasiljevic <zoran_at_munich.com> writes:
Zoran> Hi !
Zoran> First of all, I'm very excited about XOTcl ! I think
Zoran> you did an excellent job.
Zoran> ...
Zoran> Question 2: <read on>
Zoran> Having nice introspection capabilities built into the
Zoran> XOTcl, I wonder if one can write a Tcl script which
Zoran> runs against the initialized interpreter and builds up
Zoran> a script needed to re-construct all classes and/or object
Zoran> which it finds there (in the interpreter)?
Zoran> Why should one need this ?
Zoran> Well, the AOLserver webserver which we use is a little bit
Zoran> special. It sources initialization files in startup thread/interp
Zoran> and then runs a series of scripts to get the interpreter
Zoran> blue-print. This blue-print (in form of Tcl-code) is then
Zoran> ran against each newly created interpreter. This is to
Zoran> simplify and speed-up of new interpreter(s) initialization.
Zoran> In order to use XOTcl in AOLserver, one should be able to
Zoran> produce such a script programatically.
Zoran> For plain Tcl code, this is no big deal. I think XOTcl would
Zoran> not pose any problem, but nevertheless, it's better to ask.
Zoran> Any comments ?
Hi Zoran,
there are no such problems, it is indeed quite easy to reproduce
a script from Objects and classes. Here is a simple script for
object serialization that you might use as an starting point. Class
serialization works very similar...
best regards
-gustaf
===========================================================================
Object instproc serialize {} {
::set o [self]
if {![Object isobject $o]} { error "$o is not an object" }
::append cmd [list [$o info class] $o] \n
foreach i [$o info procs] {
::append cmd [list $o proc $i [$o info args $i] [$o info body $i]] \n
}
foreach v [$o info vars] {
if {[string match __* $v]} continue ;# internal variables
if {[$o array exists $v]} {
::append cmd [list $o array set $v [$o array get $v]] \n
} else {
::append cmd [list $o set $v [$o set $v]] \n
}
}
::append cmd [list $o mixin [$o info mixin]] \n
foreach child [[self] info children] {
::append cmd [$child serialize] \n
}
return $cmd
}
Object o1
o1 set var1 100
o1 set var2 "hi there"
o1 set price(potato) 10
o1 set price(tomato) 20
o1 proc test {a b} {
puts "a=$a, b=$b"
}
Object o1::x
o1::x set y 100
puts --------------------
puts [o1 serialize]
puts --------------------
===========================================================================