diff options
Diffstat (limited to 'girepository/girparser.c')
-rw-r--r-- | girepository/girparser.c | 85 |
1 files changed, 46 insertions, 39 deletions
diff --git a/girepository/girparser.c b/girepository/girparser.c index fa0de1f8..f96cfb1e 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -36,6 +36,24 @@ */ #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 { gchar **includes; @@ -77,7 +95,6 @@ typedef enum STATE_ALIAS, /* 30 */ STATE_TYPE, STATE_ATTRIBUTE, - STATE_DOC, STATE_PASSTHROUGH } ParseState; @@ -324,15 +341,20 @@ state_switch (ParseContext *ctx, ParseState newstate) g_assert (ctx->state != newstate); ctx->prev_state = ctx->state; ctx->state = newstate; + + if (ctx->state == STATE_PASSTHROUGH) + ctx->unknown_depth = 1; } static GIrNode * pop_node (ParseContext *ctx) { + GSList *top; + GIrNode *node; g_assert (ctx->node_stack != 0); - GSList *top = ctx->node_stack; - GIrNode *node = top->data; + top = ctx->node_stack; + node = top->data; g_debug ("popping node %d %s", node->type, node->name); ctx->node_stack = top->next; @@ -359,7 +381,8 @@ typedef struct { } IntegerAliasInfo; static IntegerAliasInfo integer_aliases[] = { - { "gchar", SIZEOF_CHAR, 0 }, + { "gchar", SIZEOF_CHAR, 1 }, + { "guchar", SIZEOF_CHAR, 0 }, { "gshort", SIZEOF_SHORT, 1 }, { "gushort", SIZEOF_SHORT, 0 }, { "gint", SIZEOF_INT, 1 }, @@ -552,8 +575,8 @@ parse_type_internal (GIrModule *module, if (*str == '<') { - (str)++; char *tmp, *end; + (str)++; end = strchr (str, '>'); tmp = g_strndup (str, end - str); @@ -565,9 +588,10 @@ parse_type_internal (GIrModule *module, } else { + const char *start; type->tag = GI_TYPE_TAG_INTERFACE; type->is_interface = TRUE; - const char *start = str; + start = str; /* must be an interface type */ while (g_ascii_isalnum (*str) || @@ -577,7 +601,7 @@ parse_type_internal (GIrModule *module, *str == ':') (str)++; - type->interface = g_strndup (start, str - start); + type->giinterface = g_strndup (start, str - start); } if (next) @@ -703,10 +727,7 @@ introspectable_prelude (GMarkupParseContext *context, if (introspectable) state_switch (ctx, new_state); else - { - state_switch (ctx, STATE_PASSTHROUGH); - ctx->unknown_depth = 1; - } + state_switch (ctx, STATE_PASSTHROUGH); return introspectable; } @@ -1965,7 +1986,7 @@ start_type (GMarkupParseContext *context, * doesn't look like a pointer, but is internally. */ if (typenode->tag == GI_TYPE_TAG_INTERFACE && - is_disguised_structure (ctx, typenode->interface)) + is_disguised_structure (ctx, typenode->giinterface)) pointer_depth++; if (pointer_depth > 0) @@ -2095,22 +2116,6 @@ end_type (ParseContext *ctx) } static gboolean -start_doc (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) -{ - if (strcmp (element_name, "doc") != 0) - return FALSE; - - state_switch (ctx, STATE_DOC); - - return TRUE; -} - -static gboolean start_attribute (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, @@ -2743,9 +2748,11 @@ start_element_handler (GMarkupParseContext *context, attribute_names, attribute_values, ctx, error)) goto out; - else if (start_doc (context, element_name, attribute_names, - attribute_values, ctx, error)) - goto out; + if (strcmp (element_name, "doc") == 0) + { + state_switch (ctx, STATE_PASSTHROUGH); + goto out; + } break; case 'e': @@ -2824,6 +2831,11 @@ start_element_handler (GMarkupParseContext *context, attribute_names, attribute_values, ctx, error)) goto out; + else if (strcmp (element_name, "instance-parameter") == 0) + { + state_switch (ctx, STATE_PASSTHROUGH); + goto out; + } else if (strcmp (element_name, "c:include") == 0) { state_switch (ctx, STATE_C_INCLUDE); @@ -2860,6 +2872,9 @@ start_element_handler (GMarkupParseContext *context, version = find_attribute ("version", attribute_names, attribute_values); shared_library = find_attribute ("shared-library", attribute_names, attribute_values); cprefix = find_attribute ("c:identifier-prefixes", attribute_names, attribute_values); + /* Backwards compatibility; vala currently still generates this */ + if (cprefix == NULL) + cprefix = find_attribute ("c:prefix", attribute_names, attribute_values); if (name == NULL) MISSING_ATTRIBUTE (context, error, element_name, "name"); @@ -3006,7 +3021,6 @@ start_element_handler (GMarkupParseContext *context, ctx->file_path, line_number, char_number, element_name, ctx->state); state_switch (ctx, STATE_PASSTHROUGH); - ctx->unknown_depth = 1; } out: @@ -3391,13 +3405,6 @@ end_element_handler (GMarkupParseContext *context, } break; - case STATE_DOC: - if (strcmp ("doc", element_name) == 0) - { - state_switch (ctx, ctx->prev_state); - } - break; - case STATE_PASSTHROUGH: ctx->unknown_depth -= 1; g_assert (ctx->unknown_depth >= 0); |