summaryrefslogtreecommitdiffstats
path: root/src/tests/sbus_codegen_tests_generated.c
diff options
context:
space:
mode:
authorStef Walter <stefw@redhat.com>2014-02-25 10:29:23 +0100
committerJakub Hrozek <jhrozek@redhat.com>2014-04-19 10:32:50 +0200
commitdff909d473f43a6bd0f0286fa2d279c0ebe945c6 (patch)
tree61b2f3e2c33e28b51a8ffed64a73de364093557a /src/tests/sbus_codegen_tests_generated.c
parent7a9a6ee1b5f5479c3a6958401f9b34c571c3b6bf (diff)
downloadsssd-dff909d473f43a6bd0f0286fa2d279c0ebe945c6.tar.gz
sssd-dff909d473f43a6bd0f0286fa2d279c0ebe945c6.tar.xz
sssd-dff909d473f43a6bd0f0286fa2d279c0ebe945c6.zip
sbus: Add type-safe DBus method handlers and finish functions
Type safe method handlers allow methods not to have to do tedious unwrapping and wrapping of DBus method call messages or replies. Arguments of the following DBus types are supported in type-safe method handlers. In addition arrays of these are supported. y: uint8_t b: bool (but no arrays, yet) n: int16_t q: uint16_t i: int32_t u: uint32_t x: int64_t t: uint64_t d: double s: char * (utf8 string) o: char * (object path) As an exception, arrays of booleans are not supported, but could be added later. Other more complex types could be added later if desired. If a method has other argument types, then it must be marked as having a raw handler (see below). Internally each method can have a type specific invoker function which unpacks the incoming arguments and invokes the method handler with the correct arguments. Each method also has a finish which accepts the type-safe out arguments (ie: return values) and builds the reply message. Like other request 'finish' functions, these free the request talloc context, and are to be used in place of sbus_request_finish() or friends. Raw method handlers parse their own method arguments, and prepare their own reply (ideally using sbus_request_finish() helpers). They can also do strange things like have variable arguments. To mark a DBus method as having a raw method handler use the following annotation: <annotation name="org.freedesktop.sssd.RawHandler" value="true"/> Raw methods do not have invokers or finish functions. I've left all of the internal peer to peer communication using raw method handlers. No code changes here.
Diffstat (limited to 'src/tests/sbus_codegen_tests_generated.c')
-rw-r--r--src/tests/sbus_codegen_tests_generated.c124
1 files changed, 122 insertions, 2 deletions
diff --git a/src/tests/sbus_codegen_tests_generated.c b/src/tests/sbus_codegen_tests_generated.c
index ccf612996..b5ff08d9d 100644
--- a/src/tests/sbus_codegen_tests_generated.c
+++ b/src/tests/sbus_codegen_tests_generated.c
@@ -5,6 +5,15 @@
#include "sbus/sssd_dbus_meta.h"
#include "sbus_codegen_tests_generated.h"
+/* invokes a handler with a 'bu' DBus signature */
+static int invoke_bu_method(struct sbus_request *dbus_req, void *function_ptr);
+
+/* invokes a handler with a 's' DBus signature */
+static int invoke_s_method(struct sbus_request *dbus_req, void *function_ptr);
+
+/* invokes a handler with a 'u' DBus signature */
+static int invoke_u_method(struct sbus_request *dbus_req, void *function_ptr);
+
/* arguments for com.planetexpress.Ship.MoveUniverse */
const struct sbus_arg_meta com_planetexpress_Ship_MoveUniverse__in[] = {
{ "smoothly", "b" },
@@ -18,6 +27,25 @@ const struct sbus_arg_meta com_planetexpress_Ship_MoveUniverse__out[] = {
{ NULL, }
};
+int com_planetexpress_Ship_MoveUniverse_finish(struct sbus_request *req, const char *arg_where_we_crashed)
+{
+ return sbus_request_return_and_finish(req,
+ DBUS_TYPE_STRING, &arg_where_we_crashed,
+ DBUS_TYPE_INVALID);
+}
+
+/* arguments for com.planetexpress.Ship.Crash */
+const struct sbus_arg_meta com_planetexpress_Ship_crash_now__in[] = {
+ { "where", "s" },
+ { NULL, }
+};
+
+int com_planetexpress_Ship_crash_now_finish(struct sbus_request *req)
+{
+ return sbus_request_return_and_finish(req,
+ DBUS_TYPE_INVALID);
+}
+
/* methods for com.planetexpress.Ship */
const struct sbus_method_meta com_planetexpress_Ship__methods[] = {
{
@@ -25,12 +53,21 @@ const struct sbus_method_meta com_planetexpress_Ship__methods[] = {
com_planetexpress_Ship_MoveUniverse__in,
com_planetexpress_Ship_MoveUniverse__out,
offsetof(struct com_planetexpress_Ship, MoveUniverse),
+ invoke_bu_method,
},
{
"Crash", /* name */
- NULL, /* no in_args */
+ com_planetexpress_Ship_crash_now__in,
NULL, /* no out_args */
offsetof(struct com_planetexpress_Ship, crash_now),
+ invoke_s_method,
+ },
+ {
+ "Land", /* name */
+ NULL, /* no in_args */
+ NULL, /* no out_args */
+ offsetof(struct com_planetexpress_Ship, Land),
+ NULL, /* no invoker */
},
{ NULL, }
};
@@ -68,6 +105,38 @@ const struct sbus_interface_meta com_planetexpress_Ship_meta = {
com_planetexpress_Ship__properties
};
+/* arguments for com.planetexpress.Pilot.Blink */
+const struct sbus_arg_meta test_pilot_Blink__in[] = {
+ { "duration", "u" },
+ { NULL, }
+};
+
+/* arguments for com.planetexpress.Pilot.Blink */
+const struct sbus_arg_meta test_pilot_Blink__out[] = {
+ { "crashed", "b" },
+ { NULL, }
+};
+
+int test_pilot_Blink_finish(struct sbus_request *req, bool arg_crashed)
+{
+ dbus_bool_t cast_crashed = arg_crashed;
+ return sbus_request_return_and_finish(req,
+ DBUS_TYPE_BOOLEAN, &cast_crashed,
+ DBUS_TYPE_INVALID);
+}
+
+/* methods for com.planetexpress.Pilot */
+const struct sbus_method_meta test_pilot__methods[] = {
+ {
+ "Blink", /* name */
+ test_pilot_Blink__in,
+ test_pilot_Blink__out,
+ offsetof(struct test_pilot, Blink),
+ invoke_u_method,
+ },
+ { NULL, }
+};
+
/* property info for com.planetexpress.Pilot */
const struct sbus_property_meta test_pilot__properties[] = {
{
@@ -81,7 +150,58 @@ const struct sbus_property_meta test_pilot__properties[] = {
/* interface info for com.planetexpress.Pilot */
const struct sbus_interface_meta test_pilot_meta = {
"com.planetexpress.Pilot", /* name */
- NULL, /* no methods */
+ test_pilot__methods,
NULL, /* no signals */
test_pilot__properties
};
+
+/* invokes a handler with a 'bu' DBus signature */
+static int invoke_bu_method(struct sbus_request *dbus_req, void *function_ptr)
+{
+ dbus_bool_t arg_0;
+ uint32_t arg_1;
+ int (*handler)(struct sbus_request *, void *, bool, uint32_t) = function_ptr;
+
+ if (!sbus_request_parse_or_finish(dbus_req,
+ DBUS_TYPE_BOOLEAN, &arg_0,
+ DBUS_TYPE_UINT32, &arg_1,
+ DBUS_TYPE_INVALID)) {
+ return EOK; /* request handled */
+ }
+
+ return (handler)(dbus_req, dbus_req->intf->instance_data,
+ arg_0,
+ arg_1);
+}
+
+/* invokes a handler with a 's' DBus signature */
+static int invoke_s_method(struct sbus_request *dbus_req, void *function_ptr)
+{
+ const char * arg_0;
+ int (*handler)(struct sbus_request *, void *, const char *) = function_ptr;
+
+ if (!sbus_request_parse_or_finish(dbus_req,
+ DBUS_TYPE_STRING, &arg_0,
+ DBUS_TYPE_INVALID)) {
+ return EOK; /* request handled */
+ }
+
+ return (handler)(dbus_req, dbus_req->intf->instance_data,
+ arg_0);
+}
+
+/* invokes a handler with a 'u' DBus signature */
+static int invoke_u_method(struct sbus_request *dbus_req, void *function_ptr)
+{
+ uint32_t arg_0;
+ int (*handler)(struct sbus_request *, void *, uint32_t) = function_ptr;
+
+ if (!sbus_request_parse_or_finish(dbus_req,
+ DBUS_TYPE_UINT32, &arg_0,
+ DBUS_TYPE_INVALID)) {
+ return EOK; /* request handled */
+ }
+
+ return (handler)(dbus_req, dbus_req->intf->instance_data,
+ arg_0);
+}