summaryrefslogtreecommitdiffstats
path: root/glib/dbus-gparser.c
diff options
context:
space:
mode:
Diffstat (limited to 'glib/dbus-gparser.c')
-rw-r--r--glib/dbus-gparser.c88
1 files changed, 79 insertions, 9 deletions
diff --git a/glib/dbus-gparser.c b/glib/dbus-gparser.c
index 05136aa8..3adfe32e 100644
--- a/glib/dbus-gparser.c
+++ b/glib/dbus-gparser.c
@@ -171,6 +171,7 @@ struct Parser
SignalInfo *signal;
PropertyInfo *property;
ArgInfo *arg;
+ gboolean in_annotation;
};
Parser*
@@ -240,7 +241,8 @@ parse_node (Parser *parser,
parser->method ||
parser->signal ||
parser->property ||
- parser->arg)
+ parser->arg ||
+ parser->in_annotation)
{
g_set_error (error, G_MARKUP_ERROR,
G_MARKUP_ERROR_PARSE,
@@ -308,7 +310,6 @@ parse_interface (Parser *parser,
GError **error)
{
const char *name;
- const char *c_name;
InterfaceInfo *iface;
NodeInfo *top;
@@ -317,6 +318,7 @@ parse_interface (Parser *parser,
parser->signal ||
parser->property ||
parser->arg ||
+ parser->in_annotation ||
(parser->node_stack == NULL))
{
g_set_error (error, G_MARKUP_ERROR,
@@ -330,7 +332,6 @@ parse_interface (Parser *parser,
if (!locate_attributes (element_name, attribute_names,
attribute_values, error,
"name", &name,
- "c_name", &c_name,
NULL))
return FALSE;
@@ -346,8 +347,6 @@ parse_interface (Parser *parser,
top = parser->node_stack->data;
iface = interface_info_new (name);
- if (c_name)
- interface_info_set_binding_name (iface, "C", c_name);
node_info_add_interface (top, iface);
interface_info_unref (iface);
@@ -364,7 +363,6 @@ parse_method (Parser *parser,
GError **error)
{
const char *name;
- const char *c_name;
MethodInfo *method;
NodeInfo *top;
@@ -373,6 +371,7 @@ parse_method (Parser *parser,
parser->method ||
parser->signal ||
parser->property ||
+ parser->in_annotation ||
parser->arg)
{
g_set_error (error, G_MARKUP_ERROR,
@@ -386,7 +385,6 @@ parse_method (Parser *parser,
if (!locate_attributes (element_name, attribute_names,
attribute_values, error,
"name", &name,
- "c_name", &c_name,
NULL))
return FALSE;
@@ -402,8 +400,6 @@ parse_method (Parser *parser,
top = parser->node_stack->data;
method = method_info_new (name);
- if (c_name)
- method_info_set_binding_name (method, "C", c_name);
interface_info_add_method (parser->interface, method);
method_info_unref (method);
@@ -428,6 +424,7 @@ parse_signal (Parser *parser,
parser->signal ||
parser->method ||
parser->property ||
+ parser->in_annotation ||
parser->arg)
{
g_set_error (error, G_MARKUP_ERROR,
@@ -539,6 +536,7 @@ parse_property (Parser *parser,
parser->signal ||
parser->method ||
parser->property ||
+ parser->in_annotation ||
parser->arg)
{
g_set_error (error, G_MARKUP_ERROR,
@@ -633,6 +631,7 @@ parse_arg (Parser *parser,
if (!(parser->method || parser->signal) ||
parser->node_stack == NULL ||
parser->property ||
+ parser->in_annotation ||
parser->arg)
{
g_set_error (error, G_MARKUP_ERROR,
@@ -724,6 +723,67 @@ parse_arg (Parser *parser,
return TRUE;
}
+static gboolean
+parse_annotation (Parser *parser,
+ const char *element_name,
+ const char **attribute_names,
+ const char **attribute_values,
+ GError **error)
+{
+ const char *name;
+ const char *value;
+
+ if (!(parser->method || parser->interface || parser->arg) ||
+ parser->node_stack == NULL ||
+ parser->signal ||
+ parser->in_annotation)
+ {
+ g_set_error (error, G_MARKUP_ERROR,
+ G_MARKUP_ERROR_PARSE,
+ _("Can't put <%s> element here"),
+ element_name);
+ return FALSE;
+ }
+
+ name = NULL;
+ if (!locate_attributes (element_name, attribute_names,
+ attribute_values, error,
+ "name", &name,
+ "value", &value,
+ NULL))
+ return FALSE;
+
+ /* name can be null for args */
+
+ if (name == NULL)
+ {
+ g_set_error (error, G_MARKUP_ERROR,
+ G_MARKUP_ERROR_PARSE,
+ _("\"%s\" attribute required on <%s> element "),
+ "name", element_name);
+ return FALSE;
+ }
+ if (value == NULL)
+ {
+ g_set_error (error, G_MARKUP_ERROR,
+ G_MARKUP_ERROR_PARSE,
+ _("\"%s\" attribute required on <%s> element "),
+ "value", element_name);
+ return FALSE;
+ }
+
+ if (parser->method)
+ method_info_add_annotation (parser->method, name, value);
+ else if (parser->interface)
+ interface_info_add_annotation (parser->interface, name, value);
+ else
+ g_assert_not_reached ();
+
+ parser->in_annotation = TRUE;
+
+ return TRUE;
+}
+
gboolean
parser_start_element (Parser *parser,
const char *element_name,
@@ -769,6 +829,12 @@ parser_start_element (Parser *parser,
attribute_values, error))
return FALSE;
}
+ else if (ELEMENT_IS ("annotation"))
+ {
+ if (!parse_annotation (parser, element_name, attribute_names,
+ attribute_values, error))
+ return FALSE;
+ }
else
{
g_set_error (error, G_MARKUP_ERROR,
@@ -807,6 +873,10 @@ parser_end_element (Parser *parser,
{
parser->arg = NULL;
}
+ else if (ELEMENT_IS ("annotation"))
+ {
+ parser->in_annotation = FALSE;
+ }
else if (ELEMENT_IS ("node"))
{
NodeInfo *top;