diff options
author | Christopher Wiley <wiley@google.com> | 2016-04-13 12:57:27 -0700 |
---|---|---|
committer | Christopher Wiley <wiley@google.com> | 2016-04-13 12:57:27 -0700 |
commit | bce0483dd09f592d6f9f989f0e34fc930d206810 (patch) | |
tree | 27e29c831e94f47231d247695852a3171d8fa38d | |
parent | ead09adf829d0844607cd906ce909cc1dd459356 (diff) | |
download | dbus-binding-generator-nougat-mr1-wear-release.tar.gz |
Don't generate code with unused private fieldsandroid-wear-n-preview-3android-wear-n-preview-2android-wear-n-preview-1android-wear-7.1.1_r1android-n-preview-5android-n-preview-4android-n-preview-3android-n-iot-preview-2nougat-mr1-wear-releasen-iot-preview-2
A recent update to libchrome reveals that we were previously suppressing
warnings about unused private fields. Without that, the generated code
can cause errors when interfaces have no methods.
Bug: 28117776
Change-Id: Ic734c1ce9485797065e504c566cad8d6edf45d07
Test: Generated code now compiles.
-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); |