summaryrefslogtreecommitdiff
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 14:44:47 +0100
commit1fc1d90c294a350a194b816795cd94123ca5dd3d (patch)
tree7d9679f300b727847c6909ba2c25c820031bde17
parent164cfb17296ccc8ec13c1ce69a821d1d3bbbcfde (diff)
downloadconnman-1fc1d90c294a350a194b816795cd94123ca5dd3d.tar.gz
connman-1fc1d90c294a350a194b816795cd94123ca5dd3d.tar.bz2
connman-1fc1d90c294a350a194b816795cd94123ca5dd3d.zip
gdbus: Use macros to add annotations
Besides being more readable this way it avoids going over 80 chars.
-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");
}