mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-02 05:43:07 +02:00
Merge branch 'bug552393-varargs'
svn path=/trunk/; revision=643
This commit is contained in:
parent
b26d8d2dce
commit
a99fdaf755
@ -85,6 +85,7 @@ struct _GIrNodeFunction
|
|||||||
GIrNode node;
|
GIrNode node;
|
||||||
|
|
||||||
gboolean deprecated;
|
gboolean deprecated;
|
||||||
|
gboolean is_varargs; /* Not in typelib yet */
|
||||||
|
|
||||||
gboolean is_method;
|
gboolean is_method;
|
||||||
gboolean is_setter;
|
gboolean is_setter;
|
||||||
@ -183,6 +184,7 @@ struct _GIrNodeVFunc
|
|||||||
{
|
{
|
||||||
GIrNode node;
|
GIrNode node;
|
||||||
|
|
||||||
|
gboolean is_varargs; /* Not in typelib yet */
|
||||||
gboolean must_chain_up;
|
gboolean must_chain_up;
|
||||||
gboolean must_be_implemented;
|
gboolean must_be_implemented;
|
||||||
gboolean must_not_be_implemented;
|
gboolean must_not_be_implemented;
|
||||||
|
120
girparser.c
120
girparser.c
@ -79,6 +79,7 @@ struct _ParseContext
|
|||||||
GIrModule *current_module;
|
GIrModule *current_module;
|
||||||
GIrNode *current_node;
|
GIrNode *current_node;
|
||||||
GIrNode *current_typed;
|
GIrNode *current_typed;
|
||||||
|
gboolean is_varargs;
|
||||||
GList *type_stack;
|
GList *type_stack;
|
||||||
GList *type_parameters;
|
GList *type_parameters;
|
||||||
int type_depth;
|
int type_depth;
|
||||||
@ -1420,11 +1421,13 @@ start_type (GMarkupParseContext *context,
|
|||||||
const gchar *name;
|
const gchar *name;
|
||||||
const gchar *ctype;
|
const gchar *ctype;
|
||||||
gboolean is_array;
|
gboolean is_array;
|
||||||
|
gboolean is_varargs;
|
||||||
GIrNodeType *typenode;
|
GIrNodeType *typenode;
|
||||||
|
|
||||||
is_array = strcmp (element_name, "array") == 0;
|
is_array = strcmp (element_name, "array") == 0;
|
||||||
|
is_varargs = strcmp (element_name, "varargs") == 0;
|
||||||
|
|
||||||
if (!(is_array || (strcmp (element_name, "type") == 0)))
|
if (!(is_array || is_varargs || (strcmp (element_name, "type") == 0)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (ctx->state == STATE_TYPE)
|
if (ctx->state == STATE_TYPE)
|
||||||
@ -1449,6 +1452,25 @@ start_type (GMarkupParseContext *context,
|
|||||||
{
|
{
|
||||||
state_switch (ctx, STATE_TYPE);
|
state_switch (ctx, STATE_TYPE);
|
||||||
ctx->type_depth = 1;
|
ctx->type_depth = 1;
|
||||||
|
if (is_varargs)
|
||||||
|
{
|
||||||
|
switch (ctx->current_node->type)
|
||||||
|
{
|
||||||
|
case G_IR_NODE_FUNCTION:
|
||||||
|
case G_IR_NODE_CALLBACK:
|
||||||
|
{
|
||||||
|
GIrNodeFunction *func = (GIrNodeFunction *)ctx->current_node;
|
||||||
|
func->is_varargs = TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case G_IR_NODE_VFUNC:
|
||||||
|
{
|
||||||
|
GIrNodeVFunc *vfunc = (GIrNodeVFunc *)ctx->current_node;
|
||||||
|
vfunc->is_varargs = TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
ctx->type_stack = NULL;
|
ctx->type_stack = NULL;
|
||||||
ctx->type_parameters = NULL;
|
ctx->type_parameters = NULL;
|
||||||
}
|
}
|
||||||
@ -1462,6 +1484,9 @@ start_type (GMarkupParseContext *context,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_varargs)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
if (is_array)
|
if (is_array)
|
||||||
{
|
{
|
||||||
const char *zero;
|
const char *zero;
|
||||||
@ -1509,7 +1534,12 @@ start_type (GMarkupParseContext *context,
|
|||||||
static void
|
static void
|
||||||
end_type_top (ParseContext *ctx)
|
end_type_top (ParseContext *ctx)
|
||||||
{
|
{
|
||||||
GIrNodeType *typenode = (GIrNodeType*)ctx->type_parameters->data;
|
GIrNodeType *typenode;
|
||||||
|
|
||||||
|
if (!ctx->type_parameters)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
typenode = (GIrNodeType*)ctx->type_parameters->data;
|
||||||
|
|
||||||
/* Default to pointer for unspecified containers */
|
/* Default to pointer for unspecified containers */
|
||||||
if (typenode->tag == GI_TYPE_TAG_ARRAY ||
|
if (typenode->tag == GI_TYPE_TAG_ARRAY ||
|
||||||
@ -1560,6 +1590,7 @@ end_type_top (ParseContext *ctx)
|
|||||||
}
|
}
|
||||||
g_list_free (ctx->type_parameters);
|
g_list_free (ctx->type_parameters);
|
||||||
|
|
||||||
|
out:
|
||||||
ctx->type_depth = 0;
|
ctx->type_depth = 0;
|
||||||
ctx->type_parameters = NULL;
|
ctx->type_parameters = NULL;
|
||||||
ctx->current_typed = NULL;
|
ctx->current_typed = NULL;
|
||||||
@ -2323,6 +2354,10 @@ start_element_handler (GMarkupParseContext *context,
|
|||||||
attribute_names, attribute_values,
|
attribute_names, attribute_values,
|
||||||
ctx, error))
|
ctx, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
if (start_type (context, element_name,
|
||||||
|
attribute_names, attribute_values,
|
||||||
|
ctx, error))
|
||||||
|
goto out;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2464,7 +2499,13 @@ end_element_handler (GMarkupParseContext *context,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case STATE_FUNCTION:
|
case STATE_FUNCTION:
|
||||||
if (ctx->current_node == g_list_last (ctx->current_module->entries)->data)
|
{
|
||||||
|
gboolean current_is_toplevel;
|
||||||
|
GList *last = g_list_last (ctx->current_module->entries);
|
||||||
|
|
||||||
|
current_is_toplevel = ctx->current_node == last->data;
|
||||||
|
|
||||||
|
if (current_is_toplevel)
|
||||||
{
|
{
|
||||||
ctx->current_node = NULL;
|
ctx->current_node = NULL;
|
||||||
state_switch (ctx, STATE_NAMESPACE);
|
state_switch (ctx, STATE_NAMESPACE);
|
||||||
@ -2494,6 +2535,7 @@ end_element_handler (GMarkupParseContext *context,
|
|||||||
line_number, char_number);
|
line_number, char_number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATE_CLASS_FIELD:
|
case STATE_CLASS_FIELD:
|
||||||
@ -2654,7 +2696,8 @@ end_element_handler (GMarkupParseContext *context,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case STATE_TYPE:
|
case STATE_TYPE:
|
||||||
if ((strcmp ("type", element_name) == 0) || (strcmp ("array", element_name) == 0))
|
if ((strcmp ("type", element_name) == 0) || (strcmp ("array", element_name) == 0) ||
|
||||||
|
(strcmp ("varargs", element_name) == 0))
|
||||||
{
|
{
|
||||||
end_type (ctx);
|
end_type (ctx);
|
||||||
break;
|
break;
|
||||||
@ -2700,6 +2743,69 @@ static GMarkupParser parser =
|
|||||||
cleanup
|
cleanup
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static GList *
|
||||||
|
post_filter_varargs_functions (GList *list)
|
||||||
|
{
|
||||||
|
GList *iter;
|
||||||
|
|
||||||
|
iter = list;
|
||||||
|
while (iter)
|
||||||
|
{
|
||||||
|
GList *link = iter;
|
||||||
|
GIrNode *node = iter->data;
|
||||||
|
|
||||||
|
iter = iter->next;
|
||||||
|
|
||||||
|
if (node->type == G_IR_NODE_FUNCTION)
|
||||||
|
{
|
||||||
|
if (((GIrNodeFunction*)node)->is_varargs)
|
||||||
|
{
|
||||||
|
g_printerr ("deleting varargs function\n");
|
||||||
|
list = g_list_delete_link (list, link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
post_filter (GIrModule *module)
|
||||||
|
{
|
||||||
|
GList *iter;
|
||||||
|
|
||||||
|
module->entries = post_filter_varargs_functions (module->entries);
|
||||||
|
iter = module->entries;
|
||||||
|
while (iter)
|
||||||
|
{
|
||||||
|
GList *link = iter;
|
||||||
|
GIrNode *node = iter->data;
|
||||||
|
|
||||||
|
iter = iter->next;
|
||||||
|
|
||||||
|
if (node->type == G_IR_NODE_OBJECT ||
|
||||||
|
node->type == G_IR_NODE_INTERFACE)
|
||||||
|
{
|
||||||
|
GIrNodeInterface *iface = (GIrNodeInterface*)node;
|
||||||
|
iface->members = post_filter_varargs_functions (iface->members);
|
||||||
|
}
|
||||||
|
else if (node->type == G_IR_NODE_BOXED)
|
||||||
|
{
|
||||||
|
GIrNodeBoxed *boxed = (GIrNodeBoxed*)node;
|
||||||
|
boxed->members = post_filter_varargs_functions (boxed->members);
|
||||||
|
}
|
||||||
|
else if (node->type == G_IR_NODE_STRUCT)
|
||||||
|
{
|
||||||
|
GIrNodeStruct *iface = (GIrNodeStruct*)node;
|
||||||
|
iface->members = post_filter_varargs_functions (iface->members);
|
||||||
|
}
|
||||||
|
else if (node->type == G_IR_NODE_UNION)
|
||||||
|
{
|
||||||
|
GIrNodeUnion *iface = (GIrNodeUnion*)node;
|
||||||
|
iface->members = post_filter_varargs_functions (iface->members);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GList *
|
GList *
|
||||||
g_ir_parse_string (const gchar *namespace,
|
g_ir_parse_string (const gchar *namespace,
|
||||||
const gchar *const *includes,
|
const gchar *const *includes,
|
||||||
@ -2753,6 +2859,7 @@ g_ir_parse_file (const gchar *filename,
|
|||||||
gchar *buffer;
|
gchar *buffer;
|
||||||
gsize length;
|
gsize length;
|
||||||
GList *modules;
|
GList *modules;
|
||||||
|
GList *iter;
|
||||||
const char *slash;
|
const char *slash;
|
||||||
char *namespace;
|
char *namespace;
|
||||||
|
|
||||||
@ -2779,6 +2886,11 @@ g_ir_parse_file (const gchar *filename,
|
|||||||
|
|
||||||
modules = g_ir_parse_string (namespace, includes, buffer, length, error);
|
modules = g_ir_parse_string (namespace, includes, buffer, length, error);
|
||||||
|
|
||||||
|
for (iter = modules; iter; iter = iter->next)
|
||||||
|
{
|
||||||
|
post_filter ((GIrModule*)iter->data);
|
||||||
|
}
|
||||||
|
|
||||||
g_free (namespace);
|
g_free (namespace);
|
||||||
|
|
||||||
g_free (buffer);
|
g_free (buffer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user