mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 10:00:45 -05:00
2007-10-27 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/json/json-parser.c: (json_scanner_msg_handler): Set the GError to be returned by the parsing functions into the GScanner error message handler. (json_parser_object): Return the symbol token in case we have a parse error after the member name. (json_parser_load_from_data): Propagate the error set in the message handler, if any. * clutter/json/json-node.c (json_node_free): Unref the objects only if are set, to avoid a couple of needless criticals we get on error. * tests/test-script.json: More properties.
This commit is contained in:
parent
35132fb5de
commit
d42153dc69
18
ChangeLog
18
ChangeLog
@ -1,3 +1,21 @@
|
||||
2007-10-27 Emmanuele Bassi <ebassi@openedhand.com>
|
||||
|
||||
* clutter/json/json-parser.c:
|
||||
(json_scanner_msg_handler): Set the GError to be returned by
|
||||
the parsing functions into the GScanner error message handler.
|
||||
|
||||
(json_parser_object): Return the symbol token in case we have
|
||||
a parse error after the member name.
|
||||
|
||||
(json_parser_load_from_data): Propagate the error set in the
|
||||
message handler, if any.
|
||||
|
||||
* clutter/json/json-node.c (json_node_free): Unref the objects
|
||||
only if are set, to avoid a couple of needless criticals we
|
||||
get on error.
|
||||
|
||||
* tests/test-script.json: More properties.
|
||||
|
||||
2007-10-27 Emmanuele Bassi <ebassi@openedhand.com>
|
||||
|
||||
* clutter/clutter-script.[ch]: Slight API change in the
|
||||
|
@ -332,11 +332,13 @@ json_node_free (JsonNode *node)
|
||||
switch (node->type)
|
||||
{
|
||||
case JSON_NODE_OBJECT:
|
||||
json_object_unref (node->data.object);
|
||||
if (node->data.object)
|
||||
json_object_unref (node->data.object);
|
||||
break;
|
||||
|
||||
case JSON_NODE_ARRAY:
|
||||
json_array_unref (node->data.array);
|
||||
if (node->data.array)
|
||||
json_array_unref (node->data.array);
|
||||
break;
|
||||
|
||||
case JSON_NODE_VALUE:
|
||||
|
@ -49,6 +49,8 @@ struct _JsonParserPrivate
|
||||
JsonNode *current_node;
|
||||
|
||||
GScanner *scanner;
|
||||
|
||||
GError *last_error;
|
||||
};
|
||||
|
||||
static const GScannerConfig json_scanner_config =
|
||||
@ -144,6 +146,12 @@ json_parser_dispose (GObject *gobject)
|
||||
priv->root = NULL;
|
||||
}
|
||||
|
||||
if (priv->last_error)
|
||||
{
|
||||
g_error_free (priv->last_error);
|
||||
priv->last_error = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (json_parser_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
@ -543,7 +551,10 @@ json_parse_object (JsonParser *parser,
|
||||
if (token != G_TOKEN_NONE)
|
||||
{
|
||||
g_free (name);
|
||||
json_node_free (node);
|
||||
|
||||
if (node)
|
||||
json_node_free (node);
|
||||
|
||||
json_object_unref (object);
|
||||
return token;
|
||||
}
|
||||
@ -628,7 +639,7 @@ json_parse_object (JsonParser *parser,
|
||||
break;
|
||||
|
||||
default:
|
||||
return G_TOKEN_RIGHT_BRACE;
|
||||
return G_TOKEN_SYMBOL;
|
||||
}
|
||||
|
||||
if (node)
|
||||
@ -717,9 +728,8 @@ json_scanner_msg_handler (GScanner *scanner,
|
||||
scanner->line,
|
||||
message);
|
||||
|
||||
parser->priv->last_error = error;
|
||||
g_signal_emit (parser, parser_signals[ERROR], 0, error);
|
||||
|
||||
g_error_free (error);
|
||||
}
|
||||
else
|
||||
g_warning ("Line %d: %s", scanner->line, message);
|
||||
@ -871,10 +881,10 @@ json_parser_load_from_data (JsonParser *parser,
|
||||
{
|
||||
for (i = 0; i < n_symbols; i++)
|
||||
if (symbols[i].token == expected_token)
|
||||
msg = (gchar *) symbol_names + symbols[i].name_offset;
|
||||
symbol_name = symbol_names + symbols[i].name_offset;
|
||||
|
||||
if (msg)
|
||||
msg = g_strconcat ("e.g. `", msg, "'", NULL);
|
||||
msg = g_strconcat ("e.g. `", symbol_name, "'", NULL);
|
||||
}
|
||||
|
||||
if (scanner->token > JSON_TOKEN_INVALID &&
|
||||
@ -896,6 +906,12 @@ json_parser_load_from_data (JsonParser *parser,
|
||||
symbol_name, msg,
|
||||
TRUE);
|
||||
|
||||
if (parser->priv->last_error)
|
||||
{
|
||||
g_propagate_error (error, parser->priv->last_error);
|
||||
parser->priv->last_error = NULL;
|
||||
}
|
||||
#if 0
|
||||
/* we set a generic error here; the message from
|
||||
* GScanner is relayed in the ::error signal
|
||||
*/
|
||||
@ -904,7 +920,7 @@ json_parser_load_from_data (JsonParser *parser,
|
||||
"Invalid token `%s' found: expecting %s",
|
||||
symbol_name ? symbol_name : "???",
|
||||
msg ? msg : "unknown");
|
||||
|
||||
#endif
|
||||
retval = FALSE;
|
||||
|
||||
g_free (msg);
|
||||
|
@ -22,6 +22,8 @@
|
||||
"id" : "green-button",
|
||||
"type" : "ClutterRectangle",
|
||||
"color" : "#00ff00ff",
|
||||
"border-width" : 5,
|
||||
"border-color" : "#00cc00ff",
|
||||
"x" : 200,
|
||||
"y" : 50,
|
||||
"width" : 100,
|
||||
|
Loading…
Reference in New Issue
Block a user