Skip to content

Commit

Permalink
Add emit prefix to generated signal emitting methods
Browse files Browse the repository at this point in the history
  • Loading branch information
sangelovic committed Jun 4, 2019
1 parent dbeaf87 commit fbb5242
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 10 deletions.
5 changes: 4 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions docs/using-sdbus-c++.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -666,7 +666,7 @@ protected:
}

// Emit the 'concatenated' signal with the resulting string
concatenated(result);
emitConcatenated(result);

// Return the resulting string
return result;
Expand Down Expand Up @@ -869,7 +869,7 @@ void concatenate(sdbus::Result<std::string>&& result, std::vector<int32_t> numbe
methodResult.returnReply(result);

// Emit the 'concatenated' signal with the resulting string
this->concatenated(result);
this->emitConcatenated(result);
}).detach();
}
```
Expand Down
2 changes: 1 addition & 1 deletion tests/perftests/perftests-adaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class perftests_adaptor
}

public:
void dataSignal(const std::string& data)
void emitDataSignal(const std::string& data)
{
object_.emitSignal("dataSignal").onInterface(INTERFACE_NAME).withArguments(data);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/perftests/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class PerftestAdaptor : public sdbus::AdaptorInterfaces<org::sdbuscpp::perftests
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<std::chrono::milliseconds>(stop_time - start_time).count() << " ms" << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion tests/stresstests/concatenator-adaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class concatenator_adaptor
}

public:
void concatenatedSignal(const std::string& concatenatedString)
void emitConcatenatedSignal(const std::string& concatenatedString)
{
object_.emitSignal("concatenatedSignal").onInterface(INTERFACE_NAME).withArguments(concatenatedString);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/stresstests/sdbus-c++-stress-tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class ConcatenatorAdaptor : public sdbus::AdaptorInterfaces<org::sdbuscpp::stres

request.result.returnResults(resultString);

concatenatedSignal(resultString);
emitConcatenatedSignal(resultString);
}
});

Expand Down
8 changes: 6 additions & 2 deletions tools/xml2cpp-codegen/AdaptorGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <cctype>

using std::endl;

Expand Down Expand Up @@ -202,7 +203,7 @@ std::tuple<std::string, std::string> 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(\""
Expand Down Expand Up @@ -270,7 +271,10 @@ std::tuple<std::string, std::string> 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)";
Expand Down

0 comments on commit fbb5242

Please sign in to comment.