Paul Stewart | b9b3f9d | 2014-09-10 15:12:39 -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_ADAPTOR_GENERATOR_H_ |
| 6 | #define CHROMEOS_DBUS_BINDINGS_ADAPTOR_GENERATOR_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include <base/macros.h> |
| 12 | |
| 13 | #include "chromeos-dbus-bindings/indented_text.h" |
| 14 | |
| 15 | namespace base { |
| 16 | |
| 17 | class FilePath; |
| 18 | |
| 19 | } // namespace base |
| 20 | |
| 21 | namespace chromeos_dbus_bindings { |
| 22 | |
| 23 | class IndentedText; |
| 24 | struct Interface; |
| 25 | |
| 26 | class AdaptorGenerator { |
| 27 | public: |
| 28 | AdaptorGenerator() = default; |
| 29 | virtual ~AdaptorGenerator() = default; |
| 30 | |
| 31 | bool GenerateAdaptor(const Interface& interface, |
| 32 | const base::FilePath& output_file); |
| 33 | |
| 34 | private: |
| 35 | friend class AdaptorGeneratorTest; |
| 36 | |
| 37 | // Create a unique header guard string to protect multiple includes of header. |
| 38 | static std::string GenerateHeaderGuard(const std::string& filename, |
| 39 | const std::string& interface_name); |
| 40 | |
| 41 | // Generates the constructor for the adaptor. |
| 42 | static void AddConstructor(const Interface& interface, |
| 43 | const std::string& class_name, |
| 44 | const std::string& method_interface, |
| 45 | IndentedText *text); |
| 46 | |
| 47 | // Generates the method interface class. |
| 48 | static void AddMethodInterface(const Interface& interface, |
| 49 | const std::string& class_name, |
| 50 | IndentedText *text); |
| 51 | |
| 52 | // Returns a vector of nesting namepsaces. |
| 53 | static bool GetNamespacesAndClassName(const std::string& interface_name, |
| 54 | std::vector<std::string>* namespaces, |
| 55 | std::string* class_name); |
| 56 | |
| 57 | // Used to decide whether the argument should be a const reference. |
| 58 | static bool IsIntegralType(const std::string& type); |
| 59 | |
| 60 | DISALLOW_COPY_AND_ASSIGN(AdaptorGenerator); |
| 61 | }; |
| 62 | |
| 63 | } // namespace chromeos_dbus_bindings |
| 64 | |
| 65 | #endif // CHROMEOS_DBUS_BINDINGS_ADAPTOR_GENERATOR_H_ |