[gst-devel] Re: making Python GStreamer plugins work

muppet scott at asofyet.org
Mon May 2 02:56:13 CEST 2005

On Apr 29, 2005, at 8:53 PM, Benjamin Otte wrote:

> - And here's the crux of the patch and where the most nastiness comes
>   from: Allow classes that are derived in Python to be created with
>   g_object_new from all C code. And handle the refcounting issues, too.
>   It works, but it's ugly. See the patch for implementation details.
> I believe the object creation and destruction process for this kind of
> objects requires some support from GObject to work nicely that  
> currently
> just does not exist.

I don't claim to recall or understand the details of how pygtk creates  
objects, but i don't agree that there's support missing from GObject  
for C-driven creation of instances implemented by a scripting language.

In gtk2-perl, all perl-derived GObject types are created by calling  
Glib::Object::new(), a no-frills wrapper for g_object_new().  The GType  
system does its work, normally, and when it gets to the instance-init  
function for the perl-derived type(s), the standard function for  
marshaling a GObject to perl creates the initial wrapper and bolts it  
to the C object.  This ensures that the wrapper exists in your  
INIT_INSTANCE so you can add data to the instance.

See gperl_new_object() (the wrapper setup and management) and the  
binding for g_object_new() in GObject.xs:

and gperl_type_instance_init() in GType.xs:

gtk2-perl also also supports base-init functions; we originally added  
them to support the GStreamer bindings.  ;-)

See gperl_type_base_init(), also in GType.xs.  It uses a trick with a  
seen-instance hash to make sure we don't base-init the same class on a  
given instance twice.

Don't know if this will be helpful, but it can't hurt to offer.   
Besides, i got several of the ideas from reading pygtk's sources, and  
feel i should give something back.  :-)

(for the uninitiated --- xs is a meta-language that is like a  
combination of python's .defs and .overrides files, with embedded  
documentation and C code snippets.  keywords like CODE and OUTPUT  
expand to a lot of boilerplate that isn't generally very interesting.)

"Ears!  They help us -- Ears!  They help us hear th--  
   -- A Sesame Street singing toy, with Yvonne gleefully pressing
     the button over and over and over and over and...

More information about the gstreamer-devel mailing list