gobject-introspection r721 - in trunk: . girepository
- From: tko svn gnome org
- To: svn-commits-list gnome org
- Subject: gobject-introspection r721 - in trunk: . girepository
- Date: Wed, 15 Oct 2008 22:28:41 +0000 (UTC)
Author: tko
Date: Wed Oct 15 22:28:41 2008
New Revision: 721
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=721&view=rev
Log:
2008-10-15 Tommi Komulainen <tommi komulainen iki fi>
* a/girepository/girnode.c (g_ir_node_build_members,
g_ir_node_build_typelib): refactor common code for processing
members to a function
Modified:
trunk/ChangeLog
trunk/girepository/girnode.c
Modified: trunk/girepository/girnode.c
==============================================================================
--- trunk/girepository/girnode.c (original)
+++ trunk/girepository/girnode.c Wed Oct 15 22:28:41 2008
@@ -1167,6 +1167,36 @@
}
}
+static void
+g_ir_node_build_members (GList **members,
+ GIrNodeTypeId type,
+ guint16 *count,
+ GIrModule *module,
+ GList *modules,
+ GHashTable *strings,
+ GHashTable *types,
+ guchar *data,
+ guint32 *offset,
+ guint32 *offset2)
+{
+ GList *l = *members;
+
+ while (l)
+ {
+ GIrNode *member = (GIrNode *)l->data;
+ GList *next = l->next;
+
+ if (member->type == type)
+ {
+ (*count)++;
+ g_ir_node_build_typelib (member, module, modules, strings,
+ types, data, offset, offset2);
+ *members = g_list_delete_link (*members, l);
+ }
+ l = next;
+ }
+}
+
void
g_ir_node_build_typelib (GIrNode *node,
GIrModule *module,
@@ -1601,6 +1631,7 @@
{
StructBlob *blob = (StructBlob *)&data[*offset];
GIrNodeStruct *struct_ = (GIrNodeStruct *)node;
+ GList *members;
blob->blob_type = BLOB_TYPE_STRUCT;
blob->deprecated = struct_->deprecated;
@@ -1623,29 +1654,18 @@
blob->n_methods = 0;
*offset += 20;
- for (l = struct_->members; l; l = l->next)
- {
- GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IR_NODE_FIELD)
- {
- blob->n_fields++;
- g_ir_node_build_typelib (member, module, modules, strings,
- types, data, offset, offset2);
- }
- }
+ members = g_list_copy (struct_->members);
- for (l = struct_->members; l; l = l->next)
- {
- GIrNode *member = (GIrNode *)l->data;
-
- if (member->type == G_IR_NODE_FUNCTION)
- {
- blob->n_methods++;
- g_ir_node_build_typelib (member, module, modules, strings,
- types, data, offset, offset2);
- }
- }
+ g_ir_node_build_members (&members, G_IR_NODE_FIELD, &blob->n_fields,
+ module, modules, strings,
+ types, data, offset, offset2);
+
+ g_ir_node_build_members (&members, G_IR_NODE_FUNCTION, &blob->n_methods,
+ module, modules, strings,
+ types, data, offset, offset2);
+
+ g_list_free (members);
}
break;
@@ -1653,6 +1673,7 @@
{
StructBlob *blob = (StructBlob *)&data[*offset];
GIrNodeBoxed *boxed = (GIrNodeBoxed *)node;
+ GList *members;
blob->blob_type = BLOB_TYPE_BOXED;
blob->deprecated = boxed->deprecated;
@@ -1666,29 +1687,18 @@
blob->n_methods = 0;
*offset += 20;
- for (l = boxed->members; l; l = l->next)
- {
- GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IR_NODE_FIELD)
- {
- blob->n_fields++;
- g_ir_node_build_typelib (member, module, modules, strings,
- types, data, offset, offset2);
- }
- }
+ members = g_list_copy (boxed->members);
- for (l = boxed->members; l; l = l->next)
- {
- GIrNode *member = (GIrNode *)l->data;
+ g_ir_node_build_members (&members, G_IR_NODE_FIELD, &blob->n_fields,
+ module, modules, strings,
+ types, data, offset, offset2);
- if (member->type == G_IR_NODE_FUNCTION)
- {
- blob->n_methods++;
- g_ir_node_build_typelib (member, module, modules, strings,
- types, data, offset, offset2);
- }
- }
+ g_ir_node_build_members (&members, G_IR_NODE_FUNCTION, &blob->n_methods,
+ module, modules, strings,
+ types, data, offset, offset2);
+
+ g_list_free (members);
}
break;
@@ -1696,6 +1706,7 @@
{
UnionBlob *blob = (UnionBlob *)&data[*offset];
GIrNodeUnion *union_ = (GIrNodeUnion *)node;
+ GList *members;
blob->blob_type = BLOB_TYPE_UNION;
blob->deprecated = union_->deprecated;
@@ -1734,30 +1745,17 @@
blob->discriminator_type.offset = 0;
}
-
- for (l = union_->members; l; l = l->next)
- {
- GIrNode *member = (GIrNode *)l->data;
+ members = g_list_copy (union_->members);
- if (member->type == G_IR_NODE_FIELD)
- {
- blob->n_fields++;
- g_ir_node_build_typelib (member, module, modules, strings,
- types, data, offset, offset2);
- }
- }
+ g_ir_node_build_members (&members, G_IR_NODE_FIELD, &blob->n_fields,
+ module, modules, strings,
+ types, data, offset, offset2);
- for (l = union_->members; l; l = l->next)
- {
- GIrNode *member = (GIrNode *)l->data;
+ g_ir_node_build_members (&members, G_IR_NODE_FUNCTION, &blob->n_functions,
+ module, modules, strings,
+ types, data, offset, offset2);
- if (member->type == G_IR_NODE_FUNCTION)
- {
- blob->n_functions++;
- g_ir_node_build_typelib (member, module, modules, strings,
- types, data, offset, offset2);
- }
- }
+ g_list_free (members);
if (union_->discriminator_type)
{
@@ -1819,6 +1817,7 @@
{
ObjectBlob *blob = (ObjectBlob *)&data[*offset];
GIrNodeInterface *object = (GIrNodeInterface *)node;
+ GList *members;
blob->blob_type = BLOB_TYPE_OBJECT;
blob->deprecated = object->deprecated;
@@ -1847,83 +1846,39 @@
*offset += 2;
}
- *offset = ALIGN_VALUE (*offset, 4);
- for (l = object->members; l; l = l->next)
- {
- GIrNode *member = (GIrNode *)l->data;
-
- if (member->type == G_IR_NODE_FIELD)
- {
- blob->n_fields++;
- g_ir_node_build_typelib (member, module, modules, strings,
- types, data, offset, offset2);
- }
- }
+ members = g_list_copy (object->members);
*offset = ALIGN_VALUE (*offset, 4);
- for (l = object->members; l; l = l->next)
- {
- GIrNode *member = (GIrNode *)l->data;
-
- if (member->type == G_IR_NODE_PROPERTY)
- {
- blob->n_properties++;
- g_ir_node_build_typelib (member, module, modules, strings,
- types, data, offset, offset2);
- }
- }
+ g_ir_node_build_members (&members, G_IR_NODE_FIELD, &blob->n_fields,
+ module, modules, strings,
+ types, data, offset, offset2);
*offset = ALIGN_VALUE (*offset, 4);
- for (l = object->members; l; l = l->next)
- {
- GIrNode *member = (GIrNode *)l->data;
-
- if (member->type == G_IR_NODE_FUNCTION)
- {
- blob->n_methods++;
- g_ir_node_build_typelib (member, module, modules, strings,
- types, data, offset, offset2);
- }
- }
+ g_ir_node_build_members (&members, G_IR_NODE_PROPERTY, &blob->n_properties,
+ module, modules, strings,
+ types, data, offset, offset2);
*offset = ALIGN_VALUE (*offset, 4);
- for (l = object->members; l; l = l->next)
- {
- GIrNode *member = (GIrNode *)l->data;
-
- if (member->type == G_IR_NODE_SIGNAL)
- {
- blob->n_signals++;
- g_ir_node_build_typelib (member, module, modules, strings,
- types, data, offset, offset2);
- }
- }
+ g_ir_node_build_members (&members, G_IR_NODE_FUNCTION, &blob->n_methods,
+ module, modules, strings,
+ types, data, offset, offset2);
*offset = ALIGN_VALUE (*offset, 4);
- for (l = object->members; l; l = l->next)
- {
- GIrNode *member = (GIrNode *)l->data;
+ g_ir_node_build_members (&members, G_IR_NODE_SIGNAL, &blob->n_signals,
+ module, modules, strings,
+ types, data, offset, offset2);
- if (member->type == G_IR_NODE_VFUNC)
- {
- blob->n_vfuncs++;
- g_ir_node_build_typelib (member, module, modules, strings,
- types, data, offset, offset2);
- }
- }
+ *offset = ALIGN_VALUE (*offset, 4);
+ g_ir_node_build_members (&members, G_IR_NODE_VFUNC, &blob->n_vfuncs,
+ module, modules, strings,
+ types, data, offset, offset2);
*offset = ALIGN_VALUE (*offset, 4);
- for (l = object->members; l; l = l->next)
- {
- GIrNode *member = (GIrNode *)l->data;
+ g_ir_node_build_members (&members, G_IR_NODE_CONSTANT, &blob->n_constants,
+ module, modules, strings,
+ types, data, offset, offset2);
- if (member->type == G_IR_NODE_CONSTANT)
- {
- blob->n_constants++;
- g_ir_node_build_typelib (member, module, modules, strings,
- types, data, offset, offset2);
- }
- }
+ g_list_free (members);
}
break;
@@ -1931,6 +1886,7 @@
{
InterfaceBlob *blob = (InterfaceBlob *)&data[*offset];
GIrNodeInterface *iface = (GIrNodeInterface *)node;
+ GList *members;
blob->blob_type = BLOB_TYPE_INTERFACE;
blob->deprecated = iface->deprecated;
@@ -1953,70 +1909,34 @@
*offset += 2;
}
- *offset = ALIGN_VALUE (*offset, 4);
- for (l = iface->members; l; l = l->next)
- {
- GIrNode *member = (GIrNode *)l->data;
-
- if (member->type == G_IR_NODE_PROPERTY)
- {
- blob->n_properties++;
- g_ir_node_build_typelib (member, module, modules, strings,
- types, data, offset, offset2);
- }
- }
+ members = g_list_copy (iface->members);
*offset = ALIGN_VALUE (*offset, 4);
- for (l = iface->members; l; l = l->next)
- {
- GIrNode *member = (GIrNode *)l->data;
-
- if (member->type == G_IR_NODE_FUNCTION)
- {
- blob->n_methods++;
- g_ir_node_build_typelib (member, module, modules, strings,
- types, data, offset, offset2);
- }
- }
+ g_ir_node_build_members (&members, G_IR_NODE_PROPERTY, &blob->n_properties,
+ module, modules, strings,
+ types, data, offset, offset2);
*offset = ALIGN_VALUE (*offset, 4);
- for (l = iface->members; l; l = l->next)
- {
- GIrNode *member = (GIrNode *)l->data;
-
- if (member->type == G_IR_NODE_SIGNAL)
- {
- blob->n_signals++;
- g_ir_node_build_typelib (member, module, modules, strings,
- types, data, offset, offset2);
- }
- }
+ g_ir_node_build_members (&members, G_IR_NODE_FUNCTION, &blob->n_methods,
+ module, modules, strings,
+ types, data, offset, offset2);
*offset = ALIGN_VALUE (*offset, 4);
- for (l = iface->members; l; l = l->next)
- {
- GIrNode *member = (GIrNode *)l->data;
+ g_ir_node_build_members (&members, G_IR_NODE_SIGNAL, &blob->n_signals,
+ module, modules, strings,
+ types, data, offset, offset2);
- if (member->type == G_IR_NODE_VFUNC)
- {
- blob->n_vfuncs++;
- g_ir_node_build_typelib (member, module, modules, strings,
- types, data, offset, offset2);
- }
- }
+ *offset = ALIGN_VALUE (*offset, 4);
+ g_ir_node_build_members (&members, G_IR_NODE_VFUNC, &blob->n_vfuncs,
+ module, modules, strings,
+ types, data, offset, offset2);
*offset = ALIGN_VALUE (*offset, 4);
- for (l = iface->members; l; l = l->next)
- {
- GIrNode *member = (GIrNode *)l->data;
+ g_ir_node_build_members (&members, G_IR_NODE_CONSTANT, &blob->n_constants,
+ module, modules, strings,
+ types, data, offset, offset2);
- if (member->type == G_IR_NODE_CONSTANT)
- {
- blob->n_constants++;
- g_ir_node_build_typelib (member, module, modules, strings,
- types, data, offset, offset2);
- }
- }
+ g_list_free (members);
}
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]