From 2285ac53bc7fdff2850f89f923d5575dc1bf7b2b Mon Sep 17 00:00:00 2001 From: HaseenaSainul Date: Wed, 20 Dec 2023 01:20:27 -0500 Subject: [PATCH] CPPSDK: change method.title to method.rpc.name --- languages/cpp/templates/codeblocks/setter.cpp | 4 ++-- languages/cpp/templates/declarations-override/setter.h | 2 +- languages/cpp/templates/declarations/event.h | 2 +- .../cpp/templates/declarations/polymorphic-pull-event.h | 2 +- languages/cpp/templates/declarations/setter.h | 2 +- languages/cpp/templates/methods/calls-metrics.cpp | 8 ++++---- languages/cpp/templates/methods/default.cpp | 6 +++--- languages/cpp/templates/methods/event.cpp | 4 ++-- .../cpp/templates/methods/polymorphic-pull-event.cpp | 6 +++--- languages/cpp/templates/methods/polymorphic-pull.cpp | 6 +++--- languages/cpp/templates/methods/property.cpp | 4 ++-- src/macrofier/engine.mjs | 4 +--- src/shared/modules.mjs | 2 +- 13 files changed, 25 insertions(+), 27 deletions(-) diff --git a/languages/cpp/templates/codeblocks/setter.cpp b/languages/cpp/templates/codeblocks/setter.cpp index fa0e0901..8038cf8a 100644 --- a/languages/cpp/templates/codeblocks/setter.cpp +++ b/languages/cpp/templates/codeblocks/setter.cpp @@ -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} diff --git a/languages/cpp/templates/declarations-override/setter.h b/languages/cpp/templates/declarations-override/setter.h index 8a843dc9..752833ff 100644 --- a/languages/cpp/templates/declarations-override/setter.h +++ b/languages/cpp/templates/declarations-override/setter.h @@ -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; diff --git a/languages/cpp/templates/declarations/event.h b/languages/cpp/templates/declarations/event.h index 0c1bdcb9..e9284523 100644 --- a/languages/cpp/templates/declarations/event.h +++ b/languages/cpp/templates/declarations/event.h @@ -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} diff --git a/languages/cpp/templates/declarations/polymorphic-pull-event.h b/languages/cpp/templates/declarations/polymorphic-pull-event.h index 698841e6..cb6e8dee 100644 --- a/languages/cpp/templates/declarations/polymorphic-pull-event.h +++ b/languages/cpp/templates/declarations/polymorphic-pull-event.h @@ -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; diff --git a/languages/cpp/templates/declarations/setter.h b/languages/cpp/templates/declarations/setter.h index 77659fcd..115f39f0 100644 --- a/languages/cpp/templates/declarations/setter.h +++ b/languages/cpp/templates/declarations/setter.h @@ -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; diff --git a/languages/cpp/templates/methods/calls-metrics.cpp b/languages/cpp/templates/methods/calls-metrics.cpp index 67b67d22..1b6765c6 100644 --- a/languages/cpp/templates/methods/calls-metrics.cpp +++ b/languages/cpp/templates/methods/calls-metrics.cpp @@ -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(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; @@ -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(), "${info.Title}.${method.rpc.name} is successfully invoked"); + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "${info.Title}.${method.name} is successfully invoked"); ${if.result.nonvoid}${method.result.instantiation.with.indent}${end.if.result.nonvoid} WPEFramework::Core::ProxyType job = WPEFramework::Core::ProxyType(WPEFramework::Core::ProxyType::Create(${method.name}Dispatcher, nullptr)); WPEFramework::Core::IWorkerPool::Instance().Submit(job); diff --git a/languages/cpp/templates/methods/default.cpp b/languages/cpp/templates/methods/default.cpp index f1fb6e71..0b5b31bf 100644 --- a/languages/cpp/templates/methods/default.cpp +++ b/languages/cpp/templates/methods/default.cpp @@ -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; @@ -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(), "${info.Title}.${method.rpc.name} is successfully invoked"); + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "${info.Title}.${method.name} is successfully invoked"); ${if.result.nonvoid}${method.result.instantiation.with.indent}${end.if.result.nonvoid} } diff --git a/languages/cpp/templates/methods/event.cpp b/languages/cpp/templates/methods/event.cpp index b5a797c8..ec3ba93f 100644 --- a/languages/cpp/templates/methods/event.cpp +++ b/languages/cpp/templates/methods/event.cpp @@ -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} @@ -11,7 +11,7 @@ proxyResponse.Release(); I${info.Title}::I${method.Name}Notification& notifier = *(reinterpret_cast(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 ) diff --git a/languages/cpp/templates/methods/polymorphic-pull-event.cpp b/languages/cpp/templates/methods/polymorphic-pull-event.cpp index 3bd440df..43a33df5 100644 --- a/languages/cpp/templates/methods/polymorphic-pull-event.cpp +++ b/languages/cpp/templates/methods/polymorphic-pull-event.cpp @@ -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} @@ -10,7 +10,7 @@ ${method.pulls.response.instantiation} I${info.Title}::I${method.Name}Notification& notifier = *(reinterpret_cast(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* transport = FireboltSDK::Accessor::Instance().GetTransport(); if (transport != nullptr) { @@ -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(), "${info.Title}.${method.rpc.name} is successfully pushed with status as %d", jsonResult.Value()); + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "${info.Title}.${method.name} is successfully pushed with status as %d", jsonResult.Value()); } } else { diff --git a/languages/cpp/templates/methods/polymorphic-pull.cpp b/languages/cpp/templates/methods/polymorphic-pull.cpp index 7f8368d2..1146f2d1 100644 --- a/languages/cpp/templates/methods/polymorphic-pull.cpp +++ b/languages/cpp/templates/methods/polymorphic-pull.cpp @@ -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; @@ -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(), "${info.Title}.${method.rpc.name} is successfully invoked"); + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "${info.Title}.${method.name} is successfully invoked"); ${if.result.nonvoid}${method.result.instantiation.with.indent}${end.if.result.nonvoid} } diff --git a/languages/cpp/templates/methods/property.cpp b/languages/cpp/templates/methods/property.cpp index 4fbe9fc4..607a6527 100644 --- a/languages/cpp/templates/methods/property.cpp +++ b/languages/cpp/templates/methods/property.cpp @@ -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} diff --git a/src/macrofier/engine.mjs b/src/macrofier/engine.mjs index 84ee0c10..339c9785 100644 --- a/src/macrofier/engine.mjs +++ b/src/macrofier/engine.mjs @@ -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, @@ -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) diff --git a/src/shared/modules.mjs b/src/shared/modules.mjs index ec8e84c2..fc28aa66 100644 --- a/src/shared/modules.mjs +++ b/src/shared/modules.mjs @@ -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