2012-02-03 19:42:56 +01:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
|
|
|
* 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"
|
2010-05-31 22:44:46 +02:00
|
|
|
#include "gitypelib-internal.h"
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2012-07-24 10:09:38 +02:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define strtoll _strtoi64
|
|
|
|
#define strtoull _strtoui64
|
|
|
|
#endif
|
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
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 *
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_type_to_string (GIrNodeTypeId type)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
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_XREF:
|
|
|
|
return "xref";
|
|
|
|
case G_IR_NODE_UNION:
|
|
|
|
return "union";
|
|
|
|
default:
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GIrNode *
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_new (GIrNodeTypeId type,
|
2010-07-26 22:26:46 +02:00
|
|
|
GIrModule *module)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
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_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;
|
2010-07-26 22:26:46 +02:00
|
|
|
node->module = module;
|
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
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free (GIrNode *node)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
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);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)function->result);
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = function->parameters; l; l = l->next)
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
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);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)type->parameter_type1);
|
|
|
|
_g_ir_node_free ((GIrNode *)type->parameter_type2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2012-07-24 10:09:38 +02:00
|
|
|
g_free (type->giinterface);
|
2008-08-09 14:46:48 +02:00
|
|
|
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);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)param->type);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)property->type);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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)
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
g_list_free (signal->parameters);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)signal->result);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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)
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
g_list_free (vfunc->parameters);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)vfunc->result);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)field->type);
|
|
|
|
_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);
|
2010-06-12 23:08:56 +02:00
|
|
|
g_free (iface->ref_func);
|
|
|
|
g_free (iface->unref_func);
|
|
|
|
g_free (iface->set_value_func);
|
|
|
|
g_free (iface->get_value_func);
|
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)
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
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);
|
2011-05-19 22:21:13 +02:00
|
|
|
g_free (enum_->error_domain);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
for (l = enum_->values; l; l = l->next)
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
g_list_free (enum_->values);
|
2011-08-13 17:28:30 +02:00
|
|
|
|
|
|
|
for (l = enum_->methods; l; l = l->next)
|
|
|
|
_g_ir_node_free ((GIrNode *)l->data);
|
|
|
|
g_list_free (enum_->methods);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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)
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
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)
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
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);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)constant->type);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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);
|
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)union_->discriminator_type);
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = union_->members; l; l = l->next)
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = union_->discriminators; l; l = l->next)
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_free ((GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_get_size (GIrNode *node)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
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)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_size ((GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_size ((GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_size ((GIrNode *)l->data);
|
2011-08-13 17:28:30 +02:00
|
|
|
for (l = enum_->methods; l; l = l->next)
|
|
|
|
size += _g_ir_node_get_size ((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
|
|
|
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)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_size ((GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_size ((GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_size ((GIrNode *)field->callback);
|
2009-11-09 19:17:23 +01:00
|
|
|
}
|
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_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)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_size ((GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = union_->discriminators; l; l = l->next)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_size ((GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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",
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_type_to_string (node->type));
|
2008-08-09 14:46:48 +02:00
|
|
|
size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_debug ("node %p type '%s' size %d", node,
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_type_to_string (node->type), size);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2010-06-15 16:50:42 +02:00
|
|
|
/* returns the full size of the blob including variable-size parts (including attributes) */
|
2008-08-09 14:46:48 +02:00
|
|
|
static guint32
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_get_full_size_internal (GIrNode *parent,
|
2008-08-18 10:52:47 +02:00
|
|
|
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,
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_type_to_string (node->type));
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_full_size_internal (node, (GIrNode *)function->result);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
|
|
|
|
size += _g_ir_node_get_full_size_internal (node, (GIrNode *)function->result);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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-11-16 21:08:33 +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);
|
2010-10-26 16:03:29 +02:00
|
|
|
if (!G_TYPE_TAG_IS_BASIC(type->tag))
|
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)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_full_size_internal (node, (GIrNode *)type->parameter_type1);
|
2008-08-09 14:46:48 +02:00
|
|
|
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)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_full_size_internal (node, (GIrNode *)type->parameter_type1);
|
2008-08-09 14:46:48 +02:00
|
|
|
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)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_full_size_internal (node, (GIrNode *)type->parameter_type1);
|
2008-08-09 14:46:48 +02:00
|
|
|
if (type->parameter_type2)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_full_size_internal (node, (GIrNode *)type->parameter_type2);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
2008-08-12 17:34:27 +02:00
|
|
|
case GI_TYPE_TAG_ERROR:
|
2011-05-19 22:12:03 +02:00
|
|
|
size += sizeof (ErrorTypeBlob);
|
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);
|
2010-06-12 23:08:56 +02:00
|
|
|
if (iface->ref_func)
|
|
|
|
size += ALIGN_VALUE (strlen (iface->ref_func) + 1, 4);
|
|
|
|
if (iface->unref_func)
|
|
|
|
size += ALIGN_VALUE (strlen (iface->unref_func) + 1, 4);
|
|
|
|
if (iface->set_value_func)
|
|
|
|
size += ALIGN_VALUE (strlen (iface->set_value_func) + 1, 4);
|
|
|
|
if (iface->get_value_func)
|
|
|
|
size += ALIGN_VALUE (strlen (iface->get_value_func) + 1, 4);
|
2008-08-09 14:46:48 +02:00
|
|
|
size += 2 * (n + (n % 2));
|
|
|
|
|
|
|
|
for (l = iface->members; l; l = l->next)
|
2010-11-16 21:08:33 +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_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)
|
2010-11-16 21:08:33 +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_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);
|
|
|
|
}
|
2011-05-19 22:21:13 +02:00
|
|
|
if (enum_->error_domain)
|
|
|
|
size += ALIGN_VALUE (strlen (enum_->error_domain) + 1, 4);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
for (l = enum_->values; l; l = l->next)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
|
2011-08-13 17:28:30 +02:00
|
|
|
for (l = enum_->methods; l; l = l->next)
|
|
|
|
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)
|
2010-11-16 21:08:33 +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_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)
|
2010-11-16 21:08:33 +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_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-11-16 21:08:33 +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)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
|
|
|
|
size += _g_ir_node_get_full_size_internal (node, (GIrNode *)signal->result);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
|
|
|
|
size += _g_ir_node_get_full_size_internal (node, (GIrNode *)vfunc->result);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_full_size_internal (node, (GIrNode *)field->callback);
|
2009-11-09 19:17:23 +01:00
|
|
|
else
|
2010-11-16 21:08:33 +01:00
|
|
|
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-11-16 21:08:33 +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_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)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
for (l = union_->discriminators; l; l = l->next)
|
2010-11-16 21:08:33 +01:00
|
|
|
size += _g_ir_node_get_full_size_internal (node, (GIrNode *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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 ? "' " : "",
|
2010-11-16 21:08:33 +01:00
|
|
|
node, _g_ir_node_type_to_string (node->type), size);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2010-06-15 16:50:42 +02:00
|
|
|
g_hash_table_foreach (node->attributes, add_attribute_size, &size);
|
|
|
|
|
2008-08-09 14:46:48 +02:00
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
guint32
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_get_full_size (GIrNode *node)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
2010-11-16 21:08:33 +01:00
|
|
|
return _g_ir_node_get_full_size_internal (NULL, node);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_cmp (GIrNode *node,
|
2008-08-09 14:46:48 +02:00
|
|
|
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
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_can_have_member (GIrNode *node)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
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:
|
2011-05-19 22:12:03 +02:00
|
|
|
case G_IR_NODE_INVALID_0:
|
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
|
|
|
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
|
2010-11-16 21:08:33 +01:00
|
|
|
_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,
|
2010-11-16 21:08:33 +01:00
|
|
|
(GCompareFunc) _g_ir_node_cmp);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case G_IR_NODE_BOXED:
|
|
|
|
{
|
|
|
|
GIrNodeBoxed *boxed = (GIrNodeBoxed *)node;
|
|
|
|
boxed->members =
|
|
|
|
g_list_insert_sorted (boxed->members, member,
|
2010-11-16 21:08:33 +01:00
|
|
|
(GCompareFunc) _g_ir_node_cmp);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case G_IR_NODE_STRUCT:
|
|
|
|
{
|
|
|
|
GIrNodeStruct *struct_ = (GIrNodeStruct *)node;
|
|
|
|
struct_->members =
|
|
|
|
g_list_insert_sorted (struct_->members, member,
|
2010-11-16 21:08:33 +01:00
|
|
|
(GCompareFunc) _g_ir_node_cmp);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case G_IR_NODE_UNION:
|
|
|
|
{
|
|
|
|
GIrNodeUnion *union_ = (GIrNodeUnion *)node;
|
|
|
|
union_->members =
|
|
|
|
g_list_insert_sorted (union_->members, member,
|
2010-11-16 21:08:33 +01:00
|
|
|
(GCompareFunc) _g_ir_node_cmp);
|
2008-08-09 14:46:48 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
g_error ("Cannot add a member to unknown type tag type %d\n",
|
|
|
|
node->type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const gchar *
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_param_direction_string (GIrNodeParam * node)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2013-11-29 01:12:40 +01:00
|
|
|
if (g_ascii_strcasecmp (str, "TRUE") == 0)
|
2008-08-09 14:46:48 +02:00
|
|
|
return TRUE;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2013-11-29 01:12:40 +01:00
|
|
|
if (g_ascii_strcasecmp (str, "FALSE") == 0)
|
2008-08-09 14:46:48 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return parse_int_value (str) ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GIrNode *
|
2010-07-26 22:26:46 +02:00
|
|
|
find_entry_node (GIrTypelibBuild *build,
|
2008-08-09 14:46:48 +02:00
|
|
|
const gchar *name,
|
|
|
|
guint16 *idx)
|
|
|
|
|
|
|
|
{
|
2010-07-26 22:26:46 +02:00
|
|
|
GIrModule *module = build->module;
|
2008-08-09 14:46:48 +02:00
|
|
|
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)
|
|
|
|
{
|
2010-11-16 21:08:33 +01:00
|
|
|
GIrNode *node = _g_ir_node_new (G_IR_NODE_XREF, module);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
((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-07-26 22:26:46 +02:00
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_module_fatal (build, -1, "type reference '%s' not found",
|
|
|
|
name);
|
2008-08-09 14:46:48 +02:00
|
|
|
out:
|
|
|
|
|
|
|
|
g_strfreev (names);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static guint16
|
2010-07-26 22:26:46 +02:00
|
|
|
find_entry (GIrTypelibBuild *build,
|
2008-08-09 14:46:48 +02:00
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
guint16 idx = 0;
|
|
|
|
|
2010-07-26 22:26:46 +02:00
|
|
|
find_entry_node (build, name, &idx);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
2010-07-26 22:26:46 +02:00
|
|
|
static GIrModule *
|
|
|
|
find_namespace (GIrModule *module,
|
|
|
|
const char *name)
|
2008-11-11 01:48:17 +01:00
|
|
|
{
|
2010-07-26 22:26:46 +02:00
|
|
|
GIrModule *target;
|
2008-11-11 01:48:17 +01:00
|
|
|
GList *l;
|
2010-07-26 22:26:46 +02:00
|
|
|
|
|
|
|
if (strcmp (module->name, name) == 0)
|
|
|
|
return module;
|
2008-11-11 01:48:17 +01:00
|
|
|
|
2010-07-26 22:26:46 +02:00
|
|
|
for (l = module->include_modules; l; l = l->next)
|
2008-11-11 01:48:17 +01:00
|
|
|
{
|
2010-07-26 22:26:46 +02:00
|
|
|
GIrModule *submodule = l->data;
|
2008-11-11 01:48:17 +01:00
|
|
|
|
2010-07-26 22:26:46 +02:00
|
|
|
if (strcmp (submodule->name, name) == 0)
|
|
|
|
return submodule;
|
2008-11-11 01:48:17 +01:00
|
|
|
|
2010-07-26 22:26:46 +02:00
|
|
|
target = find_namespace (submodule, name);
|
|
|
|
if (target)
|
|
|
|
return target;
|
|
|
|
}
|
2008-11-11 01:48:17 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-07-26 22:26:46 +02:00
|
|
|
GIrNode *
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_find_node (GIrTypelibBuild *build,
|
2010-07-26 22:26:46 +02:00
|
|
|
GIrModule *src_module,
|
|
|
|
const char *name)
|
2008-11-11 01:48:17 +01:00
|
|
|
{
|
2010-07-26 22:26:46 +02:00
|
|
|
GList *l;
|
|
|
|
GIrNode *return_node = NULL;
|
2008-11-11 01:48:17 +01:00
|
|
|
char **names = g_strsplit (name, ".", 0);
|
|
|
|
gint n_names = g_strv_length (names);
|
2010-07-26 22:26:46 +02:00
|
|
|
const char *target_name;
|
|
|
|
GIrModule *target_module;
|
2008-11-11 01:48:17 +01:00
|
|
|
|
|
|
|
if (n_names == 1)
|
|
|
|
{
|
2010-07-26 22:26:46 +02:00
|
|
|
target_module = src_module;
|
|
|
|
target_name = name;
|
2008-11-11 01:48:17 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-26 22:26:46 +02:00
|
|
|
target_module = find_namespace (build->module, names[0]);
|
|
|
|
target_name = names[1];
|
|
|
|
}
|
2008-11-11 01:48:17 +01:00
|
|
|
|
2013-11-06 12:37:50 +01:00
|
|
|
/* find_namespace() may return NULL. */
|
|
|
|
if (target_module == NULL)
|
|
|
|
goto done;
|
|
|
|
|
2010-07-26 22:26:46 +02:00
|
|
|
for (l = target_module->entries; l; l = l->next)
|
|
|
|
{
|
|
|
|
GIrNode *node = (GIrNode *)l->data;
|
2008-11-11 01:48:17 +01:00
|
|
|
|
2010-07-26 22:26:46 +02:00
|
|
|
if (strcmp (node->name, target_name) == 0)
|
2008-11-11 01:48:17 +01:00
|
|
|
{
|
2010-07-26 22:26:46 +02:00
|
|
|
return_node = node;
|
|
|
|
break;
|
2008-11-11 01:48:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 12:37:50 +01:00
|
|
|
done:
|
2008-11-11 01:48:17 +01:00
|
|
|
g_strfreev (names);
|
|
|
|
|
2010-07-26 22:26:46 +02:00
|
|
|
return return_node;
|
2008-11-11 01:48:17 +01:00
|
|
|
}
|
|
|
|
|
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-07-26 22:26:46 +02:00
|
|
|
serialize_type (GIrTypelibBuild *build,
|
2010-03-24 19:00:06 +01:00
|
|
|
GIrNodeType *node,
|
2008-08-09 14:46:48 +02:00
|
|
|
GString *str)
|
|
|
|
{
|
|
|
|
gint i;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2010-10-26 16:03:29 +02:00
|
|
|
if (G_TYPE_TAG_IS_BASIC(node->tag))
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
2010-07-22 03:06:17 +02:00
|
|
|
g_string_append_printf (str, "%s%s", g_type_tag_to_string (node->tag),
|
2008-11-16 22:20:26 +01:00
|
|
|
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
|
|
|
{
|
2011-02-18 18:14:25 +01:00
|
|
|
if (node->array_type == GI_ARRAY_TYPE_C)
|
|
|
|
{
|
|
|
|
serialize_type (build, node->parameter_type1, str);
|
|
|
|
g_string_append (str, "[");
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2011-02-18 18:14:25 +01:00
|
|
|
if (node->has_length)
|
|
|
|
g_string_append_printf (str, "length=%d", node->length);
|
|
|
|
else if (node->has_size)
|
|
|
|
g_string_append_printf (str, "fixed-size=%d", node->size);
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2011-02-18 18:14:25 +01:00
|
|
|
if (node->zero_terminated)
|
|
|
|
g_string_append_printf (str, "%szero-terminated=1",
|
|
|
|
node->has_length ? "," : "");
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2011-02-18 18:14:25 +01:00
|
|
|
g_string_append (str, "]");
|
2011-06-05 20:57:01 +02:00
|
|
|
if (node->is_pointer)
|
|
|
|
g_string_append (str, "*");
|
2011-02-18 18:14:25 +01:00
|
|
|
}
|
|
|
|
else if (node->array_type == GI_ARRAY_TYPE_BYTE_ARRAY)
|
|
|
|
{
|
|
|
|
/* We on purpose skip serializing parameter_type1, which should
|
|
|
|
always be void*
|
|
|
|
*/
|
|
|
|
g_string_append (str, "GByteArray");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (node->array_type == GI_ARRAY_TYPE_ARRAY)
|
|
|
|
g_string_append (str, "GArray");
|
|
|
|
else
|
|
|
|
g_string_append (str, "GPtrArray");
|
|
|
|
if (node->parameter_type1)
|
|
|
|
{
|
|
|
|
g_string_append (str, "<");
|
|
|
|
serialize_type (build, node->parameter_type1, str);
|
|
|
|
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_INTERFACE)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
GIrNode *iface;
|
|
|
|
gchar *name;
|
|
|
|
|
2012-07-24 10:09:38 +02:00
|
|
|
iface = find_entry_node (build, node->giinterface, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
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
|
|
|
|
{
|
2012-07-24 10:09:38 +02:00
|
|
|
g_warning ("Interface for type reference %s not found", node->giinterface);
|
|
|
|
name = node->giinterface;
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
|
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, "<");
|
2010-07-26 22:26:46 +02:00
|
|
|
serialize_type (build, 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, "<");
|
2010-07-26 22:26:46 +02:00
|
|
|
serialize_type (build, 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
|
|
|
{
|
2011-02-18 18:14:25 +01:00
|
|
|
g_string_append (str, "GHashTable");
|
2008-08-09 14:46:48 +02:00
|
|
|
if (node->parameter_type1)
|
|
|
|
{
|
2010-03-24 19:00:06 +01:00
|
|
|
g_string_append (str, "<");
|
2010-07-26 22:26:46 +02:00
|
|
|
serialize_type (build, node->parameter_type1, str);
|
2010-03-24 19:00:06 +01:00
|
|
|
g_string_append (str, ",");
|
2010-07-26 22:26:46 +02:00
|
|
|
serialize_type (build, 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
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (GList **members,
|
2008-10-16 00:28:41 +02:00
|
|
|
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,
|
2014-02-28 02:10:19 +01:00
|
|
|
guint32 *offset2,
|
|
|
|
guint16 *count2)
|
2008-10-16 00:28:41 +02:00
|
|
|
{
|
|
|
|
GList *l = *members;
|
|
|
|
|
|
|
|
while (l)
|
|
|
|
{
|
|
|
|
GIrNode *member = (GIrNode *)l->data;
|
|
|
|
GList *next = l->next;
|
|
|
|
|
|
|
|
if (member->type == type)
|
|
|
|
{
|
|
|
|
(*count)++;
|
2014-02-28 02:10:19 +01:00
|
|
|
_g_ir_node_build_typelib (member, parent, build, offset, offset2, count2);
|
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
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_check_unhandled_members (GList **members,
|
|
|
|
GIrNodeTypeId container_type)
|
2008-10-16 00:28:53 +02:00
|
|
|
{
|
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",
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_type_to_string (container_type),
|
2008-10-16 00:28:53 +02:00
|
|
|
member->name,
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_type_to_string (member->type));
|
2008-10-16 00:28:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_typelib (GIrNode *node,
|
|
|
|
GIrNode *parent,
|
|
|
|
GIrTypelibBuild *build,
|
|
|
|
guint32 *offset,
|
2014-02-28 02:10:19 +01:00
|
|
|
guint32 *offset2,
|
|
|
|
guint16 *count2)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
2010-07-26 22:26:46 +02:00
|
|
|
gboolean appended_stack;
|
2009-02-20 17:05:53 +01:00
|
|
|
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 ? " " : "",
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_type_to_string (node->type));
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2010-07-26 22:26:46 +02:00
|
|
|
if (build->stack)
|
|
|
|
appended_stack = node != (GIrNode*)build->stack->data;
|
|
|
|
else
|
|
|
|
appended_stack = TRUE;
|
|
|
|
if (appended_stack)
|
|
|
|
build->stack = g_list_prepend (build->stack, node);
|
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_compute_offsets (build, node);
|
2008-11-11 06:10:36 +01:00
|
|
|
|
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;
|
2010-06-15 16:50:42 +02:00
|
|
|
build->nodes_with_attributes = g_list_prepend (build->nodes_with_attributes, node);
|
2009-02-20 03:48:51 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
2010-10-26 17:12:26 +02:00
|
|
|
if (G_TYPE_TAG_IS_BASIC (type->tag))
|
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);
|
2010-07-26 22:26:46 +02:00
|
|
|
serialize_type (build, type, str);
|
2008-08-09 14:46:48 +02:00
|
|
|
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
|
|
|
|
2011-06-05 20:57:01 +02:00
|
|
|
array->pointer = type->is_pointer;
|
2008-08-09 14:46:48 +02:00
|
|
|
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
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_typelib ((GIrNode *)type->parameter_type1,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, &pos, offset2, NULL);
|
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;
|
2012-07-24 10:09:38 +02:00
|
|
|
iface->interface = find_entry (build, type->giinterface);
|
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_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
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_typelib ((GIrNode *)type->parameter_type1,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, &pos, offset2, NULL);
|
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
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_typelib ((GIrNode *)type->parameter_type1,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, &pos, offset2, NULL);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_typelib ((GIrNode *)type->parameter_type2,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, &pos, offset2, NULL);
|
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];
|
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;
|
2011-05-19 22:12:03 +02:00
|
|
|
blob->n_domains = 0;
|
|
|
|
|
|
|
|
*offset2 += sizeof (ErrorTypeBlob);
|
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
|
|
|
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];
|
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->name = _g_ir_write_string (node->name, strings, data, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
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);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_typelib ((GIrNode *)field->callback,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
|
|
|
/* Fields with callbacks are bigger than normal, update count2
|
|
|
|
* as an extra hint which represents the number of fields which are
|
|
|
|
* callbacks. This allows us to gain constant time performance in the
|
|
|
|
* repository for skipping over the fields section.
|
|
|
|
*/
|
|
|
|
if (count2)
|
|
|
|
(*count2)++;
|
2009-11-09 19:17:23 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
blob->has_embedded_type = FALSE;
|
|
|
|
/* We handle the size member specially below, so subtract it */
|
|
|
|
*offset += sizeof (FieldBlob) - sizeof (SimpleTypeBlob);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_typelib ((GIrNode *)field->type,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
2009-11-09 19:17:23 +01:00
|
|
|
}
|
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
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->name = _g_ir_write_string (node->name, strings, data, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
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;
|
2010-06-08 16:40:35 +02:00
|
|
|
blob->transfer_ownership = prop->transfer;
|
|
|
|
blob->transfer_container_ownership = prop->shallow_transfer;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->reserved = 0;
|
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_typelib ((GIrNode *)prop->type,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
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;
|
2015-06-03 14:24:21 +02:00
|
|
|
blob->throws = function->throws; /* Deprecated. Also stored in SignatureBlob. */
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->index = 0;
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->name = _g_ir_write_string (node->name, strings, data, offset2);
|
|
|
|
blob->symbol = _g_ir_write_string (function->symbol, strings, data, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->signature = signature;
|
2008-08-23 18:46:58 +02:00
|
|
|
|
2010-06-15 17:01:37 +02:00
|
|
|
/* function->result is special since it doesn't appear in the serialized format but
|
|
|
|
* we do want the attributes for it to appear
|
|
|
|
*/
|
|
|
|
build->nodes_with_attributes = g_list_prepend (build->nodes_with_attributes, function->result);
|
|
|
|
build->n_attributes += g_hash_table_size (((GIrNode *) function->result)->attributes);
|
|
|
|
g_assert (((GIrNode *) function->result)->offset == 0);
|
|
|
|
((GIrNode *) function->result)->offset = signature;
|
|
|
|
|
2008-08-23 18:46:58 +02:00
|
|
|
g_debug ("building function '%s'", function->symbol);
|
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_typelib ((GIrNode *)function->result->type,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, &signature, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2014-04-16 17:33:36 +02:00
|
|
|
blob2->may_return_null = function->result->nullable;
|
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;
|
2011-05-13 18:20:05 +02:00
|
|
|
blob2->skip_return = function->result->skip;
|
2014-05-06 18:53:21 +02:00
|
|
|
blob2->instance_transfer_ownership = function->instance_transfer_full;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob2->reserved = 0;
|
|
|
|
blob2->n_arguments = n;
|
2015-06-03 14:24:21 +02:00
|
|
|
blob2->throws = function->throws;
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2014-02-28 02:10:19 +01:00
|
|
|
_g_ir_node_build_typelib (param, node, build, &signature, offset2, NULL);
|
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;
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->name = _g_ir_write_string (node->name, strings, data, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->signature = signature;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_typelib ((GIrNode *)function->result->type,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, &signature, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2014-04-16 17:33:36 +02:00
|
|
|
blob2->may_return_null = function->result->nullable;
|
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;
|
2015-06-03 14:24:21 +02:00
|
|
|
blob2->throws = function->throws;
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2014-02-28 02:10:19 +01:00
|
|
|
_g_ir_node_build_typelib (param, node, build, &signature, offset2, NULL);
|
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 */
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->name = _g_ir_write_string (node->name, strings, data, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->signature = signature;
|
2010-03-24 19:00:06 +01:00
|
|
|
|
2010-06-15 17:01:37 +02:00
|
|
|
/* signal->result is special since it doesn't appear in the serialized format but
|
|
|
|
* we do want the attributes for it to appear
|
|
|
|
*/
|
|
|
|
build->nodes_with_attributes = g_list_prepend (build->nodes_with_attributes, signal->result);
|
|
|
|
build->n_attributes += g_hash_table_size (((GIrNode *) signal->result)->attributes);
|
|
|
|
g_assert (((GIrNode *) signal->result)->offset == 0);
|
|
|
|
((GIrNode *) signal->result)->offset = signature;
|
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_typelib ((GIrNode *)signal->result->type,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, &signature, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2014-04-16 17:33:36 +02:00
|
|
|
blob2->may_return_null = signal->result->nullable;
|
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;
|
2014-05-06 18:53:21 +02:00
|
|
|
blob2->instance_transfer_ownership = signal->instance_transfer_full;
|
2008-08-09 14:46:48 +02:00
|
|
|
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;
|
|
|
|
|
2014-02-28 02:10:19 +01:00
|
|
|
_g_ir_node_build_typelib (param, node, build, &signature, offset2, NULL);
|
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
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->name = _g_ir_write_string (node->name, strings, data, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->must_chain_up = 0; /* FIXME */
|
|
|
|
blob->must_be_implemented = 0; /* FIXME */
|
|
|
|
blob->must_not_be_implemented = 0; /* FIXME */
|
|
|
|
blob->class_closure = 0; /* FIXME */
|
2015-06-03 14:24:21 +02:00
|
|
|
blob->throws = vfunc->throws; /* Deprecated. Also stored in SignatureBlob. */
|
2008-08-09 14:46:48 +02:00
|
|
|
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
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_typelib ((GIrNode *)vfunc->result->type,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, &signature, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2014-04-16 17:33:36 +02:00
|
|
|
blob2->may_return_null = vfunc->result->nullable;
|
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;
|
2014-05-06 18:53:21 +02:00
|
|
|
blob2->instance_transfer_ownership = vfunc->instance_transfer_full;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob2->reserved = 0;
|
|
|
|
blob2->n_arguments = n;
|
2015-06-03 14:24:21 +02:00
|
|
|
blob2->throws = vfunc->throws;
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2014-02-28 02:10:19 +01:00
|
|
|
_g_ir_node_build_typelib (param, node, build, &signature, offset2, NULL);
|
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-11-16 21:08:33 +01:00
|
|
|
blob->name = _g_ir_write_string (node->name, strings, data, offset2);
|
2010-03-24 19:20:14 +01:00
|
|
|
blob->in = param->in;
|
|
|
|
blob->out = param->out;
|
2009-12-16 17:47:19 +01:00
|
|
|
blob->caller_allocates = param->caller_allocates;
|
2014-04-16 17:33:36 +02:00
|
|
|
blob->nullable = param->nullable;
|
2011-05-13 18:20:05 +02:00
|
|
|
blob->skip = param->skip;
|
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
|
|
|
|
2014-02-28 02:10:19 +01:00
|
|
|
_g_ir_node_build_typelib ((GIrNode *)param->type, node, build, offset, offset2, NULL);
|
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;
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->name = _g_ir_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;
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->gtype_name = _g_ir_write_string (struct_->gtype_name, strings, data, offset2);
|
|
|
|
blob->gtype_init = _g_ir_write_string (struct_->gtype_init, strings, data, offset2);
|
2008-09-06 22:33:51 +02:00
|
|
|
}
|
|
|
|
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
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (&members, G_IR_NODE_FIELD, &blob->n_fields,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
2008-10-16 00:28:41 +02:00
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (&members, G_IR_NODE_FUNCTION, &blob->n_methods,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
2008-10-16 00:28:41 +02:00
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_check_unhandled_members (&members, node->type);
|
2008-10-16 00:28:53 +02:00
|
|
|
|
|
|
|
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;
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->name = _g_ir_write_string (node->name, strings, data, offset2);
|
|
|
|
blob->gtype_name = _g_ir_write_string (boxed->gtype_name, strings, data, offset2);
|
|
|
|
blob->gtype_init = _g_ir_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
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (&members, G_IR_NODE_FIELD, &blob->n_fields,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (&members, G_IR_NODE_FUNCTION, &blob->n_methods,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
2008-10-16 00:28:41 +02:00
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_check_unhandled_members (&members, node->type);
|
2008-10-16 00:28:53 +02:00
|
|
|
|
|
|
|
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;
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->name = _g_ir_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;
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->gtype_name = _g_ir_write_string (union_->gtype_name, strings, data, offset2);
|
|
|
|
blob->gtype_init = _g_ir_write_string (union_->gtype_init, strings, data, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_typelib ((GIrNode *)union_->discriminator_type,
|
2014-02-28 02:10:19 +01:00
|
|
|
build, offset, offset2, NULL);
|
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
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (&members, G_IR_NODE_FIELD, &blob->n_fields,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (&members, G_IR_NODE_FUNCTION, &blob->n_functions,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_check_unhandled_members (&members, node->type);
|
2008-10-16 00:28:53 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
2014-02-28 02:10:19 +01:00
|
|
|
_g_ir_node_build_typelib (member, node, build, offset, offset2, NULL);
|
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;
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->name = _g_ir_write_string (node->name, strings, data, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
if (enum_->gtype_name)
|
|
|
|
{
|
|
|
|
blob->unregistered = FALSE;
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->gtype_name = _g_ir_write_string (enum_->gtype_name, strings, data, offset2);
|
|
|
|
blob->gtype_init = _g_ir_write_string (enum_->gtype_init, strings, data, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
blob->unregistered = TRUE;
|
|
|
|
blob->gtype_name = 0;
|
|
|
|
blob->gtype_init = 0;
|
|
|
|
}
|
2011-05-19 22:21:13 +02:00
|
|
|
if (enum_->error_domain)
|
|
|
|
blob->error_domain = _g_ir_write_string (enum_->error_domain, strings, data, offset2);
|
|
|
|
else
|
|
|
|
blob->error_domain = 0;
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
blob->n_values = 0;
|
2011-08-13 17:28:30 +02:00
|
|
|
blob->n_methods = 0;
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
for (l = enum_->values; l; l = l->next)
|
|
|
|
{
|
|
|
|
GIrNode *value = (GIrNode *)l->data;
|
|
|
|
|
|
|
|
blob->n_values++;
|
2014-02-28 02:10:19 +01:00
|
|
|
_g_ir_node_build_typelib (value, node, build, offset, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
2011-08-13 17:28:30 +02:00
|
|
|
|
|
|
|
for (l = enum_->methods; l; l = l->next)
|
|
|
|
{
|
|
|
|
GIrNode *method = (GIrNode *)l->data;
|
|
|
|
|
|
|
|
blob->n_methods++;
|
2014-02-28 02:10:19 +01:00
|
|
|
_g_ir_node_build_typelib (method, node, build, offset, offset2, NULL);
|
2011-08-13 17:28:30 +02:00
|
|
|
}
|
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;
|
2010-06-12 23:08:56 +02:00
|
|
|
blob->fundamental = object->fundamental;
|
2008-08-09 14:46:48 +02:00
|
|
|
blob->deprecated = object->deprecated;
|
|
|
|
blob->reserved = 0;
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->name = _g_ir_write_string (node->name, strings, data, offset2);
|
|
|
|
blob->gtype_name = _g_ir_write_string (object->gtype_name, strings, data, offset2);
|
|
|
|
blob->gtype_init = _g_ir_write_string (object->gtype_init, strings, data, offset2);
|
2010-06-12 23:08:56 +02:00
|
|
|
if (object->ref_func)
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->ref_func = _g_ir_write_string (object->ref_func, strings, data, offset2);
|
2010-06-12 23:08:56 +02:00
|
|
|
if (object->unref_func)
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->unref_func = _g_ir_write_string (object->unref_func, strings, data, offset2);
|
2010-06-12 23:08:56 +02:00
|
|
|
if (object->set_value_func)
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->set_value_func = _g_ir_write_string (object->set_value_func, strings, data, offset2);
|
2010-06-12 23:08:56 +02:00
|
|
|
if (object->get_value_func)
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->get_value_func = _g_ir_write_string (object->get_value_func, strings, data, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
if (object->parent)
|
2010-07-26 22:26:46 +02:00
|
|
|
blob->parent = find_entry (build, object->parent);
|
2008-08-09 14:46:48 +02:00
|
|
|
else
|
|
|
|
blob->parent = 0;
|
2009-02-20 23:34:20 +01:00
|
|
|
if (object->glib_type_struct)
|
2010-07-26 22:26:46 +02:00
|
|
|
blob->gtype_struct = find_entry (build, 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;
|
2014-02-28 02:10:19 +01:00
|
|
|
blob->n_field_callbacks = 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++;
|
2010-07-26 22:26:46 +02:00
|
|
|
*(guint16*)&data[*offset] = find_entry (build, (gchar *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
*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);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (&members, G_IR_NODE_FIELD, &blob->n_fields,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, &blob->n_field_callbacks);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (&members, G_IR_NODE_PROPERTY, &blob->n_properties,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (&members, G_IR_NODE_FUNCTION, &blob->n_methods,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (&members, G_IR_NODE_SIGNAL, &blob->n_signals,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-16 00:28:41 +02:00
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (&members, G_IR_NODE_VFUNC, &blob->n_vfuncs,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (&members, G_IR_NODE_CONSTANT, &blob->n_constants,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_check_unhandled_members (&members, node->type);
|
2008-10-16 00:28:53 +02:00
|
|
|
|
|
|
|
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;
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->name = _g_ir_write_string (node->name, strings, data, offset2);
|
|
|
|
blob->gtype_name = _g_ir_write_string (iface->gtype_name, strings, data, offset2);
|
|
|
|
blob->gtype_init = _g_ir_write_string (iface->gtype_init, strings, data, offset2);
|
2009-02-20 23:34:20 +01:00
|
|
|
if (iface->glib_type_struct)
|
2010-07-26 22:26:46 +02:00
|
|
|
blob->gtype_struct = find_entry (build, iface->glib_type_struct);
|
2009-02-20 23:34:20 +01:00
|
|
|
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++;
|
2010-07-26 22:26:46 +02:00
|
|
|
*(guint16*)&data[*offset] = find_entry (build, (gchar *)l->data);
|
2008-08-09 14:46:48 +02:00
|
|
|
*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);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (&members, G_IR_NODE_PROPERTY, &blob->n_properties,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (&members, G_IR_NODE_FUNCTION, &blob->n_methods,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (&members, G_IR_NODE_SIGNAL, &blob->n_signals,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2008-10-16 00:28:41 +02:00
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (&members, G_IR_NODE_VFUNC, &blob->n_vfuncs,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
*offset = ALIGN_VALUE (*offset, 4);
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_build_members (&members, G_IR_NODE_CONSTANT, &blob->n_constants,
|
2014-02-28 02:10:19 +01:00
|
|
|
node, build, offset, offset2, NULL);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_node_check_unhandled_members (&members, node->type);
|
2008-10-16 00:28:53 +02:00
|
|
|
|
|
|
|
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;
|
2010-09-14 17:59:03 +02:00
|
|
|
blob->unsigned_value = value->value >= 0 ? 1 : 0;
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->name = _g_ir_write_string (node->name, strings, data, offset2);
|
2010-09-14 17:59:03 +02:00
|
|
|
blob->value = (gint32)value->value;
|
2008-08-09 14:46:48 +02:00
|
|
|
}
|
|
|
|
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;
|
2010-11-16 21:08:33 +01:00
|
|
|
blob->name = _g_ir_write_string (node->name, strings, data, offset2);
|
2008-08-09 14:46:48 +02:00
|
|
|
|
|
|
|
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;
|
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
|
|
|
|
2014-02-28 02:10:19 +01:00
|
|
|
_g_ir_node_build_typelib ((GIrNode *)constant->type, node, build, &pos, offset2, NULL);
|
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 ? "' " : "",
|
2010-11-16 21:08:33 +01:00
|
|
|
node, _g_ir_node_type_to_string (node->type),
|
2008-08-09 14:46:48 +02:00
|
|
|
old_offset, *offset, old_offset2, *offset2);
|
|
|
|
|
2010-11-16 21:08:33 +01:00
|
|
|
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",
|
2010-11-16 21:08:33 +01:00
|
|
|
*offset, old_offset, *offset2, old_offset2, _g_ir_node_get_full_size (node));
|
2010-07-26 22:26:46 +02:00
|
|
|
|
|
|
|
if (appended_stack)
|
|
|
|
build->stack = g_list_delete_link (build->stack, build->stack);
|
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
|
2010-11-16 21:08:33 +01:00
|
|
|
_g_ir_write_string (const gchar *str,
|
|
|
|
GHashTable *strings,
|
|
|
|
guchar *data,
|
|
|
|
guint32 *offset)
|
2008-08-09 14:46:48 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|