mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 09:23:24 +00:00
app, libgimp*, pdb, plug-ins: first step to make int32array PDB type aware of its length.
PDB code is now looking directly into the GimpArray length for determining the data length. Also adding a 'size' argument (number of elements, not bytes) to gimp_value_(get|dup)_int32_array() to make it actually introspectable. Until now, it was somehow introspected but was segfaulting on run. I.e. that, e.g. in Python, calling Gimp.value_set_int32_array(v, [1, 2, 3]) followed by Gimp.value_get_int32_array(v) would actually make a segmentation fault. Now the binding works flawlessly. This will also make these functions much more usable in general.
This commit is contained in:
parent
87d3d921da
commit
60eb27ab18
10 changed files with 59 additions and 19 deletions
|
@ -528,32 +528,54 @@ gimp_param_spec_int32_array (const gchar *name,
|
|||
/**
|
||||
* gimp_value_get_int32_array:
|
||||
* @value: A valid value of type %GIMP_TYPE_INT32_ARRAY
|
||||
* @length: the number of returned #int32 elements.
|
||||
*
|
||||
* Gets the contents of a %GIMP_TYPE_INT32_ARRAY #GValue
|
||||
*
|
||||
* Returns: (transfer none) (array): The contents of @value
|
||||
* Returns: (transfer none) (array length=length): The contents of @value
|
||||
*/
|
||||
const gint32 *
|
||||
gimp_value_get_int32_array (const GValue *value)
|
||||
gimp_value_get_int32_array (const GValue *value,
|
||||
gsize *length)
|
||||
{
|
||||
GimpArray *array;
|
||||
|
||||
g_return_val_if_fail (GIMP_VALUE_HOLDS_INT32_ARRAY (value), NULL);
|
||||
|
||||
array = value->data[0].v_pointer;
|
||||
|
||||
g_return_val_if_fail (array->length % sizeof (gint32) == 0, NULL);
|
||||
|
||||
if (length)
|
||||
*length = array->length / sizeof (gint32);
|
||||
|
||||
return (const gint32 *) gimp_value_get_array (value);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_value_dup_int32_array:
|
||||
* @value: A valid value of type %GIMP_TYPE_INT32_ARRAY
|
||||
* @length: the number of returned #int32 elements.
|
||||
*
|
||||
* Gets the contents of a %GIMP_TYPE_INT32_ARRAY #GValue
|
||||
*
|
||||
* Returns: (transfer full) (array): The contents of @value
|
||||
* Returns: (transfer full) (array length=length): The contents of @value
|
||||
*/
|
||||
gint32 *
|
||||
gimp_value_dup_int32_array (const GValue *value)
|
||||
gimp_value_dup_int32_array (const GValue *value,
|
||||
gsize *length)
|
||||
{
|
||||
GimpArray *array;
|
||||
|
||||
g_return_val_if_fail (GIMP_VALUE_HOLDS_INT32_ARRAY (value), NULL);
|
||||
|
||||
array = value->data[0].v_pointer;
|
||||
|
||||
g_return_val_if_fail (array->length % sizeof (gint32) == 0, NULL);
|
||||
|
||||
if (length)
|
||||
*length = array->length / sizeof (gint32);
|
||||
|
||||
return (gint32 *) gimp_value_dup_array (value);
|
||||
}
|
||||
|
||||
|
|
|
@ -239,8 +239,10 @@ GParamSpec * gimp_param_spec_int32_array (const gchar *name,
|
|||
const gchar *blurb,
|
||||
GParamFlags flags);
|
||||
|
||||
const gint32 * gimp_value_get_int32_array (const GValue *value);
|
||||
gint32 * gimp_value_dup_int32_array (const GValue *value);
|
||||
const gint32 * gimp_value_get_int32_array (const GValue *value,
|
||||
gsize *length);
|
||||
gint32 * gimp_value_dup_int32_array (const GValue *value,
|
||||
gsize *length);
|
||||
void gimp_value_set_int32_array (GValue *value,
|
||||
const gint32 *data,
|
||||
gsize length);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue