summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Dahlin <johan@src.gnome.org>2008-08-06 17:34:42 +0000
committerJohan Dahlin <johan@src.gnome.org>2008-08-06 17:34:42 +0000
commitc09db950fd1e673e3127df1778117627e02d5e23 (patch)
tree0753b1c99c69e4b780f56a546f229279424c5a0b
parent7180c04a3df9a5fee853d44a3fc4b16123a405be (diff)
downloadgobject-introspection-c09db950fd1e673e3127df1778117627e02d5e23.tar.gz
Make the code compile, parse return-value and type
svn path=/branches/gir-compiler/; revision=303
-rw-r--r--tests/array.test32
-rw-r--r--tools/girparser.c83
2 files changed, 48 insertions, 67 deletions
diff --git a/tests/array.test b/tests/array.test
index 8d392c29..bdbbcaa4 100644
--- a/tests/array.test
+++ b/tests/array.test
@@ -5,23 +5,39 @@
xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<namespace name="Foo">
<function name="test1" c:identifier="test1">
- <return-type c:type="gboolean" />
+ <return-value>
+ <type name="boolean" c:type="gboolean"/>
+ </return-value>
<parameters>
- <parameter name="p1" c:type="guint8[length=1,zero-terminated=1]" transfer="full" direction="in" />
- <parameter name="p2" c:type="gint" direction="in" />
+ <parameter name="p1">
+ <type name="uint8" c:type="guint8" length="1" zero-terminated="1" transfer="full"/>
+ </parameter>
+ <parameter name="p2">
+ <type name="int" c:type="gint"/>
+ </parameter>
</parameters>
</function>
<function name="test2" c:identifier="test2">
- <return-type c:type="gboolean" />
+ <return-value>
+ <type name="boolean" c:type="gboolean"/>
+ </return-value>
<parameters>
- <parameter name="p2" c:type="gint" direction="out" />
- <parameter name="p1" c:type="guint8[length=0]" transfer="full" direction="out" />
+ <parameter name="p2">
+ <type name="uint" c:type="gint" direction="out"/>
+ </parameter>
+ <parameter name="p1">
+ <type name="uint8" c:type="guint8" length="0" direction="out" transfer="full"/>
+ </parameter>
</parameters>
</function>
<function name="test3" c:identifier="test3">
- <return-type c:type="gboolean" />
+ <return-value>
+ <type name="boolean" c:type="gboolean"/>
+ </return-value>
<parameters>
- <parameter name="p1" c:type="guint8[zero-terminated=1]" transfer="full" direction="in" />
+ <parameter name="p1">
+ <type name="uint8" c:type="guint8" length="1" zero-terminated="1" transfer="full"/>
+ </parameter>
</parameters>
</function>
</namespace>
diff --git a/tools/girparser.c b/tools/girparser.c
index 4513ee58..844bb0c0 100644
--- a/tools/girparser.c
+++ b/tools/girparser.c
@@ -46,7 +46,8 @@ typedef enum
STATE_STRUCT,
STATE_SIGNAL,
STATE_ERRORDOMAIN,
- STATE_UNION
+ STATE_UNION,
+ STATE_PARAMETERS
} ParseState;
typedef struct _ParseContext ParseContext;
@@ -1222,6 +1223,7 @@ start_type (GMarkupParseContext *context,
{
const gchar *name;
const gchar *ctype;
+ GIrNodeParam *param;
if (strcmp (element_name, "type") != 0)
return FALSE;
@@ -1234,19 +1236,13 @@ start_type (GMarkupParseContext *context,
if (ctype == NULL)
MISSING_ATTRIBUTE (error, element_name, "c:type");
+ param = (GIrNodeParam *)ctx->current_node;
+
switch (ctx->current_node->type)
{
- case G_IR_NODE_FUNCTION_RETURN:
+ case G_IR_NODE_PARAM:
{
}
- if (ctx->current_is_return)
- {
- func->result = param;
- }
- else
- {
- }
- }
break;
case G_IR_NODE_SIGNAL:
{
@@ -1261,62 +1257,31 @@ start_type (GMarkupParseContext *context,
}
break;
default:
+ g_printerr("current node is %d\n", ctx->current_node->type);
g_assert_not_reached ();
}
}
static gboolean
-start_return_type (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- ParseContext *ctx,
- GError **error)
+start_return_value (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ ParseContext *ctx,
+ GError **error)
{
if (strcmp (element_name, "return-value") == 0 &&
ctx->state == STATE_FUNCTION)
{
- const gchar *type;
- const gchar *nullok;
- const gchar *transfer;
-
- type = find_attribute ("c:type", attribute_names, attribute_values);
- nullok = find_attribute ("null-ok", attribute_names, attribute_values);
- transfer = find_attribute ("transfer", attribute_names, attribute_values);
- if (type == NULL)
- MISSING_ATTRIBUTE (error, element_name, "c:type");
- else
- {
- GIrNodeParam *param;
+ GIrNodeParam *param;
+
+ param = (GIrNodeParam *)g_ir_node_new (G_IR_NODE_PARAM);
+ param->in = FALSE;
+ param->out = FALSE;
+ param->retval = TRUE;
+
+ ctx->current_node = (GIrNode *) param;
- param = (GIrNodeParam *)g_ir_node_new (G_IR_NODE_PARAM);
- param->in = FALSE;
- param->out = FALSE;
- param->retval = TRUE;
- if (nullok && strcmp (nullok, "1") == 0)
- param->null_ok = TRUE;
- else
- param->null_ok = FALSE;
- if (transfer && strcmp (transfer, "none") == 0)
- {
- param->transfer = FALSE;
- param->shallow_transfer = FALSE;
- }
- else if (transfer && strcmp (transfer, "shallow") == 0)
- {
- param->transfer = FALSE;
- param->shallow_transfer = TRUE;
- }
- else
- {
- param->transfer = TRUE;
- param->shallow_transfer = FALSE;
- }
-
- param->type = parse_type (type);
-
- }
-
return TRUE;
}
@@ -1822,9 +1787,9 @@ start_element_handler (GMarkupParseContext *context,
goto out;
}
- else if (start_return_type (context, element_name,
- attribute_names, attribute_values,
- ctx, error))
+ else if (start_return_value (context, element_name,
+ attribute_names, attribute_values,
+ ctx, error))
goto out;
else if (strcmp (element_name, "requires") == 0 &&
ctx->state == STATE_INTERFACE)