script: Add more comments and annotations

Detail why we are adding a fake id, and under which circumstances that
happens. Also be more verbose with the debug annotations.
This commit is contained in:
Emmanuele Bassi 2010-03-18 20:20:09 +00:00
parent 203847d03c
commit a8595aec13

View File

@ -19,8 +19,6 @@
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
* *
*
*
* Original author: * Original author:
* *
* Emmanuele Bassi <ebassi@linux.intel.com> * Emmanuele Bassi <ebassi@linux.intel.com>
@ -913,16 +911,28 @@ clutter_script_parser_object_end (JsonParser *json_parser,
const gchar *id; const gchar *id;
GList *members, *l; GList *members, *l;
/* if the object definition does not have an 'id' field we'll
* fake one for it...
*/
if (!json_object_has_member (object, "id")) if (!json_object_has_member (object, "id"))
{ {
gchar *fake; gchar *fake;
/* ... unless it doesn't even have a type - in which case
* it is an internal object definition and we're not
* supposed to touch it
*/
if (!json_object_has_member (object, "type")) if (!json_object_has_member (object, "type"))
return; return;
fake = _clutter_script_generate_fake_id (script); fake = _clutter_script_generate_fake_id (script);
json_object_set_string_member (object, "id", fake); json_object_set_string_member (object, "id", fake);
CLUTTER_NOTE (SCRIPT,
"Adding fake id '%s' to object of type '%s'",
json_object_get_string_member (object, "id"),
json_object_get_string_member (object, "type"));
g_free (fake); g_free (fake);
} }
@ -937,9 +947,10 @@ clutter_script_parser_object_end (JsonParser *json_parser,
} }
id = json_object_get_string_member (object, "id"); id = json_object_get_string_member (object, "id");
CLUTTER_NOTE (SCRIPT, "Getting object info for object '%s'", id);
oinfo = _clutter_script_get_object_info (script, id); oinfo = _clutter_script_get_object_info (script, id);
if (G_LIKELY (!oinfo)) if (oinfo == NULL)
{ {
const gchar *class_name; const gchar *class_name;
@ -957,6 +968,9 @@ clutter_script_parser_object_end (JsonParser *json_parser,
type_func = json_object_get_string_member (object, "type_func"); type_func = json_object_get_string_member (object, "type_func");
oinfo->type_func = g_strdup (type_func); oinfo->type_func = g_strdup (type_func);
/* remove the type_func member; we don't want it to
* pollute the object members
*/
json_object_remove_member (object, "type_func"); json_object_remove_member (object, "type_func");
} }
} }
@ -1007,12 +1021,21 @@ clutter_script_parser_object_end (JsonParser *json_parser,
PropertyInfo *pinfo; PropertyInfo *pinfo;
JsonNode *node; JsonNode *node;
CLUTTER_NOTE (SCRIPT, "Object '%s' member '%s'",
oinfo->id,
name);
/* we have already parsed these */ /* we have already parsed these */
if (strcmp (name, "id") == 0 || strcmp (name, "type") == 0) if (strcmp (name, "id") == 0 || strcmp (name, "type") == 0)
continue; continue;
node = json_object_get_member (object, name); node = json_object_get_member (object, name);
if (node == NULL)
/* this should not really happen; we're getting a list of
* member names, and if one does not map a real member
* value then it's likely that something has gone wrong
*/
if (G_UNLIKELY (node == NULL))
{ {
CLUTTER_NOTE (SCRIPT, CLUTTER_NOTE (SCRIPT,
"Empty node for member '%s' of object '%s' (type: %s)", "Empty node for member '%s' of object '%s' (type: %s)",