2005-01-29 20:54:48 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
|
2001-11-27 11:52:11 +08:00
|
|
|
*
|
|
|
|
* Object properties deserialization routines
|
2002-03-24 01:58:57 +08:00
|
|
|
* Copyright (C) 2001-2002 Sven Neumann <sven@gimp.org>
|
2001-11-27 11:52:11 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2007-03-02 16:38:13 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-18 06:28:01 +08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2001-11-27 11:52:11 +08:00
|
|
|
*
|
2007-03-02 16:38:13 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2001-11-27 11:52:11 +08:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-03-02 16:38:13 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
2001-11-27 11:52:11 +08:00
|
|
|
*
|
2007-03-02 16:38:13 +08:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-01-18 06:28:01 +08:00
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
2001-11-27 11:52:11 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2011-04-28 21:50:39 +08:00
|
|
|
#include <cairo.h>
|
2001-11-27 11:52:11 +08:00
|
|
|
#include <glib-object.h>
|
|
|
|
|
2002-05-22 01:33:04 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2002-05-21 23:01:57 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2003-07-08 00:22:45 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2002-05-21 23:01:57 +08:00
|
|
|
|
2005-01-26 04:30:20 +08:00
|
|
|
#include "gimpconfigtypes.h"
|
|
|
|
|
2005-01-26 03:11:26 +08:00
|
|
|
#include "gimpconfigwriter.h"
|
|
|
|
#include "gimpconfig-iface.h"
|
2001-11-27 11:52:11 +08:00
|
|
|
#include "gimpconfig-deserialize.h"
|
2002-05-22 01:33:04 +08:00
|
|
|
#include "gimpconfig-params.h"
|
2002-12-30 02:58:24 +08:00
|
|
|
#include "gimpconfig-path.h"
|
2002-06-07 03:31:52 +08:00
|
|
|
#include "gimpscanner.h"
|
2001-11-27 11:52:11 +08:00
|
|
|
|
2005-01-26 03:11:26 +08:00
|
|
|
#include "libgimp/libgimp-intl.h"
|
2001-12-13 09:55:37 +08:00
|
|
|
|
2001-11-27 11:52:11 +08:00
|
|
|
|
2010-06-30 02:57:52 +08:00
|
|
|
/**
|
|
|
|
* SECTION: gimpconfig-deserialize
|
|
|
|
* @title: GimpConfig-deserialize
|
|
|
|
* @short_description: Deserializing code for libgimpconfig.
|
|
|
|
*
|
|
|
|
* Deserializing code for libgimpconfig.
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
2003-09-16 21:12:50 +08:00
|
|
|
/*
|
2001-12-09 11:00:32 +08:00
|
|
|
* All functions return G_TOKEN_RIGHT_PAREN on success,
|
|
|
|
* the GTokenType they would have expected but didn't get
|
|
|
|
* or G_TOKEN_NONE if they got the expected token but
|
|
|
|
* couldn't parse it.
|
|
|
|
*/
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2002-05-25 01:42:21 +08:00
|
|
|
static GTokenType gimp_config_deserialize_value (GValue *value,
|
2003-10-11 23:02:03 +08:00
|
|
|
GimpConfig *config,
|
2002-05-25 01:42:21 +08:00
|
|
|
GParamSpec *prop_spec,
|
|
|
|
GScanner *scanner);
|
2001-12-09 11:00:32 +08:00
|
|
|
static GTokenType gimp_config_deserialize_fundamental (GValue *value,
|
|
|
|
GParamSpec *prop_spec,
|
|
|
|
GScanner *scanner);
|
|
|
|
static GTokenType gimp_config_deserialize_enum (GValue *value,
|
|
|
|
GParamSpec *prop_spec,
|
|
|
|
GScanner *scanner);
|
|
|
|
static GTokenType gimp_config_deserialize_memsize (GValue *value,
|
|
|
|
GParamSpec *prop_spec,
|
|
|
|
GScanner *scanner);
|
|
|
|
static GTokenType gimp_config_deserialize_path (GValue *value,
|
|
|
|
GParamSpec *prop_spec,
|
|
|
|
GScanner *scanner);
|
2004-07-27 03:56:47 +08:00
|
|
|
static GTokenType gimp_config_deserialize_rgb (GValue *value,
|
2002-05-21 23:01:57 +08:00
|
|
|
GParamSpec *prop_spec,
|
|
|
|
GScanner *scanner);
|
2003-07-08 00:22:45 +08:00
|
|
|
static GTokenType gimp_config_deserialize_matrix2 (GValue *value,
|
|
|
|
GParamSpec *prop_spec,
|
|
|
|
GScanner *scanner);
|
2003-03-01 01:01:13 +08:00
|
|
|
static GTokenType gimp_config_deserialize_object (GValue *value,
|
2003-10-11 23:02:03 +08:00
|
|
|
GimpConfig *config,
|
2003-03-01 01:01:13 +08:00
|
|
|
GParamSpec *prop_spec,
|
|
|
|
GScanner *scanner,
|
|
|
|
gint nest_level);
|
2002-05-25 01:42:21 +08:00
|
|
|
static GTokenType gimp_config_deserialize_value_array (GValue *value,
|
2003-10-11 23:02:03 +08:00
|
|
|
GimpConfig *config,
|
2002-05-25 01:42:21 +08:00
|
|
|
GParamSpec *prop_spec,
|
|
|
|
GScanner *scanner);
|
2001-12-09 11:00:32 +08:00
|
|
|
static GTokenType gimp_config_deserialize_any (GValue *value,
|
|
|
|
GParamSpec *prop_spec,
|
|
|
|
GScanner *scanner);
|
2007-06-04 18:38:25 +08:00
|
|
|
static GTokenType gimp_config_skip_unknown_property (GScanner *scanner);
|
2001-11-27 11:52:11 +08:00
|
|
|
|
2003-09-16 21:12:50 +08:00
|
|
|
static inline gboolean scanner_string_utf8_valid (GScanner *scanner,
|
2001-12-13 09:55:37 +08:00
|
|
|
const gchar *token_name);
|
2001-12-11 02:31:35 +08:00
|
|
|
|
2004-11-14 10:50:33 +08:00
|
|
|
static inline gboolean
|
|
|
|
scanner_string_utf8_valid (GScanner *scanner,
|
|
|
|
const gchar *token_name)
|
|
|
|
{
|
|
|
|
if (g_utf8_validate (scanner->value.v_string, -1, NULL))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
g_scanner_error (scanner,
|
|
|
|
_("value for token %s is not a valid UTF-8 string"),
|
|
|
|
token_name);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-11-27 11:52:11 +08:00
|
|
|
|
2002-03-24 01:58:57 +08:00
|
|
|
/**
|
|
|
|
* gimp_config_deserialize_properties:
|
2003-10-11 23:02:03 +08:00
|
|
|
* @config: a #GimpConfig.
|
2002-03-24 01:58:57 +08:00
|
|
|
* @scanner: a #GScanner.
|
2010-06-30 04:19:11 +08:00
|
|
|
* @nest_level: the nest level
|
2003-09-16 21:12:50 +08:00
|
|
|
*
|
2003-10-11 23:02:03 +08:00
|
|
|
* This function uses the @scanner to configure the properties of @config.
|
2002-03-24 01:58:57 +08:00
|
|
|
*
|
2005-01-29 20:54:48 +08:00
|
|
|
* Return value: %TRUE on success, %FALSE otherwise.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2002-03-24 01:58:57 +08:00
|
|
|
**/
|
2001-11-27 11:52:11 +08:00
|
|
|
gboolean
|
2003-10-11 22:30:18 +08:00
|
|
|
gimp_config_deserialize_properties (GimpConfig *config,
|
|
|
|
GScanner *scanner,
|
2005-01-25 06:07:52 +08:00
|
|
|
gint nest_level)
|
2001-11-27 11:52:11 +08:00
|
|
|
{
|
2001-12-08 00:10:53 +08:00
|
|
|
GObjectClass *klass;
|
|
|
|
GParamSpec **property_specs;
|
|
|
|
guint n_property_specs;
|
|
|
|
guint i;
|
|
|
|
guint scope_id;
|
|
|
|
guint old_scope_id;
|
2007-06-04 18:38:25 +08:00
|
|
|
GTokenType token;
|
|
|
|
GTokenType next;
|
2001-12-08 00:10:53 +08:00
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_CONFIG (config), FALSE);
|
2001-11-27 11:52:11 +08:00
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
klass = G_OBJECT_GET_CLASS (config);
|
2001-12-08 00:10:53 +08:00
|
|
|
property_specs = g_object_class_list_properties (klass, &n_property_specs);
|
2001-11-27 11:52:11 +08:00
|
|
|
|
2007-06-04 18:38:25 +08:00
|
|
|
if (! property_specs)
|
2001-12-11 04:43:51 +08:00
|
|
|
return TRUE;
|
2001-11-27 11:52:11 +08:00
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
scope_id = g_type_qname (G_TYPE_FROM_INSTANCE (config));
|
2001-11-27 11:52:11 +08:00
|
|
|
old_scope_id = g_scanner_set_scope (scanner, scope_id);
|
|
|
|
|
|
|
|
for (i = 0; i < n_property_specs; i++)
|
|
|
|
{
|
|
|
|
GParamSpec *prop_spec = property_specs[i];
|
|
|
|
|
2005-02-05 22:52:58 +08:00
|
|
|
if (prop_spec->flags & GIMP_CONFIG_PARAM_SERIALIZE)
|
2001-11-27 11:52:11 +08:00
|
|
|
{
|
2003-09-16 21:12:50 +08:00
|
|
|
g_scanner_scope_add_symbol (scanner, scope_id,
|
2001-11-27 11:52:11 +08:00
|
|
|
prop_spec->name, prop_spec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-13 09:55:37 +08:00
|
|
|
g_free (property_specs);
|
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
g_object_freeze_notify (G_OBJECT (config));
|
2003-03-01 01:01:13 +08:00
|
|
|
|
2001-11-27 11:52:11 +08:00
|
|
|
token = G_TOKEN_LEFT_PAREN;
|
2002-05-27 22:04:21 +08:00
|
|
|
|
|
|
|
while (TRUE)
|
2001-11-27 11:52:11 +08:00
|
|
|
{
|
2001-12-09 11:00:32 +08:00
|
|
|
next = g_scanner_peek_next_token (scanner);
|
|
|
|
|
2007-06-04 18:38:25 +08:00
|
|
|
if (G_UNLIKELY (next != token &&
|
|
|
|
! (token == G_TOKEN_SYMBOL &&
|
|
|
|
next == G_TOKEN_IDENTIFIER)))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2001-11-27 11:52:11 +08:00
|
|
|
|
|
|
|
token = g_scanner_get_next_token (scanner);
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2001-11-27 11:52:11 +08:00
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case G_TOKEN_LEFT_PAREN:
|
|
|
|
token = G_TOKEN_SYMBOL;
|
|
|
|
break;
|
2002-05-27 22:04:21 +08:00
|
|
|
|
2007-06-04 18:38:25 +08:00
|
|
|
case G_TOKEN_IDENTIFIER:
|
|
|
|
token = gimp_config_skip_unknown_property (scanner);
|
|
|
|
break;
|
|
|
|
|
2001-11-27 11:52:11 +08:00
|
|
|
case G_TOKEN_SYMBOL:
|
2003-10-11 22:30:18 +08:00
|
|
|
token = gimp_config_deserialize_property (config,
|
2003-03-01 01:01:13 +08:00
|
|
|
scanner, nest_level);
|
2001-11-27 11:52:11 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case G_TOKEN_RIGHT_PAREN:
|
|
|
|
token = G_TOKEN_LEFT_PAREN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* do nothing */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-08 00:10:53 +08:00
|
|
|
g_scanner_set_scope (scanner, old_scope_id);
|
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
g_object_thaw_notify (G_OBJECT (config));
|
2003-03-01 01:01:13 +08:00
|
|
|
|
2003-10-22 02:14:58 +08:00
|
|
|
if (token == G_TOKEN_NONE)
|
|
|
|
return FALSE;
|
|
|
|
|
2002-06-18 03:36:33 +08:00
|
|
|
return gimp_config_deserialize_return (scanner, token, nest_level);
|
2001-11-27 11:52:11 +08:00
|
|
|
}
|
|
|
|
|
2005-01-29 20:54:48 +08:00
|
|
|
/**
|
|
|
|
* gimp_config_deserialize_property:
|
|
|
|
* @config: a #GimpConfig.
|
|
|
|
* @scanner: a #GScanner.
|
2010-06-30 04:19:11 +08:00
|
|
|
* @nest_level: the nest level
|
2005-01-29 20:54:48 +08:00
|
|
|
*
|
|
|
|
* This function deserializes a single property of @config. You
|
|
|
|
* shouldn't need to call this function directly. If possible, use
|
|
|
|
* gimp_config_deserialize_properties() instead.
|
|
|
|
*
|
|
|
|
* Return value: %G_TOKEN_RIGHT_PAREN on success, otherwise the
|
|
|
|
* expected #GTokenType or %G_TOKEN_NONE if the expected token was
|
|
|
|
* found but couldn't be parsed.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
|
|
|
**/
|
2005-01-25 06:05:02 +08:00
|
|
|
GTokenType
|
2003-10-11 22:30:18 +08:00
|
|
|
gimp_config_deserialize_property (GimpConfig *config,
|
2003-03-01 01:01:13 +08:00
|
|
|
GScanner *scanner,
|
|
|
|
gint nest_level)
|
2001-11-27 11:52:11 +08:00
|
|
|
{
|
2006-08-08 20:29:48 +08:00
|
|
|
GimpConfigInterface *config_iface = NULL;
|
2005-12-31 02:35:49 +08:00
|
|
|
GimpConfigInterface *parent_iface = NULL;
|
2002-05-22 21:19:19 +08:00
|
|
|
GParamSpec *prop_spec;
|
|
|
|
GTokenType token = G_TOKEN_RIGHT_PAREN;
|
|
|
|
GValue value = { 0, };
|
2003-11-14 01:09:23 +08:00
|
|
|
guint old_scope_id;
|
|
|
|
|
|
|
|
old_scope_id = g_scanner_set_scope (scanner, 0);
|
2001-11-27 11:52:11 +08:00
|
|
|
|
2002-05-22 21:19:19 +08:00
|
|
|
prop_spec = G_PARAM_SPEC (scanner->value.v_symbol);
|
2001-12-08 00:10:53 +08:00
|
|
|
|
2001-12-08 23:56:40 +08:00
|
|
|
g_value_init (&value, prop_spec->value_type);
|
|
|
|
|
2006-08-08 20:29:48 +08:00
|
|
|
if (G_TYPE_IS_OBJECT (prop_spec->owner_type))
|
2004-02-19 20:30:18 +08:00
|
|
|
{
|
2006-08-08 20:29:48 +08:00
|
|
|
GTypeClass *owner_class = g_type_class_peek (prop_spec->owner_type);
|
|
|
|
|
|
|
|
config_iface = g_type_interface_peek (owner_class, GIMP_TYPE_CONFIG);
|
|
|
|
|
|
|
|
/* We must call deserialize_property() *only* if the *exact* class
|
|
|
|
* which implements it is param_spec->owner_type's class.
|
|
|
|
*
|
|
|
|
* Therefore, we ask param_spec->owner_type's immediate parent class
|
|
|
|
* for it's GimpConfigInterface and check if we get a different
|
|
|
|
* pointer.
|
|
|
|
*
|
|
|
|
* (if the pointers are the same, param_spec->owner_type's
|
|
|
|
* GimpConfigInterface is inherited from one of it's parent classes
|
|
|
|
* and thus not able to handle param_spec->owner_type's properties).
|
|
|
|
*/
|
|
|
|
if (config_iface)
|
|
|
|
{
|
|
|
|
GTypeClass *owner_parent_class;
|
2004-02-19 20:30:18 +08:00
|
|
|
|
2006-08-08 20:29:48 +08:00
|
|
|
owner_parent_class = g_type_class_peek_parent (owner_class);
|
2004-02-19 20:30:18 +08:00
|
|
|
|
2006-08-08 20:29:48 +08:00
|
|
|
parent_iface = g_type_interface_peek (owner_parent_class,
|
|
|
|
GIMP_TYPE_CONFIG);
|
|
|
|
}
|
2004-02-19 20:30:18 +08:00
|
|
|
}
|
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
if (config_iface &&
|
2004-02-19 20:30:18 +08:00
|
|
|
config_iface != parent_iface && /* see comment above */
|
2003-10-11 22:30:18 +08:00
|
|
|
config_iface->deserialize_property &&
|
|
|
|
config_iface->deserialize_property (config,
|
|
|
|
prop_spec->param_id,
|
|
|
|
&value,
|
|
|
|
prop_spec,
|
|
|
|
scanner,
|
|
|
|
&token))
|
2002-05-22 21:19:19 +08:00
|
|
|
{
|
|
|
|
/* nop */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-03-01 01:01:13 +08:00
|
|
|
if (G_VALUE_HOLDS_OBJECT (&value))
|
|
|
|
token = gimp_config_deserialize_object (&value,
|
2003-10-11 22:30:18 +08:00
|
|
|
config, prop_spec,
|
2003-03-01 01:01:13 +08:00
|
|
|
scanner, nest_level);
|
|
|
|
else
|
|
|
|
token = gimp_config_deserialize_value (&value,
|
2003-10-11 22:30:18 +08:00
|
|
|
config, prop_spec, scanner);
|
2001-12-08 23:56:40 +08:00
|
|
|
}
|
2001-12-08 11:35:38 +08:00
|
|
|
|
2001-12-10 20:32:28 +08:00
|
|
|
if (token == G_TOKEN_RIGHT_PAREN &&
|
|
|
|
g_scanner_peek_next_token (scanner) == token)
|
|
|
|
{
|
2003-04-13 03:06:25 +08:00
|
|
|
if (! (G_VALUE_HOLDS_OBJECT (&value) &&
|
2005-02-05 22:52:58 +08:00
|
|
|
(prop_spec->flags & GIMP_CONFIG_PARAM_AGGREGATE)))
|
2003-10-11 22:30:18 +08:00
|
|
|
g_object_set_property (G_OBJECT (config), prop_spec->name, &value);
|
2001-12-10 20:32:28 +08:00
|
|
|
}
|
2003-09-16 21:12:50 +08:00
|
|
|
#ifdef CONFIG_DEBUG
|
2001-12-09 11:00:32 +08:00
|
|
|
else
|
2001-12-10 20:32:28 +08:00
|
|
|
{
|
2004-05-12 16:13:33 +08:00
|
|
|
g_warning ("%s: couldn't deserialize property %s::%s of type %s",
|
|
|
|
G_STRFUNC,
|
2003-10-11 22:30:18 +08:00
|
|
|
g_type_name (G_TYPE_FROM_INSTANCE (config)),
|
2003-09-16 21:12:50 +08:00
|
|
|
prop_spec->name,
|
2001-12-10 20:32:28 +08:00
|
|
|
g_type_name (prop_spec->value_type));
|
|
|
|
}
|
2002-03-24 01:58:57 +08:00
|
|
|
#endif
|
2001-12-08 11:35:38 +08:00
|
|
|
|
2001-12-08 23:56:40 +08:00
|
|
|
g_value_unset (&value);
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2003-11-14 01:09:23 +08:00
|
|
|
g_scanner_set_scope (scanner, old_scope_id);
|
|
|
|
|
2001-12-09 11:00:32 +08:00
|
|
|
return token;
|
2001-12-08 23:56:40 +08:00
|
|
|
}
|
|
|
|
|
2002-05-25 01:42:21 +08:00
|
|
|
static GTokenType
|
|
|
|
gimp_config_deserialize_value (GValue *value,
|
2003-10-11 23:02:03 +08:00
|
|
|
GimpConfig *config,
|
2002-05-25 01:42:21 +08:00
|
|
|
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);
|
|
|
|
}
|
2005-01-26 07:44:05 +08:00
|
|
|
else if (prop_spec->value_type == GIMP_TYPE_CONFIG_PATH)
|
2002-05-25 01:42:21 +08:00
|
|
|
{
|
2002-12-30 02:58:24 +08:00
|
|
|
return gimp_config_deserialize_path (value, prop_spec, scanner);
|
2002-05-25 01:42:21 +08:00
|
|
|
}
|
2004-07-27 03:56:47 +08:00
|
|
|
else if (prop_spec->value_type == GIMP_TYPE_RGB)
|
2002-05-25 01:42:21 +08:00
|
|
|
{
|
2004-07-27 03:56:47 +08:00
|
|
|
return gimp_config_deserialize_rgb (value, prop_spec, scanner);
|
2002-05-25 01:42:21 +08:00
|
|
|
}
|
2003-07-08 00:22:45 +08:00
|
|
|
else if (prop_spec->value_type == GIMP_TYPE_MATRIX2)
|
|
|
|
{
|
|
|
|
return gimp_config_deserialize_matrix2 (value, prop_spec, scanner);
|
|
|
|
}
|
2002-05-25 01:42:21 +08:00
|
|
|
else if (prop_spec->value_type == G_TYPE_VALUE_ARRAY)
|
|
|
|
{
|
|
|
|
return gimp_config_deserialize_value_array (value,
|
2003-10-11 23:02:03 +08:00
|
|
|
config, prop_spec, scanner);
|
2002-05-25 01:42:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
}
|
|
|
|
|
2001-12-09 11:00:32 +08:00
|
|
|
static GTokenType
|
2001-12-08 23:56:40 +08:00
|
|
|
gimp_config_deserialize_fundamental (GValue *value,
|
|
|
|
GParamSpec *prop_spec,
|
2001-12-09 11:00:32 +08:00
|
|
|
GScanner *scanner)
|
2001-12-08 23:56:40 +08:00
|
|
|
{
|
2001-12-09 11:00:32 +08:00
|
|
|
GTokenType token;
|
2003-02-03 22:37:59 +08:00
|
|
|
GType value_type;
|
|
|
|
gboolean negate = FALSE;
|
2001-12-09 11:00:32 +08:00
|
|
|
|
2003-02-03 22:37:59 +08:00
|
|
|
value_type = G_TYPE_FUNDAMENTAL (prop_spec->value_type);
|
|
|
|
|
|
|
|
switch (value_type)
|
2001-12-08 23:56:40 +08:00
|
|
|
{
|
|
|
|
case G_TYPE_STRING:
|
2001-12-09 11:00:32 +08:00
|
|
|
token = G_TOKEN_STRING;
|
2001-12-08 23:56:40 +08:00
|
|
|
break;
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2001-12-08 23:56:40 +08:00
|
|
|
case G_TYPE_BOOLEAN:
|
2001-12-09 11:00:32 +08:00
|
|
|
token = G_TOKEN_IDENTIFIER;
|
2001-12-08 23:56:40 +08:00
|
|
|
break;
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2001-12-08 23:56:40 +08:00
|
|
|
case G_TYPE_INT:
|
|
|
|
case G_TYPE_LONG:
|
2003-11-14 21:41:16 +08:00
|
|
|
case G_TYPE_INT64:
|
2003-02-03 22:37:59 +08:00
|
|
|
if (g_scanner_peek_next_token (scanner) == '-')
|
|
|
|
{
|
|
|
|
negate = TRUE;
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
}
|
|
|
|
/* fallthrough */
|
|
|
|
case G_TYPE_UINT:
|
2001-12-08 23:56:40 +08:00
|
|
|
case G_TYPE_ULONG:
|
2003-11-14 21:41:16 +08:00
|
|
|
case G_TYPE_UINT64:
|
2001-12-09 11:00:32 +08:00
|
|
|
token = G_TOKEN_INT;
|
2001-12-08 23:56:40 +08:00
|
|
|
break;
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2001-12-08 23:56:40 +08:00
|
|
|
case G_TYPE_FLOAT:
|
|
|
|
case G_TYPE_DOUBLE:
|
2003-10-26 08:03:16 +08:00
|
|
|
if (g_scanner_peek_next_token (scanner) == '-')
|
|
|
|
{
|
|
|
|
negate = TRUE;
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
}
|
2001-12-09 11:00:32 +08:00
|
|
|
token = G_TOKEN_FLOAT;
|
2001-12-08 23:56:40 +08:00
|
|
|
break;
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2001-12-08 23:56:40 +08:00
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
2001-12-09 11:00:32 +08:00
|
|
|
break;
|
2001-11-27 11:52:11 +08:00
|
|
|
}
|
|
|
|
|
2001-12-09 11:00:32 +08:00
|
|
|
if (g_scanner_peek_next_token (scanner) != token)
|
2003-02-03 22:37:59 +08:00
|
|
|
{
|
|
|
|
return token;
|
|
|
|
}
|
2001-11-27 11:52:11 +08:00
|
|
|
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
|
2003-02-03 22:37:59 +08:00
|
|
|
switch (value_type)
|
2001-11-27 11:52:11 +08:00
|
|
|
{
|
2001-12-08 23:56:40 +08:00
|
|
|
case G_TYPE_STRING:
|
2001-12-11 02:31:35 +08:00
|
|
|
if (scanner_string_utf8_valid (scanner, prop_spec->name))
|
2001-12-12 07:10:59 +08:00
|
|
|
g_value_set_static_string (value, scanner->value.v_string);
|
2001-12-11 02:31:35 +08:00
|
|
|
else
|
|
|
|
return G_TOKEN_NONE;
|
2001-12-08 23:56:40 +08:00
|
|
|
break;
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2001-12-08 23:56:40 +08:00
|
|
|
case G_TYPE_BOOLEAN:
|
|
|
|
if (! g_ascii_strcasecmp (scanner->value.v_identifier, "yes") ||
|
|
|
|
! g_ascii_strcasecmp (scanner->value.v_identifier, "true"))
|
|
|
|
g_value_set_boolean (value, TRUE);
|
|
|
|
else if (! g_ascii_strcasecmp (scanner->value.v_identifier, "no") ||
|
|
|
|
! g_ascii_strcasecmp (scanner->value.v_identifier, "false"))
|
|
|
|
g_value_set_boolean (value, FALSE);
|
2001-11-27 11:52:11 +08:00
|
|
|
else
|
2001-12-08 23:56:40 +08:00
|
|
|
{
|
2003-09-16 21:12:50 +08:00
|
|
|
g_scanner_error
|
|
|
|
(scanner,
|
2002-06-09 20:53:42 +08:00
|
|
|
/* please don't translate 'yes' and 'no' */
|
2003-09-16 21:12:50 +08:00
|
|
|
_("expected 'yes' or 'no' for boolean token %s, got '%s'"),
|
2001-12-08 23:56:40 +08:00
|
|
|
prop_spec->name, scanner->value.v_identifier);
|
2001-12-09 11:00:32 +08:00
|
|
|
return G_TOKEN_NONE;
|
2001-12-08 23:56:40 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_TYPE_INT:
|
2003-02-03 22:37:59 +08:00
|
|
|
g_value_set_int (value, (negate ?
|
2003-11-14 21:41:16 +08:00
|
|
|
- scanner->value.v_int64 :
|
|
|
|
scanner->value.v_int64));
|
2001-12-08 23:56:40 +08:00
|
|
|
break;
|
|
|
|
case G_TYPE_UINT:
|
2003-11-14 21:41:16 +08:00
|
|
|
g_value_set_uint (value, scanner->value.v_int64);
|
2001-12-08 23:56:40 +08:00
|
|
|
break;
|
2003-11-14 21:41:16 +08:00
|
|
|
|
2001-12-08 23:56:40 +08:00
|
|
|
case G_TYPE_LONG:
|
2003-02-03 22:37:59 +08:00
|
|
|
g_value_set_long (value, (negate ?
|
2003-11-14 21:41:16 +08:00
|
|
|
- scanner->value.v_int64 :
|
|
|
|
scanner->value.v_int64));
|
2001-12-08 23:56:40 +08:00
|
|
|
break;
|
|
|
|
case G_TYPE_ULONG:
|
2003-11-14 21:41:16 +08:00
|
|
|
g_value_set_ulong (value, scanner->value.v_int64);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_TYPE_INT64:
|
|
|
|
g_value_set_int64 (value, (negate ?
|
|
|
|
- scanner->value.v_int64 :
|
|
|
|
scanner->value.v_int64));
|
2002-05-27 22:04:21 +08:00
|
|
|
break;
|
2003-11-14 21:41:16 +08:00
|
|
|
case G_TYPE_UINT64:
|
|
|
|
g_value_set_uint64 (value, scanner->value.v_int64);
|
|
|
|
break;
|
|
|
|
|
2001-12-08 23:56:40 +08:00
|
|
|
case G_TYPE_FLOAT:
|
2003-10-26 08:03:16 +08:00
|
|
|
g_value_set_float (value, negate ?
|
|
|
|
- scanner->value.v_float : scanner->value.v_float);
|
2001-12-08 23:56:40 +08:00
|
|
|
break;
|
|
|
|
case G_TYPE_DOUBLE:
|
2003-10-26 08:03:16 +08:00
|
|
|
g_value_set_double (value, negate ?
|
|
|
|
- scanner->value.v_float: scanner->value.v_float);
|
2001-12-08 23:56:40 +08:00
|
|
|
break;
|
2002-05-27 22:04:21 +08:00
|
|
|
|
2001-12-08 23:56:40 +08:00
|
|
|
default:
|
2001-12-09 11:00:32 +08:00
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
2001-11-27 11:52:11 +08:00
|
|
|
}
|
2001-12-08 23:56:40 +08:00
|
|
|
|
2001-12-09 11:00:32 +08:00
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
2001-12-08 23:56:40 +08:00
|
|
|
}
|
|
|
|
|
2001-12-09 11:00:32 +08:00
|
|
|
static GTokenType
|
2001-12-08 23:56:40 +08:00
|
|
|
gimp_config_deserialize_enum (GValue *value,
|
|
|
|
GParamSpec *prop_spec,
|
2001-12-09 11:00:32 +08:00
|
|
|
GScanner *scanner)
|
2001-12-08 23:56:40 +08:00
|
|
|
{
|
|
|
|
GEnumClass *enum_class;
|
|
|
|
GEnumValue *enum_value;
|
|
|
|
|
|
|
|
enum_class = g_type_class_peek (G_VALUE_TYPE (value));
|
2002-11-19 02:31:49 +08:00
|
|
|
|
|
|
|
switch (g_scanner_peek_next_token (scanner))
|
2001-12-08 11:35:38 +08:00
|
|
|
{
|
2002-11-19 02:31:49 +08:00
|
|
|
case G_TOKEN_IDENTIFIER:
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
|
2004-07-08 08:09:41 +08:00
|
|
|
enum_value = g_enum_get_value_by_nick (enum_class,
|
2006-04-12 18:53:28 +08:00
|
|
|
scanner->value.v_identifier);
|
2002-11-19 02:31:49 +08:00
|
|
|
if (!enum_value)
|
2006-04-12 18:53:28 +08:00
|
|
|
enum_value = g_enum_get_value_by_name (enum_class,
|
|
|
|
scanner->value.v_identifier);
|
2002-11-19 02:31:49 +08:00
|
|
|
|
|
|
|
if (!enum_value)
|
2006-04-12 18:53:28 +08:00
|
|
|
{
|
|
|
|
g_scanner_error (scanner,
|
|
|
|
_("invalid value '%s' for token %s"),
|
|
|
|
scanner->value.v_identifier, prop_spec->name);
|
|
|
|
return G_TOKEN_NONE;
|
|
|
|
}
|
2002-11-19 02:31:49 +08:00
|
|
|
break;
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2002-11-19 02:31:49 +08:00
|
|
|
case G_TOKEN_INT:
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
|
2003-11-14 21:41:16 +08:00
|
|
|
enum_value = g_enum_get_value (enum_class,
|
|
|
|
(gint) scanner->value.v_int64);
|
2002-11-19 02:31:49 +08:00
|
|
|
|
|
|
|
if (!enum_value)
|
2006-04-12 18:53:28 +08:00
|
|
|
{
|
|
|
|
g_scanner_error (scanner,
|
|
|
|
_("invalid value '%ld' for token %s"),
|
|
|
|
(glong) scanner->value.v_int64, prop_spec->name);
|
|
|
|
return G_TOKEN_NONE;
|
|
|
|
}
|
2002-11-19 02:31:49 +08:00
|
|
|
break;
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2002-11-19 02:31:49 +08:00
|
|
|
default:
|
|
|
|
return G_TOKEN_IDENTIFIER;
|
2001-12-08 23:56:40 +08:00
|
|
|
}
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2001-12-08 23:56:40 +08:00
|
|
|
g_value_set_enum (value, enum_value->value);
|
|
|
|
|
2001-12-09 11:00:32 +08:00
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
2001-12-08 23:56:40 +08:00
|
|
|
}
|
|
|
|
|
2001-12-09 11:00:32 +08:00
|
|
|
static GTokenType
|
|
|
|
gimp_config_deserialize_memsize (GValue *value,
|
|
|
|
GParamSpec *prop_spec,
|
|
|
|
GScanner *scanner)
|
|
|
|
{
|
2004-07-28 00:39:00 +08:00
|
|
|
gchar *orig_cset_first = scanner->config->cset_identifier_first;
|
|
|
|
gchar *orig_cset_nth = scanner->config->cset_identifier_nth;
|
|
|
|
guint64 memsize;
|
2001-12-09 11:00:32 +08:00
|
|
|
|
|
|
|
scanner->config->cset_identifier_first = G_CSET_DIGITS;
|
|
|
|
scanner->config->cset_identifier_nth = G_CSET_DIGITS "gGmMkKbB";
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2002-05-29 17:20:56 +08:00
|
|
|
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER)
|
|
|
|
return G_TOKEN_IDENTIFIER;
|
2001-12-09 11:00:32 +08:00
|
|
|
|
2002-05-29 17:20:56 +08:00
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
|
|
|
|
scanner->config->cset_identifier_first = orig_cset_first;
|
|
|
|
scanner->config->cset_identifier_nth = orig_cset_nth;
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2004-07-28 00:39:00 +08:00
|
|
|
if (! gimp_memsize_deserialize (scanner->value.v_identifier, &memsize))
|
2002-05-29 17:20:56 +08:00
|
|
|
return G_TOKEN_NONE;
|
2004-07-28 00:39:00 +08:00
|
|
|
|
|
|
|
g_value_set_uint64 (value, memsize);
|
|
|
|
|
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
2001-12-09 11:00:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static GTokenType
|
|
|
|
gimp_config_deserialize_path (GValue *value,
|
|
|
|
GParamSpec *prop_spec,
|
|
|
|
GScanner *scanner)
|
|
|
|
{
|
2003-03-01 01:01:13 +08:00
|
|
|
GError *error = NULL;
|
2001-12-11 02:31:35 +08:00
|
|
|
|
2001-12-09 11:00:32 +08:00
|
|
|
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
|
|
|
|
return G_TOKEN_STRING;
|
|
|
|
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
|
2001-12-11 02:31:35 +08:00
|
|
|
if (!scanner_string_utf8_valid (scanner, prop_spec->name))
|
|
|
|
return G_TOKEN_NONE;
|
|
|
|
|
2002-12-30 02:58:24 +08:00
|
|
|
if (scanner->value.v_string)
|
|
|
|
{
|
|
|
|
/* Check if the string can be expanded
|
2003-01-26 09:20:20 +08:00
|
|
|
* and converted to the filesystem encoding.
|
2002-12-30 02:58:24 +08:00
|
|
|
*/
|
|
|
|
gchar *expand = gimp_config_path_expand (scanner->value.v_string,
|
|
|
|
TRUE, &error);
|
2001-12-09 11:00:32 +08:00
|
|
|
|
2002-12-30 02:58:24 +08:00
|
|
|
if (!expand)
|
|
|
|
{
|
|
|
|
g_scanner_error (scanner,
|
2003-11-14 23:33:40 +08:00
|
|
|
_("while parsing token '%s': %s"),
|
2002-12-30 02:58:24 +08:00
|
|
|
prop_spec->name, error->message);
|
|
|
|
g_error_free (error);
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2002-12-30 02:58:24 +08:00
|
|
|
return G_TOKEN_NONE;
|
|
|
|
}
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2002-12-30 02:58:24 +08:00
|
|
|
g_free (expand);
|
2001-12-11 02:31:35 +08:00
|
|
|
|
2002-12-30 02:58:24 +08:00
|
|
|
g_value_set_static_string (value, scanner->value.v_string);
|
|
|
|
}
|
2001-12-09 11:00:32 +08:00
|
|
|
|
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
|
|
|
}
|
|
|
|
|
2002-05-21 23:01:57 +08:00
|
|
|
static GTokenType
|
2004-07-27 03:56:47 +08:00
|
|
|
gimp_config_deserialize_rgb (GValue *value,
|
|
|
|
GParamSpec *prop_spec,
|
|
|
|
GScanner *scanner)
|
2002-05-21 23:01:57 +08:00
|
|
|
{
|
2004-07-27 03:56:47 +08:00
|
|
|
GimpRGB rgb;
|
2002-05-21 23:01:57 +08:00
|
|
|
|
2004-07-27 03:56:47 +08:00
|
|
|
if (! gimp_scanner_parse_color (scanner, &rgb))
|
2002-05-31 21:58:18 +08:00
|
|
|
return G_TOKEN_NONE;
|
2002-05-21 23:01:57 +08:00
|
|
|
|
2004-07-27 03:56:47 +08:00
|
|
|
g_value_set_boxed (value, &rgb);
|
2002-05-21 23:01:57 +08:00
|
|
|
|
2002-05-31 21:58:18 +08:00
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
2002-05-21 23:01:57 +08:00
|
|
|
}
|
|
|
|
|
2003-07-08 00:22:45 +08:00
|
|
|
static GTokenType
|
|
|
|
gimp_config_deserialize_matrix2 (GValue *value,
|
|
|
|
GParamSpec *prop_spec,
|
|
|
|
GScanner *scanner)
|
|
|
|
{
|
|
|
|
GimpMatrix2 matrix;
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_matrix2 (scanner, &matrix))
|
|
|
|
return G_TOKEN_NONE;
|
|
|
|
|
|
|
|
g_value_set_boxed (value, &matrix);
|
|
|
|
|
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
|
|
|
}
|
|
|
|
|
2003-03-01 01:01:13 +08:00
|
|
|
static GTokenType
|
|
|
|
gimp_config_deserialize_object (GValue *value,
|
2003-10-11 22:30:18 +08:00
|
|
|
GimpConfig *config,
|
2003-03-01 01:01:13 +08:00
|
|
|
GParamSpec *prop_spec,
|
|
|
|
GScanner *scanner,
|
|
|
|
gint nest_level)
|
|
|
|
{
|
2003-10-11 22:30:18 +08:00
|
|
|
GimpConfigInterface *config_iface;
|
|
|
|
GimpConfig *prop_object;
|
2003-03-01 01:01:13 +08:00
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
g_object_get_property (G_OBJECT (config), prop_spec->name, value);
|
2003-03-01 01:01:13 +08:00
|
|
|
|
|
|
|
prop_object = g_value_get_object (value);
|
|
|
|
|
|
|
|
if (! prop_object)
|
2004-06-17 02:14:44 +08:00
|
|
|
{
|
2005-02-05 22:52:58 +08:00
|
|
|
/* if the object property is not GIMP_CONFIG_PARAM_AGGREGATE, read
|
2004-06-17 02:14:44 +08:00
|
|
|
* the type of the object and create it
|
|
|
|
*/
|
2005-02-05 22:52:58 +08:00
|
|
|
if (! (prop_spec->flags & GIMP_CONFIG_PARAM_AGGREGATE))
|
2004-06-17 02:14:44 +08:00
|
|
|
{
|
|
|
|
gchar *type_name;
|
|
|
|
GType type;
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_string (scanner, &type_name))
|
|
|
|
return G_TOKEN_STRING;
|
|
|
|
|
|
|
|
type = g_type_from_name (type_name);
|
|
|
|
g_free (type_name);
|
|
|
|
|
|
|
|
if (! g_type_is_a (type, prop_spec->value_type))
|
|
|
|
return G_TOKEN_STRING;
|
|
|
|
|
|
|
|
prop_object = g_object_new (type, NULL);
|
|
|
|
|
|
|
|
g_value_take_object (value, prop_object);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
|
|
|
}
|
|
|
|
}
|
2003-03-01 01:01:13 +08:00
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
config_iface = GIMP_CONFIG_GET_INTERFACE (prop_object);
|
2003-03-01 01:01:13 +08:00
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
if (! config_iface)
|
2003-03-01 01:01:13 +08:00
|
|
|
return gimp_config_deserialize_any (value, prop_spec, scanner);
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
if (! config_iface->deserialize (prop_object, scanner, nest_level + 1, NULL))
|
2003-03-01 01:01:13 +08:00
|
|
|
return G_TOKEN_NONE;
|
|
|
|
|
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
|
|
|
}
|
|
|
|
|
2002-05-25 01:42:21 +08:00
|
|
|
static GTokenType
|
|
|
|
gimp_config_deserialize_value_array (GValue *value,
|
2003-10-11 22:30:18 +08:00
|
|
|
GimpConfig *config,
|
2002-05-25 01:42:21 +08:00
|
|
|
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);
|
|
|
|
|
2002-05-31 21:58:18 +08:00
|
|
|
if (! gimp_scanner_parse_int (scanner, &n_values))
|
2002-05-25 01:42:21 +08:00
|
|
|
return G_TOKEN_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,
|
2003-10-11 22:30:18 +08:00
|
|
|
config,
|
2002-05-25 01:42:21 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-05-12 01:19:24 +08:00
|
|
|
g_value_take_boxed (value, array);
|
2002-05-29 00:41:56 +08:00
|
|
|
|
2002-05-25 01:42:21 +08:00
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
|
|
|
}
|
|
|
|
|
2001-12-09 11:00:32 +08:00
|
|
|
static GTokenType
|
2001-12-08 23:56:40 +08:00
|
|
|
gimp_config_deserialize_any (GValue *value,
|
|
|
|
GParamSpec *prop_spec,
|
2001-12-09 11:00:32 +08:00
|
|
|
GScanner *scanner)
|
2001-12-08 23:56:40 +08:00
|
|
|
{
|
2001-12-09 11:00:32 +08:00
|
|
|
GValue src = { 0, };
|
2001-12-08 23:56:40 +08:00
|
|
|
|
|
|
|
if (!g_value_type_transformable (G_TYPE_STRING, prop_spec->value_type))
|
|
|
|
{
|
|
|
|
g_warning ("%s: %s can not be transformed from a string",
|
2004-05-12 16:13:33 +08:00
|
|
|
G_STRFUNC, g_type_name (prop_spec->value_type));
|
2001-12-09 11:00:32 +08:00
|
|
|
return G_TOKEN_NONE;
|
2001-12-08 11:35:38 +08:00
|
|
|
}
|
2001-12-08 23:56:40 +08:00
|
|
|
|
2001-12-09 11:00:32 +08:00
|
|
|
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER)
|
|
|
|
return G_TOKEN_IDENTIFIER;
|
2001-12-08 23:56:40 +08:00
|
|
|
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
|
|
|
|
g_value_init (&src, G_TYPE_STRING);
|
2001-12-12 07:10:59 +08:00
|
|
|
g_value_set_static_string (&src, scanner->value.v_identifier);
|
2001-12-08 23:56:40 +08:00
|
|
|
g_value_transform (&src, value);
|
2001-12-12 07:10:59 +08:00
|
|
|
g_value_unset (&src);
|
2001-12-08 23:56:40 +08:00
|
|
|
|
2001-12-09 11:00:32 +08:00
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
2001-11-27 11:52:11 +08:00
|
|
|
}
|
2007-06-04 18:38:25 +08:00
|
|
|
|
|
|
|
static GTokenType
|
|
|
|
gimp_config_skip_unknown_property (GScanner *scanner)
|
|
|
|
{
|
|
|
|
gint open_paren = 0;
|
|
|
|
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
GTokenType token = g_scanner_peek_next_token (scanner);
|
|
|
|
|
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case G_TOKEN_LEFT_PAREN:
|
|
|
|
open_paren++;
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_TOKEN_RIGHT_PAREN:
|
|
|
|
if (open_paren == 0)
|
|
|
|
return token;
|
|
|
|
|
|
|
|
open_paren--;
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_TOKEN_EOF:
|
|
|
|
return token;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|