summaryrefslogtreecommitdiff
path: root/gdbus/object.c
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2012-10-04 04:26:26 -0300
committerMarcel Holtmann <marcel@holtmann.org>2012-11-26 12:51:53 +0100
commitcb44357b67a888dd266e040329d357218275e0fe (patch)
tree13134603c68466eb53bab34ca0d805ad54833971 /gdbus/object.c
parent0e1baf199724bad99efd5199acf8a977ca2c73b7 (diff)
gdbus: Use macros to add annotations
Besides being more readable this way it avoids going over 80 chars.
Diffstat (limited to 'gdbus/object.c')
-rw-r--r--gdbus/object.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/gdbus/object.c b/gdbus/object.c
index 96890064..24e8285d 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -76,6 +76,16 @@ static void print_arguments(GString *gstr, const GDBusArgInfo *args,
}
}
+#define G_DBUS_ANNOTATE(prefix_, name_, value_) \
+ prefix_ "<annotation name=\"org.freedesktop.DBus." name_ "\" " \
+ "value=\"" value_ "\"/>\n"
+
+#define G_DBUS_ANNOTATE_DEPRECATED(prefix_) \
+ G_DBUS_ANNOTATE(prefix_, "Deprecated", "true")
+
+#define G_DBUS_ANNOTATE_NOREPLY(prefix_) \
+ G_DBUS_ANNOTATE(prefix_, "Method.NoReply", "true")
+
static void generate_interface_xml(GString *gstr, struct interface_data *iface)
{
const GDBusMethodTable *method;
@@ -90,19 +100,22 @@ static void generate_interface_xml(GString *gstr, struct interface_data *iface)
if (!deprecated && !noreply &&
!(method->in_args && method->in_args->name) &&
!(method->out_args && method->out_args->name))
- g_string_append_printf(gstr, "\t\t<method name=\"%s\"/>\n",
- method->name);
+ g_string_append_printf(gstr,
+ "\t\t<method name=\"%s\"/>\n",
+ method->name);
else {
- g_string_append_printf(gstr, "\t\t<method name=\"%s\">\n",
- method->name);
+ g_string_append_printf(gstr,
+ "\t\t<method name=\"%s\">\n",
+ method->name);
print_arguments(gstr, method->in_args, "in");
print_arguments(gstr, method->out_args, "out");
if (deprecated)
- g_string_append_printf(gstr, "\t\t\t<annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n");
-
+ g_string_append_printf(gstr,
+ G_DBUS_ANNOTATE_DEPRECATED("\t\t\t"));
if (noreply)
- g_string_append_printf(gstr, "\t\t\t<annotation name=\"org.freedesktop.DBus.Method.NoReply\" value=\"true\"/>\n");
+ g_string_append_printf(gstr,
+ G_DBUS_ANNOTATE_NOREPLY("\t\t\t"));
g_string_append_printf(gstr, "\t\t</method>\n");
}
@@ -113,15 +126,18 @@ static void generate_interface_xml(GString *gstr, struct interface_data *iface)
G_DBUS_SIGNAL_FLAG_DEPRECATED;
if (!deprecated && !(signal->args && signal->args->name))
- g_string_append_printf(gstr, "\t\t<signal name=\"%s\"/>\n",
- signal->name);
+ g_string_append_printf(gstr,
+ "\t\t<signal name=\"%s\"/>\n",
+ signal->name);
else {
- g_string_append_printf(gstr, "\t\t<signal name=\"%s\">\n",
- signal->name);
+ g_string_append_printf(gstr,
+ "\t\t<signal name=\"%s\">\n",
+ signal->name);
print_arguments(gstr, signal->args, NULL);
if (deprecated)
- g_string_append_printf(gstr, "\t\t\t<annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n");
+ g_string_append_printf(gstr,
+ G_DBUS_ANNOTATE_DEPRECATED("\t\t\t"));
g_string_append_printf(gstr, "\t\t</signal>\n");
}