Re: Best way to pass c++ pointer to tcl

On Nov 19, 12:24 am, "thibault.daoulas" <thibault.daou...@xxxxxxxxx>
On Nov 18, 8:30 pm, Alexandre Ferrieux <alexandre.ferri...@xxxxxxxxx>

On Nov 18, 5:08 am, "thibault.daoulas" <thibault.daou...@xxxxxxxxx>

Then, Alexandre, I am not quite aware about if I need a link-level
coupling, but now that you know better my situation, maybe you are
able to tell me ?

Fifteen updates per second is a rate that is within easy reach of the
script level nowadays.
So, the idea is to leave your C part completely inside a separate
process, and do I/O with it from the Tcl side.
For example, if the C part is the interface to some device or
complicated network protocol, and just outputs updates periodically,
you can simply hook a fileevent to its output and read updates as they
If it is more interactive and also needs stimuli from the script, you
can also write to its input.

Bottom line: going to the details of the C-Tcl API is something that
should only be done when "process-level coupling" is too slow for the


If I understand well, the fileevent makes sense when it comes to files
or network sockets, correct me if I'm wrong.

Not files, pipes.

In my case I implemented
a decoder in C, and now I want to implement a renderer that would only
get the pointer to that video data after it has been decompressed by
the codec.

Don't talk about "pointers", talk about what data must cross the
boundaries, and how it is used on either side.
If your decoder is put inside a child process writing to a pipe, it
can simply write binary data chunks (like frames or GOPs or RTP
packets, you choose), that Tcl will happily read from the pipe
whenever they are available. Then what is Tcl supposed to do with the
frame to display it ? If it is a Jpeg image it could be directly
rendered as a Tk image. Otherwise more work may be due. Please give
some details.


The tcl handles seem to do the job, even easier with tclX,
but the point for me (as a newbie, as you may have guessed..) is that
I do not manage to get this pointer from tcl. I indeed create in C and
get from tcl the string representation of my video data, but from tcl,
should I be able to manipulate this string (let's say Video0) directly
as a pointer?
Sorry for maybe obvious questions, but reading docs and newsgroups I
wasn't able to solve my issue.
Otherwise, I am not quite in favor for using swig, since it seems to
cause some linking problems, and that I'm not sure if it suits to a
very frequently updated data (once more, correct me if I'm wrong...).