From: Lucas De Marchi <lucas.demarchi@profusion.mobi>
To: linux-bluetooth@vger.kernel.org
Cc: Lucas De Marchi <lucas.demarchi@profusion.mobi>
Subject: [PATCH BlueZ v5 07/13] gdbus: use GDBusArgInfo to generate introspection
Date: Wed, 16 May 2012 20:33:07 -0300 [thread overview]
Message-ID: <1337211193-18230-8-git-send-email-lucas.demarchi@profusion.mobi> (raw)
In-Reply-To: <1337211193-18230-1-git-send-email-lucas.demarchi@profusion.mobi>
By using GDBusArgInfo in methods and signals, the introspection
generation is much simpler and we can add each argument name.
---
gdbus/object.c | 75 +++++++++++---------------------------------------------
1 file changed, 14 insertions(+), 61 deletions(-)
diff --git a/gdbus/object.c b/gdbus/object.c
index e99757f..b999323 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -59,68 +59,20 @@ struct security_data {
void *iface_user_data;
};
-static void print_arguments(GString *gstr, const char *sig,
+static void print_arguments(GString *gstr, const GDBusArgInfo *args,
const char *direction)
{
- int i;
-
- for (i = 0; sig[i]; i++) {
- char type[32];
- int struct_level, dict_level;
- unsigned int len;
- gboolean complete;
-
- complete = FALSE;
- struct_level = dict_level = 0;
-
- /* Gather enough data to have a single complete type */
- for (len = 0; len < (sizeof(type) - 1) && sig[i]; len++, i++) {
- switch (sig[i]) {
- case '(':
- struct_level++;
- break;
- case ')':
- struct_level--;
- if (struct_level <= 0 && dict_level <= 0)
- complete = TRUE;
- break;
- case '{':
- dict_level++;
- break;
- case '}':
- dict_level--;
- if (struct_level <= 0 && dict_level <= 0)
- complete = TRUE;
- break;
- case 'a':
- break;
- default:
- if (struct_level <= 0 && dict_level <= 0)
- complete = TRUE;
- break;
- }
-
- type[len] = sig[i];
-
- if (complete)
- break;
- }
-
- type[len + 1] = '\0';
-
- if (!complete) {
- error("Unexpected signature: %s", sig);
- return;
- }
+ for (; args && args->name; args++) {
+ g_string_append_printf(gstr,
+ "\t\t\t<arg name=\"%s\" type=\"%s\"",
+ args->name, args->signature);
if (direction)
g_string_append_printf(gstr,
- "\t\t\t<arg type=\"%s\" direction=\"%s\"/>\n",
- type, direction);
+ " direction=\"%s\"/>\n", direction);
else
- g_string_append_printf(gstr,
- "\t\t\t<arg type=\"%s\"/>\n",
- type);
+ g_string_append_printf(gstr, "/>\n");
+
}
}
@@ -130,26 +82,27 @@ static void generate_interface_xml(GString *gstr, struct interface_data *iface)
const GDBusSignalTable *signal;
for (method = iface->methods; method && method->name; method++) {
- if (!strlen(method->signature) && !strlen(method->reply))
+ if (!(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);
else {
g_string_append_printf(gstr, "\t\t<method name=\"%s\">\n",
method->name);
- print_arguments(gstr, method->signature, "in");
- print_arguments(gstr, method->reply, "out");
+ print_arguments(gstr, method->in_args, "in");
+ print_arguments(gstr, method->out_args, "out");
g_string_append_printf(gstr, "\t\t</method>\n");
}
}
for (signal = iface->signals; signal && signal->name; signal++) {
- if (!strlen(signal->signature))
+ if (!(signal->args && signal->args->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);
- print_arguments(gstr, signal->signature, NULL);
+ print_arguments(gstr, signal->args, NULL);
g_string_append_printf(gstr, "\t\t</signal>\n");
}
}
--
1.7.10.2
next prev parent reply other threads:[~2012-05-16 23:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-16 23:33 [PATCH BlueZ v5 00/13] gdbus: Better D-Bus introspection Lucas De Marchi
2012-05-16 23:33 ` [PATCH BlueZ v5 01/13] gdbus: return if method signature is malformed Lucas De Marchi
2012-05-16 23:33 ` [PATCH BlueZ v5 02/13] gdbus: do not call memset for terminating NUL Lucas De Marchi
2012-05-16 23:33 ` [PATCH BlueZ v5 03/13] Constify GDBus method tables Lucas De Marchi
2012-05-16 23:33 ` [PATCH BlueZ v5 04/13] Constify GDBus signal tables Lucas De Marchi
2012-05-16 23:33 ` [PATCH BlueZ v5 05/13] gdbus: add argument info to methods and signals Lucas De Marchi
2012-05-16 23:33 ` [PATCH BlueZ v5 06/13] Convert GDBus methods and signals to use GDBusArgInfo Lucas De Marchi
2012-05-16 23:33 ` Lucas De Marchi [this message]
2012-05-16 23:33 ` [PATCH BlueZ v5 08/13] gdbus: loop over args to check message signature Lucas De Marchi
2012-05-16 23:33 ` [PATCH BlueZ v5 09/13] gdbus: remove signatures from tables Lucas De Marchi
2012-05-16 23:43 ` Marcel Holtmann
2012-05-16 23:33 ` [PATCH BlueZ v5 10/13] gdbus: add Deprecated annotation in introspection Lucas De Marchi
2012-05-16 23:33 ` [PATCH BlueZ v5 11/13] gdbus: add Method.NoReply " Lucas De Marchi
2012-05-16 23:33 ` [PATCH BlueZ v5 12/13] gdbus: do not check signature twice Lucas De Marchi
2012-05-16 23:33 ` [PATCH BlueZ v5 13/13] adapter: " Lucas De Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1337211193-18230-8-git-send-email-lucas.demarchi@profusion.mobi \
--to=lucas.demarchi@profusion.mobi \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).