| 169 | |
| 170 | |
| 171 | std::tuple<std::vector<std::string>, std::string> AdaptorGenerator::processMethods(const Nodes& methods) const |
| 172 | { |
| 173 | std::ostringstream declarationSS; |
| 174 | |
| 175 | std::vector<std::string> methodRegistrations; |
| 176 | |
| 177 | for (const auto& method : methods) |
| 178 | { |
| 179 | std::ostringstream registrationSS; |
| 180 | |
| 181 | auto methodName = method->get("name"); |
| 182 | auto methodNameSafe = mangle_name(methodName); |
| 183 | |
| 184 | auto annotations = getAnnotations(*method); |
| 185 | bool async{false}; |
| 186 | std::string annotationRegistration; |
| 187 | for (const auto& annotation : annotations) |
| 188 | { |
| 189 | const auto& annotationName = annotation.first; |
| 190 | const auto& annotationValue = annotation.second; |
| 191 | |
| 192 | if (annotationName == "org.freedesktop.DBus.Deprecated") |
| 193 | { |
| 194 | if (annotationValue == "true") |
| 195 | annotationRegistration += ".markAsDeprecated()"; |
| 196 | } |
| 197 | else if (annotationName == "org.freedesktop.DBus.Method.NoReply") |
| 198 | { |
| 199 | if (annotationValue == "true") |
| 200 | annotationRegistration += ".withNoReply()"; |
| 201 | } |
| 202 | else if (annotationName == "org.freedesktop.DBus.Method.Async") |
| 203 | { |
| 204 | if (annotationValue == "server" || annotationValue == "clientserver" || annotationValue == "client-server") |
| 205 | async = true; |
| 206 | } |
| 207 | else if (annotationName == "org.freedesktop.systemd1.Privileged") |
| 208 | { |
| 209 | if (annotationValue == "true") |
| 210 | annotationRegistration += ".markAsPrivileged()"; |
| 211 | } |
| 212 | else if (annotationName != "org.freedesktop.DBus.Method.Timeout") // Whatever else... |
| 213 | { |
| 214 | std::cerr << "Node: " << methodName << ": " |
| 215 | << "Option '" << annotationName << "' not allowed or supported in this context! Option ignored..." << std::endl; |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | Nodes args = (*method)["arg"]; |
| 220 | Nodes inArgs = args.select("direction" , "in"); |
| 221 | Nodes outArgs = args.select("direction" , "out"); |
| 222 | |
| 223 | std::string argStr, argTypeStr, argStringsStr, outArgStringsStr; |
| 224 | std::tie(argStr, argTypeStr, std::ignore, argStringsStr) = argsToNamesAndTypes(inArgs, async); |
| 225 | std::tie(std::ignore, std::ignore, std::ignore, outArgStringsStr) = argsToNamesAndTypes(outArgs); |
| 226 | |
| 227 | using namespace std::string_literals; |
| 228 |
nothing calls this directly
no test coverage detected