girepository: Remove C99ism and other updates

-Make code using libgirepository_internals relocatable on Windows,
 like what is done in the GTK+ stack, and the girepository DLL.
-Remove C99isms
-"interface" is a reserved keyword on certain compilers, so change that to
 "giinterface"

https://bugzilla.gnome.org/show_bug.cgi?id=681820
This commit is contained in:
Chun-wei Fan 2012-07-24 16:09:38 +08:00 committed by Colin Walters
parent c449db7704
commit 08da5d65ee
5 changed files with 42 additions and 15 deletions

View File

@ -261,8 +261,9 @@ add_directory_index_section (guint8 *data, GIrModule *module, guint32 *offset2)
for (i = 0; i < n_interfaces; i++) for (i = 0; i < n_interfaces; i++)
{ {
const char *str;
entry = (DirEntry *)&data[header->directory + (i * header->entry_blob_size)]; entry = (DirEntry *)&data[header->directory + (i * header->entry_blob_size)];
const char *str = (const char *) (&data[entry->name]); str = (const char *) (&data[entry->name]);
_gi_typelib_hash_builder_add_string (dirindex_builder, str, i); _gi_typelib_hash_builder_add_string (dirindex_builder, str, i);
} }

View File

@ -28,6 +28,11 @@
#include "girnode.h" #include "girnode.h"
#include "gitypelib-internal.h" #include "gitypelib-internal.h"
#ifdef _MSC_VER
#define strtoll _strtoi64
#define strtoull _strtoui64
#endif
static gulong string_count = 0; static gulong string_count = 0;
static gulong unique_string_count = 0; static gulong unique_string_count = 0;
static gulong string_size = 0; static gulong string_size = 0;
@ -228,7 +233,7 @@ _g_ir_node_free (GIrNode *node)
_g_ir_node_free ((GIrNode *)type->parameter_type1); _g_ir_node_free ((GIrNode *)type->parameter_type1);
_g_ir_node_free ((GIrNode *)type->parameter_type2); _g_ir_node_free ((GIrNode *)type->parameter_type2);
g_free (type->interface); g_free (type->giinterface);
g_strfreev (type->errors); g_strfreev (type->errors);
} }
@ -1244,7 +1249,7 @@ serialize_type (GIrTypelibBuild *build,
GIrNode *iface; GIrNode *iface;
gchar *name; gchar *name;
iface = find_entry_node (build, node->interface, NULL); iface = find_entry_node (build, node->giinterface, NULL);
if (iface) if (iface)
{ {
if (iface->type == G_IR_NODE_XREF) if (iface->type == G_IR_NODE_XREF)
@ -1253,8 +1258,8 @@ serialize_type (GIrTypelibBuild *build,
} }
else else
{ {
g_warning ("Interface for type reference %s not found", node->interface); g_warning ("Interface for type reference %s not found", node->giinterface);
name = node->interface; name = node->giinterface;
} }
g_string_append_printf (str, "%s%s", name, g_string_append_printf (str, "%s%s", name,
@ -1483,7 +1488,7 @@ _g_ir_node_build_typelib (GIrNode *node,
iface->reserved = 0; iface->reserved = 0;
iface->tag = type->tag; iface->tag = type->tag;
iface->reserved2 = 0; iface->reserved2 = 0;
iface->interface = find_entry (build, type->interface); iface->interface = find_entry (build, type->giinterface);
} }
break; break;

View File

@ -133,7 +133,7 @@ struct _GIrNodeType
GIrNodeType *parameter_type1; GIrNodeType *parameter_type1;
GIrNodeType *parameter_type2; GIrNodeType *parameter_type2;
gchar *interface; gchar *giinterface;
gchar **errors; gchar **errors;
}; };

View File

@ -190,10 +190,10 @@ get_interface_size_alignment (GIrTypelibBuild *build,
{ {
GIrNode *iface; GIrNode *iface;
iface = _g_ir_find_node (build, ((GIrNode*)type)->module, type->interface); iface = _g_ir_find_node (build, ((GIrNode*)type)->module, type->giinterface);
if (!iface) if (!iface)
{ {
_g_ir_module_fatal (build, 0, "Can't resolve type '%s' for %s", type->interface, who); _g_ir_module_fatal (build, 0, "Can't resolve type '%s' for %s", type->giinterface, who);
*size = -1; *size = -1;
*alignment = -1; *alignment = -1;
return FALSE; return FALSE;

View File

@ -36,6 +36,24 @@
*/ */
#define SUPPORTED_GIR_VERSION "1.2" #define SUPPORTED_GIR_VERSION "1.2"
#ifdef G_OS_WIN32
#include <windows.h>
#ifdef GIR_DIR
#undef GIR_DIR
#endif
/* GIR_DIR is used only in code called just once,
* so no problem leaking this
*/
#define GIR_DIR \
g_build_filename (g_win32_get_package_installation_directory_of_module(NULL), \
"share", \
GIR_SUFFIX, \
NULL)
#endif
struct _GIrParser struct _GIrParser
{ {
gchar **includes; gchar **includes;
@ -329,10 +347,12 @@ state_switch (ParseContext *ctx, ParseState newstate)
static GIrNode * static GIrNode *
pop_node (ParseContext *ctx) pop_node (ParseContext *ctx)
{ {
GSList *top;
GIrNode *node;
g_assert (ctx->node_stack != 0); g_assert (ctx->node_stack != 0);
GSList *top = ctx->node_stack; top = ctx->node_stack;
GIrNode *node = top->data; node = top->data;
g_debug ("popping node %d %s", node->type, node->name); g_debug ("popping node %d %s", node->type, node->name);
ctx->node_stack = top->next; ctx->node_stack = top->next;
@ -552,8 +572,8 @@ parse_type_internal (GIrModule *module,
if (*str == '<') if (*str == '<')
{ {
(str)++;
char *tmp, *end; char *tmp, *end;
(str)++;
end = strchr (str, '>'); end = strchr (str, '>');
tmp = g_strndup (str, end - str); tmp = g_strndup (str, end - str);
@ -565,9 +585,10 @@ parse_type_internal (GIrModule *module,
} }
else else
{ {
const char *start;
type->tag = GI_TYPE_TAG_INTERFACE; type->tag = GI_TYPE_TAG_INTERFACE;
type->is_interface = TRUE; type->is_interface = TRUE;
const char *start = str; start = str;
/* must be an interface type */ /* must be an interface type */
while (g_ascii_isalnum (*str) || while (g_ascii_isalnum (*str) ||
@ -577,7 +598,7 @@ parse_type_internal (GIrModule *module,
*str == ':') *str == ':')
(str)++; (str)++;
type->interface = g_strndup (start, str - start); type->giinterface = g_strndup (start, str - start);
} }
if (next) if (next)
@ -1965,7 +1986,7 @@ start_type (GMarkupParseContext *context,
* doesn't look like a pointer, but is internally. * doesn't look like a pointer, but is internally.
*/ */
if (typenode->tag == GI_TYPE_TAG_INTERFACE && if (typenode->tag == GI_TYPE_TAG_INTERFACE &&
is_disguised_structure (ctx, typenode->interface)) is_disguised_structure (ctx, typenode->giinterface))
pointer_depth++; pointer_depth++;
if (pointer_depth > 0) if (pointer_depth > 0)