diff options
author | Christopher Wiley <wiley@google.com> | 2016-04-13 20:53:16 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-04-13 20:53:16 +0000 |
commit | ab6efe1aa3f30726e372e934150aaa5dc2c5032e (patch) | |
tree | 27e29c831e94f47231d247695852a3171d8fa38d | |
parent | ead09adf829d0844607cd906ce909cc1dd459356 (diff) | |
parent | bce0483dd09f592d6f9f989f0e34fc930d206810 (diff) | |
download | dbus-binding-generator-ab6efe1aa3f30726e372e934150aaa5dc2c5032e.tar.gz |
Don\'t generate code with unused private fields
am: bce0483
* commit 'bce0483dd09f592d6f9f989f0e34fc930d206810':
Don't generate code with unused private fields
Change-Id: Id21936e6ac6b8ee6e8d6c2bb126695e51d886034
-rw-r--r-- | chromeos-dbus-bindings/adaptor_generator.cc | 23 | ||||
-rw-r--r-- | chromeos-dbus-bindings/adaptor_generator.h | 3 |
2 files changed, 18 insertions, 8 deletions
diff --git a/chromeos-dbus-bindings/adaptor_generator.cc b/chromeos-dbus-bindings/adaptor_generator.cc index 0f980b5..1916534 100644 --- a/chromeos-dbus-bindings/adaptor_generator.cc +++ b/chromeos-dbus-bindings/adaptor_generator.cc @@ -86,7 +86,7 @@ void AdaptorGenerator::GenerateInterfaceAdaptor( text->AddLine(StringPrintf("class %s {", class_name.c_str())); text->AddLineWithOffset("public:", kScopeOffset); text->PushOffset(kBlockOffset); - AddConstructor(class_name, itf_name, text); + AddConstructor(interface, class_name, itf_name, text); AddRegisterWithDBusObject(itf_name, interface, text); AddSendSignalMethods(interface, text); AddPropertyMethodImplementation(interface, text); @@ -107,9 +107,11 @@ void AdaptorGenerator::GenerateInterfaceAdaptor( AddSignalDataMembers(interface, text); AddPropertyDataMembers(interface, text); - text->AddLine(StringPrintf( - "%s* interface_; // Owned by container of this adapter.", - itf_name.c_str())); + if (!interface.methods.empty()) { + text->AddLine(StringPrintf( + "%s* interface_; // Owned by container of this adapter.", + itf_name.c_str())); + } text->AddBlankLine(); text->AddLine(StringPrintf("DISALLOW_COPY_AND_ASSIGN(%s);", @@ -122,11 +124,18 @@ void AdaptorGenerator::GenerateInterfaceAdaptor( } // static -void AdaptorGenerator::AddConstructor(const string& class_name, +void AdaptorGenerator::AddConstructor(const Interface& interface, + const string& class_name, const string& itf_name, IndentedText *text) { - text->AddLine(StringPrintf("%s(%s* interface) : interface_(interface) {}", - class_name.c_str(), itf_name.c_str())); + if (interface.methods.empty()) { + text->AddLine(StringPrintf("%s(%s* /* interface */) {}", + class_name.c_str(), itf_name.c_str())); + + } else { + text->AddLine(StringPrintf("%s(%s* interface) : interface_(interface) {}", + class_name.c_str(), itf_name.c_str())); + } } // static diff --git a/chromeos-dbus-bindings/adaptor_generator.h b/chromeos-dbus-bindings/adaptor_generator.h index 57e2bf5..5cd68a3 100644 --- a/chromeos-dbus-bindings/adaptor_generator.h +++ b/chromeos-dbus-bindings/adaptor_generator.h @@ -41,7 +41,8 @@ class AdaptorGenerator : public HeaderGenerator { IndentedText *text); // Generates the constructor for the adaptor. - static void AddConstructor(const std::string& class_name, + static void AddConstructor(const Interface& interface, + const std::string& class_name, const std::string& itf_name, IndentedText *text); |