gobject-introspection r303 - in branches/gir-compiler: tests tools



Author: johan
Date: Wed Aug  6 17:34:42 2008
New Revision: 303
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=303&view=rev

Log:
Make the code compile, parse return-value and type

Modified:
   branches/gir-compiler/tests/array.test
   branches/gir-compiler/tools/girparser.c

Modified: branches/gir-compiler/tests/array.test
==============================================================================
--- branches/gir-compiler/tests/array.test	(original)
+++ branches/gir-compiler/tests/array.test	Wed Aug  6 17:34:42 2008
@@ -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>

Modified: branches/gir-compiler/tools/girparser.c
==============================================================================
--- branches/gir-compiler/tools/girparser.c	(original)
+++ branches/gir-compiler/tools/girparser.c	Wed Aug  6 17:34:42 2008
@@ -46,7 +46,8 @@
   STATE_STRUCT,
   STATE_SIGNAL,
   STATE_ERRORDOMAIN,
-  STATE_UNION
+  STATE_UNION,
+  STATE_PARAMETERS
 } ParseState;
 
 typedef struct _ParseContext ParseContext;
@@ -1222,6 +1223,7 @@
 {
   const gchar *name;
   const gchar *ctype;
+  GIrNodeParam *param;
 
   if (strcmp (element_name, "type") != 0)
     return FALSE;
@@ -1234,19 +1236,13 @@
   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 @@
       }
       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 @@
 	  
 	  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)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]