switch (node->type)
{
case G_IR_NODE_CALLBACK:
- size = 12;
+ size = sizeof (CallbackBlob);
break;
case G_IR_NODE_FUNCTION:
break;
case G_IR_NODE_PARAM:
- size = 12;
+ /* See the comment in the G_IR_NODE_PARAM/ArgBlob writing below */
+ size = sizeof (ArgBlob) - sizeof (SimpleTypeBlob);
break;
case G_IR_NODE_TYPE:
- size = 4;
+ size = sizeof (SimpleTypeBlob);
break;
case G_IR_NODE_OBJECT:
GIrNodeInterface *iface = (GIrNodeInterface *)node;
n = g_list_length (iface->interfaces);
- size = sizeof(ObjectBlob) + 2 * (n + (n % 2));
+ size = sizeof (ObjectBlob) + 2 * (n + (n % 2));
for (l = iface->members; l; l = l->next)
size += g_ir_node_get_size ((GIrNode *)l->data);
GIrNodeInterface *iface = (GIrNodeInterface *)node;
n = g_list_length (iface->prerequisites);
- size = 28 + 2 * (n + (n % 2));
+ size = sizeof (InterfaceBlob) + 2 * (n + (n % 2));
for (l = iface->members; l; l = l->next)
size += g_ir_node_get_size ((GIrNode *)l->data);
{
GIrNodeEnum *enum_ = (GIrNodeEnum *)node;
- size = 20;
+ size = sizeof (EnumBlob);
for (l = enum_->values; l; l = l->next)
size += g_ir_node_get_size ((GIrNode *)l->data);
}
break;
case G_IR_NODE_VALUE:
- size = 12;
+ size = sizeof (ValueBlob);
break;
case G_IR_NODE_STRUCT:
{
GIrNodeStruct *struct_ = (GIrNodeStruct *)node;
- size = 24;
+ size = sizeof (StructBlob);
for (l = struct_->members; l; l = l->next)
size += g_ir_node_get_size ((GIrNode *)l->data);
}
{
GIrNodeBoxed *boxed = (GIrNodeBoxed *)node;
- size = 24;
+ size = sizeof (StructBlob);
for (l = boxed->members; l; l = l->next)
size += g_ir_node_get_size ((GIrNode *)l->data);
}
break;
case G_IR_NODE_PROPERTY:
- size = 12;
+ size = sizeof (PropertyBlob);
break;
case G_IR_NODE_SIGNAL:
- size = 12;
+ size = sizeof (SignalBlob);
break;
case G_IR_NODE_VFUNC:
- size = 16;
+ size = sizeof (VFuncBlob);
break;
case G_IR_NODE_FIELD:
- size = 12;
+ size = sizeof (FieldBlob);
break;
case G_IR_NODE_CONSTANT:
- size = 20;
+ size = sizeof (ConstantBlob);
break;
case G_IR_NODE_ERROR_DOMAIN:
- size = 16;
+ size = sizeof (ErrorDomainBlob);
break;
case G_IR_NODE_XREF:
{
GIrNodeUnion *union_ = (GIrNodeUnion *)node;
- size = 32;
+ size = sizeof (UnionBlob);
for (l = union_->members; l; l = l->next)
size += g_ir_node_get_size ((GIrNode *)l->data);
for (l = union_->discriminators; l; l = l->next)
case G_IR_NODE_CALLBACK:
{
GIrNodeFunction *function = (GIrNodeFunction *)node;
- size = 12;
+ size = sizeof (CallbackBlob);
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
for (l = function->parameters; l; l = l->next)
{
case G_IR_NODE_FUNCTION:
{
GIrNodeFunction *function = (GIrNodeFunction *)node;
- size = 24;
+ size = sizeof (FunctionBlob);
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
size += ALIGN_VALUE (strlen (function->symbol) + 1, 4);
for (l = function->parameters; l; l = l->next)
{
GIrNodeParam *param = (GIrNodeParam *)node;
- size = 16;
+ /* See the comment in the G_IR_NODE_PARAM/ArgBlob writing below */
+ size = sizeof (ArgBlob) - sizeof (SimpleTypeBlob);
if (node->name)
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
size += g_ir_node_get_full_size_internal (node, (GIrNode *)param->type);
case G_IR_NODE_TYPE:
{
GIrNodeType *type = (GIrNodeType *)node;
- if (type->tag < GI_TYPE_TAG_ARRAY)
- size = 4;
- else
+ size = sizeof (SimpleTypeBlob);
+ if (type->tag >= GI_TYPE_TAG_ARRAY)
{
g_debug ("node %p type tag '%s'", node,
g_type_tag_to_string (type->tag));
switch (type->tag)
{
case GI_TYPE_TAG_ARRAY:
- size = 4 + 4;
+ size = sizeof (ArrayTypeBlob);
if (type->parameter_type1)
size += g_ir_node_get_full_size_internal (node, (GIrNode *)type->parameter_type1);
break;
case GI_TYPE_TAG_INTERFACE:
- size = 4 + 4;
+ size += sizeof (InterfaceTypeBlob);
break;
case GI_TYPE_TAG_GLIST:
case GI_TYPE_TAG_GSLIST:
- size = 4 + 4;
+ size += sizeof (ParamTypeBlob);
if (type->parameter_type1)
size += g_ir_node_get_full_size_internal (node, (GIrNode *)type->parameter_type1);
break;
case GI_TYPE_TAG_GHASH:
- size = 4 + 4 + 4;
+ size += sizeof (ParamTypeBlob) * 2;
if (type->parameter_type1)
size += g_ir_node_get_full_size_internal (node, (GIrNode *)type->parameter_type1);
if (type->parameter_type2)
else
n = 0;
- size = 4 + 4 + 2 * (n + n % 2);
+ size += sizeof (ErrorTypeBlob) + 2 * (n + n % 2);
}
break;
default:
GIrNodeInterface *iface = (GIrNodeInterface *)node;
n = g_list_length (iface->prerequisites);
- size = 28;
+ size = sizeof (InterfaceBlob);
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
size += ALIGN_VALUE (strlen (iface->gtype_name) + 1, 4);
size += ALIGN_VALUE (strlen (iface->gtype_init) + 1, 4);
{
GIrNodeEnum *enum_ = (GIrNodeEnum *)node;
- size = 20;
+ size = sizeof (EnumBlob);
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
if (enum_->gtype_name)
{
case G_IR_NODE_VALUE:
{
- size = 12;
+ size = sizeof (ValueBlob);
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
}
break;
{
GIrNodeStruct *struct_ = (GIrNodeStruct *)node;
- size = 24;
+ size = sizeof (StructBlob);
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
if (struct_->gtype_name)
size += ALIGN_VALUE (strlen (struct_->gtype_name) + 1, 4);
{
GIrNodeBoxed *boxed = (GIrNodeBoxed *)node;
- size = 24;
+ size = sizeof (StructBlob);
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
if (boxed->gtype_name)
{
{
GIrNodeProperty *prop = (GIrNodeProperty *)node;
- size = 12;
+ size = sizeof (PropertyBlob);
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
size += g_ir_node_get_full_size_internal (node, (GIrNode *)prop->type);
}
{
GIrNodeSignal *signal = (GIrNodeSignal *)node;
- size = 12;
+ size = sizeof (SignalBlob);
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
for (l = signal->parameters; l; l = l->next)
size += g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
{
GIrNodeVFunc *vfunc = (GIrNodeVFunc *)node;
- size = 16;
+ size = sizeof (VFuncBlob);
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
for (l = vfunc->parameters; l; l = l->next)
size += g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
{
GIrNodeField *field = (GIrNodeField *)node;
- size = 12;
+ size = sizeof (FieldBlob);
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
size += g_ir_node_get_full_size_internal (node, (GIrNode *)field->type);
}
{
GIrNodeConstant *constant = (GIrNodeConstant *)node;
- size = 20;
+ size = sizeof (ConstantBlob);
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
/* FIXME non-string values */
size += ALIGN_VALUE (strlen (constant->value) + 1, 4);
{
GIrNodeErrorDomain *domain = (GIrNodeErrorDomain *)node;
- size = 16;
+ size = sizeof (ErrorDomainBlob);
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
size += ALIGN_VALUE (strlen (domain->getquark) + 1, 4);
}
{
GIrNodeUnion *union_ = (GIrNodeUnion *)node;
- size = 32;
+ size = sizeof (UnionBlob);
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
if (union_->gtype_name)
size += ALIGN_VALUE (strlen (union_->gtype_name) + 1, 4);
GIrNodeType *type = (GIrNodeType *)node;
SimpleTypeBlob *blob = (SimpleTypeBlob *)&data[*offset];
- *offset += 4;
+ *offset += sizeof (SimpleTypeBlob);
if (type->tag < GI_TYPE_TAG_ARRAY ||
type->tag == GI_TYPE_TAG_UTF8 ||
else
array->length = -1;
- pos = *offset2 + 4;
- *offset2 += 8;
+ pos = *offset2 + G_STRUCT_OFFSET (ArrayTypeBlob, type);
+ *offset2 += sizeof (ArrayTypeBlob);
g_ir_node_build_typelib ((GIrNode *)type->parameter_type1,
module, modules, strings, types,
case GI_TYPE_TAG_INTERFACE:
{
InterfaceTypeBlob *iface = (InterfaceTypeBlob *)&data[*offset2];
- *offset2 += 4;
+ *offset2 += sizeof (InterfaceTypeBlob);
iface->pointer = type->is_pointer;
iface->reserved = 0;
param->reserved2 = 0;
param->n_types = 1;
- pos = *offset2 + 4;
- *offset2 += 8;
+ pos = *offset2 + G_STRUCT_OFFSET (ParamTypeBlob, type);
+ *offset2 += sizeof (ParamTypeBlob) + sizeof (SimpleTypeBlob);
g_ir_node_build_typelib ((GIrNode *)type->parameter_type1,
module, modules, strings, types,
param->reserved2 = 0;
param->n_types = 2;
- pos = *offset2 + 4;
- *offset2 += 12;
+ pos = *offset2 + G_STRUCT_OFFSET (ParamTypeBlob, type);
+ *offset2 += sizeof (ParamTypeBlob) + sizeof (SimpleTypeBlob)*2;
g_ir_node_build_typelib ((GIrNode *)type->parameter_type1,
module, modules, strings, types,
else
blob->n_domains = 0;
- *offset2 = ALIGN_VALUE (*offset2 + 4 + 2 * blob->n_domains, 4);
+ *offset2 = ALIGN_VALUE (*offset2 + G_STRUCT_OFFSET (ErrorTypeBlob, domains)
+ + 2 * blob->n_domains, 4);
for (i = 0; i < blob->n_domains; i++)
blob->domains[i] = find_entry (module, modules, type->errors[i]);
}
FieldBlob *blob;
blob = (FieldBlob *)&data[*offset];
- *offset += 8;
+ /* We handle the size member specially below, so subtract it */
+ *offset += sizeof (FieldBlob) - sizeof (SimpleTypeBlob);
blob->name = write_string (node->name, strings, data, offset2);
blob->readable = field->readable;
{
GIrNodeProperty *prop = (GIrNodeProperty *)node;
PropertyBlob *blob = (PropertyBlob *)&data[*offset];
- *offset += 8;
+ /* We handle the size member specially below, so subtract it */
+ *offset += sizeof (PropertyBlob) - sizeof (SimpleTypeBlob);
blob->name = write_string (node->name, strings, data, offset2);
blob->deprecated = prop->deprecated;
signature = *offset2;
n = g_list_length (function->parameters);
- *offset += sizeof(FunctionBlob);
- *offset2 += sizeof(SignatureBlob) + n * sizeof(ArgBlob);
+ *offset += sizeof (FunctionBlob);
+ *offset2 += sizeof (SignatureBlob) + n * sizeof (ArgBlob);
blob->blob_type = BLOB_TYPE_FUNCTION;
blob->deprecated = function->deprecated;
signature = *offset2;
n = g_list_length (function->parameters);
- *offset += sizeof(CallbackBlob);
- *offset2 += sizeof(SignatureBlob) + n * sizeof(ArgBlob);
+ *offset += sizeof (CallbackBlob);
+ *offset2 += sizeof (SignatureBlob) + n * sizeof (ArgBlob);
blob->blob_type = BLOB_TYPE_CALLBACK;
blob->deprecated = function->deprecated;
signature = *offset2;
n = g_list_length (signal->parameters);
- *offset += sizeof(SignalBlob);
- *offset2 += sizeof(SignatureBlob) + n * sizeof(ArgBlob);
+ *offset += sizeof (SignalBlob);
+ *offset2 += sizeof (SignatureBlob) + n * sizeof (ArgBlob);
blob->deprecated = signal->deprecated;
blob->run_first = signal->run_first;
signature = *offset2;
n = g_list_length (vfunc->parameters);
- *offset += sizeof(VFuncBlob);
- *offset2 += sizeof(SignatureBlob) + n * sizeof(ArgBlob);
+ *offset += sizeof (VFuncBlob);
+ *offset2 += sizeof (SignatureBlob) + n * sizeof (ArgBlob);
blob->name = write_string (node->name, strings, data, offset2);
blob->must_chain_up = 0; /* FIXME */
{
ArgBlob *blob = (ArgBlob *)&data[*offset];
GIrNodeParam *param = (GIrNodeParam *)node;
-
- *offset += 12;
+
+ /* The offset for this one is smaller than the struct because
+ * we recursively build the simple type inline here below.
+ */
+ *offset += sizeof (ArgBlob) - sizeof (SimpleTypeBlob);
blob->name = write_string (node->name, strings, data, offset2);
blob->in = param->in;
blob->n_fields = 0;
blob->n_methods = 0;
- *offset += 24;
+ *offset += sizeof (StructBlob);
members = g_list_copy (struct_->members);
blob->n_fields = 0;
blob->n_methods = 0;
- *offset += 24;
+ *offset += sizeof (StructBlob);
members = g_list_copy (boxed->members);
blob->discriminator_offset = union_->discriminator_offset;
+ /* We don't support Union discriminators right now. */
if (union_->discriminator_type)
{
*offset += 28;
}
else
{
- *offset += 32;
- blob->discriminated = FALSE;
- blob->discriminator_type.offset = 0;
- }
+ */
+ /* Always do the non-discriminated case */
+ *offset += sizeof (UnionBlob);
+ blob->discriminated = FALSE;
+ blob->discriminator_type.offset = 0;
members = g_list_copy (union_->members);
EnumBlob *blob = (EnumBlob *)&data[*offset];
GIrNodeEnum *enum_ = (GIrNodeEnum *)node;
- *offset += 20;
-
+ *offset += sizeof (EnumBlob);
+
if (node->type == G_IR_NODE_ENUM)
blob->blob_type = BLOB_TYPE_ENUM;
else
blob->n_vfuncs = 0;
blob->n_constants = 0;
- *offset += 28;
+ *offset += sizeof (InterfaceBlob);
for (l = iface->prerequisites; l; l = l->next)
{
blob->n_prerequisites++;
{
GIrNodeValue *value = (GIrNodeValue *)node;
ValueBlob *blob = (ValueBlob *)&data[*offset];
- *offset += 12;
+ *offset += sizeof (ValueBlob);
blob->deprecated = value->deprecated;
blob->reserved = 0;
{
GIrNodeErrorDomain *domain = (GIrNodeErrorDomain *)node;
ErrorDomainBlob *blob = (ErrorDomainBlob *)&data[*offset];
- *offset += 16;
+ *offset += sizeof (ErrorDomainBlob);
blob->blob_type = BLOB_TYPE_ERROR_DOMAIN;
blob->deprecated = domain->deprecated;
ConstantBlob *blob = (ConstantBlob *)&data[*offset];
guint32 pos;
- pos = *offset + 8;
- *offset += 20;
+ pos = *offset + G_STRUCT_OFFSET (ConstantBlob, type);
+ *offset += sizeof (ConstantBlob);
blob->blob_type = BLOB_TYPE_CONSTANT;
blob->deprecated = constant->deprecated;