[cable] Re: [Insight-developers] Re: Tcl Wrapped ImageGaussianFilter & Questions

Brad King brad.king at kitware.com
Wed Oct 31 10:02:27 EST 2001


Luis,

> be taken to avoid the ending ">" of templates declarations to be side
> by side and create the ">>" token.
This is an easy fix in CMake's CABLE_CLASS_SET command.  I'll make it and
check it in when I get a chance.

> I couldn't use the tags anymore when using the CLASS_SETs...
> is there a different way to do it ?
>     CABLE_CLASS_SET(ImageType "itk::Image<char,3>")
>     CABLE_WRAP_TCL( ImageTcl
>       "myImageType:$ImageType;itkImage.h")
The idea of the [tag:] syntax is to allow you to specify a tag for an
entry's portion of the tag in case one can't be auto-generated.  The real
tag will still have any tags concatenated that come from the referecned
class sets.

> The notation
>   $size SetSize { 100 160 }
> didn't work for me, Tcl looked for a method of signature
>   "SetSize( char*)"
That's strange, it has always worked for me since I added the magical
conversion features.  Can you send an example script that fails, please?

> How can I use "std::cout"  ?
> should I ask cable to wrap the class too ?
I have been working on a class that uses std::ostrstream to let you pass
an object to any std::ostream& argument and ask for the string that it got
back in Tcl.  However, there seems to be some kind of threading problem
with using ostrstream in a Tcl application, and it hangs on an infinite
mutex wait.  Once I have solved this problem or hacked in a work-around,
then you should be able to write code like this:

set s [itk::StringStream]
$obj PrintSelf $s
puts [$s str]

I've also thought about a special string stream class that knows about the
Tcl interpreter and sets the Tcl result to the string value in its
destructor.  This would allow code like this:

$obj PrintSelf [itk::StringStreamTcl [wrap::Interpreter]]

or to hide the wrap::Interpreter call:

proc tclStringStream {} {
  return [itk::StringStreamTcl [wrap::Interpreter]]
}

$obj PrintSelf [tclStringStream]

This could create a string stream that gets passed to the PrintSelf
method.  When the method returns, the Tcl result will have the return
value to PrintSelf, except that the cleanup code after the call will
destroy the temporary instance of itk::StringStreamTcl, which will cause
the Tcl result to be overwritten with the string collected by the string
stream.  This approach still has the same threading problem with
ostrstream right now, though.

-Brad




More information about the cable mailing list