add a test type

This commit is contained in:
John Cupitt 2012-01-13 12:11:12 +00:00
parent 429c9977d4
commit 23807b5999
2 changed files with 25 additions and 6 deletions

View File

@ -51,7 +51,7 @@ typedef struct _VipsThing {
#define VIPS_TYPE_THING (vips_thing_get_type())
GType vips_thing_get_type( void );
VipsThing *vips_thing_new( int i );
int vips_thing_get_thing( VipsThing *thing );
int vips_thing_get_i( VipsThing *thing );
/* A ref-counted area of memory. Can hold arrays of things as well.
*/

View File

@ -63,28 +63,47 @@
VipsThing *
vips_thing_new( int i )
{
VipsThing *thing = g_new( VipsThing, 1);
VipsThing *thing;
thing = g_new( VipsThing, 1 );
thing->i = i;
printf( "vips_thing_new: %d %p\n", i, thing );
return( thing );
}
VipsThing *
static VipsThing *
vips_thing_copy( VipsThing *thing )
{
return( vips_thing_new( thing->i ) );
VipsThing *thing2;
thing2 = vips_thing_new( thing->i );
printf( "vips_thing_copy: %d %p = %p\n", thing->i, thing2, thing );
return( thing2 );
}
static void
vips_thing_free( VipsThing *thing )
{
printf( "vips_thing_free: %d %p\n", thing->i, thing );
g_free( thing );
}
int
vips_thing_get_thing( VipsThing *thing )
vips_thing_get_i( VipsThing *thing )
{
printf( "vips_thing_get_i: %d %p\n", thing->i, thing );
return( thing->i );
}
G_DEFINE_BOXED_TYPE( VipsThing, vips_thing,
(GBoxedCopyFunc) vips_thing_copy,
(GBoxedFreeFunc) g_free );
(GBoxedFreeFunc) vips_thing_free );
/**