Пример #1
0
/* Do "dir". 
 */
static void
apply_dir_call( Reduce *rc, const char *name, HeapNode **arg, PElement *out )
{
	PElement rhs;

        PEPOINTRIGHT( arg[0], &rhs );

	if( PEISCLASS( &rhs ) ) 
		/* This is more complex than it looks. We have to walk a class
		 * instance generating a list of member names, while not
		 * destroying the instance as we go, in the case that out will
		 * overwrite (rhs) arg[0].
		 */
		reduce_safe_pointer( rc, (reduce_safe_pointer_fn) dir_object,
			&rhs, out, NULL, NULL );
	else if( PEISSYMREF( &rhs ) ) {
		Symbol *sym = PEGETSYMREF( &rhs );

		if( is_scope( sym ) && sym->expr && sym->expr->compile ) {
			PElement list;

			list = *out;
			heap_list_init( &list );

			icontainer_map( ICONTAINER( sym->expr->compile ),
				(icontainer_map_fn) dir_scope, rc, &list );
		}
	}
	else if( PEISREAL( &rhs ) ) {
		/* Assume this is a gtype and try to get the children of that
		 * type.
		 */
		GType type = PEGETREAL( &rhs );
		PElement list;

		list = *out;
		heap_list_init( &list );

		if( !g_type_name( type ) ) {
			error_top( _( "No such type" ) );
			error_sub( _( "GType %u not found." ), 
				(unsigned int) type );
			reduce_throw( rc );
		}

		if( vips_type_map( type, dir_gtype, rc, &list ) ) 
			reduce_throw( rc );
	}
	else if( PEISMANAGEDGOBJECT( &rhs ) ) {
		guint n_properties;
		ManagedgobjectClass *class = 
			MANAGEDGOBJECT_GET_CLASS( PEGETMANAGEDGOBJECT( &rhs ) ); 
		GParamSpec **properties;

		properties = g_object_class_list_properties( 
			G_OBJECT_CLASS( class ), &n_properties );
		dir_gobject( rc, properties, n_properties, out );
		g_free( properties);
	}
Пример #2
0
void *
ruby_vips_class_map_all( GType type, VipsClassMap fn, void *a )
{
	void *result;

	if( !G_TYPE_IS_ABSTRACT( type ) ) {
		if( (result = fn( 
			VIPS_OBJECT_CLASS( g_type_class_ref( type ) ), a )) )
			return( result );
	}

	if( (result = vips_type_map( type, 
		(VipsTypeMap2) ruby_vips_class_map_all, fn, a )) )
		return( result );

	return( NULL );
}