2007-12-25 Emmanuele Bassi <ebassi@openedhand.com>
reviewed by: <delete if not using a buddy> * clutter/clutter-actor.c: (parse_rotation_array): Inline, and get the JsonArray as a parameter (parse_rotation): Update * clutter/clutter-script.c: (warn_missing_attribute): Fix for emacs-style warnings (clutter_script_parse_node): Remove an ifdeffed out section (clutter_script_construct_parameters), (clutter_script_construct_object): Rename get_parameters, so it's obvious what it does
This commit is contained in:
parent
0bfe32314a
commit
ac9f2fb1c5
18
ChangeLog
18
ChangeLog
@ -1,3 +1,21 @@
|
|||||||
|
2007-12-25 Emmanuele Bassi <ebassi@openedhand.com>
|
||||||
|
|
||||||
|
reviewed by: <delete if not using a buddy>
|
||||||
|
|
||||||
|
* clutter/clutter-actor.c:
|
||||||
|
(parse_rotation_array): Inline, and get the JsonArray as a parameter
|
||||||
|
|
||||||
|
(parse_rotation): Update
|
||||||
|
|
||||||
|
* clutter/clutter-script.c:
|
||||||
|
(warn_missing_attribute): Fix for emacs-style warnings
|
||||||
|
|
||||||
|
(clutter_script_parse_node): Remove an ifdeffed out section
|
||||||
|
|
||||||
|
(clutter_script_construct_parameters),
|
||||||
|
(clutter_script_construct_object): Rename get_parameters, so
|
||||||
|
it's obvious what it does
|
||||||
|
|
||||||
2007-12-25 Emmanuele Bassi <ebassi@openedhand.com>
|
2007-12-25 Emmanuele Bassi <ebassi@openedhand.com>
|
||||||
|
|
||||||
* tests/test-script.json: Fix the JSON syntax
|
* tests/test-script.json: Fix the JSON syntax
|
||||||
|
@ -4302,12 +4302,11 @@ typedef struct {
|
|||||||
ClutterUnit center_z;
|
ClutterUnit center_z;
|
||||||
} RotationInfo;
|
} RotationInfo;
|
||||||
|
|
||||||
static gboolean
|
static inline gboolean
|
||||||
parse_rotation_array (ClutterActor *actor,
|
parse_rotation_array (ClutterActor *actor,
|
||||||
JsonNode *node,
|
JsonArray *array,
|
||||||
RotationInfo *info)
|
RotationInfo *info)
|
||||||
{
|
{
|
||||||
JsonArray *array = json_node_get_array (node);
|
|
||||||
JsonNode *element;
|
JsonNode *element;
|
||||||
|
|
||||||
if (json_array_get_length (array) != 2)
|
if (json_array_get_length (array) != 2)
|
||||||
@ -4403,7 +4402,9 @@ parse_rotation (ClutterActor *actor,
|
|||||||
retval = TRUE;
|
retval = TRUE;
|
||||||
}
|
}
|
||||||
else if (JSON_NODE_TYPE (member) == JSON_NODE_ARRAY)
|
else if (JSON_NODE_TYPE (member) == JSON_NODE_ARRAY)
|
||||||
retval = parse_rotation_array (actor, member, info);
|
retval = parse_rotation_array (actor,
|
||||||
|
json_node_get_array (member),
|
||||||
|
info);
|
||||||
else
|
else
|
||||||
retval = FALSE;
|
retval = FALSE;
|
||||||
}
|
}
|
||||||
@ -4419,7 +4420,9 @@ parse_rotation (ClutterActor *actor,
|
|||||||
retval = TRUE;
|
retval = TRUE;
|
||||||
}
|
}
|
||||||
else if (JSON_NODE_TYPE (member) == JSON_NODE_ARRAY)
|
else if (JSON_NODE_TYPE (member) == JSON_NODE_ARRAY)
|
||||||
retval = parse_rotation_array (actor, member, info);
|
retval = parse_rotation_array (actor,
|
||||||
|
json_node_get_array (member),
|
||||||
|
info);
|
||||||
else
|
else
|
||||||
retval = FALSE;
|
retval = FALSE;
|
||||||
}
|
}
|
||||||
@ -4435,7 +4438,9 @@ parse_rotation (ClutterActor *actor,
|
|||||||
retval = TRUE;
|
retval = TRUE;
|
||||||
}
|
}
|
||||||
else if (JSON_NODE_TYPE (member) == JSON_NODE_ARRAY)
|
else if (JSON_NODE_TYPE (member) == JSON_NODE_ARRAY)
|
||||||
retval = parse_rotation_array (actor, member, info);
|
retval = parse_rotation_array (actor,
|
||||||
|
json_node_get_array (member),
|
||||||
|
info);
|
||||||
else
|
else
|
||||||
retval = FALSE;
|
retval = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ warn_missing_attribute (ClutterScript *script,
|
|||||||
|
|
||||||
if (G_LIKELY (id))
|
if (G_LIKELY (id))
|
||||||
{
|
{
|
||||||
g_warning ("%s: %d: object `%s' has no `%s' attribute",
|
g_warning ("%s:%d: object `%s' has no `%s' attribute",
|
||||||
priv->is_filename ? priv->filename : "<input>",
|
priv->is_filename ? priv->filename : "<input>",
|
||||||
json_parser_get_current_line (priv->parser),
|
json_parser_get_current_line (priv->parser),
|
||||||
id,
|
id,
|
||||||
@ -220,7 +220,7 @@ warn_missing_attribute (ClutterScript *script,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_warning ("%s: %d: object has no `%s' attribute",
|
g_warning ("%s:%d: object has no `%s' attribute",
|
||||||
priv->is_filename ? priv->filename : "<input>",
|
priv->is_filename ? priv->filename : "<input>",
|
||||||
json_parser_get_current_line (priv->parser),
|
json_parser_get_current_line (priv->parser),
|
||||||
attribute);
|
attribute);
|
||||||
@ -237,7 +237,7 @@ warn_invalid_value (ClutterScript *script,
|
|||||||
|
|
||||||
if (G_LIKELY (node))
|
if (G_LIKELY (node))
|
||||||
{
|
{
|
||||||
g_warning ("%s: %d: invalid value of type `%s' for attribute `%s'",
|
g_warning ("%s:%d: invalid value of type `%s' for attribute `%s'",
|
||||||
priv->is_filename ? priv->filename : "<input>",
|
priv->is_filename ? priv->filename : "<input>",
|
||||||
json_parser_get_current_line (priv->parser),
|
json_parser_get_current_line (priv->parser),
|
||||||
json_node_type_name (node),
|
json_node_type_name (node),
|
||||||
@ -245,7 +245,7 @@ warn_invalid_value (ClutterScript *script,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_warning ("%s: %d: invalid value for attribute `%s'",
|
g_warning ("%s:%d: invalid value for attribute `%s'",
|
||||||
priv->is_filename ? priv->filename : "<input>",
|
priv->is_filename ? priv->filename : "<input>",
|
||||||
json_parser_get_current_line (priv->parser),
|
json_parser_get_current_line (priv->parser),
|
||||||
attribute);
|
attribute);
|
||||||
@ -931,17 +931,6 @@ clutter_script_parse_node (ClutterScript *script,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (!retval)
|
|
||||||
{
|
|
||||||
if (pspec)
|
|
||||||
{
|
|
||||||
g_param_value_defaults (pspec, value);
|
|
||||||
retval = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1010,11 +999,11 @@ clutter_script_translate_parameters (ClutterScript *script,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GList *
|
static GList *
|
||||||
clutter_script_get_parameters (ClutterScript *script,
|
clutter_script_construct_parameters (ClutterScript *script,
|
||||||
GType gtype,
|
GType gtype,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
GList *properties,
|
GList *properties,
|
||||||
GArray **construct_params)
|
GArray **construct_params)
|
||||||
{
|
{
|
||||||
GObjectClass *klass;
|
GObjectClass *klass;
|
||||||
GList *l, *unparsed;
|
GList *l, *unparsed;
|
||||||
@ -1039,9 +1028,7 @@ clutter_script_get_parameters (ClutterScript *script,
|
|||||||
*/
|
*/
|
||||||
pspec = g_object_class_find_property (klass, pinfo->name);
|
pspec = g_object_class_find_property (klass, pinfo->name);
|
||||||
if (pspec)
|
if (pspec)
|
||||||
{
|
pinfo->pspec = g_param_spec_ref (pspec);
|
||||||
pinfo->pspec = g_param_spec_ref (pspec);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pinfo->pspec = NULL;
|
pinfo->pspec = NULL;
|
||||||
@ -1055,6 +1042,8 @@ clutter_script_get_parameters (ClutterScript *script,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
param.name = g_strdup (pinfo->name);
|
||||||
|
|
||||||
if (!clutter_script_parse_node (script, ¶m.value,
|
if (!clutter_script_parse_node (script, ¶m.value,
|
||||||
pinfo->name,
|
pinfo->name,
|
||||||
pinfo->node,
|
pinfo->node,
|
||||||
@ -1064,8 +1053,6 @@ clutter_script_get_parameters (ClutterScript *script,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
param.name = g_strdup (pinfo->name);
|
|
||||||
|
|
||||||
g_array_append_val (*construct_params, param);
|
g_array_append_val (*construct_params, param);
|
||||||
|
|
||||||
property_info_free (pinfo);
|
property_info_free (pinfo);
|
||||||
@ -1197,23 +1184,24 @@ clutter_script_construct_object (ClutterScript *script,
|
|||||||
else if (oinfo->gtype == CLUTTER_TYPE_STAGE)
|
else if (oinfo->gtype == CLUTTER_TYPE_STAGE)
|
||||||
{
|
{
|
||||||
/* the stage is a complex beast: we cannot create it using
|
/* the stage is a complex beast: we cannot create it using
|
||||||
* g_object_newv() but we need clutter_script_get_parameters()
|
* g_object_newv() but we need clutter_script_construct_parameters()
|
||||||
* to add the GParamSpec to the PropertyInfo pspec member, so
|
* to add the GParamSpec to the PropertyInfo pspec member, so
|
||||||
* that we don't have to implement every complex property (like
|
* that we don't have to implement every complex property (like
|
||||||
* the "color" one) directly inside the ClutterStage class.
|
* the "color" one) directly inside the ClutterStage class.
|
||||||
*/
|
*/
|
||||||
oinfo->properties = clutter_script_get_parameters (script,
|
oinfo->properties =
|
||||||
oinfo->gtype,
|
clutter_script_construct_parameters (script,
|
||||||
oinfo->id,
|
oinfo->gtype,
|
||||||
oinfo->properties,
|
oinfo->id,
|
||||||
&construct_params);
|
oinfo->properties,
|
||||||
|
&construct_params);
|
||||||
|
|
||||||
object = G_OBJECT (clutter_stage_get_default ());
|
object = G_OBJECT (clutter_stage_get_default ());
|
||||||
|
|
||||||
for (i = 0; i < construct_params->len; i++)
|
for (i = 0; i < construct_params->len; i++)
|
||||||
{
|
{
|
||||||
GParameter *param = &g_array_index (construct_params, GParameter, i);
|
GParameter *param = &g_array_index (construct_params, GParameter, i);
|
||||||
|
|
||||||
g_free ((gchar *) param->name);
|
g_free ((gchar *) param->name);
|
||||||
g_value_unset (¶m->value);
|
g_value_unset (¶m->value);
|
||||||
}
|
}
|
||||||
@ -1223,11 +1211,12 @@ clutter_script_construct_object (ClutterScript *script,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* every other object: first, we get the construction parameters */
|
/* every other object: first, we get the construction parameters */
|
||||||
oinfo->properties = clutter_script_get_parameters (script,
|
oinfo->properties =
|
||||||
oinfo->gtype,
|
clutter_script_construct_parameters (script,
|
||||||
oinfo->id,
|
oinfo->gtype,
|
||||||
oinfo->properties,
|
oinfo->id,
|
||||||
&construct_params);
|
oinfo->properties,
|
||||||
|
&construct_params);
|
||||||
|
|
||||||
object = g_object_newv (oinfo->gtype,
|
object = g_object_newv (oinfo->gtype,
|
||||||
construct_params->len,
|
construct_params->len,
|
||||||
@ -1244,15 +1233,6 @@ clutter_script_construct_object (ClutterScript *script,
|
|||||||
g_array_free (construct_params, TRUE);
|
g_array_free (construct_params, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* then we get the rest of the parameters, asking the object itself
|
|
||||||
* to translate them for us, if we cannot do that
|
|
||||||
*/
|
|
||||||
oinfo->properties = clutter_script_translate_parameters (script,
|
|
||||||
object,
|
|
||||||
oinfo->id,
|
|
||||||
oinfo->properties,
|
|
||||||
¶ms);
|
|
||||||
|
|
||||||
/* shortcut, to avoid typechecking every time */
|
/* shortcut, to avoid typechecking every time */
|
||||||
if (CLUTTER_IS_SCRIPTABLE (object))
|
if (CLUTTER_IS_SCRIPTABLE (object))
|
||||||
{
|
{
|
||||||
@ -1263,6 +1243,15 @@ clutter_script_construct_object (ClutterScript *script,
|
|||||||
set_custom_property = TRUE;
|
set_custom_property = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* then we get the rest of the parameters, asking the object itself
|
||||||
|
* to translate them for us, if we cannot do that
|
||||||
|
*/
|
||||||
|
oinfo->properties = clutter_script_translate_parameters (script,
|
||||||
|
object,
|
||||||
|
oinfo->id,
|
||||||
|
oinfo->properties,
|
||||||
|
¶ms);
|
||||||
|
|
||||||
/* consume all the properties we could translate in this pass */
|
/* consume all the properties we could translate in this pass */
|
||||||
for (i = 0; i < params->len; i++)
|
for (i = 0; i < params->len; i++)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user