mirror of https://github.com/GNOME/gimp.git
added deserialization of GValueArrays (untested). Added
2002-05-24 Michael Natterer <mitch@gimp.org> * app/config/gimpconfig-deserialize.c: added deserialization of GValueArrays (untested). Added gimp_config_deserialize_value() which is factored out from gimp_config_deserialize_property().
This commit is contained in:
parent
e9d0daff72
commit
40caeab174
|
@ -1,3 +1,9 @@
|
|||
2002-05-24 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/config/gimpconfig-deserialize.c: added deserialization of
|
||||
GValueArrays (untested). Added gimp_config_deserialize_value()
|
||||
which is factored out from gimp_config_deserialize_property().
|
||||
|
||||
2002-05-24 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/FractalExplorer/Dialogs.c
|
||||
|
|
|
@ -54,6 +54,10 @@ static GTokenType gimp_config_deserialize_unknown (GObject *object,
|
|||
GScanner *scanner);
|
||||
static GTokenType gimp_config_deserialize_property (GObject *object,
|
||||
GScanner *scanner);
|
||||
static GTokenType gimp_config_deserialize_value (GValue *value,
|
||||
GObject *object,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner);
|
||||
static GTokenType gimp_config_deserialize_fundamental (GValue *value,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner);
|
||||
|
@ -70,6 +74,10 @@ static GTokenType gimp_config_deserialize_path (GValue *value,
|
|||
static GTokenType gimp_config_deserialize_color (GValue *value,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner);
|
||||
static GTokenType gimp_config_deserialize_value_array (GValue *value,
|
||||
GObject *object,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner);
|
||||
static GTokenType gimp_config_deserialize_any (GValue *value,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner);
|
||||
|
@ -235,32 +243,9 @@ gimp_config_deserialize_property (GObject *object,
|
|||
{
|
||||
/* nop */
|
||||
}
|
||||
else if (G_TYPE_FUNDAMENTAL (prop_spec->value_type) == G_TYPE_ENUM)
|
||||
{
|
||||
token = gimp_config_deserialize_enum (&value, prop_spec, scanner);
|
||||
}
|
||||
else if (G_TYPE_IS_FUNDAMENTAL (prop_spec->value_type))
|
||||
{
|
||||
token = gimp_config_deserialize_fundamental (&value, prop_spec, scanner);
|
||||
}
|
||||
else if (prop_spec->value_type == GIMP_TYPE_MEMSIZE)
|
||||
{
|
||||
token = gimp_config_deserialize_memsize (&value, prop_spec, scanner);
|
||||
}
|
||||
else if (prop_spec->value_type == GIMP_TYPE_PATH)
|
||||
{
|
||||
token = gimp_config_deserialize_path (&value,
|
||||
object, prop_spec, scanner);
|
||||
}
|
||||
else if (prop_spec->value_type == GIMP_TYPE_COLOR)
|
||||
{
|
||||
token = gimp_config_deserialize_color (&value, prop_spec, scanner);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This fallback will only work for value_types that */
|
||||
/* can be transformed from a string value. */
|
||||
token = gimp_config_deserialize_any (&value, prop_spec, scanner);
|
||||
token = gimp_config_deserialize_value (&value, object, prop_spec, scanner);
|
||||
}
|
||||
|
||||
if (token == G_TOKEN_RIGHT_PAREN &&
|
||||
|
@ -283,6 +268,45 @@ gimp_config_deserialize_property (GObject *object,
|
|||
return token;
|
||||
}
|
||||
|
||||
static GTokenType
|
||||
gimp_config_deserialize_value (GValue *value,
|
||||
GObject *object,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner)
|
||||
{
|
||||
if (G_TYPE_FUNDAMENTAL (prop_spec->value_type) == G_TYPE_ENUM)
|
||||
{
|
||||
return gimp_config_deserialize_enum (value, prop_spec, scanner);
|
||||
}
|
||||
else if (G_TYPE_IS_FUNDAMENTAL (prop_spec->value_type))
|
||||
{
|
||||
return gimp_config_deserialize_fundamental (value, prop_spec, scanner);
|
||||
}
|
||||
else if (prop_spec->value_type == GIMP_TYPE_MEMSIZE)
|
||||
{
|
||||
return gimp_config_deserialize_memsize (value, prop_spec, scanner);
|
||||
}
|
||||
else if (prop_spec->value_type == GIMP_TYPE_PATH)
|
||||
{
|
||||
return gimp_config_deserialize_path (value,
|
||||
object, prop_spec, scanner);
|
||||
}
|
||||
else if (prop_spec->value_type == GIMP_TYPE_COLOR)
|
||||
{
|
||||
return gimp_config_deserialize_color (value, prop_spec, scanner);
|
||||
}
|
||||
else if (prop_spec->value_type == G_TYPE_VALUE_ARRAY)
|
||||
{
|
||||
return gimp_config_deserialize_value_array (value,
|
||||
object, prop_spec, scanner);
|
||||
}
|
||||
|
||||
/* This fallback will only work for value_types that
|
||||
* can be transformed from a string value.
|
||||
*/
|
||||
return gimp_config_deserialize_any (value, prop_spec, scanner);
|
||||
}
|
||||
|
||||
static GTokenType
|
||||
gimp_config_deserialize_fundamental (GValue *value,
|
||||
GParamSpec *prop_spec,
|
||||
|
@ -580,6 +604,50 @@ gimp_config_deserialize_color (GValue *value,
|
|||
return token;
|
||||
}
|
||||
|
||||
static GTokenType
|
||||
gimp_config_deserialize_value_array (GValue *value,
|
||||
GObject *object,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner)
|
||||
{
|
||||
GParamSpecValueArray *array_spec;
|
||||
GValueArray *array;
|
||||
GValue array_value = { 0, };
|
||||
gint n_values;
|
||||
GTokenType token;
|
||||
gint i;
|
||||
|
||||
array_spec = G_PARAM_SPEC_VALUE_ARRAY (prop_spec);
|
||||
|
||||
if (g_scanner_peek_next_token (scanner) != G_TOKEN_INT)
|
||||
return G_TOKEN_INT;
|
||||
|
||||
g_scanner_get_next_token (scanner);
|
||||
n_values = scanner->value.v_int;
|
||||
|
||||
array = g_value_array_new (n_values);
|
||||
|
||||
for (i = 0; i < n_values; i++)
|
||||
{
|
||||
g_value_init (&array_value, array_spec->element_spec->value_type);
|
||||
|
||||
token = gimp_config_deserialize_value (&array_value,
|
||||
object,
|
||||
array_spec->element_spec,
|
||||
scanner);
|
||||
|
||||
if (token == G_TOKEN_RIGHT_PAREN)
|
||||
g_value_array_append (array, &array_value);
|
||||
|
||||
g_value_unset (&array_value);
|
||||
|
||||
if (token != G_TOKEN_RIGHT_PAREN)
|
||||
return token;
|
||||
}
|
||||
|
||||
return G_TOKEN_RIGHT_PAREN;
|
||||
}
|
||||
|
||||
static GTokenType
|
||||
gimp_config_deserialize_any (GValue *value,
|
||||
GParamSpec *prop_spec,
|
||||
|
|
|
@ -54,6 +54,10 @@ static GTokenType gimp_config_deserialize_unknown (GObject *object,
|
|||
GScanner *scanner);
|
||||
static GTokenType gimp_config_deserialize_property (GObject *object,
|
||||
GScanner *scanner);
|
||||
static GTokenType gimp_config_deserialize_value (GValue *value,
|
||||
GObject *object,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner);
|
||||
static GTokenType gimp_config_deserialize_fundamental (GValue *value,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner);
|
||||
|
@ -70,6 +74,10 @@ static GTokenType gimp_config_deserialize_path (GValue *value,
|
|||
static GTokenType gimp_config_deserialize_color (GValue *value,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner);
|
||||
static GTokenType gimp_config_deserialize_value_array (GValue *value,
|
||||
GObject *object,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner);
|
||||
static GTokenType gimp_config_deserialize_any (GValue *value,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner);
|
||||
|
@ -235,32 +243,9 @@ gimp_config_deserialize_property (GObject *object,
|
|||
{
|
||||
/* nop */
|
||||
}
|
||||
else if (G_TYPE_FUNDAMENTAL (prop_spec->value_type) == G_TYPE_ENUM)
|
||||
{
|
||||
token = gimp_config_deserialize_enum (&value, prop_spec, scanner);
|
||||
}
|
||||
else if (G_TYPE_IS_FUNDAMENTAL (prop_spec->value_type))
|
||||
{
|
||||
token = gimp_config_deserialize_fundamental (&value, prop_spec, scanner);
|
||||
}
|
||||
else if (prop_spec->value_type == GIMP_TYPE_MEMSIZE)
|
||||
{
|
||||
token = gimp_config_deserialize_memsize (&value, prop_spec, scanner);
|
||||
}
|
||||
else if (prop_spec->value_type == GIMP_TYPE_PATH)
|
||||
{
|
||||
token = gimp_config_deserialize_path (&value,
|
||||
object, prop_spec, scanner);
|
||||
}
|
||||
else if (prop_spec->value_type == GIMP_TYPE_COLOR)
|
||||
{
|
||||
token = gimp_config_deserialize_color (&value, prop_spec, scanner);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This fallback will only work for value_types that */
|
||||
/* can be transformed from a string value. */
|
||||
token = gimp_config_deserialize_any (&value, prop_spec, scanner);
|
||||
token = gimp_config_deserialize_value (&value, object, prop_spec, scanner);
|
||||
}
|
||||
|
||||
if (token == G_TOKEN_RIGHT_PAREN &&
|
||||
|
@ -283,6 +268,45 @@ gimp_config_deserialize_property (GObject *object,
|
|||
return token;
|
||||
}
|
||||
|
||||
static GTokenType
|
||||
gimp_config_deserialize_value (GValue *value,
|
||||
GObject *object,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner)
|
||||
{
|
||||
if (G_TYPE_FUNDAMENTAL (prop_spec->value_type) == G_TYPE_ENUM)
|
||||
{
|
||||
return gimp_config_deserialize_enum (value, prop_spec, scanner);
|
||||
}
|
||||
else if (G_TYPE_IS_FUNDAMENTAL (prop_spec->value_type))
|
||||
{
|
||||
return gimp_config_deserialize_fundamental (value, prop_spec, scanner);
|
||||
}
|
||||
else if (prop_spec->value_type == GIMP_TYPE_MEMSIZE)
|
||||
{
|
||||
return gimp_config_deserialize_memsize (value, prop_spec, scanner);
|
||||
}
|
||||
else if (prop_spec->value_type == GIMP_TYPE_PATH)
|
||||
{
|
||||
return gimp_config_deserialize_path (value,
|
||||
object, prop_spec, scanner);
|
||||
}
|
||||
else if (prop_spec->value_type == GIMP_TYPE_COLOR)
|
||||
{
|
||||
return gimp_config_deserialize_color (value, prop_spec, scanner);
|
||||
}
|
||||
else if (prop_spec->value_type == G_TYPE_VALUE_ARRAY)
|
||||
{
|
||||
return gimp_config_deserialize_value_array (value,
|
||||
object, prop_spec, scanner);
|
||||
}
|
||||
|
||||
/* This fallback will only work for value_types that
|
||||
* can be transformed from a string value.
|
||||
*/
|
||||
return gimp_config_deserialize_any (value, prop_spec, scanner);
|
||||
}
|
||||
|
||||
static GTokenType
|
||||
gimp_config_deserialize_fundamental (GValue *value,
|
||||
GParamSpec *prop_spec,
|
||||
|
@ -580,6 +604,50 @@ gimp_config_deserialize_color (GValue *value,
|
|||
return token;
|
||||
}
|
||||
|
||||
static GTokenType
|
||||
gimp_config_deserialize_value_array (GValue *value,
|
||||
GObject *object,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner)
|
||||
{
|
||||
GParamSpecValueArray *array_spec;
|
||||
GValueArray *array;
|
||||
GValue array_value = { 0, };
|
||||
gint n_values;
|
||||
GTokenType token;
|
||||
gint i;
|
||||
|
||||
array_spec = G_PARAM_SPEC_VALUE_ARRAY (prop_spec);
|
||||
|
||||
if (g_scanner_peek_next_token (scanner) != G_TOKEN_INT)
|
||||
return G_TOKEN_INT;
|
||||
|
||||
g_scanner_get_next_token (scanner);
|
||||
n_values = scanner->value.v_int;
|
||||
|
||||
array = g_value_array_new (n_values);
|
||||
|
||||
for (i = 0; i < n_values; i++)
|
||||
{
|
||||
g_value_init (&array_value, array_spec->element_spec->value_type);
|
||||
|
||||
token = gimp_config_deserialize_value (&array_value,
|
||||
object,
|
||||
array_spec->element_spec,
|
||||
scanner);
|
||||
|
||||
if (token == G_TOKEN_RIGHT_PAREN)
|
||||
g_value_array_append (array, &array_value);
|
||||
|
||||
g_value_unset (&array_value);
|
||||
|
||||
if (token != G_TOKEN_RIGHT_PAREN)
|
||||
return token;
|
||||
}
|
||||
|
||||
return G_TOKEN_RIGHT_PAREN;
|
||||
}
|
||||
|
||||
static GTokenType
|
||||
gimp_config_deserialize_any (GValue *value,
|
||||
GParamSpec *prop_spec,
|
||||
|
|
Loading…
Reference in New Issue