2008-08-09 14:55:32 +02:00
|
|
|
/* GObject introspection: Typelib creation
|
2008-08-09 14:46:48 +02:00
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Matthias Clasen
|
2009-02-20 03:48:51 +01:00
|
|
|
* Copyright (C) 2008,2009 Red Hat, Inc.
|
2008-08-09 14:46:48 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "girmodule.h"
|
|
|
|
#include "girnode.h"
|
|
|
|
#include "gtypelib.h"
|
|
|
|
|
|
|
|
static gulong string_count = 0;
|
|
|
|
static gulong unique_string_count = 0;
|
|
|
|
static gulong string_size = 0;
|
|
|
|
static gulong unique_string_size = 0;
|
|
|
|
static gulong types_count = 0;
|
|
|
|
static gulong unique_types_count = 0;
|
|
|
|
|
|
|
|
void
|
Bug 556543 – reduce compiler warnings
2008-10-16 Tommi Komulainen <tommi.komulainen@iki.fi>
Bug 556543 – reduce compiler warnings
* girepository/ginfo.c:
* girepository/girepository.c (register_internal,
count_interfaces, find_interface, find_namespace_version,
parse_version, g_irepository_require):
* girepository/girmodule.c (g_ir_module_build_typelib):
* girepository/girnode.c (init_stats, dump_stats,
_g_irnode_init_stats, _g_irnode_dump_stats,
g_ir_node_can_have_member):
* girepository/girparser.c (firstpass_end_element_handler,
locate_gir, parse_basic, parse_type_internal, resolve_aliases,
start_alias, start_type, end_type_top, parse_include, cleanup,
post_filter):
* girepository/gtypelib.c (validate_function_blob, validate_enum_blob):
* giscanner/giscannermodule.c (directive_get_options,
type_get_child_list):
* giscanner/scannerlexer.l (parse_gtkdoc):
* giscanner/scannerparser.y (ctype_free):
* giscanner/sourcescanner.c:
* giscanner/sourcescanner.h (gi_source_scanner_parse_macros):
* tests/types/gitesttypes.c:
* tools/compiler.c (main):
* tools/generate.c (write_repository): Remove unused variables
and code, add missing includes, declarations and case
statements.
svn path=/trunk/; revision=730
2008-10-16 19:07:05 +02:00
|
|
|
_g_irnode_init_stats (void)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
string_count = 0;
|
|
|
|
unique_string_count = 0;
|
|
|
|
string_size = 0;
|
|
|
|
unique_string_size = 0;
|
|
|
|
types_count = 0;
|
|
|
|
unique_types_count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
Bug 556543 – reduce compiler warnings
2008-10-16 Tommi Komulainen <tommi.komulainen@iki.fi>
Bug 556543 – reduce compiler warnings
* girepository/ginfo.c:
* girepository/girepository.c (register_internal,
count_interfaces, find_interface, find_namespace_version,
parse_version, g_irepository_require):
* girepository/girmodule.c (g_ir_module_build_typelib):
* girepository/girnode.c (init_stats, dump_stats,
_g_irnode_init_stats, _g_irnode_dump_stats,
g_ir_node_can_have_member):
* girepository/girparser.c (firstpass_end_element_handler,
locate_gir, parse_basic, parse_type_internal, resolve_aliases,
start_alias, start_type, end_type_top, parse_include, cleanup,
post_filter):
* girepository/gtypelib.c (validate_function_blob, validate_enum_blob):
* giscanner/giscannermodule.c (directive_get_options,
type_get_child_list):
* giscanner/scannerlexer.l (parse_gtkdoc):
* giscanner/scannerparser.y (ctype_free):
* giscanner/sourcescanner.c:
* giscanner/sourcescanner.h (gi_source_scanner_parse_macros):
* tests/types/gitesttypes.c:
* tools/compiler.c (main):
* tools/generate.c (write_repository): Remove unused variables
and code, add missing includes, declarations and case
statements.
svn path=/trunk/; revision=730
2008-10-16 19:07:05 +02:00
|
|
|
_g_irnode_dump_stats (void)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
g_message ("%lu strings (%lu before sharing), %lu bytes (%lu before sharing)",
|
|
|
|
unique_string_count, string_count, unique_string_size, string_size);
|
|
|
|
g_message ("%lu types (%lu before sharing)", unique_types_count, types_count);
|
|
|
|
}
|
|
|
|
|
2009-10-21 13:28:12 +02:00
|
|
|
#define DO_ALIGNED_COPY(dest_addr, value, type) \
|
|
|
|
do { \
|
|
|
|
type tmp_var; \
|
|
|
|
tmp_var = value; \
|
|
|
|
memcpy(dest_addr, &tmp_var, sizeof(type)); \
|
|
|
|
} while(0)
|
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
#define ALIGN_VALUE(this, boundary) \
|
|
|
|
(( ((unsigned long)(this)) + (((unsigned long)(boundary)) -1)) & (~(((unsigned long)(boundary))-1)))
|
|
|
|
|
|
|
|
|
2008-08-18 10:52:47 +02:00
|
|
|
const gchar *
|
2008-08-09 14:46:48 +02:00
|
|
|
g_ir_node_type_to_string (GIrNodeTypeId type)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case G_IR_NODE_FUNCTION:
|
|
|
|
return "function";
|
|
|
|
case G_IR_NODE_CALLBACK:
|
|
|
|
return "callback";
|
|
|
|
case G_IR_NODE_PARAM:
|
|
|
|
return "param";
|
|
|
|
case G_IR_NODE_TYPE:
|
|
|
|
return "type";
|
|
|
|
case G_IR_NODE_OBJECT:
|
|
|
|
return "object";
|
|
|
|
case G_IR_NODE_INTERFACE:
|
|
|
|
return "interface";
|
|
|
|
case G_IR_NODE_SIGNAL:
|
|
|
|
return "signal";
|
|
|
|
case G_IR_NODE_PROPERTY:
|
|
|
|
return "property";
|
|
|
|
case G_IR_NODE_VFUNC:
|
|
|
|
return "vfunc";
|
|
|
|
case G_IR_NODE_FIELD:
|
|
|
|
return "field";
|
|
|
|
case G_IR_NODE_ENUM:
|
|
|
|
return "enum";
|
|
|
|
case G_IR_NODE_FLAGS:
|
|
|
|
return "flags";
|
|
|
|
case G_IR_NODE_BOXED:
|
|
|
|
return "boxed";
|
|
|
|
case G_IR_NODE_STRUCT:
|
|
|
|
return "struct";
|
|
|
|
case G_IR_NODE_VALUE:
|
|
|
|
return "value";
|
|
|
|
case G_IR_NODE_CONSTANT:
|
|
|
|
return "constant";
|
|
|
|
case G_IR_NODE_ERROR_DOMAIN:
|
|
|
|
return "error-domain";
|
|
|
|
case G_IR_NODE_XREF:
|
|
|
|
return "xref";
|
|
|
|
case G_IR_NODE_UNION:
|
|
|
|
return "union";
|
|
|
|
default:
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GIrNode *
|
|
|
|
g_ir_node_new (GIrNodeTypeId type)
|
|
|
|
{
|
|
|
|
GIrNode *node = NULL;
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case G_IR_NODE_FUNCTION:
|
|
|
|
case G_IR_NODE_CALLBACK:
|
|
|
|
node = g_malloc0 (sizeof (GIrNodeFunction));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_PARAM:
|
|
|
|
node = g_malloc0 (sizeof (GIrNodeParam));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_TYPE:
|
|
|
|
node = g_malloc0 (sizeof (GIrNodeType));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_OBJECT:
|
|
|
|
case G_IR_NODE_INTERFACE:
|
|
|
|
node = g_malloc0 (sizeof (GIrNodeInterface));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_SIGNAL:
|
|
|
|
node = g_malloc0 (sizeof (GIrNodeSignal));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_PROPERTY:
|
|
|
|
node = g_malloc0 (sizeof (GIrNodeProperty));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_VFUNC:
|
|
|
|
node = g_malloc0 (sizeof (GIrNodeFunction));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_FIELD:
|
|
|
|
node = g_malloc0 (sizeof (GIrNodeField));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_ENUM:
|
|
|
|
case G_IR_NODE_FLAGS:
|
|
|
|
node = g_malloc0 (sizeof (GIrNodeEnum));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_BOXED:
|
|
|
|
node = g_malloc0 (sizeof (GIrNodeBoxed));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_STRUCT:
|
|
|
|
node = g_malloc0 (sizeof (GIrNodeStruct));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_VALUE:
|
|
|
|
node = g_malloc0 (sizeof (GIrNodeValue));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_CONSTANT:
|
|
|
|
node = g_malloc0 (sizeof (GIrNodeConstant));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_ERROR_DOMAIN:
|
|
|
|
node = g_malloc0 (sizeof (GIrNodeErrorDomain));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_XREF:
|
|
|
|
node = g_malloc0 (sizeof (GIrNodeXRef));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_UNION:
|
|
|
|
node = g_malloc0 (sizeof (GIrNodeUnion));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_error ("Unhandled node type %d\n", type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
node->type = type;
|
2009-02-20 03:48:51 +01:00
|
|
|
node->offset = 0;
|
|
|
|
node->attributes = g_hash_table_new_full (g_str_hash, g_str_equal,
|
|
|
|
g_free, g_free);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
g_ir_node_free (GIrNode *node)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
if (node == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (node->type)
|
|
|
|
{
|
|
|
|
case G_IR_NODE_FUNCTION:
|
|
|
|
case G_IR_NODE_CALLBACK:
|
|
|
|
{
|
|
|
|
GIrNodeFunction *function = (GIrNodeFunction *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
g_free (node->name);
|
|
|
|
g_free (function->symbol);
|
|
|
|
g_ir_node_free ((GIrNode *)function->result);
|
|
|
|
for (l = function->parameters; l; l = l->next)
|
|
|
|
g_ir_node_free ((GIrNode *)l->data);
|
|
|
|
g_list_free (function->parameters);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_TYPE:
|
|
|
|
{
|
|
|
|
GIrNodeType *type = (GIrNodeType *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
g_free (node->name);
|
|
|
|
g_ir_node_free ((GIrNode *)type->parameter_type1);
|
|
|
|
g_ir_node_free ((GIrNode *)type->parameter_type2);
|
|
|
|
|
|
|
|
g_free (type->interface);
|
|
|
|
g_strfreev (type->errors);
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_PARAM:
|
|
|
|
{
|
|
|
|
GIrNodeParam *param = (GIrNodeParam *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
g_free (node->name);
|
|
|
|
g_ir_node_free ((GIrNode *)param->type);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_PROPERTY:
|
|
|
|
{
|
|
|
|
GIrNodeProperty *property = (GIrNodeProperty *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
g_free (node->name);
|
|
|
|
g_ir_node_free ((GIrNode *)property->type);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_SIGNAL:
|
|
|
|
{
|
|
|
|
GIrNodeSignal *signal = (GIrNodeSignal *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
g_free (node->name);
|
|
|
|
for (l = signal->parameters; l; l = l->next)
|
|
|
|
g_ir_node_free ((GIrNode *)l->data);
|
|
|
|
g_list_free (signal->parameters);
|
|
|
|
g_ir_node_free ((GIrNode *)signal->result);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_VFUNC:
|
|
|
|
{
|
|
|
|
GIrNodeVFunc *vfunc = (GIrNodeVFunc *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
g_free (node->name);
|
2009-02-28 01:02:48 +01:00
|
|
|
g_free (vfunc->invoker);
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = vfunc->parameters; l; l = l->next)
|
|
|
|
g_ir_node_free ((GIrNode *)l->data);
|
|
|
|
g_list_free (vfunc->parameters);
|
|
|
|
g_ir_node_free ((GIrNode *)vfunc->result);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_FIELD:
|
|
|
|
{
|
|
|
|
GIrNodeField *field = (GIrNodeField *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
g_free (node->name);
|
|
|
|
g_ir_node_free ((GIrNode *)field->type);
|
2009-11-09 19:17:23 +01:00
|
|
|
g_ir_node_free ((GIrNode *)field->callback);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_OBJECT:
|
|
|
|
case G_IR_NODE_INTERFACE:
|
|
|
|
{
|
|
|
|
GIrNodeInterface *iface = (GIrNodeInterface *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
g_free (node->name);
|
|
|
|
g_free (iface->gtype_name);
|
|
|
|
g_free (iface->gtype_init);
|
2009-02-06 19:37:13 +01:00
|
|
|
|
2009-02-20 23:34:20 +01:00
|
|
|
|
|
|
|
g_free (iface->glib_type_struct);
|
2008-08-09 14:46:48 +02:00
|
|
|
g_free (iface->parent);
|
|
|
|
|
|
|
|
for (l = iface->interfaces; l; l = l->next)
|
|
|
|
g_free ((GIrNode *)l->data);
|
|
|
|
g_list_free (iface->interfaces);
|
|
|
|
|
|
|
|
for (l = iface->members; l; l = l->next)
|
|
|
|
g_ir_node_free ((GIrNode *)l->data);
|
|
|
|
g_list_free (iface->members);
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
case G_IR_NODE_VALUE:
|
|
|
|
{
|
|
|
|
g_free (node->name);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_ENUM:
|
|
|
|
case G_IR_NODE_FLAGS:
|
|
|
|
{
|
|
|
|
GIrNodeEnum *enum_ = (GIrNodeEnum *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
g_free (node->name);
|
|
|
|
g_free (enum_->gtype_name);
|
|
|
|
g_free (enum_->gtype_init);
|
|
|
|
|
|
|
|
for (l = enum_->values; l; l = l->next)
|
|
|
|
g_ir_node_free ((GIrNode *)l->data);
|
|
|
|
g_list_free (enum_->values);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_BOXED:
|
|
|
|
{
|
|
|
|
GIrNodeBoxed *boxed = (GIrNodeBoxed *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
g_free (node->name);
|
|
|
|
g_free (boxed->gtype_name);
|
|
|
|
g_free (boxed->gtype_init);
|
|
|
|
|
|
|
|
for (l = boxed->members; l; l = l->next)
|
|
|
|
g_ir_node_free ((GIrNode *)l->data);
|
|
|
|
g_list_free (boxed->members);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_STRUCT:
|
|
|
|
{
|
|
|
|
GIrNodeStruct *struct_ = (GIrNodeStruct *)node;
|
|
|
|
|
|
|
|
g_free (node->name);
|
2008-09-06 22:33:51 +02:00
|
|
|
g_free (struct_->gtype_name);
|
|
|
|
g_free (struct_->gtype_init);
|
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = struct_->members; l; l = l->next)
|
|
|
|
g_ir_node_free ((GIrNode *)l->data);
|
|
|
|
g_list_free (struct_->members);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_CONSTANT:
|
|
|
|
{
|
|
|
|
GIrNodeConstant *constant = (GIrNodeConstant *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
g_free (node->name);
|
|
|
|
g_free (constant->value);
|
|
|
|
g_ir_node_free ((GIrNode *)constant->type);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_ERROR_DOMAIN:
|
|
|
|
{
|
|
|
|
GIrNodeErrorDomain *domain = (GIrNodeErrorDomain *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
g_free (node->name);
|
|
|
|
g_free (domain->getquark);
|
|
|
|
g_free (domain->codes);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_XREF:
|
|
|
|
{
|
|
|
|
GIrNodeXRef *xref = (GIrNodeXRef *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
g_free (node->name);
|
|
|
|
g_free (xref->namespace);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_UNION:
|
|
|
|
{
|
|
|
|
GIrNodeUnion *union_ = (GIrNodeUnion *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
g_free (node->name);
|
|
|
|
g_free (union_->gtype_name);
|
|
|
|
g_free (union_->gtype_init);
|
|
|
|
|
|
|
|
g_ir_node_free ((GIrNode *)union_->discriminator_type);
|
|
|
|
for (l = union_->members; l; l = l->next)
|
|
|
|
g_ir_node_free ((GIrNode *)l->data);
|
|
|
|
for (l = union_->discriminators; l; l = l->next)
|
|
|
|
g_ir_node_free ((GIrNode *)l->data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_error ("Unhandled node type %d\n", node->type);
|
|
|
|
break;
|
2010-03-24 19:00:06 +01:00
|
|
|
}
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2009-02-20 03:48:51 +01:00
|
|
|
g_hash_table_destroy (node->attributes);
|
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
g_free (node);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* returns the fixed size of the blob */
|
|
|
|
guint32
|
|
|
|
g_ir_node_get_size (GIrNode *node)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
gint size, n;
|
|
|
|
|
|
|
|
switch (node->type)
|
|
|
|
{
|
|
|
|
case G_IR_NODE_CALLBACK:
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (CallbackBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_FUNCTION:
|
2008-11-25 23:29:20 +01:00
|
|
|
size = sizeof (FunctionBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_PARAM:
|
2009-02-12 05:53:05 +01:00
|
|
|
/* See the comment in the G_IR_NODE_PARAM/ArgBlob writing below */
|
|
|
|
size = sizeof (ArgBlob) - sizeof (SimpleTypeBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_TYPE:
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (SimpleTypeBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_OBJECT:
|
|
|
|
{
|
|
|
|
GIrNodeInterface *iface = (GIrNodeInterface *)node;
|
|
|
|
|
|
|
|
n = g_list_length (iface->interfaces);
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (ObjectBlob) + 2 * (n + (n % 2));
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
for (l = iface->members; l; l = l->next)
|
|
|
|
size += g_ir_node_get_size ((GIrNode *)l->data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_INTERFACE:
|
|
|
|
{
|
|
|
|
GIrNodeInterface *iface = (GIrNodeInterface *)node;
|
|
|
|
|
|
|
|
n = g_list_length (iface->prerequisites);
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (InterfaceBlob) + 2 * (n + (n % 2));
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
for (l = iface->members; l; l = l->next)
|
|
|
|
size += g_ir_node_get_size ((GIrNode *)l->data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_ENUM:
|
|
|
|
case G_IR_NODE_FLAGS:
|
|
|
|
{
|
|
|
|
GIrNodeEnum *enum_ = (GIrNodeEnum *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (EnumBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = enum_->values; l; l = l->next)
|
|
|
|
size += g_ir_node_get_size ((GIrNode *)l->data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_VALUE:
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (ValueBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_STRUCT:
|
|
|
|
{
|
|
|
|
GIrNodeStruct *struct_ = (GIrNodeStruct *)node;
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (StructBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = struct_->members; l; l = l->next)
|
|
|
|
size += g_ir_node_get_size ((GIrNode *)l->data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_BOXED:
|
|
|
|
{
|
|
|
|
GIrNodeBoxed *boxed = (GIrNodeBoxed *)node;
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (StructBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = boxed->members; l; l = l->next)
|
|
|
|
size += g_ir_node_get_size ((GIrNode *)l->data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_PROPERTY:
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (PropertyBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_SIGNAL:
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (SignalBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_VFUNC:
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (VFuncBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_FIELD:
|
2009-11-09 19:17:23 +01:00
|
|
|
{
|
|
|
|
GIrNodeField *field = (GIrNodeField *)node;
|
|
|
|
|
|
|
|
size = sizeof (FieldBlob);
|
|
|
|
if (field->callback)
|
|
|
|
size += g_ir_node_get_size ((GIrNode *)field->callback);
|
|
|
|
}
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_CONSTANT:
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (ConstantBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_ERROR_DOMAIN:
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (ErrorDomainBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_XREF:
|
|
|
|
size = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_UNION:
|
|
|
|
{
|
|
|
|
GIrNodeUnion *union_ = (GIrNodeUnion *)node;
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (UnionBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
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)
|
|
|
|
size += g_ir_node_get_size ((GIrNode *)l->data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-03-24 19:00:06 +01:00
|
|
|
default:
|
2008-08-09 14:46:48 +02:00
|
|
|
g_error ("Unhandled node type '%s'\n",
|
|
|
|
g_ir_node_type_to_string (node->type));
|
|
|
|
size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_debug ("node %p type '%s' size %d", node,
|
|
|
|
g_ir_node_type_to_string (node->type), size);
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2009-02-20 03:48:51 +01:00
|
|
|
static void
|
|
|
|
add_attribute_size (gpointer key, gpointer value, gpointer data)
|
|
|
|
{
|
|
|
|
const gchar *key_str = key;
|
|
|
|
const gchar *value_str = value;
|
|
|
|
gint *size_p = data;
|
|
|
|
|
|
|
|
*size_p += sizeof (AttributeBlob);
|
|
|
|
*size_p += ALIGN_VALUE (strlen (key_str) + 1, 4);
|
|
|
|
*size_p += ALIGN_VALUE (strlen (value_str) + 1, 4);
|
|
|
|
}
|
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
/* returns the full size of the blob including variable-size parts */
|
|
|
|
static guint32
|
2008-08-18 10:52:47 +02:00
|
|
|
g_ir_node_get_full_size_internal (GIrNode *parent,
|
|
|
|
GIrNode *node)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
gint size, n;
|
|
|
|
|
|
|
|
if (node == NULL && parent != NULL)
|
|
|
|
g_error ("Caught NULL node, parent=%s", parent->name);
|
|
|
|
|
|
|
|
g_debug ("node %p type '%s'", node,
|
|
|
|
g_ir_node_type_to_string (node->type));
|
|
|
|
|
|
|
|
switch (node->type)
|
|
|
|
{
|
|
|
|
case G_IR_NODE_CALLBACK:
|
|
|
|
{
|
|
|
|
GIrNodeFunction *function = (GIrNodeFunction *)node;
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (CallbackBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
|
|
|
|
for (l = function->parameters; l; l = l->next)
|
|
|
|
{
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
|
|
|
|
}
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)function->result);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_FUNCTION:
|
|
|
|
{
|
|
|
|
GIrNodeFunction *function = (GIrNodeFunction *)node;
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (FunctionBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
|
|
|
|
size += ALIGN_VALUE (strlen (function->symbol) + 1, 4);
|
|
|
|
for (l = function->parameters; l; l = l->next)
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)function->result);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_PARAM:
|
|
|
|
{
|
|
|
|
GIrNodeParam *param = (GIrNodeParam *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
/* See the comment in the G_IR_NODE_PARAM/ArgBlob writing below */
|
|
|
|
size = sizeof (ArgBlob) - sizeof (SimpleTypeBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
if (node->name)
|
|
|
|
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
|
2010-03-24 19:00:06 +01:00
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)param->type);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_TYPE:
|
|
|
|
{
|
|
|
|
GIrNodeType *type = (GIrNodeType *)node;
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (SimpleTypeBlob);
|
|
|
|
if (type->tag >= GI_TYPE_TAG_ARRAY)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
g_debug ("node %p type tag '%s'", node,
|
2008-08-18 10:52:47 +02:00
|
|
|
g_type_tag_to_string (type->tag));
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
switch (type->tag)
|
|
|
|
{
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_ARRAY:
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (ArrayTypeBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
if (type->parameter_type1)
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)type->parameter_type1);
|
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_INTERFACE:
|
2009-02-12 05:53:05 +01:00
|
|
|
size += sizeof (InterfaceTypeBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_GLIST:
|
|
|
|
case GI_TYPE_TAG_GSLIST:
|
2009-02-12 05:53:05 +01:00
|
|
|
size += sizeof (ParamTypeBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
if (type->parameter_type1)
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)type->parameter_type1);
|
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_GHASH:
|
2009-02-12 05:53:05 +01:00
|
|
|
size += sizeof (ParamTypeBlob) * 2;
|
2008-08-09 14:46:48 +02:00
|
|
|
if (type->parameter_type1)
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)type->parameter_type1);
|
|
|
|
if (type->parameter_type2)
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)type->parameter_type2);
|
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_ERROR:
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
gint n;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
if (type->errors)
|
|
|
|
n = g_strv_length (type->errors);
|
|
|
|
else
|
|
|
|
n = 0;
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
size += sizeof (ErrorTypeBlob) + 2 * (n + n % 2);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_error ("Unknown type tag %d\n", type->tag);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_OBJECT:
|
|
|
|
{
|
|
|
|
GIrNodeInterface *iface = (GIrNodeInterface *)node;
|
|
|
|
|
|
|
|
n = g_list_length (iface->interfaces);
|
2009-02-06 19:37:13 +01:00
|
|
|
size = sizeof(ObjectBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
if (iface->parent)
|
|
|
|
size += ALIGN_VALUE (strlen (iface->parent) + 1, 4);
|
2009-02-20 23:34:20 +01:00
|
|
|
if (iface->glib_type_struct)
|
|
|
|
size += ALIGN_VALUE (strlen (iface->glib_type_struct) + 1, 4);
|
2008-08-09 14:46:48 +02:00
|
|
|
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
|
|
|
|
size += ALIGN_VALUE (strlen (iface->gtype_name) + 1, 4);
|
2008-08-13 23:44:38 +02:00
|
|
|
if (iface->gtype_init)
|
|
|
|
size += ALIGN_VALUE (strlen (iface->gtype_init) + 1, 4);
|
2008-08-09 14:46:48 +02:00
|
|
|
size += 2 * (n + (n % 2));
|
|
|
|
|
|
|
|
for (l = iface->members; l; l = l->next)
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_INTERFACE:
|
|
|
|
{
|
|
|
|
GIrNodeInterface *iface = (GIrNodeInterface *)node;
|
|
|
|
|
|
|
|
n = g_list_length (iface->prerequisites);
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (InterfaceBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
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);
|
|
|
|
size += 2 * (n + (n % 2));
|
|
|
|
|
|
|
|
for (l = iface->members; l; l = l->next)
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_ENUM:
|
|
|
|
case G_IR_NODE_FLAGS:
|
|
|
|
{
|
|
|
|
GIrNodeEnum *enum_ = (GIrNodeEnum *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (EnumBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
|
|
|
|
if (enum_->gtype_name)
|
|
|
|
{
|
|
|
|
size += ALIGN_VALUE (strlen (enum_->gtype_name) + 1, 4);
|
|
|
|
size += ALIGN_VALUE (strlen (enum_->gtype_init) + 1, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (l = enum_->values; l; l = l->next)
|
2010-03-24 19:00:06 +01:00
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_VALUE:
|
|
|
|
{
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (ValueBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_STRUCT:
|
|
|
|
{
|
|
|
|
GIrNodeStruct *struct_ = (GIrNodeStruct *)node;
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (StructBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
|
2008-09-06 22:33:51 +02:00
|
|
|
if (struct_->gtype_name)
|
|
|
|
size += ALIGN_VALUE (strlen (struct_->gtype_name) + 1, 4);
|
|
|
|
if (struct_->gtype_init)
|
|
|
|
size += ALIGN_VALUE (strlen (struct_->gtype_init) + 1, 4);
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = struct_->members; l; l = l->next)
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_BOXED:
|
|
|
|
{
|
|
|
|
GIrNodeBoxed *boxed = (GIrNodeBoxed *)node;
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (StructBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
|
|
|
|
if (boxed->gtype_name)
|
|
|
|
{
|
|
|
|
size += ALIGN_VALUE (strlen (boxed->gtype_name) + 1, 4);
|
|
|
|
size += ALIGN_VALUE (strlen (boxed->gtype_init) + 1, 4);
|
|
|
|
}
|
|
|
|
for (l = boxed->members; l; l = l->next)
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_PROPERTY:
|
|
|
|
{
|
|
|
|
GIrNodeProperty *prop = (GIrNodeProperty *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (PropertyBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
|
2010-03-24 19:00:06 +01:00
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)prop->type);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_SIGNAL:
|
|
|
|
{
|
|
|
|
GIrNodeSignal *signal = (GIrNodeSignal *)node;
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (SignalBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
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);
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)signal->result);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_VFUNC:
|
|
|
|
{
|
|
|
|
GIrNodeVFunc *vfunc = (GIrNodeVFunc *)node;
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (VFuncBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
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);
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)vfunc->result);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_FIELD:
|
|
|
|
{
|
|
|
|
GIrNodeField *field = (GIrNodeField *)node;
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (FieldBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
|
2009-11-09 19:17:23 +01:00
|
|
|
if (field->callback)
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)field->callback);
|
|
|
|
else
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)field->type);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_CONSTANT:
|
|
|
|
{
|
|
|
|
GIrNodeConstant *constant = (GIrNodeConstant *)node;
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (ConstantBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
|
|
|
|
/* FIXME non-string values */
|
|
|
|
size += ALIGN_VALUE (strlen (constant->value) + 1, 4);
|
2010-03-24 19:00:06 +01:00
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)constant->type);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_ERROR_DOMAIN:
|
|
|
|
{
|
|
|
|
GIrNodeErrorDomain *domain = (GIrNodeErrorDomain *)node;
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (ErrorDomainBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
|
|
|
|
size += ALIGN_VALUE (strlen (domain->getquark) + 1, 4);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_XREF:
|
|
|
|
{
|
|
|
|
GIrNodeXRef *xref = (GIrNodeXRef *)node;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
size = 0;
|
|
|
|
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
|
|
|
|
size += ALIGN_VALUE (strlen (xref->namespace) + 1, 4);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_UNION:
|
|
|
|
{
|
|
|
|
GIrNodeUnion *union_ = (GIrNodeUnion *)node;
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
size = sizeof (UnionBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
|
2008-09-06 22:33:51 +02:00
|
|
|
if (union_->gtype_name)
|
|
|
|
size += ALIGN_VALUE (strlen (union_->gtype_name) + 1, 4);
|
|
|
|
if (union_->gtype_init)
|
|
|
|
size += ALIGN_VALUE (strlen (union_->gtype_init) + 1, 4);
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = union_->members; l; l = l->next)
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
|
|
|
|
for (l = union_->discriminators; l; l = l->next)
|
|
|
|
size += g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-03-24 19:00:06 +01:00
|
|
|
default:
|
2008-08-09 14:46:48 +02:00
|
|
|
g_error ("Unknown type tag %d\n", node->type);
|
|
|
|
size = 0;
|
|
|
|
}
|
|
|
|
|
2008-08-28 18:55:37 +02:00
|
|
|
g_debug ("node %s%s%s%p type '%s' full size %d",
|
|
|
|
node->name ? "'" : "",
|
|
|
|
node->name ? node->name : "",
|
|
|
|
node->name ? "' " : "",
|
|
|
|
node, g_ir_node_type_to_string (node->type), size);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
guint32
|
|
|
|
g_ir_node_get_full_size (GIrNode *node)
|
|
|
|
{
|
|
|
|
return g_ir_node_get_full_size_internal (NULL, node);
|
|
|
|
}
|
|
|
|
|
2009-02-20 03:48:51 +01:00
|
|
|
guint32
|
|
|
|
g_ir_node_get_attribute_size (GIrNode *node)
|
|
|
|
{
|
|
|
|
guint32 size = 0;
|
|
|
|
g_hash_table_foreach (node->attributes, add_attribute_size, &size);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
int
|
|
|
|
g_ir_node_cmp (GIrNode *node,
|
|
|
|
GIrNode *other)
|
|
|
|
{
|
|
|
|
if (node->type < other->type)
|
|
|
|
return -1;
|
|
|
|
else if (node->type > other->type)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return strcmp (node->name, other->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
g_ir_node_can_have_member (GIrNode *node)
|
|
|
|
{
|
|
|
|
switch (node->type)
|
|
|
|
{
|
|
|
|
case G_IR_NODE_OBJECT:
|
|
|
|
case G_IR_NODE_INTERFACE:
|
|
|
|
case G_IR_NODE_BOXED:
|
|
|
|
case G_IR_NODE_STRUCT:
|
|
|
|
case G_IR_NODE_UNION:
|
|
|
|
return TRUE;
|
Bug 556543 – reduce compiler warnings
2008-10-16 Tommi Komulainen <tommi.komulainen@iki.fi>
Bug 556543 – reduce compiler warnings
* girepository/ginfo.c:
* girepository/girepository.c (register_internal,
count_interfaces, find_interface, find_namespace_version,
parse_version, g_irepository_require):
* girepository/girmodule.c (g_ir_module_build_typelib):
* girepository/girnode.c (init_stats, dump_stats,
_g_irnode_init_stats, _g_irnode_dump_stats,
g_ir_node_can_have_member):
* girepository/girparser.c (firstpass_end_element_handler,
locate_gir, parse_basic, parse_type_internal, resolve_aliases,
start_alias, start_type, end_type_top, parse_include, cleanup,
post_filter):
* girepository/gtypelib.c (validate_function_blob, validate_enum_blob):
* giscanner/giscannermodule.c (directive_get_options,
type_get_child_list):
* giscanner/scannerlexer.l (parse_gtkdoc):
* giscanner/scannerparser.y (ctype_free):
* giscanner/sourcescanner.c:
* giscanner/sourcescanner.h (gi_source_scanner_parse_macros):
* tests/types/gitesttypes.c:
* tools/compiler.c (main):
* tools/generate.c (write_repository): Remove unused variables
and code, add missing includes, declarations and case
statements.
svn path=/trunk/; revision=730
2008-10-16 19:07:05 +02:00
|
|
|
/* list others individually rather than with default: so that compiler
|
|
|
|
* warns if new node types are added without adding them to the switch
|
|
|
|
*/
|
|
|
|
case G_IR_NODE_INVALID:
|
|
|
|
case G_IR_NODE_FUNCTION:
|
|
|
|
case G_IR_NODE_CALLBACK:
|
|
|
|
case G_IR_NODE_ENUM:
|
|
|
|
case G_IR_NODE_FLAGS:
|
|
|
|
case G_IR_NODE_CONSTANT:
|
|
|
|
case G_IR_NODE_ERROR_DOMAIN:
|
|
|
|
case G_IR_NODE_PARAM:
|
|
|
|
case G_IR_NODE_TYPE:
|
|
|
|
case G_IR_NODE_PROPERTY:
|
|
|
|
case G_IR_NODE_SIGNAL:
|
|
|
|
case G_IR_NODE_VALUE:
|
|
|
|
case G_IR_NODE_VFUNC:
|
|
|
|
case G_IR_NODE_FIELD:
|
|
|
|
case G_IR_NODE_XREF:
|
|
|
|
return FALSE;
|
2008-08-09 14:46:48 +02:00
|
|
|
};
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
g_ir_node_add_member (GIrNode *node,
|
2008-08-18 10:52:47 +02:00
|
|
|
GIrNodeFunction *member)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
g_return_if_fail (node != NULL);
|
|
|
|
g_return_if_fail (member != NULL);
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
switch (node->type)
|
|
|
|
{
|
|
|
|
case G_IR_NODE_OBJECT:
|
|
|
|
case G_IR_NODE_INTERFACE:
|
|
|
|
{
|
|
|
|
GIrNodeInterface *iface = (GIrNodeInterface *)node;
|
|
|
|
iface->members =
|
|
|
|
g_list_insert_sorted (iface->members, member,
|
|
|
|
(GCompareFunc) g_ir_node_cmp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case G_IR_NODE_BOXED:
|
|
|
|
{
|
|
|
|
GIrNodeBoxed *boxed = (GIrNodeBoxed *)node;
|
|
|
|
boxed->members =
|
|
|
|
g_list_insert_sorted (boxed->members, member,
|
|
|
|
(GCompareFunc) g_ir_node_cmp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case G_IR_NODE_STRUCT:
|
|
|
|
{
|
|
|
|
GIrNodeStruct *struct_ = (GIrNodeStruct *)node;
|
|
|
|
struct_->members =
|
|
|
|
g_list_insert_sorted (struct_->members, member,
|
|
|
|
(GCompareFunc) g_ir_node_cmp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case G_IR_NODE_UNION:
|
|
|
|
{
|
|
|
|
GIrNodeUnion *union_ = (GIrNodeUnion *)node;
|
|
|
|
union_->members =
|
|
|
|
g_list_insert_sorted (union_->members, member,
|
|
|
|
(GCompareFunc) g_ir_node_cmp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
g_error ("Cannot add a member to unknown type tag type %d\n",
|
|
|
|
node->type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const gchar *
|
|
|
|
g_ir_node_param_direction_string (GIrNodeParam * node)
|
|
|
|
{
|
|
|
|
if (node->out)
|
|
|
|
{
|
|
|
|
if (node->in)
|
|
|
|
return "in-out";
|
|
|
|
else
|
|
|
|
return "out";
|
|
|
|
}
|
|
|
|
return "in";
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint64
|
|
|
|
parse_int_value (const gchar *str)
|
|
|
|
{
|
|
|
|
return strtoll (str, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static guint64
|
|
|
|
parse_uint_value (const gchar *str)
|
|
|
|
{
|
|
|
|
return strtoull (str, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gdouble
|
|
|
|
parse_float_value (const gchar *str)
|
|
|
|
{
|
|
|
|
return strtod (str, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
parse_boolean_value (const gchar *str)
|
|
|
|
{
|
|
|
|
if (strcmp (str, "TRUE") == 0)
|
|
|
|
return TRUE;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
if (strcmp (str, "FALSE") == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return parse_int_value (str) ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GIrNode *
|
2008-08-18 10:52:47 +02:00
|
|
|
find_entry_node (GIrModule *module,
|
2008-08-09 14:46:48 +02:00
|
|
|
GList *modules,
|
|
|
|
const gchar *name,
|
|
|
|
guint16 *idx)
|
|
|
|
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
gint i;
|
|
|
|
gchar **names;
|
|
|
|
gint n_names;
|
|
|
|
GIrNode *result = NULL;
|
|
|
|
|
2008-08-18 10:52:47 +02:00
|
|
|
g_assert (name != NULL);
|
|
|
|
g_assert (strlen (name) > 0);
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
names = g_strsplit (name, ".", 0);
|
|
|
|
n_names = g_strv_length (names);
|
|
|
|
if (n_names > 2)
|
|
|
|
g_error ("Too many name parts");
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = module->entries, i = 1; l; l = l->next, i++)
|
|
|
|
{
|
|
|
|
GIrNode *node = (GIrNode *)l->data;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
if (n_names > 1)
|
|
|
|
{
|
|
|
|
if (node->type != G_IR_NODE_XREF)
|
|
|
|
continue;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
if (((GIrNodeXRef *)node)->namespace == NULL ||
|
|
|
|
strcmp (((GIrNodeXRef *)node)->namespace, names[0]) != 0)
|
|
|
|
continue;
|
|
|
|
}
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
if (strcmp (node->name, names[n_names - 1]) == 0)
|
|
|
|
{
|
|
|
|
if (idx)
|
|
|
|
*idx = i;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
result = node;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n_names > 1)
|
|
|
|
{
|
|
|
|
GIrNode *node = g_ir_node_new (G_IR_NODE_XREF);
|
|
|
|
|
|
|
|
((GIrNodeXRef *)node)->namespace = g_strdup (names[0]);
|
|
|
|
node->name = g_strdup (names[1]);
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
module->entries = g_list_append (module->entries, node);
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
if (idx)
|
|
|
|
*idx = g_list_length (module->entries);
|
|
|
|
|
|
|
|
result = node;
|
|
|
|
|
2008-08-23 23:30:06 +02:00
|
|
|
g_debug ("Creating XREF: %s %s", names[0], names[1]);
|
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2010-02-11 23:18:28 +01:00
|
|
|
g_ir_module_fatal (module, 0, "Type reference '%s' not found", name);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
out:
|
|
|
|
|
|
|
|
g_strfreev (names);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static guint16
|
2008-08-18 10:52:47 +02:00
|
|
|
find_entry (GIrModule *module,
|
2008-08-09 14:46:48 +02:00
|
|
|
GList *modules,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
guint16 idx = 0;
|
|
|
|
|
|
|
|
find_entry_node (module, modules, name, &idx);
|
|
|
|
|
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
2008-11-11 01:48:17 +01:00
|
|
|
static GIrNode *
|
|
|
|
find_name_in_module (GIrModule *module,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = module->entries; l; l = l->next)
|
|
|
|
{
|
|
|
|
GIrNode *node = (GIrNode *)l->data;
|
|
|
|
|
|
|
|
if (strcmp (node->name, name) == 0)
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
g_ir_find_node (GIrModule *module,
|
|
|
|
GList *modules,
|
|
|
|
const char *name,
|
|
|
|
GIrNode **node_out,
|
|
|
|
GIrModule **module_out)
|
|
|
|
{
|
|
|
|
char **names = g_strsplit (name, ".", 0);
|
|
|
|
gint n_names = g_strv_length (names);
|
|
|
|
GIrNode *node = NULL;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
if (n_names == 0)
|
|
|
|
{
|
|
|
|
g_warning ("Name can't be empty");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n_names > 2)
|
|
|
|
{
|
|
|
|
g_warning ("Too many name parts in '%s'", name);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n_names == 1)
|
|
|
|
{
|
|
|
|
*module_out = module;
|
|
|
|
node = find_name_in_module (module, names[0]);
|
|
|
|
}
|
|
|
|
else if (strcmp (names[0], module->name) == 0)
|
|
|
|
{
|
|
|
|
*module_out = module;
|
|
|
|
node = find_name_in_module (module, names[1]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (l = module->include_modules; l; l = l->next)
|
|
|
|
{
|
|
|
|
GIrModule *m = l->data;
|
|
|
|
|
|
|
|
if (strcmp (names[0], m->name) == 0)
|
|
|
|
{
|
|
|
|
*module_out = m;
|
|
|
|
node = find_name_in_module (m, names[1]);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (l = modules; l; l = l->next)
|
|
|
|
{
|
|
|
|
GIrModule *m = l->data;
|
|
|
|
|
|
|
|
if (strcmp (names[0], m->name) == 0)
|
|
|
|
{
|
|
|
|
*module_out = m;
|
|
|
|
node = find_name_in_module (m, names[1]);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
g_strfreev (names);
|
|
|
|
|
|
|
|
*node_out = node;
|
|
|
|
|
|
|
|
return node != NULL;
|
|
|
|
}
|
|
|
|
|
2009-02-28 01:02:48 +01:00
|
|
|
static int
|
|
|
|
get_index_of_member_type (GIrNodeInterface *node,
|
|
|
|
GIrNodeTypeId type,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
guint index = -1;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = node->members; l; l = l->next)
|
|
|
|
{
|
|
|
|
GIrNode *node = l->data;
|
|
|
|
|
|
|
|
if (node->type != type)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
if (strcmp (node->name, name) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
static void
|
2010-03-24 19:00:06 +01:00
|
|
|
serialize_type (GIrModule *module,
|
2008-08-09 14:46:48 +02:00
|
|
|
GList *modules,
|
2010-03-24 19:00:06 +01:00
|
|
|
GIrNodeType *node,
|
2008-08-09 14:46:48 +02:00
|
|
|
GString *str)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
const gchar* basic[] = {
|
2010-03-24 19:00:06 +01:00
|
|
|
"void",
|
|
|
|
"boolean",
|
|
|
|
"int8",
|
|
|
|
"uint8",
|
|
|
|
"int16",
|
|
|
|
"uint16",
|
|
|
|
"int32",
|
|
|
|
"uint32",
|
|
|
|
"int64",
|
|
|
|
"uint64",
|
2009-07-06 17:17:40 +02:00
|
|
|
"short",
|
|
|
|
"ushort",
|
2008-08-09 14:46:48 +02:00
|
|
|
"int",
|
|
|
|
"uint",
|
|
|
|
"long",
|
|
|
|
"ulong",
|
|
|
|
"ssize",
|
|
|
|
"size",
|
2010-03-24 19:00:06 +01:00
|
|
|
"float",
|
2008-08-09 14:46:48 +02:00
|
|
|
"double",
|
2009-07-06 17:17:40 +02:00
|
|
|
"time_t",
|
|
|
|
"GType",
|
2010-03-24 19:00:06 +01:00
|
|
|
"utf8",
|
2008-08-09 14:46:48 +02:00
|
|
|
"filename",
|
|
|
|
};
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-23 00:15:28 +02:00
|
|
|
if (node->tag < GI_TYPE_TAG_ARRAY)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
2008-11-16 22:20:26 +01:00
|
|
|
g_string_append_printf (str, "%s%s", basic[node->tag],
|
|
|
|
node->is_pointer ? "*" : "");
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
2008-08-23 00:15:28 +02:00
|
|
|
else if (node->tag == GI_TYPE_TAG_ARRAY)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
serialize_type (module, modules, node->parameter_type1, str);
|
|
|
|
g_string_append (str, "[");
|
|
|
|
|
|
|
|
if (node->has_length)
|
|
|
|
g_string_append_printf (str, "length=%d", node->length);
|
2008-10-25 17:20:54 +02:00
|
|
|
else if (node->has_size)
|
|
|
|
g_string_append_printf (str, "fixed-size=%d", node->size);
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
if (node->zero_terminated)
|
2010-03-24 19:00:06 +01:00
|
|
|
g_string_append_printf (str, "%szero-terminated=1",
|
2008-08-09 14:46:48 +02:00
|
|
|
node->has_length ? "," : "");
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
g_string_append (str, "]");
|
|
|
|
}
|
2008-08-23 00:15:28 +02:00
|
|
|
else if (node->tag == GI_TYPE_TAG_INTERFACE)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
GIrNode *iface;
|
|
|
|
gchar *name;
|
|
|
|
|
|
|
|
iface = find_entry_node (module, modules, node->interface, NULL);
|
|
|
|
if (iface)
|
2008-11-13 23:56:15 +01:00
|
|
|
{
|
|
|
|
if (iface->type == G_IR_NODE_XREF)
|
|
|
|
g_string_append_printf (str, "%s.", ((GIrNodeXRef *)iface)->namespace);
|
|
|
|
name = iface->name;
|
|
|
|
}
|
2008-08-09 14:46:48 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("Interface for type reference %s not found", node->interface);
|
|
|
|
name = node->interface;
|
|
|
|
}
|
|
|
|
|
2008-11-16 22:20:26 +01:00
|
|
|
g_string_append_printf (str, "%s%s", name,
|
|
|
|
node->is_pointer ? "*" : "");
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
2008-08-23 00:15:28 +02:00
|
|
|
else if (node->tag == GI_TYPE_TAG_GLIST)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
g_string_append (str, "GList");
|
|
|
|
if (node->parameter_type1)
|
|
|
|
{
|
2010-03-24 19:00:06 +01:00
|
|
|
g_string_append (str, "<");
|
2008-08-09 14:46:48 +02:00
|
|
|
serialize_type (module, modules, node->parameter_type1, str);
|
2010-03-24 19:00:06 +01:00
|
|
|
g_string_append (str, ">");
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
}
|
2008-08-23 00:15:28 +02:00
|
|
|
else if (node->tag == GI_TYPE_TAG_GSLIST)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
g_string_append (str, "GSList");
|
|
|
|
if (node->parameter_type1)
|
|
|
|
{
|
2010-03-24 19:00:06 +01:00
|
|
|
g_string_append (str, "<");
|
2008-08-09 14:46:48 +02:00
|
|
|
serialize_type (module, modules, node->parameter_type1, str);
|
2010-03-24 19:00:06 +01:00
|
|
|
g_string_append (str, ">");
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
}
|
2008-08-23 00:15:28 +02:00
|
|
|
else if (node->tag == GI_TYPE_TAG_GHASH)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
g_string_append (str, "GHashTable<");
|
|
|
|
if (node->parameter_type1)
|
|
|
|
{
|
2010-03-24 19:00:06 +01:00
|
|
|
g_string_append (str, "<");
|
2008-08-09 14:46:48 +02:00
|
|
|
serialize_type (module, modules, node->parameter_type1, str);
|
2010-03-24 19:00:06 +01:00
|
|
|
g_string_append (str, ",");
|
2008-08-09 14:46:48 +02:00
|
|
|
serialize_type (module, modules, node->parameter_type2, str);
|
2010-03-24 19:00:06 +01:00
|
|
|
g_string_append (str, ">");
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
}
|
2008-08-23 00:15:28 +02:00
|
|
|
else if (node->tag == GI_TYPE_TAG_ERROR)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
g_string_append (str, "GError");
|
|
|
|
if (node->errors)
|
|
|
|
{
|
2010-03-24 19:00:06 +01:00
|
|
|
g_string_append (str, "<");
|
2008-08-09 14:46:48 +02:00
|
|
|
for (i = 0; node->errors[i]; i++)
|
|
|
|
{
|
|
|
|
if (i > 0)
|
|
|
|
g_string_append (str, ",");
|
|
|
|
g_string_append (str, node->errors[i]);
|
|
|
|
}
|
2010-03-24 19:00:06 +01:00
|
|
|
g_string_append (str, ">");
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-16 00:28:41 +02:00
|
|
|
static void
|
|
|
|
g_ir_node_build_members (GList **members,
|
|
|
|
GIrNodeTypeId type,
|
|
|
|
guint16 *count,
|
2009-02-28 01:11:26 +01:00
|
|
|
GIrNode *parent,
|
2009-02-20 17:05:53 +01:00
|
|
|
GIrTypelibBuild *build,
|
2008-10-16 00:28:41 +02:00
|
|
|
guint32 *offset,
|
|
|
|
guint32 *offset2)
|
|
|
|
{
|
|
|
|
GList *l = *members;
|
|
|
|
|
|
|
|
while (l)
|
|
|
|
{
|
|
|
|
GIrNode *member = (GIrNode *)l->data;
|
|
|
|
GList *next = l->next;
|
|
|
|
|
|
|
|
if (member->type == type)
|
|
|
|
{
|
|
|
|
(*count)++;
|
2009-02-28 01:11:26 +01:00
|
|
|
g_ir_node_build_typelib (member, parent, build, offset, offset2);
|
2008-10-16 00:28:41 +02:00
|
|
|
*members = g_list_delete_link (*members, l);
|
|
|
|
}
|
|
|
|
l = next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-16 00:28:53 +02:00
|
|
|
static void
|
|
|
|
g_ir_node_check_unhandled_members (GList **members,
|
|
|
|
GIrNodeTypeId container_type)
|
|
|
|
{
|
2008-10-24 13:33:33 +02:00
|
|
|
#if 0
|
2008-10-16 00:28:53 +02:00
|
|
|
if (*members)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = *members; l; l = l->next)
|
|
|
|
{
|
|
|
|
GIrNode *member = (GIrNode *)l->data;
|
|
|
|
g_printerr ("Unhandled '%s' member '%s' type '%s'\n",
|
|
|
|
g_ir_node_type_to_string (container_type),
|
|
|
|
member->name,
|
|
|
|
g_ir_node_type_to_string (member->type));
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (*members);
|
|
|
|
*members = NULL;
|
|
|
|
|
|
|
|
g_error ("Unhandled members. Aborting.");
|
|
|
|
}
|
2008-10-24 13:33:33 +02:00
|
|
|
#else
|
|
|
|
g_list_free (*members);
|
|
|
|
*members = NULL;
|
|
|
|
#endif
|
2008-10-16 00:28:53 +02:00
|
|
|
}
|
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
void
|
2009-02-20 17:05:53 +01:00
|
|
|
g_ir_node_build_typelib (GIrNode *node,
|
2009-02-28 01:11:26 +01:00
|
|
|
GIrNode *parent,
|
2009-02-20 17:05:53 +01:00
|
|
|
GIrTypelibBuild *build,
|
|
|
|
guint32 *offset,
|
|
|
|
guint32 *offset2)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
2009-02-20 17:05:53 +01:00
|
|
|
GIrModule *module = build->module;
|
|
|
|
GList *modules = build->modules;
|
|
|
|
GHashTable *strings = build->strings;
|
|
|
|
GHashTable *types = build->types;
|
|
|
|
guchar *data = build->data;
|
2008-08-09 14:46:48 +02:00
|
|
|
GList *l;
|
|
|
|
guint32 old_offset = *offset;
|
|
|
|
guint32 old_offset2 = *offset2;
|
|
|
|
|
|
|
|
g_assert (node != NULL);
|
|
|
|
|
2008-08-28 18:55:37 +02:00
|
|
|
g_debug ("build_typelib: %s%s(%s)",
|
|
|
|
node->name ? node->name : "",
|
|
|
|
node->name ? " " : "",
|
2008-08-09 14:46:48 +02:00
|
|
|
g_ir_node_type_to_string (node->type));
|
|
|
|
|
2008-11-11 06:10:36 +01:00
|
|
|
g_ir_node_compute_offsets (node, module, modules);
|
|
|
|
|
2009-02-20 03:48:51 +01:00
|
|
|
/* We should only be building each node once. If we do a typelib expansion, we also
|
|
|
|
* reset the offset in girmodule.c.
|
|
|
|
*/
|
|
|
|
g_assert (node->offset == 0);
|
|
|
|
node->offset = *offset;
|
|
|
|
build->offset_ordered_nodes = g_list_prepend (build->offset_ordered_nodes, node);
|
|
|
|
|
|
|
|
build->n_attributes += g_hash_table_size (node->attributes);
|
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
switch (node->type)
|
|
|
|
{
|
|
|
|
case G_IR_NODE_TYPE:
|
|
|
|
{
|
|
|
|
GIrNodeType *type = (GIrNodeType *)node;
|
|
|
|
SimpleTypeBlob *blob = (SimpleTypeBlob *)&data[*offset];
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
*offset += sizeof (SimpleTypeBlob);
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-12 17:34:27 +02:00
|
|
|
if (type->tag < GI_TYPE_TAG_ARRAY ||
|
2008-11-12 13:59:01 +01:00
|
|
|
type->tag == GI_TYPE_TAG_UTF8 ||
|
|
|
|
type->tag == GI_TYPE_TAG_FILENAME)
|
2010-03-24 19:00:06 +01:00
|
|
|
{
|
2009-06-24 23:52:05 +02:00
|
|
|
blob->flags.reserved = 0;
|
|
|
|
blob->flags.reserved2 = 0;
|
|
|
|
blob->flags.pointer = type->is_pointer;
|
|
|
|
blob->flags.reserved3 = 0;
|
|
|
|
blob->flags.tag = type->tag;
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
2010-03-24 19:00:06 +01:00
|
|
|
else
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
GString *str;
|
|
|
|
gchar *s;
|
|
|
|
gpointer value;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
str = g_string_new (0);
|
|
|
|
serialize_type (module, modules, type, str);
|
|
|
|
s = g_string_free (str, FALSE);
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
types_count += 1;
|
|
|
|
value = g_hash_table_lookup (types, s);
|
|
|
|
if (value)
|
|
|
|
{
|
2008-08-23 23:30:06 +02:00
|
|
|
blob->offset = GPOINTER_TO_UINT (value);
|
2008-08-09 14:46:48 +02:00
|
|
|
g_free (s);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unique_types_count += 1;
|
2008-08-23 23:30:06 +02:00
|
|
|
g_hash_table_insert (types, s, GUINT_TO_POINTER(*offset2));
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->offset = *offset2;
|
|
|
|
switch (type->tag)
|
|
|
|
{
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_ARRAY:
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
ArrayTypeBlob *array = (ArrayTypeBlob *)&data[*offset2];
|
|
|
|
guint32 pos;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
array->pointer = 1;
|
|
|
|
array->reserved = 0;
|
|
|
|
array->tag = type->tag;
|
|
|
|
array->zero_terminated = type->zero_terminated;
|
|
|
|
array->has_length = type->has_length;
|
2008-10-25 17:20:54 +02:00
|
|
|
array->has_size = type->has_size;
|
2010-05-04 16:57:51 +02:00
|
|
|
array->array_type = type->array_type;
|
2008-08-09 14:46:48 +02:00
|
|
|
array->reserved2 = 0;
|
2008-10-25 17:20:54 +02:00
|
|
|
if (array->has_length)
|
2009-06-24 23:52:05 +02:00
|
|
|
array->dimensions.length = type->length;
|
2008-10-25 17:20:54 +02:00
|
|
|
else if (array->has_size)
|
2009-06-24 23:52:05 +02:00
|
|
|
array->dimensions.size = type->size;
|
2008-10-25 17:20:54 +02:00
|
|
|
else
|
2009-06-24 23:52:05 +02:00
|
|
|
array->dimensions.length = -1;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
pos = *offset2 + G_STRUCT_OFFSET (ArrayTypeBlob, type);
|
|
|
|
*offset2 += sizeof (ArrayTypeBlob);
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2009-02-28 01:11:26 +01:00
|
|
|
g_ir_node_build_typelib ((GIrNode *)type->parameter_type1,
|
|
|
|
node, build, &pos, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_INTERFACE:
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
InterfaceTypeBlob *iface = (InterfaceTypeBlob *)&data[*offset2];
|
2009-02-12 05:53:05 +01:00
|
|
|
*offset2 += sizeof (InterfaceTypeBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
iface->pointer = type->is_pointer;
|
|
|
|
iface->reserved = 0;
|
|
|
|
iface->tag = type->tag;
|
|
|
|
iface->reserved2 = 0;
|
|
|
|
iface->interface = find_entry (module, modules, type->interface);
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_GLIST:
|
|
|
|
case GI_TYPE_TAG_GSLIST:
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
ParamTypeBlob *param = (ParamTypeBlob *)&data[*offset2];
|
|
|
|
guint32 pos;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
param->pointer = 1;
|
|
|
|
param->reserved = 0;
|
|
|
|
param->tag = type->tag;
|
|
|
|
param->reserved2 = 0;
|
|
|
|
param->n_types = 1;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
pos = *offset2 + G_STRUCT_OFFSET (ParamTypeBlob, type);
|
|
|
|
*offset2 += sizeof (ParamTypeBlob) + sizeof (SimpleTypeBlob);
|
2010-03-24 19:00:06 +01:00
|
|
|
|
|
|
|
g_ir_node_build_typelib ((GIrNode *)type->parameter_type1,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, &pos, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_GHASH:
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
ParamTypeBlob *param = (ParamTypeBlob *)&data[*offset2];
|
|
|
|
guint32 pos;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
param->pointer = 1;
|
|
|
|
param->reserved = 0;
|
|
|
|
param->tag = type->tag;
|
|
|
|
param->reserved2 = 0;
|
|
|
|
param->n_types = 2;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
pos = *offset2 + G_STRUCT_OFFSET (ParamTypeBlob, type);
|
|
|
|
*offset2 += sizeof (ParamTypeBlob) + sizeof (SimpleTypeBlob)*2;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
|
|
|
g_ir_node_build_typelib ((GIrNode *)type->parameter_type1,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, &pos, offset2);
|
2010-03-24 19:00:06 +01:00
|
|
|
g_ir_node_build_typelib ((GIrNode *)type->parameter_type2,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, &pos, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_ERROR:
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
ErrorTypeBlob *blob = (ErrorTypeBlob *)&data[*offset2];
|
|
|
|
gint i;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->pointer = 1;
|
|
|
|
blob->reserved = 0;
|
|
|
|
blob->tag = type->tag;
|
|
|
|
blob->reserved2 = 0;
|
2010-03-24 19:00:06 +01:00
|
|
|
if (type->errors)
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->n_domains = g_strv_length (type->errors);
|
|
|
|
else
|
|
|
|
blob->n_domains = 0;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
*offset2 = ALIGN_VALUE (*offset2 + G_STRUCT_OFFSET (ErrorTypeBlob, domains)
|
|
|
|
+ 2 * blob->n_domains, 4);
|
2008-08-09 14:46:48 +02:00
|
|
|
for (i = 0; i < blob->n_domains; i++)
|
|
|
|
blob->domains[i] = find_entry (module, modules, type->errors[i]);
|
|
|
|
}
|
|
|
|
break;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
default:
|
|
|
|
g_error ("Unknown type tag %d\n", type->tag);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_FIELD:
|
|
|
|
{
|
|
|
|
GIrNodeField *field = (GIrNodeField *)node;
|
|
|
|
FieldBlob *blob;
|
|
|
|
|
|
|
|
blob = (FieldBlob *)&data[*offset];
|
|
|
|
|
|
|
|
blob->name = write_string (node->name, strings, data, offset2);
|
|
|
|
blob->readable = field->readable;
|
|
|
|
blob->writable = field->writable;
|
|
|
|
blob->reserved = 0;
|
|
|
|
blob->bits = 0;
|
2008-11-11 06:10:36 +01:00
|
|
|
if (field->offset >= 0)
|
|
|
|
blob->struct_offset = field->offset;
|
|
|
|
else
|
|
|
|
blob->struct_offset = 0xFFFF; /* mark as unknown */
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2009-11-09 19:17:23 +01:00
|
|
|
if (field->callback)
|
|
|
|
{
|
|
|
|
blob->has_embedded_type = TRUE;
|
|
|
|
blob->type.offset = GI_INFO_TYPE_CALLBACK;
|
|
|
|
*offset += sizeof (FieldBlob);
|
|
|
|
g_ir_node_build_typelib ((GIrNode *)field->callback,
|
|
|
|
node, build, offset, offset2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
blob->has_embedded_type = FALSE;
|
|
|
|
/* We handle the size member specially below, so subtract it */
|
|
|
|
*offset += sizeof (FieldBlob) - sizeof (SimpleTypeBlob);
|
|
|
|
g_ir_node_build_typelib ((GIrNode *)field->type,
|
|
|
|
node, build, offset, offset2);
|
|
|
|
}
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_PROPERTY:
|
|
|
|
{
|
|
|
|
GIrNodeProperty *prop = (GIrNodeProperty *)node;
|
|
|
|
PropertyBlob *blob = (PropertyBlob *)&data[*offset];
|
2009-02-12 05:53:05 +01:00
|
|
|
/* We handle the size member specially below, so subtract it */
|
|
|
|
*offset += sizeof (PropertyBlob) - sizeof (SimpleTypeBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
blob->name = write_string (node->name, strings, data, offset2);
|
|
|
|
blob->deprecated = prop->deprecated;
|
|
|
|
blob->readable = prop->readable;
|
2010-03-24 19:20:14 +01:00
|
|
|
blob->writable = prop->writable;
|
|
|
|
blob->construct = prop->construct;
|
|
|
|
blob->construct_only = prop->construct_only;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->reserved = 0;
|
|
|
|
|
2010-03-24 19:00:06 +01:00
|
|
|
g_ir_node_build_typelib ((GIrNode *)prop->type,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_FUNCTION:
|
|
|
|
{
|
|
|
|
FunctionBlob *blob = (FunctionBlob *)&data[*offset];
|
|
|
|
SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2];
|
|
|
|
GIrNodeFunction *function = (GIrNodeFunction *)node;
|
|
|
|
guint32 signature;
|
|
|
|
gint n;
|
|
|
|
|
|
|
|
signature = *offset2;
|
|
|
|
n = g_list_length (function->parameters);
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
*offset += sizeof (FunctionBlob);
|
|
|
|
*offset2 += sizeof (SignatureBlob) + n * sizeof (ArgBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
blob->blob_type = BLOB_TYPE_FUNCTION;
|
|
|
|
blob->deprecated = function->deprecated;
|
2008-11-25 23:29:20 +01:00
|
|
|
blob->is_static = !function->is_method;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->setter = function->is_setter;
|
|
|
|
blob->getter = function->is_getter;
|
|
|
|
blob->constructor = function->is_constructor;
|
|
|
|
blob->wraps_vfunc = function->wraps_vfunc;
|
2008-10-21 19:04:11 +02:00
|
|
|
blob->throws = function->throws;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->index = 0;
|
|
|
|
blob->name = write_string (node->name, strings, data, offset2);
|
|
|
|
blob->symbol = write_string (function->symbol, strings, data, offset2);
|
|
|
|
blob->signature = signature;
|
2008-08-23 18:46:58 +02:00
|
|
|
|
|
|
|
g_debug ("building function '%s'", function->symbol);
|
|
|
|
|
2010-03-24 19:00:06 +01:00
|
|
|
g_ir_node_build_typelib ((GIrNode *)function->result->type,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, &signature, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-22 16:02:02 +02:00
|
|
|
blob2->may_return_null = function->result->allow_none;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob2->caller_owns_return_value = function->result->transfer;
|
|
|
|
blob2->caller_owns_return_container = function->result->shallow_transfer;
|
|
|
|
blob2->reserved = 0;
|
|
|
|
blob2->n_arguments = n;
|
|
|
|
|
|
|
|
signature += 4;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = function->parameters; l; l = l->next)
|
|
|
|
{
|
|
|
|
GIrNode *param = (GIrNode *)l->data;
|
|
|
|
|
2009-02-28 01:11:26 +01:00
|
|
|
g_ir_node_build_typelib (param, node, build, &signature, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
2008-08-23 18:46:58 +02:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_CALLBACK:
|
|
|
|
{
|
|
|
|
CallbackBlob *blob = (CallbackBlob *)&data[*offset];
|
|
|
|
SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2];
|
|
|
|
GIrNodeFunction *function = (GIrNodeFunction *)node;
|
|
|
|
guint32 signature;
|
|
|
|
gint n;
|
|
|
|
|
|
|
|
signature = *offset2;
|
|
|
|
n = g_list_length (function->parameters);
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
*offset += sizeof (CallbackBlob);
|
|
|
|
*offset2 += sizeof (SignatureBlob) + n * sizeof (ArgBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
blob->blob_type = BLOB_TYPE_CALLBACK;
|
|
|
|
blob->deprecated = function->deprecated;
|
|
|
|
blob->reserved = 0;
|
|
|
|
blob->name = write_string (node->name, strings, data, offset2);
|
|
|
|
blob->signature = signature;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
|
|
|
g_ir_node_build_typelib ((GIrNode *)function->result->type,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, &signature, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-22 16:02:02 +02:00
|
|
|
blob2->may_return_null = function->result->allow_none;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob2->caller_owns_return_value = function->result->transfer;
|
|
|
|
blob2->caller_owns_return_container = function->result->shallow_transfer;
|
|
|
|
blob2->reserved = 0;
|
|
|
|
blob2->n_arguments = n;
|
|
|
|
|
|
|
|
signature += 4;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = function->parameters; l; l = l->next)
|
|
|
|
{
|
|
|
|
GIrNode *param = (GIrNode *)l->data;
|
|
|
|
|
2009-02-28 01:11:26 +01:00
|
|
|
g_ir_node_build_typelib (param, node, build, &signature, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_SIGNAL:
|
|
|
|
{
|
|
|
|
SignalBlob *blob = (SignalBlob *)&data[*offset];
|
|
|
|
SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2];
|
|
|
|
GIrNodeSignal *signal = (GIrNodeSignal *)node;
|
|
|
|
guint32 signature;
|
|
|
|
gint n;
|
|
|
|
|
|
|
|
signature = *offset2;
|
|
|
|
n = g_list_length (signal->parameters);
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
*offset += sizeof (SignalBlob);
|
|
|
|
*offset2 += sizeof (SignatureBlob) + n * sizeof (ArgBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
blob->deprecated = signal->deprecated;
|
|
|
|
blob->run_first = signal->run_first;
|
|
|
|
blob->run_last = signal->run_last;
|
|
|
|
blob->run_cleanup = signal->run_cleanup;
|
|
|
|
blob->no_recurse = signal->no_recurse;
|
|
|
|
blob->detailed = signal->detailed;
|
|
|
|
blob->action = signal->action;
|
|
|
|
blob->no_hooks = signal->no_hooks;
|
|
|
|
blob->has_class_closure = 0; /* FIXME */
|
|
|
|
blob->true_stops_emit = 0; /* FIXME */
|
|
|
|
blob->reserved = 0;
|
|
|
|
blob->class_closure = 0; /* FIXME */
|
|
|
|
blob->name = write_string (node->name, strings, data, offset2);
|
|
|
|
blob->signature = signature;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
|
|
|
g_ir_node_build_typelib ((GIrNode *)signal->result->type,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, &signature, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-22 16:02:02 +02:00
|
|
|
blob2->may_return_null = signal->result->allow_none;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob2->caller_owns_return_value = signal->result->transfer;
|
|
|
|
blob2->caller_owns_return_container = signal->result->shallow_transfer;
|
|
|
|
blob2->reserved = 0;
|
|
|
|
blob2->n_arguments = n;
|
|
|
|
|
|
|
|
signature += 4;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = signal->parameters; l; l = l->next)
|
|
|
|
{
|
|
|
|
GIrNode *param = (GIrNode *)l->data;
|
|
|
|
|
2009-02-28 01:11:26 +01:00
|
|
|
g_ir_node_build_typelib (param, node, build, &signature, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_VFUNC:
|
|
|
|
{
|
|
|
|
VFuncBlob *blob = (VFuncBlob *)&data[*offset];
|
|
|
|
SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2];
|
|
|
|
GIrNodeVFunc *vfunc = (GIrNodeVFunc *)node;
|
|
|
|
guint32 signature;
|
|
|
|
gint n;
|
|
|
|
|
|
|
|
signature = *offset2;
|
|
|
|
n = g_list_length (vfunc->parameters);
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
*offset += sizeof (VFuncBlob);
|
|
|
|
*offset2 += sizeof (SignatureBlob) + n * sizeof (ArgBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
blob->name = write_string (node->name, strings, data, offset2);
|
|
|
|
blob->must_chain_up = 0; /* FIXME */
|
|
|
|
blob->must_be_implemented = 0; /* FIXME */
|
|
|
|
blob->must_not_be_implemented = 0; /* FIXME */
|
|
|
|
blob->class_closure = 0; /* FIXME */
|
|
|
|
blob->reserved = 0;
|
|
|
|
|
2009-02-28 01:02:48 +01:00
|
|
|
if (vfunc->invoker)
|
|
|
|
{
|
|
|
|
int index = get_index_of_member_type ((GIrNodeInterface*)parent, G_IR_NODE_FUNCTION, vfunc->invoker);
|
|
|
|
if (index == -1)
|
|
|
|
{
|
|
|
|
g_error ("Unknown member function %s for vfunc %s", vfunc->invoker, node->name);
|
|
|
|
}
|
|
|
|
blob->invoker = (guint) index;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
blob->invoker = 0x3ff; /* max of 10 bits */
|
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->struct_offset = vfunc->offset;
|
|
|
|
blob->reserved2 = 0;
|
|
|
|
blob->signature = signature;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
|
|
|
g_ir_node_build_typelib ((GIrNode *)vfunc->result->type,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, &signature, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-22 16:02:02 +02:00
|
|
|
blob2->may_return_null = vfunc->result->allow_none;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob2->caller_owns_return_value = vfunc->result->transfer;
|
|
|
|
blob2->caller_owns_return_container = vfunc->result->shallow_transfer;
|
|
|
|
blob2->reserved = 0;
|
|
|
|
blob2->n_arguments = n;
|
|
|
|
|
|
|
|
signature += 4;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = vfunc->parameters; l; l = l->next)
|
|
|
|
{
|
|
|
|
GIrNode *param = (GIrNode *)l->data;
|
|
|
|
|
2009-02-28 01:11:26 +01:00
|
|
|
g_ir_node_build_typelib (param, node, build, &signature, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_PARAM:
|
|
|
|
{
|
|
|
|
ArgBlob *blob = (ArgBlob *)&data[*offset];
|
|
|
|
GIrNodeParam *param = (GIrNodeParam *)node;
|
2009-02-12 05:53:05 +01:00
|
|
|
|
|
|
|
/* 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);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2010-03-24 19:20:14 +01:00
|
|
|
blob->name = write_string (node->name, strings, data, offset2);
|
|
|
|
blob->in = param->in;
|
|
|
|
blob->out = param->out;
|
2009-12-16 17:47:19 +01:00
|
|
|
blob->caller_allocates = param->caller_allocates;
|
2008-10-22 16:02:02 +02:00
|
|
|
blob->allow_none = param->allow_none;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->optional = param->optional;
|
|
|
|
blob->transfer_ownership = param->transfer;
|
|
|
|
blob->transfer_container_ownership = param->shallow_transfer;
|
|
|
|
blob->return_value = param->retval;
|
Bug 556489 – callback annotations
2008-01-03 Andreas Rottmann <a.rottmann@gmx.at>
Bug 556489 – callback annotations
* giscanner/transformer.py
* tools/generate.c (write_callable_info): Write out the new scope,
closure and destroy attributes.
* giscanner/transformer.py (Transformer._type_is_callback): New
method, checking if a given type is a callback.
(Transformer._augment_callback_params): New method; adds
information (closure, destroy) to callback parameters.
(Transformer._handle_closure, Transformer._handle_destroy): New methods,
auxiliary to _augment_callback_params.
(Transformer._create_function): Call _augment_callback_params().
(Transformer._create_parameter): Handle scope option.
(Transformer._create_typedef_callback): New method, creates a
callback, and registers it in the typedef namespace
(Transformer._create_typedef): Use _create_typedef_callback()
instead of the plain _create_callback().
* giscanner/ast.py (Parameter): Added callback-related fields.
* giscanner/girwriter.py: Write out new Parameter fields.
* girepository/girnode.h (GIrNodeParam): Added fields scope,
closure and destroy.
* girepository/gtypelib.h (ArgBlob): Ditto.
* girepository/girparser.c (start_parameter): Handle new fields.
* girepository/girmodule.c (g_ir_module_build_typelib): Adjust
arg_blob_size, bump major version due to this change.
* girepository/girnode.c (g_ir_node_get_full_size_internal)
(g_ir_node_build_typelib)
* girepository/gtypelib.c (g_typelib_check_sanity): ArgBlob size
adjustments.
(g_ir_node_build_typelib): Fill in new ArgBlob flags from param.
* girepository/girepository.h (GIScope): New enumeration, listing
the different possible scopes for callbacks.
* girepository/ginfo.c (g_arg_info_get_scope)
(g_arg_info_get_closure, g_arg_info_get_destroy): Accessors for
callback-related argument indices (callback scope, closure for a
callback, destroy notification for a callback).
* tests/scanner/: Added testcases for new features.
svn path=/trunk/; revision=998
2009-01-03 14:44:42 +01:00
|
|
|
blob->scope = param->scope;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->reserved = 0;
|
Bug 556489 – callback annotations
2008-01-03 Andreas Rottmann <a.rottmann@gmx.at>
Bug 556489 – callback annotations
* giscanner/transformer.py
* tools/generate.c (write_callable_info): Write out the new scope,
closure and destroy attributes.
* giscanner/transformer.py (Transformer._type_is_callback): New
method, checking if a given type is a callback.
(Transformer._augment_callback_params): New method; adds
information (closure, destroy) to callback parameters.
(Transformer._handle_closure, Transformer._handle_destroy): New methods,
auxiliary to _augment_callback_params.
(Transformer._create_function): Call _augment_callback_params().
(Transformer._create_parameter): Handle scope option.
(Transformer._create_typedef_callback): New method, creates a
callback, and registers it in the typedef namespace
(Transformer._create_typedef): Use _create_typedef_callback()
instead of the plain _create_callback().
* giscanner/ast.py (Parameter): Added callback-related fields.
* giscanner/girwriter.py: Write out new Parameter fields.
* girepository/girnode.h (GIrNodeParam): Added fields scope,
closure and destroy.
* girepository/gtypelib.h (ArgBlob): Ditto.
* girepository/girparser.c (start_parameter): Handle new fields.
* girepository/girmodule.c (g_ir_module_build_typelib): Adjust
arg_blob_size, bump major version due to this change.
* girepository/girnode.c (g_ir_node_get_full_size_internal)
(g_ir_node_build_typelib)
* girepository/gtypelib.c (g_typelib_check_sanity): ArgBlob size
adjustments.
(g_ir_node_build_typelib): Fill in new ArgBlob flags from param.
* girepository/girepository.h (GIScope): New enumeration, listing
the different possible scopes for callbacks.
* girepository/ginfo.c (g_arg_info_get_scope)
(g_arg_info_get_closure, g_arg_info_get_destroy): Accessors for
callback-related argument indices (callback scope, closure for a
callback, destroy notification for a callback).
* tests/scanner/: Added testcases for new features.
svn path=/trunk/; revision=998
2009-01-03 14:44:42 +01:00
|
|
|
blob->closure = param->closure;
|
|
|
|
blob->destroy = param->destroy;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2009-02-28 01:11:26 +01:00
|
|
|
g_ir_node_build_typelib ((GIrNode *)param->type, node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_STRUCT:
|
|
|
|
{
|
|
|
|
StructBlob *blob = (StructBlob *)&data[*offset];
|
|
|
|
GIrNodeStruct *struct_ = (GIrNodeStruct *)node;
|
2008-10-16 00:28:41 +02:00
|
|
|
GList *members;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->blob_type = BLOB_TYPE_STRUCT;
|
2010-03-26 03:12:12 +01:00
|
|
|
blob->foreign = struct_->foreign;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->deprecated = struct_->deprecated;
|
2009-02-20 23:34:20 +01:00
|
|
|
blob->is_gtype_struct = struct_->is_gtype_struct;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->reserved = 0;
|
|
|
|
blob->name = write_string (node->name, strings, data, offset2);
|
2008-11-16 22:15:54 +01:00
|
|
|
blob->alignment = struct_->alignment;
|
|
|
|
blob->size = struct_->size;
|
|
|
|
|
2008-09-06 22:33:51 +02:00
|
|
|
if (struct_->gtype_name)
|
|
|
|
{
|
|
|
|
blob->unregistered = FALSE;
|
|
|
|
blob->gtype_name = write_string (struct_->gtype_name, strings, data, offset2);
|
|
|
|
blob->gtype_init = write_string (struct_->gtype_init, strings, data, offset2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
blob->unregistered = TRUE;
|
|
|
|
blob->gtype_name = 0;
|
|
|
|
blob->gtype_init = 0;
|
|
|
|
}
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
blob->n_fields = 0;
|
|
|
|
blob->n_methods = 0;
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
*offset += sizeof (StructBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-16 00:28:41 +02:00
|
|
|
members = g_list_copy (struct_->members);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-16 00:28:41 +02:00
|
|
|
g_ir_node_build_members (&members, G_IR_NODE_FIELD, &blob->n_fields,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-10-16 00:28:41 +02:00
|
|
|
|
|
|
|
g_ir_node_build_members (&members, G_IR_NODE_FUNCTION, &blob->n_methods,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-10-16 00:28:41 +02:00
|
|
|
|
2008-10-16 00:28:53 +02:00
|
|
|
g_ir_node_check_unhandled_members (&members, node->type);
|
|
|
|
|
|
|
|
g_assert (members == NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_BOXED:
|
|
|
|
{
|
|
|
|
StructBlob *blob = (StructBlob *)&data[*offset];
|
|
|
|
GIrNodeBoxed *boxed = (GIrNodeBoxed *)node;
|
2008-10-16 00:28:41 +02:00
|
|
|
GList *members;
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
blob->blob_type = BLOB_TYPE_BOXED;
|
|
|
|
blob->deprecated = boxed->deprecated;
|
|
|
|
blob->unregistered = FALSE;
|
|
|
|
blob->reserved = 0;
|
|
|
|
blob->name = write_string (node->name, strings, data, offset2);
|
|
|
|
blob->gtype_name = write_string (boxed->gtype_name, strings, data, offset2);
|
|
|
|
blob->gtype_init = write_string (boxed->gtype_init, strings, data, offset2);
|
2008-11-16 22:15:54 +01:00
|
|
|
blob->alignment = boxed->alignment;
|
|
|
|
blob->size = boxed->size;
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
blob->n_fields = 0;
|
|
|
|
blob->n_methods = 0;
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
*offset += sizeof (StructBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-16 00:28:41 +02:00
|
|
|
members = g_list_copy (boxed->members);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-16 00:28:41 +02:00
|
|
|
g_ir_node_build_members (&members, G_IR_NODE_FIELD, &blob->n_fields,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-16 00:28:41 +02:00
|
|
|
g_ir_node_build_members (&members, G_IR_NODE_FUNCTION, &blob->n_methods,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-10-16 00:28:41 +02:00
|
|
|
|
2008-10-16 00:28:53 +02:00
|
|
|
g_ir_node_check_unhandled_members (&members, node->type);
|
|
|
|
|
|
|
|
g_assert (members == NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_UNION:
|
|
|
|
{
|
|
|
|
UnionBlob *blob = (UnionBlob *)&data[*offset];
|
|
|
|
GIrNodeUnion *union_ = (GIrNodeUnion *)node;
|
2008-10-16 00:28:41 +02:00
|
|
|
GList *members;
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
blob->blob_type = BLOB_TYPE_UNION;
|
|
|
|
blob->deprecated = union_->deprecated;
|
2010-03-25 13:17:03 +01:00
|
|
|
blob->reserved = 0;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->name = write_string (node->name, strings, data, offset2);
|
2008-11-16 22:15:54 +01:00
|
|
|
blob->alignment = union_->alignment;
|
|
|
|
blob->size = union_->size;
|
2008-08-09 14:46:48 +02:00
|
|
|
if (union_->gtype_name)
|
|
|
|
{
|
|
|
|
blob->unregistered = FALSE;
|
|
|
|
blob->gtype_name = write_string (union_->gtype_name, strings, data, offset2);
|
|
|
|
blob->gtype_init = write_string (union_->gtype_init, strings, data, offset2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
blob->unregistered = TRUE;
|
|
|
|
blob->gtype_name = 0;
|
|
|
|
blob->gtype_init = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
blob->n_fields = 0;
|
|
|
|
blob->n_functions = 0;
|
|
|
|
|
|
|
|
blob->discriminator_offset = union_->discriminator_offset;
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
/* We don't support Union discriminators right now. */
|
2009-02-19 17:18:48 +01:00
|
|
|
/*
|
2008-08-09 14:46:48 +02:00
|
|
|
if (union_->discriminator_type)
|
|
|
|
{
|
2008-11-16 22:15:54 +01:00
|
|
|
*offset += 28;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->discriminated = TRUE;
|
2010-03-24 19:00:06 +01:00
|
|
|
g_ir_node_build_typelib ((GIrNode *)union_->discriminator_type,
|
2009-02-20 17:05:53 +01:00
|
|
|
build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
2009-02-19 15:56:20 +01:00
|
|
|
else
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
2009-02-19 15:56:20 +01:00
|
|
|
*/
|
2009-02-12 05:53:05 +01:00
|
|
|
*offset += sizeof (UnionBlob);
|
|
|
|
blob->discriminated = FALSE;
|
|
|
|
blob->discriminator_type.offset = 0;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-10-16 00:28:41 +02:00
|
|
|
members = g_list_copy (union_->members);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-16 00:28:41 +02:00
|
|
|
g_ir_node_build_members (&members, G_IR_NODE_FIELD, &blob->n_fields,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-16 00:28:41 +02:00
|
|
|
g_ir_node_build_members (&members, G_IR_NODE_FUNCTION, &blob->n_functions,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-16 00:28:53 +02:00
|
|
|
g_ir_node_check_unhandled_members (&members, node->type);
|
|
|
|
|
|
|
|
g_assert (members == NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
if (union_->discriminator_type)
|
|
|
|
{
|
|
|
|
for (l = union_->discriminators; l; l = l->next)
|
|
|
|
{
|
|
|
|
GIrNode *member = (GIrNode *)l->data;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2009-02-28 01:11:26 +01:00
|
|
|
g_ir_node_build_typelib (member, node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_ENUM:
|
|
|
|
case G_IR_NODE_FLAGS:
|
|
|
|
{
|
|
|
|
EnumBlob *blob = (EnumBlob *)&data[*offset];
|
|
|
|
GIrNodeEnum *enum_ = (GIrNodeEnum *)node;
|
|
|
|
|
2010-03-24 19:00:06 +01:00
|
|
|
*offset += sizeof (EnumBlob);
|
2009-02-12 05:53:05 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
if (node->type == G_IR_NODE_ENUM)
|
|
|
|
blob->blob_type = BLOB_TYPE_ENUM;
|
|
|
|
else
|
|
|
|
blob->blob_type = BLOB_TYPE_FLAGS;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->deprecated = enum_->deprecated;
|
|
|
|
blob->reserved = 0;
|
2008-11-18 13:29:10 +01:00
|
|
|
blob->storage_type = enum_->storage_type;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->name = write_string (node->name, strings, data, offset2);
|
|
|
|
if (enum_->gtype_name)
|
|
|
|
{
|
|
|
|
blob->unregistered = FALSE;
|
|
|
|
blob->gtype_name = write_string (enum_->gtype_name, strings, data, offset2);
|
|
|
|
blob->gtype_init = write_string (enum_->gtype_init, strings, data, offset2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
blob->unregistered = TRUE;
|
|
|
|
blob->gtype_name = 0;
|
|
|
|
blob->gtype_init = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
blob->n_values = 0;
|
|
|
|
blob->reserved2 = 0;
|
|
|
|
|
|
|
|
for (l = enum_->values; l; l = l->next)
|
|
|
|
{
|
|
|
|
GIrNode *value = (GIrNode *)l->data;
|
|
|
|
|
|
|
|
blob->n_values++;
|
2009-02-28 01:11:26 +01:00
|
|
|
g_ir_node_build_typelib (value, node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
case G_IR_NODE_OBJECT:
|
|
|
|
{
|
|
|
|
ObjectBlob *blob = (ObjectBlob *)&data[*offset];
|
|
|
|
GIrNodeInterface *object = (GIrNodeInterface *)node;
|
2008-10-16 00:28:41 +02:00
|
|
|
GList *members;
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
blob->blob_type = BLOB_TYPE_OBJECT;
|
2008-10-20 19:04:17 +02:00
|
|
|
blob->abstract = object->abstract;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->deprecated = object->deprecated;
|
|
|
|
blob->reserved = 0;
|
|
|
|
blob->name = write_string (node->name, strings, data, offset2);
|
|
|
|
blob->gtype_name = write_string (object->gtype_name, strings, data, offset2);
|
|
|
|
blob->gtype_init = write_string (object->gtype_init, strings, data, offset2);
|
|
|
|
if (object->parent)
|
|
|
|
blob->parent = find_entry (module, modules, object->parent);
|
|
|
|
else
|
|
|
|
blob->parent = 0;
|
2009-02-20 23:34:20 +01:00
|
|
|
if (object->glib_type_struct)
|
|
|
|
blob->gtype_struct = find_entry (module, modules, object->glib_type_struct);
|
2009-02-06 19:37:13 +01:00
|
|
|
else
|
2009-02-20 23:34:20 +01:00
|
|
|
blob->gtype_struct = 0;
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
blob->n_interfaces = 0;
|
|
|
|
blob->n_fields = 0;
|
|
|
|
blob->n_properties = 0;
|
|
|
|
blob->n_methods = 0;
|
|
|
|
blob->n_signals = 0;
|
|
|
|
blob->n_vfuncs = 0;
|
|
|
|
blob->n_constants = 0;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2009-02-06 19:37:13 +01:00
|
|
|
*offset += sizeof(ObjectBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = object->interfaces; l; l = l->next)
|
|
|
|
{
|
|
|
|
blob->n_interfaces++;
|
|
|
|
*(guint16*)&data[*offset] = find_entry (module, modules, (gchar *)l->data);
|
|
|
|
*offset += 2;
|
|
|
|
}
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-10-16 00:28:41 +02:00
|
|
|
members = g_list_copy (object->members);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2008-10-16 00:28:41 +02:00
|
|
|
g_ir_node_build_members (&members, G_IR_NODE_FIELD, &blob->n_fields,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2008-10-16 00:28:41 +02:00
|
|
|
g_ir_node_build_members (&members, G_IR_NODE_PROPERTY, &blob->n_properties,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2008-10-16 00:28:41 +02:00
|
|
|
g_ir_node_build_members (&members, G_IR_NODE_FUNCTION, &blob->n_methods,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2008-10-16 00:28:41 +02:00
|
|
|
g_ir_node_build_members (&members, G_IR_NODE_SIGNAL, &blob->n_signals,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-16 00:28:41 +02:00
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
|
|
|
g_ir_node_build_members (&members, G_IR_NODE_VFUNC, &blob->n_vfuncs,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2008-10-16 00:28:41 +02:00
|
|
|
g_ir_node_build_members (&members, G_IR_NODE_CONSTANT, &blob->n_constants,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-16 00:28:53 +02:00
|
|
|
g_ir_node_check_unhandled_members (&members, node->type);
|
|
|
|
|
|
|
|
g_assert (members == NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_INTERFACE:
|
|
|
|
{
|
|
|
|
InterfaceBlob *blob = (InterfaceBlob *)&data[*offset];
|
|
|
|
GIrNodeInterface *iface = (GIrNodeInterface *)node;
|
2008-10-16 00:28:41 +02:00
|
|
|
GList *members;
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
blob->blob_type = BLOB_TYPE_INTERFACE;
|
|
|
|
blob->deprecated = iface->deprecated;
|
|
|
|
blob->reserved = 0;
|
|
|
|
blob->name = write_string (node->name, strings, data, offset2);
|
|
|
|
blob->gtype_name = write_string (iface->gtype_name, strings, data, offset2);
|
|
|
|
blob->gtype_init = write_string (iface->gtype_init, strings, data, offset2);
|
2009-02-20 23:34:20 +01:00
|
|
|
if (iface->glib_type_struct)
|
|
|
|
blob->gtype_struct = find_entry (module, modules, iface->glib_type_struct);
|
|
|
|
else
|
|
|
|
blob->gtype_struct = 0;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->n_prerequisites = 0;
|
|
|
|
blob->n_properties = 0;
|
|
|
|
blob->n_methods = 0;
|
|
|
|
blob->n_signals = 0;
|
|
|
|
blob->n_vfuncs = 0;
|
|
|
|
blob->n_constants = 0;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
*offset += sizeof (InterfaceBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = iface->prerequisites; l; l = l->next)
|
|
|
|
{
|
|
|
|
blob->n_prerequisites++;
|
|
|
|
*(guint16*)&data[*offset] = find_entry (module, modules, (gchar *)l->data);
|
|
|
|
*offset += 2;
|
|
|
|
}
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-10-16 00:28:41 +02:00
|
|
|
members = g_list_copy (iface->members);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2008-10-16 00:28:41 +02:00
|
|
|
g_ir_node_build_members (&members, G_IR_NODE_PROPERTY, &blob->n_properties,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2008-10-16 00:28:41 +02:00
|
|
|
g_ir_node_build_members (&members, G_IR_NODE_FUNCTION, &blob->n_methods,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2008-10-16 00:28:41 +02:00
|
|
|
g_ir_node_build_members (&members, G_IR_NODE_SIGNAL, &blob->n_signals,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-16 00:28:41 +02:00
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
|
|
|
g_ir_node_build_members (&members, G_IR_NODE_VFUNC, &blob->n_vfuncs,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2008-10-16 00:28:41 +02:00
|
|
|
g_ir_node_build_members (&members, G_IR_NODE_CONSTANT, &blob->n_constants,
|
2009-02-28 01:11:26 +01:00
|
|
|
node, build, offset, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-16 00:28:53 +02:00
|
|
|
g_ir_node_check_unhandled_members (&members, node->type);
|
|
|
|
|
|
|
|
g_assert (members == NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case G_IR_NODE_VALUE:
|
|
|
|
{
|
|
|
|
GIrNodeValue *value = (GIrNodeValue *)node;
|
|
|
|
ValueBlob *blob = (ValueBlob *)&data[*offset];
|
2009-02-12 05:53:05 +01:00
|
|
|
*offset += sizeof (ValueBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
blob->deprecated = value->deprecated;
|
|
|
|
blob->reserved = 0;
|
|
|
|
blob->name = write_string (node->name, strings, data, offset2);
|
|
|
|
blob->value = value->value;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_ERROR_DOMAIN:
|
|
|
|
{
|
|
|
|
GIrNodeErrorDomain *domain = (GIrNodeErrorDomain *)node;
|
|
|
|
ErrorDomainBlob *blob = (ErrorDomainBlob *)&data[*offset];
|
2009-02-12 05:53:05 +01:00
|
|
|
*offset += sizeof (ErrorDomainBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
blob->blob_type = BLOB_TYPE_ERROR_DOMAIN;
|
|
|
|
blob->deprecated = domain->deprecated;
|
|
|
|
blob->reserved = 0;
|
|
|
|
blob->name = write_string (node->name, strings, data, offset2);
|
|
|
|
blob->get_quark = write_string (domain->getquark, strings, data, offset2);
|
|
|
|
blob->error_codes = find_entry (module, modules, domain->codes);
|
|
|
|
blob->reserved2 = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_IR_NODE_CONSTANT:
|
|
|
|
{
|
|
|
|
GIrNodeConstant *constant = (GIrNodeConstant *)node;
|
|
|
|
ConstantBlob *blob = (ConstantBlob *)&data[*offset];
|
|
|
|
guint32 pos;
|
|
|
|
|
2009-02-12 05:53:05 +01:00
|
|
|
pos = *offset + G_STRUCT_OFFSET (ConstantBlob, type);
|
|
|
|
*offset += sizeof (ConstantBlob);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
blob->blob_type = BLOB_TYPE_CONSTANT;
|
|
|
|
blob->deprecated = constant->deprecated;
|
|
|
|
blob->reserved = 0;
|
|
|
|
blob->name = write_string (node->name, strings, data, offset2);
|
|
|
|
|
|
|
|
blob->offset = *offset2;
|
|
|
|
switch (constant->type->tag)
|
|
|
|
{
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_BOOLEAN:
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->size = 4;
|
|
|
|
*(gboolean*)&data[blob->offset] = parse_boolean_value (constant->value);
|
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_INT8:
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->size = 1;
|
|
|
|
*(gint8*)&data[blob->offset] = (gint8) parse_int_value (constant->value);
|
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_UINT8:
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->size = 1;
|
|
|
|
*(guint8*)&data[blob->offset] = (guint8) parse_uint_value (constant->value);
|
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_INT16:
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->size = 2;
|
|
|
|
*(gint16*)&data[blob->offset] = (gint16) parse_int_value (constant->value);
|
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_UINT16:
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->size = 2;
|
|
|
|
*(guint16*)&data[blob->offset] = (guint16) parse_uint_value (constant->value);
|
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_INT32:
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->size = 4;
|
|
|
|
*(gint32*)&data[blob->offset] = (gint32) parse_int_value (constant->value);
|
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_UINT32:
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->size = 4;
|
|
|
|
*(guint32*)&data[blob->offset] = (guint32) parse_uint_value (constant->value);
|
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_INT64:
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->size = 8;
|
2009-10-21 13:28:12 +02:00
|
|
|
DO_ALIGNED_COPY(&data[blob->offset], parse_int_value (constant->value), gint64);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_UINT64:
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->size = 8;
|
2009-10-21 13:28:12 +02:00
|
|
|
DO_ALIGNED_COPY(&data[blob->offset], parse_uint_value (constant->value), guint64);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
2009-06-20 01:53:03 +02:00
|
|
|
case GI_TYPE_TAG_SHORT:
|
|
|
|
blob->size = sizeof (gshort);
|
|
|
|
*(gshort*)&data[blob->offset] = (gshort) parse_int_value (constant->value);
|
|
|
|
break;
|
|
|
|
case GI_TYPE_TAG_USHORT:
|
|
|
|
blob->size = sizeof (gushort);
|
|
|
|
*(gushort*)&data[blob->offset] = (gushort) parse_uint_value (constant->value);
|
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_INT:
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->size = sizeof (gint);
|
|
|
|
*(gint*)&data[blob->offset] = (gint) parse_int_value (constant->value);
|
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_UINT:
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->size = sizeof (guint);
|
|
|
|
*(gint*)&data[blob->offset] = (guint) parse_uint_value (constant->value);
|
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_SSIZE: /* FIXME */
|
|
|
|
case GI_TYPE_TAG_LONG:
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->size = sizeof (glong);
|
2009-10-21 13:28:12 +02:00
|
|
|
DO_ALIGNED_COPY(&data[blob->offset], parse_int_value (constant->value), glong);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_SIZE: /* FIXME */
|
2010-03-24 19:00:06 +01:00
|
|
|
case GI_TYPE_TAG_TIME_T:
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_ULONG:
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->size = sizeof (gulong);
|
2009-10-21 13:28:12 +02:00
|
|
|
DO_ALIGNED_COPY(&data[blob->offset], parse_uint_value (constant->value), gulong);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_FLOAT:
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->size = sizeof (gfloat);
|
2009-10-21 13:28:12 +02:00
|
|
|
DO_ALIGNED_COPY(&data[blob->offset], parse_float_value (constant->value), gfloat);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_DOUBLE:
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->size = sizeof (gdouble);
|
2009-10-21 13:28:12 +02:00
|
|
|
DO_ALIGNED_COPY(&data[blob->offset], parse_float_value (constant->value), gdouble);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_UTF8:
|
|
|
|
case GI_TYPE_TAG_FILENAME:
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->size = strlen (constant->value) + 1;
|
|
|
|
memcpy (&data[blob->offset], constant->value, blob->size);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
*offset2 += ALIGN_VALUE (blob->size, 4);
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2009-02-28 01:11:26 +01:00
|
|
|
g_ir_node_build_typelib ((GIrNode *)constant->type, node, build, &pos, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-28 18:55:37 +02:00
|
|
|
g_debug ("node %s%s%s%p type '%s', offset %d -> %d, offset2 %d -> %d",
|
|
|
|
node->name ? "'" : "",
|
|
|
|
node->name ? node->name : "",
|
|
|
|
node->name ? "' " : "",
|
|
|
|
node, g_ir_node_type_to_string (node->type),
|
2008-08-09 14:46:48 +02:00
|
|
|
old_offset, *offset, old_offset2, *offset2);
|
|
|
|
|
|
|
|
if (*offset2 - old_offset2 + *offset - old_offset > g_ir_node_get_full_size (node))
|
2009-02-20 03:48:51 +01:00
|
|
|
g_error ("exceeding space reservation; offset: %d (prev %d) offset2: %d (prev %d) nodesize: %d",
|
|
|
|
*offset, old_offset, *offset2, old_offset2, g_ir_node_get_full_size (node));
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* if str is already in the pool, return previous location, otherwise write str
|
2010-03-24 19:00:06 +01:00
|
|
|
* to the typelib at offset, put it in the pool and update offset. If the
|
2008-08-09 14:55:32 +02:00
|
|
|
* typelib is not large enough to hold the string, reallocate it.
|
2008-08-09 14:46:48 +02:00
|
|
|
*/
|
2010-03-24 19:00:06 +01:00
|
|
|
guint32
|
2008-08-09 14:46:48 +02:00
|
|
|
write_string (const gchar *str,
|
2010-03-24 19:00:06 +01:00
|
|
|
GHashTable *strings,
|
2008-08-09 14:46:48 +02:00
|
|
|
guchar *data,
|
|
|
|
guint32 *offset)
|
|
|
|
{
|
|
|
|
gpointer value;
|
|
|
|
guint32 start;
|
|
|
|
|
|
|
|
string_count += 1;
|
|
|
|
string_size += strlen (str);
|
|
|
|
|
|
|
|
value = g_hash_table_lookup (strings, str);
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
if (value)
|
2008-08-21 18:15:55 +02:00
|
|
|
return GPOINTER_TO_UINT (value);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
unique_string_count += 1;
|
|
|
|
unique_string_size += strlen (str);
|
|
|
|
|
2008-08-21 18:15:55 +02:00
|
|
|
g_hash_table_insert (strings, (gpointer)str, GUINT_TO_POINTER (*offset));
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
start = *offset;
|
|
|
|
*offset = ALIGN_VALUE (start + strlen (str) + 1, 4);
|
|
|
|
|
|
|
|
strcpy ((gchar*)&data[start], str);
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
return start;
|
|
|
|
}
|
|
|
|
|