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>
diff --git a/chromeos-dbus-bindings/adaptor_generator.h b/chromeos-dbus-bindings/adaptor_generator.h
index 84adec7..87e1b26 100644
--- a/chromeos-dbus-bindings/adaptor_generator.h
+++ b/chromeos-dbus-bindings/adaptor_generator.h
@@ -26,20 +26,34 @@
 
 class AdaptorGenerator : public HeaderGenerator {
  public:
-  static bool GenerateAdaptor(const Interface& interface,
-                              const base::FilePath& output_file);
+  static bool GenerateAdaptors(const std::vector<Interface>& interfaces,
+                               const base::FilePath& output_file);
 
  private:
   friend class AdaptorGeneratorTest;
 
+  // Generates one interface adaptor.
+  static void GenerateInterfaceAdaptor(const Interface& interface,
+                                       IndentedText *text);
+
+  // Generates the method prototypes for an interface declaration.
+  static void AddInterfaceMethods(const Interface& interface,
+                                  IndentedText *text);
+
   // Generates the constructor for the adaptor.
-  static void AddConstructor(const Interface& interface,
-                             const std::string& class_name,
+  static void AddConstructor(const std::string& class_name,
+                             const std::string& itf_name,
                              IndentedText *text);
 
-  // Generates the method interface class.
-  static void AddMethodInterface(const Interface& interface,
-                                 IndentedText *text);
+  // Generates RegisterWithDBusObject() method.
+  static void AddRegisterWithDBusObject(const std::string& itf_name,
+                                        const Interface& interface,
+                                        IndentedText *text);
+
+  // Generates the code to register the interface with a D-Bus object.
+  static void RegisterInterface(const std::string& itf_name,
+                                const Interface& interface,
+                                IndentedText *text);
 
   // Generates adaptor methods to send the signals.
   static void AddSendSignalMethods(const Interface& interface,
@@ -50,8 +64,8 @@
                                    IndentedText *text);
 
   // Generates adaptor accessor methods for the properties.
-  static void AddPropertyMethods(const Interface& interface,
-                                 IndentedText *text);
+  static void AddPropertyMethodImplementation(const Interface& interface,
+                                              IndentedText *text);
 
   // Generate ExportProperty data members for the properties.
   static void AddPropertyDataMembers(const Interface& interface,