gobject-introspection r146 - in trunk: . relaxng tests/parser tools
- From: johan svn gnome org
- To: svn-commits-list gnome org
- Subject: gobject-introspection r146 - in trunk: . relaxng tests/parser tools
- Date: Tue, 11 Mar 2008 13:18:57 +0000 (GMT)
Author: johan
Date: Tue Mar 11 13:18:56 2008
New Revision: 146
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=146&view=rev
Log:
2008-03-11 Johan Dahlin <johan gnome org>
* tests/parser/Foo-expected.gidl:
* tests/parser/foo-object.h:
* tools/scanner.c:
* tools/scanner.h:
* tools/scannerlexer.l:
Add support for parsing return arguments. Add support for
caller-owns return types.
Patch by Philip Van Hoof.
Modified:
trunk/ChangeLog
trunk/relaxng/c-types.xml
trunk/tests/parser/Foo-expected.gidl
trunk/tests/parser/foo-object.h
trunk/tests/parser/foo.c
trunk/tools/gidlwriter.c
trunk/tools/scanner.c
trunk/tools/scannerlexer.l
Modified: trunk/relaxng/c-types.xml
==============================================================================
--- trunk/relaxng/c-types.xml (original)
+++ trunk/relaxng/c-types.xml Tue Mar 11 13:18:56 2008
@@ -147,7 +147,7 @@
<choice>
<value>full</value>
<value>shallow</value>
- <value>transfer</value>
+ <value>none</value>
</choice>
</attribute>
</optional>
Modified: trunk/tests/parser/Foo-expected.gidl
==============================================================================
--- trunk/tests/parser/Foo-expected.gidl (original)
+++ trunk/tests/parser/Foo-expected.gidl Tue Mar 11 13:18:56 2008
@@ -37,6 +37,12 @@
<member name="FOO_FLAGS_THIRD" value="4"/>
</flags>
<object name="FooObject" parent="GLib.Object" type-name="FooObject" get-type="foo_object_get_type">
+ <method name="create_object" symbol="foo_object_create_object">
+ <return-type type="GObject*" transfer="full"/>
+ <parameters>
+ <parameter name="object" type="FooObject*"/>
+ </parameters>
+ </method>
<method name="method" symbol="foo_object_method">
<return-type type="gint"/>
<parameters>
Modified: trunk/tests/parser/foo-object.h
==============================================================================
--- trunk/tests/parser/foo-object.h (original)
+++ trunk/tests/parser/foo-object.h Tue Mar 11 13:18:56 2008
@@ -46,6 +46,8 @@
gint foo_object_method (FooObject *object);
gint foo_object_out (FooObject *object,
int *outarg);
+GObject* foo_object_create_object (FooObject *object);
+
struct _FooSubobject
{
Modified: trunk/tests/parser/foo.c
==============================================================================
--- trunk/tests/parser/foo.c (original)
+++ trunk/tests/parser/foo.c Tue Mar 11 13:18:56 2008
@@ -52,13 +52,31 @@
/**
* foo_object_out:
+ * @object: a #GObject
+ *
* This is a test for out arguments
+ *
* @outarg: (out): This is an argument test
+ * Return value: an int
*/
gint
foo_object_out (FooObject *object, int *outarg)
{
+ return 1;
+}
+/**
+ * foo_object_create_object:
+ * @object: a #GObject
+ *
+ * Test returning a caller-owned object
+ *
+ * Return value: (caller-owns): The object
+ **/
+GObject*
+foo_object_create_object (FooObject *object)
+{
+ return g_object_ref (object);
}
G_DEFINE_TYPE (FooSubobject, foo_subobject, FOO_TYPE_OBJECT);
Modified: trunk/tools/gidlwriter.c
==============================================================================
--- trunk/tools/gidlwriter.c (original)
+++ trunk/tools/gidlwriter.c Tue Mar 11 13:18:56 2008
@@ -150,11 +150,17 @@
g_writer_write_indent (writer, markup_s->str);
g_string_free (markup_s, TRUE);
- markup =
- g_markup_printf_escaped ("<return-type type=\"%s\"/>\n",
- node->result->type->unparsed);
- g_writer_write (writer, markup);
- g_free (markup);
+ markup_s =
+ g_string_new (g_markup_printf_escaped ("<return-type type=\"%s\"",
+ node->result->type->unparsed));
+
+ if (node->result->transfer)
+ g_string_append (markup_s, g_markup_printf_escaped (" transfer=\"full\"/>\n"));
+ else
+ g_string_append (markup_s, "/>\n");
+
+ g_writer_write (writer, markup_s->str);
+ g_string_free (markup_s, TRUE);
if (node->parameters != NULL)
{
@@ -173,6 +179,10 @@
g_markup_printf_escaped (" type=\"%s\"",
param->type->unparsed));
+ if (param->transfer)
+ g_string_append (markup_s,
+ g_markup_printf_escaped (" transfer=\"full"));
+
if (param->null_ok)
g_string_append (markup_s,
g_markup_printf_escaped (" null-ok=\"1\""));
Modified: trunk/tools/scanner.c
==============================================================================
--- trunk/tools/scanner.c (original)
+++ trunk/tools/scanner.c Tue Mar 11 13:18:56 2008
@@ -674,6 +674,21 @@
directives = g_hash_table_lookup (igenerator->directives_map, func->symbol);
+ for (j = directives; j; j = j->next)
+ {
+ CDirective *directive = j->data;
+ if (g_ascii_strncasecmp ("return", directive->name, 6) == 0)
+ {
+ GSList *options;
+ for (options = directive->options; options; options = options->next)
+ {
+ gchar *stringy_data = options->data;
+ if (g_ascii_strcasecmp (stringy_data, "caller-owns") == 0)
+ func->result->transfer = TRUE;
+ }
+ }
+ }
+
for (param_l = sym->base_type->child_list, i = 1; param_l != NULL;
param_l = param_l->next, i++)
{
@@ -688,14 +703,16 @@
CDirective *directive = j->data;
if (g_ascii_strcasecmp (param_sym->ident, directive->name) == 0)
- {
-
- GSList *options;
+ {
+
+ GSList *options;
for (options = directive->options; options; options = options->next)
{
gchar *stringy_data = options->data;
+ if (g_ascii_strcasecmp (stringy_data, "callee-owns") == 0)
+ param->transfer = TRUE;
if (g_ascii_strcasecmp (stringy_data, "null-ok") == 0)
param->null_ok = TRUE;
if (g_ascii_strcasecmp (stringy_data, "in") == 0)
Modified: trunk/tools/scannerlexer.l
==============================================================================
--- trunk/tools/scannerlexer.l (original)
+++ trunk/tools/scannerlexer.l Tue Mar 11 13:18:56 2008
@@ -173,12 +173,18 @@
%%
-static int yywrap (void)
+static int
+yywrap (void)
{
return 1;
}
-static void parse_gtkdoc (GIGenerator *igenerator, gchar *symbol, int *c1, int *c2)
+
+static void
+parse_gtkdoc (GIGenerator *igenerator,
+ gchar *symbol,
+ int *c1,
+ int *c2)
{
gboolean isline = FALSE;
gchar line[256];
@@ -188,6 +194,7 @@
char *name,*value;
GSList *directives;
GSList *options = NULL;
+ char *rname;
i = 0;
do
@@ -241,25 +248,35 @@
name = parts[0];
value = NULL;
}
-
- directive = cdirective_new (name, value, options);
-
+
+ /*
+ * This is a special case for return values, name will only be
+ * 'eturn' or a valid name, check the call site.
+ * Context-sensitive parsing would probably be the right way to go
+ */
+ if (g_ascii_strncasecmp ("eturn", name, 5) == 0)
+ rname = "return";
+ else
+ rname = name;
+
+ directive = cdirective_new (rname, value, options);
directives = g_hash_table_lookup (igenerator->directives_map, symbol);
directives = g_slist_prepend (directives, directive);
-
g_hash_table_replace (igenerator->directives_map,
g_strdup (symbol), directives);
+
g_strfreev (parts);
}
-
-static void parse_comment (GIGenerator *igenerator)
+
+static void
+parse_comment (GIGenerator *igenerator)
{
GString *symbol = NULL;
gboolean startofline = FALSE, have_symbol = FALSE, start1 = FALSE, start_symbol = FALSE;
int c1, c2;
-
+
c1 = input();
c2 = input();
@@ -291,20 +308,23 @@
if ((c1 != '*' && c1 != ' '))
startofline = FALSE;
- if (startofline && c1 == ' ' && c2 == '@')
+ if (startofline && (c1 == ' ') && (c2 == '@' || (c2 == 'r') || (c2 == 'R')))
{
c1 = c2;
c2 = input();
- parse_gtkdoc (igenerator, symbol ? symbol->str : NULL, &c1, &c2);
-
- }
+ if (symbol)
+ parse_gtkdoc (igenerator, symbol->str, &c1, &c2);
+ }
}
+
if (symbol)
g_string_free (symbol, TRUE);
}
-static int check_identifier (GIGenerator *igenerator, const char *s)
+static int
+check_identifier (GIGenerator *igenerator,
+ const char *s)
{
/*
* This function checks if `s' is a type name or an
@@ -320,7 +340,8 @@
return IDENTIFIER;
}
-static void process_directive (GIGenerator *igenerator)
+static void
+process_directive (GIGenerator *igenerator)
{
/* extract current filename from #line directives */
GString *filename_builder;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]