gobject-introspection and GBoxed



Hi all,

I'm adding gobject-introspection support to my library. It's working
well for the GObject classes, but I just can't get it to work for
GBoxed objects. I'm sure I'm missing something obvious. Do I need to
write an override to make a class for the type myself?

I've spent some time googling and grepping around and not found a
simple example. Again, I'm probably being stupid.

I'm doing something like this in a header:

/**
 * VIPS_TYPE_BLOB:
 *
 * The %GType for a #VipsBlob.
 */
#define VIPS_TYPE_BLOB (vips_blob_get_type())
GType vips_blob_get_type( void );
typedef ... VipsBlob;
VipsBlob *vips_blob_new( int n );

and this in the .c file:

GType
vips_blob_get_type( void )
{
        static GType type = 0;

        if( !type )
                type = g_boxed_type_register_static( "VipsBlob",
                        (GBoxedCopyFunc) ...,
                        (GBoxedFreeFunc) ... );

        return( type );
}

/**
 * vips_blob_new:
 * @n:
 *
 * Returns: (transfer full): the new #VipsBlob.
 */
VipsBlob *
vips_blob_new( int n )
{
        return (...a new VipsBlob);
}

Now when I start up Python I get this:

>>> from gi.repository import Vips
>>> Vips.blob_new
<function blob_new at 0x7ffff7e31de8>
>>> Vips.blob_new(12)

Program received signal SIGSEGV, Segmentation fault.
_args_cache_generate (callable_cache=0x9b04c0, callable_info=0xa6d280)
    at /build/buildd/pygobject-3.0.0/gi/pygi-cache.c:1282

This is on current Ubuntu, so:

$ pkg-config gobject-introspection-1.0 --modversion
1.30.0

John


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