From fbb5242729396a5279e0f89ff1c8689ea10f1233 Mon Sep 17 00:00:00 2001 From: sangelovic Date: Tue, 4 Jun 2019 21:29:04 +0200 Subject: [PATCH] Add emit prefix to generated signal emitting methods --- ChangeLog | 5 ++++- docs/using-sdbus-c++.md | 6 +++--- tests/perftests/perftests-adaptor.h | 2 +- tests/perftests/server.cpp | 2 +- tests/stresstests/concatenator-adaptor.h | 2 +- tests/stresstests/sdbus-c++-stress-tests.cpp | 2 +- tools/xml2cpp-codegen/AdaptorGenerator.cpp | 8 ++++++-- 7 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index b4eb28a..1369c59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -91,8 +91,11 @@ v0.6.0 - Use release v1.8.1 of googletest for tests vX.Y.Z -- [[Breaking ABI change]] Added support for ObjectManager and other standard D-Bus interfaces +- [[Breaking ABI change]] Added full support for ObjectManager, Properties and other standard D-Bus interfaces (Reordering virtual functions in interface classes) - sdbus-c++ now can automatically download, build and incorporate libsystemd static library, which makes things pretty easy in non-systemd environments +- Minor changes in generated proxy/adaptor code: + * renamed interfaceName to INTERFACE_NAME to avoid potential naming clashes + * signal emitting methods now begin with "emit" prefix and capitalized first letter of signal name - sdbus-c++ file organization has been adjusted to comply to de-facto OSS project standards - Build system improvements -- moving towards more modern CMake - Using googletest from master branch instead of v1.8.1 which has THREADS_PTHREAD_ARG issue when cross-compiling diff --git a/docs/using-sdbus-c++.md b/docs/using-sdbus-c++.md index 1a4fa45..3b66686 100644 --- a/docs/using-sdbus-c++.md +++ b/docs/using-sdbus-c++.md @@ -552,7 +552,7 @@ protected: } public: - void concatenated(const std::string& concatenatedString) + void emitConcatenated(const std::string& concatenatedString) { object_.emitSignal("concatenated").onInterface(INTERFACE_NAME).withArguments(concatenatedString); } @@ -666,7 +666,7 @@ protected: } // Emit the 'concatenated' signal with the resulting string - concatenated(result); + emitConcatenated(result); // Return the resulting string return result; @@ -869,7 +869,7 @@ void concatenate(sdbus::Result&& result, std::vector numbe methodResult.returnReply(result); // Emit the 'concatenated' signal with the resulting string - this->concatenated(result); + this->emitConcatenated(result); }).detach(); } ``` diff --git a/tests/perftests/perftests-adaptor.h b/tests/perftests/perftests-adaptor.h index b84b8dd..f6d6b41 100644 --- a/tests/perftests/perftests-adaptor.h +++ b/tests/perftests/perftests-adaptor.h @@ -28,7 +28,7 @@ protected: } public: - void dataSignal(const std::string& data) + void emitDataSignal(const std::string& data) { object_.emitSignal("dataSignal").onInterface(INTERFACE_NAME).withArguments(data); } diff --git a/tests/perftests/server.cpp b/tests/perftests/server.cpp index 6944508..8575434 100644 --- a/tests/perftests/server.cpp +++ b/tests/perftests/server.cpp @@ -59,7 +59,7 @@ protected: for (uint32_t i = 0; i < numberOfSignals; ++i) { // Emit signal - dataSignal(data); + emitDataSignal(data); } auto stop_time = std::chrono::steady_clock::now(); std::cout << "Server sent " << numberOfSignals << " signals in: " << std::chrono::duration_cast(stop_time - start_time).count() << " ms" << std::endl; diff --git a/tests/stresstests/concatenator-adaptor.h b/tests/stresstests/concatenator-adaptor.h index 89ce88a..8f4d987 100644 --- a/tests/stresstests/concatenator-adaptor.h +++ b/tests/stresstests/concatenator-adaptor.h @@ -28,7 +28,7 @@ protected: } public: - void concatenatedSignal(const std::string& concatenatedString) + void emitConcatenatedSignal(const std::string& concatenatedString) { object_.emitSignal("concatenatedSignal").onInterface(INTERFACE_NAME).withArguments(concatenatedString); } diff --git a/tests/stresstests/sdbus-c++-stress-tests.cpp b/tests/stresstests/sdbus-c++-stress-tests.cpp index d5b1e2f..1e808c1 100644 --- a/tests/stresstests/sdbus-c++-stress-tests.cpp +++ b/tests/stresstests/sdbus-c++-stress-tests.cpp @@ -255,7 +255,7 @@ public: request.result.returnResults(resultString); - concatenatedSignal(resultString); + emitConcatenatedSignal(resultString); } }); diff --git a/tools/xml2cpp-codegen/AdaptorGenerator.cpp b/tools/xml2cpp-codegen/AdaptorGenerator.cpp index fafe3e5..4c9001e 100644 --- a/tools/xml2cpp-codegen/AdaptorGenerator.cpp +++ b/tools/xml2cpp-codegen/AdaptorGenerator.cpp @@ -33,6 +33,7 @@ #include #include #include +#include using std::endl; @@ -202,7 +203,7 @@ std::tuple AdaptorGenerator::processMethods(const Node std::string argStr, argTypeStr; std::tie(argStr, argTypeStr, std::ignore) = argsToNamesAndTypes(inArgs, async); - + using namespace std::string_literals; registrationSS << tab << tab << "object_.registerMethod(\"" @@ -270,7 +271,10 @@ std::tuple AdaptorGenerator::processSignals(const Node signalRegistrationSS << annotationRegistration; signalRegistrationSS << ";" << endl; - signalMethodSS << tab << "void " << name << "(" << argTypeStr << ")" << endl + auto nameWithCapFirstLetter = name; + nameWithCapFirstLetter[0] = std::toupper(nameWithCapFirstLetter[0]); + + signalMethodSS << tab << "void emit" << nameWithCapFirstLetter << "(" << argTypeStr << ")" << endl << tab << "{" << endl << tab << tab << "object_.emitSignal(\"" << name << "\")" ".onInterface(INTERFACE_NAME)";