Skip to content

Commit

Permalink
CPPSDK: template added for capabilties-method (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul authored Oct 31, 2023
1 parent 24eedc4 commit ebe1439
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 72 deletions.
68 changes: 0 additions & 68 deletions languages/cpp/src/shared/include/firebolt.h

This file was deleted.

5 changes: 5 additions & 0 deletions languages/cpp/templates/declarations-override/default.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
${method.name}
${method.description}
*/
${method.signature.result} ${method.Name}( ${method.signature.params}${if.params}, ${end.if.params}Firebolt::Error *err = nullptr )${if.result.nonvoid}${if.params.empty} const${end.if.params.empty}${end.if.result.nonvoid} override;
6 changes: 6 additions & 0 deletions languages/cpp/templates/declarations/default.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
${method.name}
${method.description}
${method.params.annotations}${if.deprecated} * @deprecated ${method.deprecation}${end.if.deprecated}
*/
virtual ${method.signature.result} ${method.Name}( ${method.signature.params}${if.params}, ${end.if.params}Firebolt::Error *err = nullptr )${if.result.nonvoid}${if.params.empty} const${end.if.params.empty}${end.if.result.nonvoid} = 0;
Empty file.
23 changes: 23 additions & 0 deletions languages/cpp/templates/methods/default.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* ${method.rpc.name} - ${method.description} */
${method.signature.result} ${info.Title}Impl::${method.Name}( ${method.signature.params}${if.params}, ${end.if.params}Firebolt::Error *err ) ${if.result.nonvoid}${if.params.empty} const${end.if.params.empty}${end.if.result.nonvoid}
{
Firebolt::Error status = Firebolt::Error::NotConnected;
${if.result.nonvoid}${method.result.initialization}${end.if.result.nonvoid}
FireboltSDK::Transport<WPEFramework::Core::JSON::IElement>* transport = FireboltSDK::Accessor::Instance().GetTransport();
if (transport != nullptr) {

JsonObject jsonParameters;
${method.params.serialization.with.indent}
${method.result.json.type} jsonResult;
status = transport->Invoke("${info.title.lowercase}.${method.rpc.name}", jsonParameters, jsonResult);
if (status == Firebolt::Error::None) {
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "${info.Title}.${method.rpc.name} is successfully invoked");
${if.result.nonvoid}${method.result.instantiation.with.indent}${end.if.result.nonvoid}
}

} else {
FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "Error in getting Transport err = %d", status);
}

return${if.result.nonvoid} ${method.result.name}${end.if.result.nonvoid};
}
Empty file.
2 changes: 1 addition & 1 deletion languages/cpp/templates/parameter-serialization/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
}
WPEFramework::Core::JSON::Variant ${Property}Variant;
${Property}Variant.Array(${Property});
jsonParameters.Set(_T("${property}"), ${Property}Variant);
jsonParameters.Set(_T("${property}"), ${Property}Variant);
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
WPEFramework::Core::JSON::Variant ${Property}(${property}${if.optional}.value()${end.if.optional});
jsonParameters.Set(_T("${property}"), ${Property});
jsonParameters.Set(_T("${property}"), ${Property});
2 changes: 1 addition & 1 deletion languages/cpp/templates/result-initialization/array.cpp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
${type} ${property};
${type} ${property};
2 changes: 1 addition & 1 deletion languages/cpp/templates/result-initialization/string.cpp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
${type} ${property};
${type} ${property};

0 comments on commit ebe1439

Please sign in to comment.