diff options
author | Alex Vakulenko <avakulenko@chromium.org> | 2014-11-03 14:52:09 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-11-06 06:32:43 +0000 |
commit | fafef1300f94cada37c4fac0e0c7ba46aeee5ad1 (patch) | |
tree | 66f335624af7de6436aaac780bd40dce477ebbde /chromeos-dbus-bindings/header_generator.h | |
parent | dd885751db1da01f14c873484e1344378614108a (diff) | |
download | dbus-binding-generator-fafef1300f94cada37c4fac0e0c7ba46aeee5ad1.tar.gz |
chromeos-dbus-bindings: Redesign due to underlying DBusObject change.
DBusObject method handlers have been changed to allow for async
method handlers. D-Bus proxy generator is changing accordingly
to reflect the underlying implementation change.
Now it is possible to generate asyc-ready method handlers by
adding annotations to the method elements in the source XML file.
With the "org.chromium.DBus.Method.Kind" attribute on a method
description element, you can now control which of the four
supported method handers are to be used:
- "normal" (default): the handler signature is as follows:
bool Handler(ErrorPtr* error, const Type1& in1, const Type2& in2, ...
Type3* out1, Type4* out2, ...);
- "simple": the handler does not fail and hence does not return
any error information. One of the following two signatures:
RetType Handler(const Type1& in1, const Type2& in2, ...);
void Handler(const Type1& in1, const Type2& in2, ...,
Type3* out1, Type4* out2, ...);
- "async": is a possibly asynchronous method handler:
void Handler(scoped_ptr<DBusMethodResponse> response,
const Type1& in1, const Type2& in2, ...);
- "raw": the fully custom specialty handler that allows
raw implementation of D-Bus method with no additional framework:
void Handler(dbus::MethodCall* method_call, ResponseSender sender);
As part of this change, it was also possible to provide implementations
for methods returning more than one value.
A method element can also specify that the method handler can be
marked as 'const' in the C++ adapter by adding the following attribute
with the value of "true": "org.chromium.DBus.Method.Const"
Another significant change to the D-Bus binding generator is the
support of multiple interfaces per D-Bus object. Now the XML file
can list multiple <interface> tags for a class node. This makes the
generator to create the abstract C++ interface adaptors that contain
protorypes for all the methods, signals and properties for that interface.
The final interface implementation class derives from one or more adaptor(s)
and implements the actual interface methods.
Finally, updated lorgnette to use the new generated adaptor for its
D-Bus interfaces.
BUG=chromium:419271, chromium:420925, chromium:428390
TEST=FEATURES=test emerge-link chromeos-dbus-bindings
Change-Id: I02d1fc2e21a230e0f4c959c54ed7c71490945b12
Reviewed-on: https://chromium-review.googlesource.com/227281
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Diffstat (limited to 'chromeos-dbus-bindings/header_generator.h')
-rw-r--r-- | chromeos-dbus-bindings/header_generator.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/chromeos-dbus-bindings/header_generator.h b/chromeos-dbus-bindings/header_generator.h index 7be8d5b..b4f521d 100644 --- a/chromeos-dbus-bindings/header_generator.h +++ b/chromeos-dbus-bindings/header_generator.h @@ -27,11 +27,16 @@ class HeaderGenerator { static std::string GenerateHeaderGuard(const base::FilePath& output_file, const std::string& interface_name); - // Returns a vector of nesting namepsaces. + // Returns a vector of nesting namespaces. static bool GetNamespacesAndClassName(const std::string& interface_name, std::vector<std::string>* namespaces, std::string* class_name); + // Returns a fully-qualified class name like "ns1::ns2::class_name". + static std::string GetFullClassName( + const std::vector<std::string>& namespaces, + const std::string& class_name); + // Used to decide whether the argument should be a const reference. static bool IsIntegralType(const std::string& type); @@ -39,6 +44,13 @@ class HeaderGenerator { static bool WriteTextToFile(const base::FilePath& output_file, const IndentedText& text); + // Generate a name of a method/signal argument based on the name provided in + // the XML file. If |arg_name| is empty, it generates a name using + // the |arg_index| counter. + static std::string GetArgName(const char* prefix, + const std::string& arg_name, + int arg_index); + static const int kScopeOffset = 1; static const int kBlockOffset = 2; static const int kLineContinuationOffset = 4; |