(self)
return result
Get the contents of a GValue.

        The contents of the GValue are read out as a Python type.
Get the contents of a GValue.
Get the contents of a GValue .
def get(self):
        """Get the contents of a GValue.

        The contents of the GValue are read out as a Python type.
        """

        # logger.debug('GValue.get: self = %s', self)

        gtype = self.gvalue.g_type
        fundamental = gobject_lib.g_type_fundamental(gtype)

        result = None

        if gtype == GValue.gbool_type:
            result = bool(gobject_lib.g_value_get_boolean(self.gvalue))
        elif gtype == GValue.gint_type:
            result = gobject_lib.g_value_get_int(self.gvalue)
        elif gtype == GValue.guint64_type:
            result = gobject_lib.g_value_get_uint64(self.gvalue)
        elif gtype == GValue.gdouble_type:
            result = gobject_lib.g_value_get_double(self.gvalue)
        elif fundamental == GValue.genum_type:
            return GValue.from_enum(gtype,
                                    gobject_lib.g_value_get_enum(self.gvalue))
        elif fundamental == GValue.gflags_type:
            result = gobject_lib.g_value_get_flags(self.gvalue)
        elif gtype == GValue.gstr_type:
            pointer = gobject_lib.g_value_get_string(self.gvalue)

            if pointer != ffi.NULL:
                result = _to_string(pointer)
        elif gtype == GValue.refstr_type:
            psize = ffi.new('size_t *')
            pointer = vips_lib.vips_value_get_ref_string(self.gvalue, psize)

            # psize[0] will be number of bytes in string, but just assume it's
            # NULL-terminated
            result = _to_string(pointer)
        elif gtype == GValue.image_type:
            # g_value_get_object() will not add a ref ... that is
            # held by the gvalue
            go = gobject_lib.g_value_get_object(self.gvalue)
            vi = ffi.cast('VipsImage *', go)

            # we want a ref that will last with the life of the vimage:
            # this ref is matched by the unref that's attached to finalize
            # by Image()
            gobject_lib.g_object_ref(vi)

            result = pyvips.Image(vi)
        elif gtype == GValue.array_int_type:
            pint = ffi.new('int *')
            array = vips_lib.vips_value_get_array_int(self.gvalue, pint)

            result = []
            for i in range(0, pint[0]):
                result.append(array[i])
        elif gtype == GValue.array_double_type:
            pint = ffi.new('int *')
            array = vips_lib.vips_value_get_array_double(self.gvalue, pint)

            result = []
            for i in range(0, pint[0]):
                result.append(array[i])
        elif gtype == GValue.array_image_type:
            pint = ffi.new('int *')
            array = vips_lib.vips_value_get_array_image(self.gvalue, pint)

            result = []
            for i in range(0, pint[0]):
                vi = array[i]
                gobject_lib.g_object_ref(vi)
                image = pyvips.Image(vi)
                result.append(image)
        elif gtype == GValue.blob_type:
            psize = ffi.new('size_t *')
            array = vips_lib.vips_value_get_blob(self.gvalue, psize)
            buf = ffi.cast('char*', array)

            result = ffi.unpack(buf, psize[0])
        else:
            raise Error('unsupported gtype for get {0}'.
                        format(type_name(gtype)))

        return result
def get ( self ) : # logger.debug('GValue.get: self = %s', self) gtype = self . gvalue . g_type fundamental = gobject_lib . g_type_fundamental ( gtype ) result = None if gtype == GValue . gbool_type : result = bool ( gobject_lib . g_value_get_boolean ( self . gvalue ) ) elif gtype == GValue . gint_type : result = gobject_lib . g_value_get_int ( self . gvalue ) elif gtype == GValue . guint64_type : result = gobject_lib . g_value_get_uint64 ( self . gvalue ) elif gtype == GValue . gdouble_type : result = gobject_lib . g_value_get_double ( self . gvalue ) elif fundamental == GValue . genum_type : return GValue . from_enum ( gtype , gobject_lib . g_value_get_enum ( self . gvalue ) ) elif fundamental == GValue . gflags_type : result = gobject_lib . g_value_get_flags ( self . gvalue ) elif gtype == GValue . gstr_type : pointer = gobject_lib . g_value_get_string ( self . gvalue ) if pointer != ffi . NULL : result = _to_string ( pointer ) elif gtype == GValue . refstr_type : psize = ffi . new ( 'size_t *' ) pointer = vips_lib . vips_value_get_ref_string ( self . gvalue , psize ) # psize[0] will be number of bytes in string, but just assume it's # NULL-terminated result = _to_string ( pointer ) elif gtype == GValue . image_type : # g_value_get_object() will not add a ref ... that is # held by the gvalue go = gobject_lib . g_value_get_object ( self . gvalue ) vi = ffi . cast ( 'VipsImage *' , go ) # we want a ref that will last with the life of the vimage: # this ref is matched by the unref that's attached to finalize # by Image() gobject_lib . g_object_ref ( vi ) result = pyvips . Image ( vi ) elif gtype == GValue . array_int_type : pint = ffi . new ( 'int *' ) array = vips_lib . vips_value_get_array_int ( self . gvalue , pint ) result = [ ] for i in range ( 0 , pint [ 0 ] ) : result . append ( array [ i ] ) elif gtype == GValue . array_double_type : pint = ffi . new ( 'int *' ) array = vips_lib . vips_value_get_array_double ( self . gvalue , pint ) result = [ ] for i in range ( 0 , pint [ 0 ] ) : result . append ( array [ i ] ) elif gtype == GValue . array_image_type : pint = ffi . new ( 'int *' ) array = vips_lib . vips_value_get_array_image ( self . gvalue , pint ) result = [ ] for i in range ( 0 , pint [ 0 ] ) : vi = array [ i ] gobject_lib . g_object_ref ( vi ) image = pyvips . Image ( vi ) result . append ( image ) elif gtype == GValue . blob_type : psize = ffi . new ( 'size_t *' ) array = vips_lib . vips_value_get_blob ( self . gvalue , psize ) buf = ffi . cast ( 'char*' , array ) result = ffi . unpack ( buf , psize [ 0 ] ) else : raise Error ( 'unsupported gtype for get {0}' . format ( type_name ( gtype ) ) ) return result