gobject-introspection r377 - in trunk: . girepository tests tools



Author: johan
Date: Thu Aug 14 19:32:26 2008
New Revision: 377
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=377&view=rev

Log:
2008-08-14  Johan Dahlin  <johan gnome org>

    * girepository/girparser.c (start_field), (start_constant),
    (start_type), (end_element_handler):
    Clear up constant parsing

    * tests/object.gir:
    Update

    * tools/generate.c (write_callable_info), (write_function_info),
    (write_callback_info), (write_constant_info), (write_signal_info),
    (write_vfunc_info), (write_property_info), (write_object_info),
    (write_interface_info):
    Constants/Signals are handled now.



Removed:
   trunk/tests/object.test1
Modified:
   trunk/ChangeLog
   trunk/girepository/girparser.c
   trunk/tests/Makefile.am
   trunk/tests/object.gir
   trunk/tools/generate.c

Modified: trunk/girepository/girparser.c
==============================================================================
--- trunk/girepository/girparser.c	(original)
+++ trunk/girepository/girparser.c	Thu Aug 14 19:32:26 2008
@@ -53,8 +53,10 @@
   STATE_STRUCT_FIELD,
   STATE_ERRORDOMAIN, 
   STATE_UNION,
-  STATE_CONSTANT,
-  STATE_ALIAS,  /* 25 */
+  STATE_NAMESPACE_CONSTANT,
+  STATE_CLASS_CONSTANT, /* 25 */
+  STATE_INTERFACE_CONSTANT,
+  STATE_ALIAS
 } ParseState;
 
 typedef struct _ParseContext ParseContext;
@@ -776,7 +778,6 @@
        ctx->state == STATE_INTERFACE))
     {
       const gchar *name;
-      const gchar *type;
       const gchar *readable;
       const gchar *writable;
       const gchar *bits;
@@ -784,7 +785,6 @@
       const gchar *offset;
       
       name = find_attribute ("name", attribute_names, attribute_values);
-      type = find_attribute ("c:type", attribute_names, attribute_values);
       readable = find_attribute ("readable", attribute_names, attribute_values);
       writable = find_attribute ("writable", attribute_names, attribute_values);
       bits = find_attribute ("bits", attribute_names, attribute_values);
@@ -1119,19 +1119,15 @@
        ctx->state == STATE_INTERFACE))
     {
       const gchar *name;
-      const gchar *type;
       const gchar *value;
       const gchar *deprecated;
       
       name = find_attribute ("name", attribute_names, attribute_values);
-      type = find_attribute ("c:type", attribute_names, attribute_values);
       value = find_attribute ("value", attribute_names, attribute_values);
       deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
       
       if (name == NULL)
 	MISSING_ATTRIBUTE (context, error, element_name, "name");
-      else if (type == NULL)
-	MISSING_ATTRIBUTE (context, error, element_name, "c:type");
       else if (value == NULL)
 	MISSING_ATTRIBUTE (context, error, element_name, "value");
       else 
@@ -1142,8 +1138,8 @@
 
 	  ((GIrNode *)constant)->name = g_strdup (name);
 	  constant->value = g_strdup (value);
-	  
-	  constant->type = parse_type (ctx, type);
+
+	  ctx->current_typed = (GIrNode*) constant;
 
 	  if (deprecated && strcmp (deprecated, "1") == 0)
 	    constant->deprecated = TRUE;
@@ -1163,7 +1159,22 @@
 	      iface = (GIrNodeInterface *)ctx->current_node;
 	      iface->members = g_list_append (iface->members, constant);
 	    }
-	  state_switch (ctx, STATE_CONSTANT);
+
+	  switch (ctx->state)
+	    {
+	    case STATE_NAMESPACE:
+	      state_switch (ctx, STATE_NAMESPACE_CONSTANT);
+	      break;
+	    case STATE_CLASS:
+	      state_switch (ctx, STATE_CLASS_CONSTANT);
+	      break;
+	    case STATE_INTERFACE:
+	      state_switch (ctx, STATE_INTERFACE_CONSTANT);
+	      break;
+	    default:
+	      g_assert_not_reached ();
+	      break;
+	    }
 	}
       
       return TRUE;
@@ -1351,7 +1362,10 @@
 	ctx->state == STATE_CLASS_FIELD ||
 	ctx->state == STATE_INTERFACE_FIELD ||
 	ctx->state == STATE_INTERFACE_PROPERTY ||
-	ctx->state == STATE_BOXED_FIELD
+	ctx->state == STATE_BOXED_FIELD ||
+	ctx->state == STATE_NAMESPACE_CONSTANT ||
+	ctx->state == STATE_CLASS_CONSTANT ||
+	ctx->state == STATE_INTERFACE_CONSTANT
 	))
     return FALSE;
 
@@ -1373,8 +1387,7 @@
     {
     case G_IR_NODE_PARAM:
       {
-	GIrNodeParam *param;
-	param = (GIrNodeParam *)ctx->current_typed;
+	GIrNodeParam *param = (GIrNodeParam *)ctx->current_typed;
 	param->type = parse_type (ctx, name);
       }
       break;
@@ -1390,6 +1403,12 @@
 	property->type = parse_type (ctx, name);
       }
       break;
+    case G_IR_NODE_CONSTANT:
+      {
+	GIrNodeConstant *constant = (GIrNodeConstant *)ctx->current_typed;
+	constant->type = parse_type (ctx, name);
+      }
+      break;
     default:
       g_printerr("current node is %d\n", ctx->current_node->type);
       g_assert_not_reached ();
@@ -2308,11 +2327,29 @@
       if (require_end_element (context, ctx, "requires", element_name, error))
         state_switch (ctx, STATE_INTERFACE);
       break;
-    case STATE_CONSTANT:
+    case STATE_NAMESPACE_CONSTANT:
+    case STATE_CLASS_CONSTANT:
+    case STATE_INTERFACE_CONSTANT:
+      if (strcmp ("type", element_name) == 0)
+	break;
       if (require_end_element (context, ctx, "constant", element_name, error))
 	{
 	  ctx->current_node = NULL;
-	  state_switch (ctx, STATE_NAMESPACE);
+	  switch (ctx->state)
+	    {
+	    case STATE_NAMESPACE_CONSTANT:
+	      state_switch (ctx, STATE_NAMESPACE);
+	      break;
+	    case STATE_CLASS_CONSTANT:
+	      state_switch (ctx, STATE_CLASS);
+	      break;
+	    case STATE_INTERFACE_CONSTANT:
+	      state_switch (ctx, STATE_INTERFACE);
+	      break;
+	    default:
+	      g_assert_not_reached ();
+	      break;
+	    }
 	}
       break;
     default:

Modified: trunk/tests/Makefile.am
==============================================================================
--- trunk/tests/Makefile.am	(original)
+++ trunk/tests/Makefile.am	Thu Aug 14 19:32:26 2008
@@ -17,7 +17,8 @@
 	xref2.gir
 
 GIRTESTS = 		\
-	boxed.gir.test
+	boxed.gir.test  \
+	object.gir.test
 
 %.gir.test: %.gir
 	@echo Testing $<:

Modified: trunk/tests/object.gir
==============================================================================
--- trunk/tests/object.gir	(original)
+++ trunk/tests/object.gir	Thu Aug 14 19:32:26 2008
@@ -9,50 +9,52 @@
         <interface name="Iface1" />
       </implements>
       <property name="prop1" readable="0" writable="0">
-        <type name="int" c:type="gint"/>
+        <type name="int"/>
       </property>
       <glib:signal name="signal1" when="LAST">
-        <return-value> 
-          <type name="boolean" c:type="gboolean"/>
+        <return-value>
+          <type name="boolean"/>
         </return-value>
         <parameters>
-          <parameter name="obj" transfer="full" direction="in">
-            <type name="Object1" c:type="Object1*"/>
-	  </parameter>
+          <parameter name="obj" direction="in">
+            <type name="Object1"/>
+          </parameter>
         </parameters>
       </glib:signal>
       <glib:signal name="signal2" when="FIRST" no-recurse="1" detailed="1" action="1" no-hooks="1">
-        <return-value> 
-          <type name="void" c:type="void"/>
+        <return-value>
+          <type name="none"/>
         </return-value>
         <parameters>
-          <parameter name="obj" transfer="full" direction="in">
-            <type name="Object1" c:type="Object1*"/>
-	  </parameter>
+          <parameter name="obj" direction="in">
+            <type name="Object1"/>
+          </parameter>
         </parameters>
       </glib:signal>
-      <vfunc name="vfunc1" offset="20">
-        <return-value> 
-          <type name="Object2" c:type="Object2*"/>
+      <vfunc name="vfunc1" offset="20" transfer="none">
+        <return-value>
+          <type name="Object2*"/>
         </return-value>
         <parameters>
-          <parameter name="param1" transfer="full" direction="in">
-            <type name="Object1" c:type="Object1*"/>
-	  </parameter>
+          <parameter name="param1" direction="in">
+            <type name="Object1"/>
+          </parameter>
         </parameters>
       </vfunc>
-      <vfunc name="vfunc2" offset="24">
-        <return-value> 
-          <type name="Object2" c:type="Object2*"/>
+      <vfunc name="vfunc2" offset="24" transfer="none">
+        <return-value>
+          <type name="Object2*"/>
         </return-value>
         <parameters>
-          <parameter name="param1" transfer="full" direction="in">
-            <type name="Object1" c:type="Object1*"/>
-	  </parameter>
+          <parameter name="param1" direction="in">
+            <type name="Object1"/>
+          </parameter>
         </parameters>
       </vfunc>
     </class>
-    <constant name="constant1" c:type="gint" value="42" />
+    <constant name="constant1" value="42">
+      <type name="int"/>
+    </constant>
     <interface name="Iface1" glib:type-name="Iface1" glib:get-type="iface1_get_type">
     </interface>
     <class name="Object2" parent="GObject.GObject" glib:type-name="Object2" glib:get-type="object2_get_type">

Modified: trunk/tools/generate.c
==============================================================================
--- trunk/tools/generate.c	(original)
+++ trunk/tools/generate.c	Thu Aug 14 19:32:26 2008
@@ -242,8 +242,6 @@
   GITypeInfo *type;
   gint i;
 
-  g_fprintf (file, "%*s  <return-value>\n", indent, "");
-  
   type = g_callable_info_get_return_type (info);
 
   if (g_type_info_is_pointer (type))
@@ -263,6 +261,11 @@
 	  g_assert_not_reached ();
 	}
     }
+
+  g_fprintf (file, ">\n");
+
+  g_fprintf (file, "%*s  <return-value>\n", indent, "");
+  
   g_base_info_unref ((GIBaseInfo *)type);
   if (g_callable_info_may_return_null (info))
     g_fprintf (file, " null-ok=\"1\"");
@@ -384,7 +387,6 @@
   if (deprecated)
     g_fprintf (file, " deprecated=\"1\"");
 	
-  g_fprintf (file, ">\n");
   write_callable_info (namespace, (GICallableInfo*)info, file, indent);
   g_fprintf (file, "%*s</%s>\n", indent, "", tag);
 }
@@ -406,7 +408,6 @@
   if (deprecated)
     g_fprintf (file, " deprecated=\"1\"");
 	
-  g_fprintf (file, ">\n");
   write_callable_info (namespace, (GICallableInfo*)info, file, indent);
   g_fprintf (file, "%*s</callback>\n", indent, "");
 }
@@ -563,15 +564,22 @@
   name = g_base_info_get_name ((GIBaseInfo *)info);
   deprecated = g_base_info_is_deprecated ((GIBaseInfo *)info);
 
-  g_fprintf (file, "%*s<constant name=\"%s\" type=\"", indent, "", name);
+  g_fprintf (file, "%*s<constant name=\"%s\"", indent, "", name);
 
   type = g_constant_info_get_type (info);
-  write_type_info (namespace, type, file);
-  g_fprintf (file, "\" value=\"");
+  g_fprintf (file, " value=\"");
 
   g_constant_info_get_value (info, &value);
   write_constant_value (namespace, type, &value, file);
-  g_fprintf (file, "\" />\n");
+  g_fprintf (file, "\">\n");
+
+  g_fprintf (file, "%*s<type name=\"", indent + 2, "");
+
+  write_type_info (namespace, type, file);
+
+  g_fprintf (file, "\"/>\n");
+
+  g_fprintf (file, "%*s</constant>\n", indent, "");
   
   g_base_info_unref ((GIBaseInfo *)type);
 }
@@ -634,7 +642,7 @@
   flags = g_signal_info_get_flags (info);
   deprecated = g_base_info_is_deprecated ((GIBaseInfo *)info);
 
-  g_fprintf (file, "      <signal name=\"%s\"", name);
+  g_fprintf (file, "      <glib:signal name=\"%s\"", name);
 
   if (deprecated)
     g_fprintf (file, " deprecated=\"1\"");
@@ -658,10 +666,9 @@
   if (flags & G_SIGNAL_NO_HOOKS)
     g_fprintf (file, " no-hooks=\"1\"");
 
-  g_fprintf (file, ">\n");
-
   write_callable_info (namespace, (GICallableInfo*)info, file, 6);
-  g_fprintf (file, "      </signal>\n");
+
+  g_fprintf (file, "      </glib:signal>\n");
 }
 
 static void
@@ -693,9 +700,9 @@
     g_fprintf (file, " override=\"never\"");
     
   g_fprintf (file, " offset=\"%d\"", offset);
-  g_fprintf (file, ">\n");
 
   write_callable_info (namespace, (GICallableInfo*)info, file, 6);
+
   g_fprintf (file, "      </vfunc>\n");
 }
 
@@ -735,11 +742,17 @@
     g_fprintf (file, " construct-only=\"1\"");
     
   type = g_property_info_get_type (info);
-  g_fprintf (file, " type=\"");
+
+  g_fprintf (file, ">\n");
+
+  g_fprintf (file, "        <type name=\"", name);
+
   write_type_info (namespace, type, file);
-  g_fprintf (file, "\"");
 
-  g_fprintf (file, " />\n");
+  g_fprintf (file, "\"/>\n");
+  
+  g_fprintf (file, "      </property>\n");
+
 }
 
 static void
@@ -759,7 +772,7 @@
   
   type_name = g_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info);
   type_init = g_registered_type_info_get_type_init ((GIRegisteredTypeInfo*)info);
-  g_fprintf (file, "    <object name=\"%s\"", name);
+  g_fprintf (file, "    <class name=\"%s\"", name);
 
   pnode = g_object_info_get_parent (info);
   if (pnode)
@@ -770,7 +783,7 @@
       g_base_info_unref ((GIBaseInfo *)pnode);
     }
 
-  g_fprintf (file, " type-name=\"%s\" get-type=\"%s\"", type_name, type_init);
+  g_fprintf (file, " glib:type-name=\"%s\" glib:get-type=\"%s\"", type_name, type_init);
 
   if (deprecated)
     g_fprintf (file, " deprecated=\"1\"");
@@ -833,7 +846,7 @@
       g_base_info_unref ((GIBaseInfo *)constant);
     }
   
-  g_fprintf (file, "    </object>\n");
+  g_fprintf (file, "    </class>\n");
 }
 
 static void
@@ -852,7 +865,7 @@
 
   type_name = g_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info);
   type_init = g_registered_type_info_get_type_init ((GIRegisteredTypeInfo*)info);
-  g_fprintf (file, "    <interface name=\"%s\" type-name=\"%s\" get-type=\"%s\"",
+  g_fprintf (file, "    <interface name=\"%s\" glib:type-name=\"%s\" glib:get-type=\"%s\"",
 	     name, type_name, type_init);
 
   if (deprecated)



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