Re: piping from external program not working..

On Fri, Jun 04, 2004 at 16:38:03 -0400, muppet wrote:

On Friday, June 4, 2004, at 03:18 PM, Jan Hudec wrote:

I really wish perl IO descriptors had a 'buffer' method. It would 
return the internal buffer as a (read-only) string. Then we could have 
Glib::IO watchers properly generating 'in' event when the perlio 
descriptor (not the underlying file) have some data to read!

the old gtk-perl used some interesting MAGIC vtable tricks to allow 
subs to be called whenever a scalar is changed.  perhaps we should 
modify Glib::IO::add_watch() to use a similar mechanism?

The vtable MAGIC was about the scalars. The interface to glib is not
magic at all. And for watching perlio objects, you don't need the vtable

On the glib side, it means to implement an object based on GSource
structure. It has a "vtable" GSourceFuncs with four functions --
prepare, check, dispatch and finalize.

prepare is called before poll. It must look whether there are data in
the buffer. This is actualy the hardest part, at least for me, since
I don't understand internals of perlio. prepare returns true if the
source is ready (buffer not empty).

check is called after poll and gets it's results. It should return true
if it now knows the source is ready.

dispatch is a marshaller. It is there to create argument list
appropriate for this source type.

finalize is a destructor.

                                                 Jan 'Bulb' Hudec <bulb ucw cz>

Attachment: signature.asc
Description: Digital signature

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]