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



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



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

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
come.
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
job.

-Alex

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.

-Alex

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...).

.



Relevant Pages

  • Re: Best way to pass c++ pointer to tcl
    ... script level nowadays. ... and do I/O with it from the Tcl side. ... should only be done when "process-level coupling" is too slow for the ... I do not manage to get this pointer from tcl. ...
    (comp.lang.tcl)
  • Re: Obstacles for Tcl/Tk commercial application development ?
    ... And once I put an integer into a variable in Tcl, it stays an integer until I assign something else to that variable. ... Usually, when I code, I know the language well enough to know what types the expressions return, so I don't wind up with the wrong types in variables. ... It takes a char* as the second argument, not a pointer to the structure you're trying to write out. ... If I expect my code to pass me an open file handle, and I pass that argument to and it throws, I'm going to catch that error at the top level, log the stack trace back, clean up, and restart the processing. ...
    (comp.lang.tcl)
  • ANN: Maybe package for handling unknown data
    ... I hereby present the "maybe" package for Tcl that provides complete support for handling missing/unknown data in much the same way as a NULL pointer does in C, ...
    (comp.lang.tcl)
  • Re: Why this fix work ?
    ... Now you have initialized all 64 bits of "myobj", ... So basically what you and Chris say is that after the TCL function ... TCL is that, the data is in memory, the interface passes an integer ... pointer to C code, that pointer points to the memory location of the ...
    (comp.lang.c)
  • Tcl 8.5 HP/UX Compiler warnings
    ... CVS access, and many packages don't have up to date release files, ... I encountered a bunch of warnings in the Tcl compilation step, ... incorrect argument type, pointer assignment incompatlible, illegal ... The C compiler is HP's optional ANSI C compiler. ...
    (comp.lang.tcl)