Paul Stewart | 1dce1ae | 2014-10-01 05:30:18 -0700 | [diff] [blame] | 1 | // Copyright 2014 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROMEOS_DBUS_BINDINGS_PROXY_GENERATOR_H_ |
| 6 | #define CHROMEOS_DBUS_BINDINGS_PROXY_GENERATOR_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include <base/macros.h> |
| 12 | |
| 13 | #include "chromeos-dbus-bindings/header_generator.h" |
| 14 | #include "chromeos-dbus-bindings/indented_text.h" |
| 15 | #include "chromeos-dbus-bindings/interface.h" |
| 16 | |
| 17 | namespace base { |
| 18 | |
| 19 | class FilePath; |
| 20 | |
| 21 | } // namespace base |
| 22 | |
| 23 | namespace chromeos_dbus_bindings { |
| 24 | |
| 25 | class IndentedText; |
| 26 | struct Interface; |
| 27 | |
| 28 | class ProxyGenerator : public HeaderGenerator { |
| 29 | public: |
Alex Vakulenko | c95f06b | 2014-11-20 15:06:09 -0800 | [diff] [blame] | 30 | static bool GenerateProxies(const std::vector<Interface>& interfaces, |
| 31 | const base::FilePath& output_file); |
Paul Stewart | 1dce1ae | 2014-10-01 05:30:18 -0700 | [diff] [blame] | 32 | |
| 33 | private: |
| 34 | friend class ProxyGeneratorTest; |
| 35 | |
Alex Vakulenko | c95f06b | 2014-11-20 15:06:09 -0800 | [diff] [blame] | 36 | // Generates one interface proxy. |
| 37 | static void GenerateInterfaceProxy(const Interface& interface, |
| 38 | IndentedText* text); |
| 39 | |
Paul Stewart | 1dce1ae | 2014-10-01 05:30:18 -0700 | [diff] [blame] | 40 | // Generates the constructor and destructor for the proxy. |
Alex Vakulenko | c95f06b | 2014-11-20 15:06:09 -0800 | [diff] [blame] | 41 | static void AddConstructor(const Interface& interface, |
Paul Stewart | 1dce1ae | 2014-10-01 05:30:18 -0700 | [diff] [blame] | 42 | const std::string& class_name, |
| 43 | IndentedText* text); |
| 44 | static void AddDestructor(const std::string& class_name, |
| 45 | IndentedText* text); |
| 46 | |
| 47 | // Generates a callback for signal receiver registration completion. |
Alex Vakulenko | c95f06b | 2014-11-20 15:06:09 -0800 | [diff] [blame] | 48 | static void AddSignalConnectedCallback(IndentedText* text); |
| 49 | |
| 50 | // Generates ReleaseObjectProxy() method to release ownership |
| 51 | // of the object proxy. |
| 52 | static void AddReleaseObjectProxy(IndentedText* text); |
Paul Stewart | 1dce1ae | 2014-10-01 05:30:18 -0700 | [diff] [blame] | 53 | |
| 54 | // Generates the method signatures for signal receivers. |
Alex Vakulenko | c95f06b | 2014-11-20 15:06:09 -0800 | [diff] [blame] | 55 | static void AddSignalReceiver(const Interface& interface, |
Alex Vakulenko | fafef13 | 2014-11-03 14:52:09 -0800 | [diff] [blame] | 56 | IndentedText* text); |
Paul Stewart | 1dce1ae | 2014-10-01 05:30:18 -0700 | [diff] [blame] | 57 | |
| 58 | // Generates a native C++ method which calls a D-Bus method on the proxy. |
| 59 | static void AddMethodProxy(const Interface::Method& interface, |
| 60 | const std::string& interface_name, |
| 61 | IndentedText* text); |
| 62 | |
| 63 | // Generates the signal handler name for a given signal name. |
| 64 | static std::string GetHandlerNameForSignal(const std::string& signal); |
| 65 | |
| 66 | DISALLOW_COPY_AND_ASSIGN(ProxyGenerator); |
| 67 | }; |
| 68 | |
| 69 | } // namespace chromeos_dbus_bindings |
| 70 | |
| 71 | #endif // CHROMEOS_DBUS_BINDINGS_PROXY_GENERATOR_H_ |