Skip to content

Commit

Permalink
CPPSDK: change method.title to method.rpc.name
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Dec 20, 2023
1 parent 22adea4 commit 2285ac5
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 27 deletions.
4 changes: 2 additions & 2 deletions languages/cpp/templates/codeblocks/setter.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

/* ${method.rpc.name} - ${method.description} */
/* ${method.name} - ${method.description} */
void ${info.Title}Impl::${method.name}( ${method.signature.params}${if.params}, ${end.if.params}Firebolt::Error *err )
{
const string method = _T("${info.title.lowercase}.${method.rpc.name}");
const string method = _T("${info.title.lowercase}.${method.name}");

JsonObject jsonParameters;
${if.params}${method.params.serialization}${end.if.params}
Expand Down
2 changes: 1 addition & 1 deletion languages/cpp/templates/declarations-override/setter.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* ${method.rpc.name}
* ${method.name}
* ${method.description}
*/
void ${method.name}( ${method.signature.params}${if.params}, ${end.if.params}Firebolt::Error *err = nullptr ) override;
2 changes: 1 addition & 1 deletion languages/cpp/templates/declarations/event.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ${method.name} - ${method.description} */
struct I${method.Name}Notification {
virtual void ${method.title}( ${event.signature.callback.params}${if.event.params}, ${end.if.event.params}${event.result.type} ) = 0;
virtual void ${method.rpc.name}( ${event.signature.callback.params}${if.event.params}, ${end.if.event.params}${event.result.type} ) = 0;
};
// signature callback params: ${event.signature.callback.params}
// method result properties : ${method.result.properties}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ${method.name} - ${method.description} */
struct I${method.Name}Notification {
virtual ${method.pulls.type} ${method.title}( ${method.pulls.param.type} ) = 0;
virtual ${method.pulls.type} ${method.rpc.name}( ${method.pulls.param.type} ) = 0;
};
virtual void subscribe( I${method.Name}Notification& notification, Firebolt::Error *err = nullptr ) = 0;
virtual void unsubscribe( I${method.Name}Notification& notification, Firebolt::Error *err = nullptr ) = 0;
2 changes: 1 addition & 1 deletion languages/cpp/templates/declarations/setter.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
${method.rpc.name}
${method.name}
${method.description}
*/
virtual void ${method.name}( ${method.signature.params}${if.params}, ${end.if.params}Firebolt::Error *err = nullptr ) = 0;
8 changes: 4 additions & 4 deletions languages/cpp/templates/methods/calls-metrics.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* ${method.rpc.name} - ${method.description} */
/* ${method.name} - ${method.description} */
static void ${method.name}Dispatcher(const void* result) {
Metrics::MetricsImpl::${method.name}(${if.result.nonboolean}${if.result.nonvoid}(static_cast<${method.result.json.type}>(const_cast<void*>(result)))${end.if.result.nonvoid}${end.if.result.nonboolean});
}
/* ${method.rpc.name} - ${method.description} */
/* ${method.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;
Expand All @@ -13,9 +13,9 @@
JsonObject jsonParameters;
${method.params.serialization.with.indent}
${method.result.json.type} jsonResult;
status = transport->Invoke("${info.title.lowercase}.${method.rpc.name}", jsonParameters, jsonResult);
status = transport->Invoke("${info.title.lowercase}.${method.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");
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "${info.Title}.${method.name} is successfully invoked");
${if.result.nonvoid}${method.result.instantiation.with.indent}${end.if.result.nonvoid}
WPEFramework::Core::ProxyType<WPEFramework::Core::IDispatch> job = WPEFramework::Core::ProxyType<WPEFramework::Core::IDispatch>(WPEFramework::Core::ProxyType<FireboltSDK::Worker>::Create(${method.name}Dispatcher, nullptr));
WPEFramework::Core::IWorkerPool::Instance().Submit(job);
Expand Down
6 changes: 3 additions & 3 deletions languages/cpp/templates/methods/default.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* ${method.rpc.name} - ${method.description} */
/* ${method.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;
Expand All @@ -9,9 +9,9 @@
JsonObject jsonParameters;
${method.params.serialization.with.indent}
${method.result.json.type} jsonResult;
status = transport->Invoke("${info.title.lowercase}.${method.rpc.name}", jsonParameters, jsonResult);
status = transport->Invoke("${info.title.lowercase}.${method.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");
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "${info.Title}.${method.name} is successfully invoked");
${if.result.nonvoid}${method.result.instantiation.with.indent}${end.if.result.nonvoid}
}

Expand Down
4 changes: 2 additions & 2 deletions languages/cpp/templates/methods/event.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* ${method.rpc.name} - ${method.description} */
/* ${method.name} - ${method.description} */
static void ${method.name}InnerCallback( void* notification, const void* userData, void* jsonResponse )
{
${event.callback.serialization}
Expand All @@ -11,7 +11,7 @@
proxyResponse.Release();

I${info.Title}::I${method.Name}Notification& notifier = *(reinterpret_cast<I${info.Title}::I${method.Name}Notification*>(notification));
notifier.${method.title}(${event.callback.response.instantiation});
notifier.${method.rpc.name}(${event.callback.response.instantiation});
}
}
void ${info.Title}Impl::subscribe( ${event.signature.params}${if.event.params}, ${end.if.event.params}I${info.Title}::I${method.Name}Notification& notification, Firebolt::Error *err )
Expand Down
6 changes: 3 additions & 3 deletions languages/cpp/templates/methods/polymorphic-pull-event.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* ${method.rpc.name} - ${method.description} */
/* ${method.name} - ${method.description} */
static void ${method.name}InnerCallback( void* notification, const void* userData, void* jsonResponse )
{
${event.callback.serialization}
Expand All @@ -10,7 +10,7 @@
${method.pulls.response.instantiation}

I${info.Title}::I${method.Name}Notification& notifier = *(reinterpret_cast<I${info.Title}::I${method.Name}Notification*>(notification));
${method.pulls.type} element = notifier.${method.title}(${method.pulls.param.title});
${method.pulls.type} element = notifier.${method.rpc.name}(${method.pulls.param.title});
Firebolt::Error status = Firebolt::Error::NotConnected;
FireboltSDK::Transport<WPEFramework::Core::JSON::IElement>* transport = FireboltSDK::Accessor::Instance().GetTransport();
if (transport != nullptr) {
Expand All @@ -30,7 +30,7 @@

status = transport->Invoke("${info.title.lowercase}.${method.pulls.for}", 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 pushed with status as %d", jsonResult.Value());
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "${info.Title}.${method.name} is successfully pushed with status as %d", jsonResult.Value());
}

} else {
Expand Down
6 changes: 3 additions & 3 deletions languages/cpp/templates/methods/polymorphic-pull.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* ${method.rpc.name} - ${method.description} */
/* ${method.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;
Expand All @@ -9,9 +9,9 @@
JsonObject jsonParameters;
${method.params.serialization.with.indent}
${method.result.json.type} jsonResult;
status = transport->Invoke("${info.title.lowercase}.${method.rpc.name}", jsonParameters, jsonResult);
status = transport->Invoke("${info.title.lowercase}.${method.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");
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "${info.Title}.${method.name} is successfully invoked");
${if.result.nonvoid}${method.result.instantiation.with.indent}${end.if.result.nonvoid}
}

Expand Down
4 changes: 2 additions & 2 deletions languages/cpp/templates/methods/property.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* ${method.rpc.name} - ${method.description} */
/* ${method.name} - ${method.description} */
${method.signature.result} ${info.Title}Impl::${method.name}( ${method.signature.params}${if.params}, ${end.if.params}Firebolt::Error *err ) const
{
const string method = _T("${info.title.lowercase}.${method.rpc.name}");
const string method = _T("${info.title.lowercase}.${method.name}");
${if.params}${method.params.serialization}${end.if.params}
${method.result.json} jsonResult;
${method.result.initialization}
Expand Down
4 changes: 1 addition & 3 deletions src/macrofier/engine.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,6 @@ function insertMethodMacros(template, methodObj, json, templates, examples = {})
}
const method = {
name: methodObj.name,
title: methodObj.title,
params: methodObj.params.map(p => p.name).join(', '),
transforms: null,
alternative: null,
Expand Down Expand Up @@ -1348,8 +1347,7 @@ function insertMethodMacros(template, methodObj, json, templates, examples = {})
template = insertExampleMacros(template, examples[methodObj.name] || [], methodObj, json, templates)

template = template.replace(/\$\{method\.name\}/g, method.name)
.replace(/\$\{method\.title\}/g, method.title ? method.title : method.name)
.replace(/\$\{method\.rpc\.name\}/g, methodObj.title || methodObj.name)
.replace(/\$\{method\.rpc\.name\}/g, methodObj.rpc_name || methodObj.name)
.replace(/\$\{method\.summary\}/g, methodObj.summary)
.replace(/\$\{method\.description\}/g, methodObj.description
|| methodObj.summary)
Expand Down
2 changes: 1 addition & 1 deletion src/shared/modules.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ const createPolymorphicMethods = (method, json) => {
let localized = localizeDependencies(anyOf, json)
let title = localized.title || localized.name || ''
let summary = localized.summary || localized.description || ''
polymorphicMethodSchema.title = method.name
polymorphicMethodSchema.rpc_name = method.name
polymorphicMethodSchema.name = foundAnyOfResult && isEventMethod(method) ? `${method.name}${title}` : method.name
polymorphicMethodSchema.tags = method.tags
polymorphicMethodSchema.params = foundAnyOfParams ? generateParamsAnyOfSchema(methodParams, anyOf, anyOfTypes, title, summary) : methodParams
Expand Down

0 comments on commit 2285ac5

Please sign in to comment.