Thank you, Stefan.
After fiddling around, it seems (at first sight) that the following snippet does the trick:
if {[info command ::nx::methodParameterSlot] ne ""} { ::nx::MethodParameterSlot method type=sourced_guid {name value} { if {![::nsf::is object $value] || [xotcl::Object info instances -closure $value] eq ""} { return -code error "'$value' is not an XOTcl object" } if {![$value istype ::foo::bar::SourcedGuid]} { return -code error "'$value' is not of type SourcedGuid but [$value info class]" } } ::Serializer exportMethods { ::nx::MethodParameterSlot method type=sourced_guid } }
All the best, Michael
PS: For novices the "mixture" of ::nx and ::xotcl is a bit unexpected, for example when serializing ::xotcl::MetaSlot on my OpenACS instance, one can see, that e.g. the superclass of ::xotcl::MetaSlot is ::nx::MetaSlot et cetera. My intuitive expectation was that both XOTcl 2 and NX exist as different languages within NSF, but more or less completely isolated from each other. I suppose the reason is to keep the source code required to support the "legacy" XOTcl syntax as small as possible?
On Wed, Jul 15, 2015 at 1:58 PM, Stefan Sobernig stefan.sobernig@wu.ac.at wrote:
Hi Michael!
What is the correct way to port this to XOTcl 2.0?
This is most likely not an authoritative answer, I don't have the time right now to think this through properly. The following should get you going for the time being:
if {[info command ::nx::methodParameterSlot] ne ""} { ::nx::methodParameterSlot object method type=sourced_guid {name value args} { if {![::nsf::is object $value] || [xotcl::Object info instances -closure $value] eq ""} { error "'$value' is not an XOTcl object" } if {![$value istype ::foo::bar::SourcedGuid]} { error "'$value' is not of type SourcedGuid but [$value info class]" } } }
If you plan to co-maintain two code bases (one compatible with 1.6 and the other for 2+), then you might want to consider factoring out the value checker into a plain Tcl proc and forward/alias to this proc conditionally from ::xotcl::nonposArgs and ::nx::methodParameterSlot, respectively.
I leave this as an exercise to you ;)
Let me know whether the above works for you for the time being.
Cheers, Stefan
P.S.: I suggest using "return -code error" in your value checker to skip one level on the callstack trace reported to the developer, to hide the details of the value checker in the reported trace.