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.
+
+2008-08-14 Johan Dahlin <johan@gnome.org>
+
* girepository/girparser.c (start_type):
Don't require c:type.
* tests/Makefile.am:
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;
ctx->state == STATE_INTERFACE))
{
const gchar *name;
- const gchar *type;
const gchar *readable;
const gchar *writable;
const gchar *bits;
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);
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
((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;
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;
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;
{
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;
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 ();
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:
xref2.gir
GIRTESTS = \
- boxed.gir.test
+ boxed.gir.test \
+ object.gir.test
%.gir.test: %.gir
@echo Testing $<:
<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">
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))
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\"");
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);
}
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, "");
}
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);
}
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\"");
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
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");
}
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
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)
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\"");
g_base_info_unref ((GIBaseInfo *)constant);
}
- g_fprintf (file, " </object>\n");
+ g_fprintf (file, " </class>\n");
}
static void
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)