Skip to content

Commit

Permalink
Merge branch 'next' into features/cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Dec 5, 2023
2 parents f31b5d7 + cc719bb commit f583521
Show file tree
Hide file tree
Showing 32 changed files with 234 additions and 108 deletions.
57 changes: 57 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
# [2.2.0-next.1](https://github.com/rdkcentral/firebolt-openrpc/compare/v2.1.1-next.3...v2.2.0-next.1) (2023-11-30)


### Features

* Improve generated doc formatting ([#155](https://github.com/rdkcentral/firebolt-openrpc/issues/155)) ([4613281](https://github.com/rdkcentral/firebolt-openrpc/commit/46132810ac5e5b0a8b9baa22903cb8a367b46f63))

## [2.1.1-next.3](https://github.com/rdkcentral/firebolt-openrpc/compare/v2.1.1-next.2...v2.1.1-next.3) (2023-11-09)


### Bug Fixes

* Provider openrpc response and error methods have a wrapper object ([#148](https://github.com/rdkcentral/firebolt-openrpc/issues/148)) ([373626e](https://github.com/rdkcentral/firebolt-openrpc/commit/373626ed598447bb670ac67e97ca8ed1bf32f28f))

## [2.1.1-next.2](https://github.com/rdkcentral/firebolt-openrpc/compare/v2.1.1-next.1...v2.1.1-next.2) (2023-11-01)


### Bug Fixes

* Errors thrown in async provider methods do not send the JSONRPC error response ([#143](https://github.com/rdkcentral/firebolt-openrpc/issues/143)) ([ec8e259](https://github.com/rdkcentral/firebolt-openrpc/commit/ec8e2599d530f9d2bd38fbb53b36e13c038edf2a))

## [2.1.1-next.1](https://github.com/rdkcentral/firebolt-openrpc/compare/v2.1.0...v2.1.1-next.1) (2023-09-14)


### Bug Fixes

* Macro not replaced for provider docs ([ef1aecd](https://github.com/rdkcentral/firebolt-openrpc/commit/ef1aecd0092a8652bc7b936604f9478b7b55df27))

# [2.1.0](https://github.com/rdkcentral/firebolt-openrpc/compare/v2.0.4...v2.1.0) (2023-09-07)


### Bug Fixes

* Changes based on schema update ([#131](https://github.com/rdkcentral/firebolt-openrpc/issues/131)) ([9df4f15](https://github.com/rdkcentral/firebolt-openrpc/commit/9df4f1545835ed6d81d8998174f9e11b8df53550))
* Enabled setter to have null as param value ([#122](https://github.com/rdkcentral/firebolt-openrpc/issues/122)) ([2bfee25](https://github.com/rdkcentral/firebolt-openrpc/commit/2bfee2514bdc9e11ba7390ae40b6c6c820de6784))
* Setters w/ no params fail mock ([#124](https://github.com/rdkcentral/firebolt-openrpc/issues/124)) ([0538eff](https://github.com/rdkcentral/firebolt-openrpc/commit/0538effd64ac84f7468f3dc6a5050167f5e5b152))
* Update package.json ([c7bf0e3](https://github.com/rdkcentral/firebolt-openrpc/commit/c7bf0e3cf8a90b2a3afce23cecaf10c027a7319d))


### Features

* C Language Support ([#130](https://github.com/rdkcentral/firebolt-openrpc/issues/130)) ([33db98c](https://github.com/rdkcentral/firebolt-openrpc/commit/33db98ca5f6a4179c42b3693c96b797210e85a67)), closes [#90](https://github.com/rdkcentral/firebolt-openrpc/issues/90) [#93](https://github.com/rdkcentral/firebolt-openrpc/issues/93) [#94](https://github.com/rdkcentral/firebolt-openrpc/issues/94) [#96](https://github.com/rdkcentral/firebolt-openrpc/issues/96) [#97](https://github.com/rdkcentral/firebolt-openrpc/issues/97) [#100](https://github.com/rdkcentral/firebolt-openrpc/issues/100) [#99](https://github.com/rdkcentral/firebolt-openrpc/issues/99) [#101](https://github.com/rdkcentral/firebolt-openrpc/issues/101) [#102](https://github.com/rdkcentral/firebolt-openrpc/issues/102) [#107](https://github.com/rdkcentral/firebolt-openrpc/issues/107) [#106](https://github.com/rdkcentral/firebolt-openrpc/issues/106) [#105](https://github.com/rdkcentral/firebolt-openrpc/issues/105) [#103](https://github.com/rdkcentral/firebolt-openrpc/issues/103) [#109](https://github.com/rdkcentral/firebolt-openrpc/issues/109) [#112](https://github.com/rdkcentral/firebolt-openrpc/issues/112) [#111](https://github.com/rdkcentral/firebolt-openrpc/issues/111) [#113](https://github.com/rdkcentral/firebolt-openrpc/issues/113) [#114](https://github.com/rdkcentral/firebolt-openrpc/issues/114) [#115](https://github.com/rdkcentral/firebolt-openrpc/issues/115) [#110](https://github.com/rdkcentral/firebolt-openrpc/issues/110) [#117](https://github.com/rdkcentral/firebolt-openrpc/issues/117) [#116](https://github.com/rdkcentral/firebolt-openrpc/issues/116) [#118](https://github.com/rdkcentral/firebolt-openrpc/issues/118) [#121](https://github.com/rdkcentral/firebolt-openrpc/issues/121) [#119](https://github.com/rdkcentral/firebolt-openrpc/issues/119) [#90](https://github.com/rdkcentral/firebolt-openrpc/issues/90) [#93](https://github.com/rdkcentral/firebolt-openrpc/issues/93) [#94](https://github.com/rdkcentral/firebolt-openrpc/issues/94) [#96](https://github.com/rdkcentral/firebolt-openrpc/issues/96) [#97](https://github.com/rdkcentral/firebolt-openrpc/issues/97) [#100](https://github.com/rdkcentral/firebolt-openrpc/issues/100) [#99](https://github.com/rdkcentral/firebolt-openrpc/issues/99) [#101](https://github.com/rdkcentral/firebolt-openrpc/issues/101) [#102](https://github.com/rdkcentral/firebolt-openrpc/issues/102) [#107](https://github.com/rdkcentral/firebolt-openrpc/issues/107) [#106](https://github.com/rdkcentral/firebolt-openrpc/issues/106) [#105](https://github.com/rdkcentral/firebolt-openrpc/issues/105) [#103](https://github.com/rdkcentral/firebolt-openrpc/issues/103) [#109](https://github.com/rdkcentral/firebolt-openrpc/issues/109) [#112](https://github.com/rdkcentral/firebolt-openrpc/issues/112) [#111](https://github.com/rdkcentral/firebolt-openrpc/issues/111) [#113](https://github.com/rdkcentral/firebolt-openrpc/issues/113) [#114](https://github.com/rdkcentral/firebolt-openrpc/issues/114) [#115](https://github.com/rdkcentral/firebolt-openrpc/issues/115) [#110](https://github.com/rdkcentral/firebolt-openrpc/issues/110) [#117](https://github.com/rdkcentral/firebolt-openrpc/issues/117) [#116](https://github.com/rdkcentral/firebolt-openrpc/issues/116) [#118](https://github.com/rdkcentral/firebolt-openrpc/issues/118) [#121](https://github.com/rdkcentral/firebolt-openrpc/issues/121) [#119](https://github.com/rdkcentral/firebolt-openrpc/issues/119) [#127](https://github.com/rdkcentral/firebolt-openrpc/issues/127)

# [2.1.0-next.3](https://github.com/rdkcentral/firebolt-openrpc/compare/v2.1.0-next.2...v2.1.0-next.3) (2023-09-07)


### Bug Fixes

* Null support for property setters ([#125](https://github.com/rdkcentral/firebolt-openrpc/issues/125)) ([1ff5f42](https://github.com/rdkcentral/firebolt-openrpc/commit/1ff5f42c36de0e70a03ede35baaedfb78351e9c2)), closes [#122](https://github.com/rdkcentral/firebolt-openrpc/issues/122) [#123](https://github.com/rdkcentral/firebolt-openrpc/issues/123) [#124](https://github.com/rdkcentral/firebolt-openrpc/issues/124)

## [2.0.4](https://github.com/rdkcentral/firebolt-openrpc/compare/v2.0.3...v2.0.4) (2023-08-11)


### Bug Fixes

* Null support for property setters ([#125](https://github.com/rdkcentral/firebolt-openrpc/issues/125)) ([1ff5f42](https://github.com/rdkcentral/firebolt-openrpc/commit/1ff5f42c36de0e70a03ede35baaedfb78351e9c2)), closes [#122](https://github.com/rdkcentral/firebolt-openrpc/issues/122) [#123](https://github.com/rdkcentral/firebolt-openrpc/issues/123) [#124](https://github.com/rdkcentral/firebolt-openrpc/issues/124)

## [2.0.4-next.3](https://github.com/rdkcentral/firebolt-openrpc/compare/v2.0.4-next.2...v2.0.4-next.3) (2023-08-10)


Expand Down
8 changes: 2 additions & 6 deletions languages/c/Types.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,9 @@ function getSchemaTypeInfo(module = {}, json = {}, name = '', schemas = {}, pref
// grab the type for the non-array schema
res = getSchemaTypeInfo(module, json.items, json.items.name || name, schemas, prefix)
}

name = name.endsWith("_ArrayType") ? name.split('_ArrayType')[0] : name
name = capitalize(name)
res.name = capitalize(res.name)
prefix = prefix ? prefix + ((name !== res.name) ? name : '') : name
let n = getTypeName(getModuleName(module), res.name, prefix)
structure.name = (name && (name !== res.name)) ? name + capitalize(res.name) : res.name
let n = getTypeName(getModuleName(module), res.name, '')
structure.name = res.name
structure.type = n + 'Array_t'
structure.json = json
structure.namespace = getModuleName(module)
Expand Down
15 changes: 2 additions & 13 deletions languages/c/language.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"langcode": "c",
"createModuleDirectories": false,
"extractSubSchemas": true,
"unwrapResultObjects": false,
"createPolymorphicMethods": true,
"excludeDeclarations":true,
"templatesPerModule": [
"/include/module.h",
"/src/module.cpp"
Expand All @@ -16,14 +13,6 @@
"/src/jsondata_module.h"
],
"persistPermission": true,
"primitives": {
"boolean": "bool",
"integer": "int",
"number": "float",
"string": "char*"
},
"allocatedPrimitiveProxies": {
"string": "FireboltTypes_StringHandle"
},
"additionalSchemaTemplates": [ "json-types" ]
"createPolymorphicMethods": true,
"excludeDeclarations":true
}
3 changes: 2 additions & 1 deletion languages/c/templates/declarations/default.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* ${method.name} - ${method.description}
${method.params.annotations}${if.deprecated} * @deprecated ${method.deprecation}${end.if.deprecated} */
int32_t F${info.Title}_${method.Name}( ${method.signature.params}${if.result}${if.params}, ${end.if.params}${method.result.type}* ${method.result.name}${end.if.result}${if.signature.empty}void${end.if.signature.empty} );
int32_t ${info.Title}_${method.Name}( ${method.signature.params}${if.result}${if.params}, ${end.if.params}OUT ${method.result.type}* ${method.result.name}${end.if.result}${if.signature.empty}void${end.if.signature.empty} );

8 changes: 3 additions & 5 deletions languages/c/templates/declarations/event.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* ${method.name} - ${method.description} */
typedef void (*F${info.Title}${method.Name}Callback)( const void* userData, ${event.signature.callback.params}${if.event.params}, ${end.if.event.params}${method.result.properties} );
int32_t F${info.title}_Register_${method.Name}( ${event.signature.params}${if.event.params}, ${end.if.event.params}F${info.Title}${method.Name}Callback userCB, const void* userData );
int32_t F${info.title}_Unregister_${method.Name}( F${info.Title}${method.Name}Callback userCB);
typedef void (*${info.Title}${method.Name}Callback)( const void* userData, ${event.signature.callback.params}${if.event.params}, ${end.if.event.params}${event.result.type} );
int32_t ${info.Title}_Register_${method.Name}( ${event.signature.params}${if.event.params}, ${end.if.event.params}${info.Title}${method.Name}Callback userCB, const void* userData );
int32_t ${info.Title}_Unregister_${method.Name}( ${info.Title}${method.Name}Callback userCB);

// signature callback params: ${event.signature.callback.params}
// method result properties : ${method.result.properties}
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
typedef void* (*${info.Title}${method.Name}Callback)( const void* userData, ${method.pulls.param.type} );
int32_t ${info.Title}_Register_${method.Name}( ${info.Title}${method.Name}Callback userCB, const void* userData );
int32_t ${info.Title}_Unregister_${method.Name}( ${info.Title}${method.Name}Callback userCB);

1 change: 1 addition & 0 deletions languages/c/templates/declarations/polymorphic-pull.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/* ${method.name} - ${method.description} */
int32_t ${info.Title}_Push${method.Name}( ${method.signature.params} );

4 changes: 3 additions & 1 deletion languages/c/templates/declarations/polymorphic-reducer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
* ${method.summary}
* ${method.params}
*/
int F${info.title}_${method.Name}(${method.signature.params}${if.result.properties}${if.params}, ${end.if.params}${end.if.result.properties}${method.result.properties});
${method.signature}

// TODO: generate reducer signature
2 changes: 1 addition & 1 deletion languages/c/templates/declarations/property.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
* ${method.summary}
* ${method.params}
*/
int F${info.title}_Get${method.Name}(${method.signature.params}${if.params}, ${end.if.params}${method.result.properties});
${method.signature}
1 change: 1 addition & 0 deletions languages/c/templates/methods/calls-metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ int32_t ${info.Title}_${method.Name}( ${method.signature.params}${if.result}${if

return status;
}

3 changes: 2 additions & 1 deletion languages/c/templates/methods/default.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ${method.rpc.name} - ${method.description} */
int32_t ${info.Title}_${method.Name}( ${method.signature.params}${if.result}${if.params}, ${end.if.params} ${method.result.type}* ${method.result.name}${end.if.result}${if.signature.empty}void${end.if.signature.empty} ) {
int32_t ${info.Title}_${method.Name}( ${method.signature.params}${if.result}${if.params}, ${end.if.params}OUT ${method.result.type}* ${method.result.name}${end.if.result}${if.signature.empty}void${end.if.signature.empty} ) {

int32_t status = FireboltSDKErrorUnavailable;
FireboltSDK::Transport<WPEFramework::Core::JSON::IElement>* transport = FireboltSDK::Accessor::Instance().GetTransport();
Expand All @@ -19,3 +19,4 @@ int32_t ${info.Title}_${method.Name}( ${method.signature.params}${if.result}${if

return status;
}

1 change: 1 addition & 0 deletions languages/c/templates/methods/polymorphic-pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ int32_t ${info.Title}_Push${method.Name}( ${method.signature.params} )

return status;
}

2 changes: 1 addition & 1 deletion languages/c/templates/methods/property.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ${method.rpc.name} - ${method.description} */
int32_t ${info.Title}_Get${method.Name}( ${method.signature.params}${if.params}, ${end.if.params} ${method.result.type}* ${method.result.name} )
int32_t ${info.Title}_Get${method.Name}( ${method.signature.params}${if.params}, ${end.if.params}OUT ${method.result.type}* ${method.result.name} )
{
const string method = _T("${info.title.lowercase}.${method.rpc.name}");
${if.params}${method.params.serialization}${end.if.params}
Expand Down
4 changes: 2 additions & 2 deletions languages/c/templates/modules/src/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
${if.types}namespace FireboltSDK {
namespace ${info.Title} {
// Types
/* ${TYPES:json-types} */
/* ${TYPES} */
}
}${end.if.types}

/* ${ENUMS:json-types} */
/* ${ENUMS} */

${if.definitions}#ifdef __cplusplus
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion languages/c/templates/schemas/src/jsondata_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
namespace ${info.Title} {
// Types

/* ${SCHEMAS:json-types} */
/* ${SCHEMAS} */
}
}${end.if.schemas}
2 changes: 1 addition & 1 deletion languages/c/templates/sdk/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ done
GetVersion()
{
PackagePath=${SdkPath}/../../../../../../package-lock.json
InputKey="name\": \"@firebolt-js/openrpc"
InputKey="name\": \"@firebolt-js/sdks"
LineNo="$(grep -n "${InputKey}" ${PackagePath} | head -n 1 | cut -d: -f1)"
VersionLine=$((LineNo++))
eval "array=(`sed -n "${LineNo}p" < ${PackagePath} | sed 's/\"/\n/g'`)"
Expand Down
1 change: 0 additions & 1 deletion languages/c/templates/sections/accessors.c
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// Accessors
${schema.list}
3 changes: 0 additions & 3 deletions languages/c/templates/sections/methods.c
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@

// Methods

${method.list}
4 changes: 2 additions & 2 deletions languages/c/templates/types/enum.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* ${title} ${description} */
typedef enum {
${NAME}_${key},
} ${name};
${info.TITLE}_${NAME}_${key},
} ${info.Title}_${name};
25 changes: 14 additions & 11 deletions languages/javascript/src/shared/ProvideManager/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ const provide = function(capability, provider) {
const response = {
correlationId: request.correlationId
}
let handleError = error => {
response.error = {
code: error.code || 1000, // todo: should be some reserved code for "Unknown"
message: error.message || `An error occured while calling provided ${method} method.`
}

if (error.data) {
response.error.data = JSON.parse(JSON.stringify(error.data))
}

Transport.send(module, `${method}Error`, response)
}

try {
const result = provider[method].apply(provider, providerCallArgs)
Expand All @@ -107,19 +119,10 @@ const provide = function(capability, provider) {
}

Transport.send(module, `${method}Response`, response)
})
}).catch(err => handleError(err))
}
catch(error) {
response.error = {
code: error.code || 1000, // todo: should be some reserved code for "Unknown"
message: error.message || `An error occured while calling provided ${method} method.`
}

if (error.data) {
response.error.data = JSON.parse(JSON.stringify(error.data))
}

Transport.send(module, `${method}Error`, response)
handleError(error)
}
})
})
Expand Down
6 changes: 2 additions & 4 deletions languages/javascript/templates/examples/default.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { ${module} } from '${package.name}'

${module}.${method.name}(${example.params})
.then(${method.result.name} => {
console.log(${method.result.name})
})
let ${method.result.name} = await ${module}.${method.name}(${example.params})
console.log(${method.result.name})
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { ${module} } from '${package.name}'

${module}.${method.pulls.for}(function(parameters) {
let success = await ${module}.${method.pulls.for}(async parameters => {
console.log(parameters.entityId)
console.log(parameters.assetId)
return Promise.resolve(${originator.params[1].example.value})
}).then(success => {
console.log(success)
})
return ${originator.params[1].example.value}
})
console.log(success)
6 changes: 2 additions & 4 deletions languages/javascript/templates/examples/polymorphic-pull.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { ${module} } from '${package.name}'

${module}.${method.name}(${method.params[1].example.value})
.then(success => {
console.log(success)
})
let success = await ${module}.${method.name}(${method.params[1].example.value})
console.log(success)
6 changes: 2 additions & 4 deletions languages/javascript/templates/examples/setter.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { ${module} } from '${package.name}'

${module}.${method.setter.for}(${example.params})
.then(${method.result.name} => {
console.log(${method.result.name})
})
let ${method.result.name} = await ${module}.${method.setter.for}(${example.params})
console.log(${method.result.name})
7 changes: 3 additions & 4 deletions languages/javascript/templates/examples/subscriber.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ${module} } from '${package.name}'

${method.alternative}(value => {
let listenerId = await ${method.alternative}(value => {
console.log(value)
}).then(listenerId => {
console.log(listenerId)
})
})
console.log(listenerId)
2 changes: 1 addition & 1 deletion languages/markdown/templates/codeblocks/provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { ${info.title} } from '${package.name}'
class My${provider} {
${provider.interface.start}
async ${provider.interface.name}(parameters, session) {
return await Promise.resolve(${provider.interface.example.result})
return ${provider.interface.example.result}
}
${provider.interface.end}
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@firebolt-js/openrpc",
"version": "2.0.4-next.3",
"version": "2.2.0-next.1",
"description": "The Firebolt SDK Code & Doc Generator",
"main": "languages/javascript/src/sdk.mjs",
"type": "module",
Expand Down
1 change: 0 additions & 1 deletion src/macrofier/engine.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1679,7 +1679,6 @@ function generateProviderSubscribe(json, templates) {
return interfaces.length ? template.replace(/\$\{providers\.list\}/g, providers) : ''
}


function generateProviderInterfaces(json, templates) {
const interfaces = getProvidedCapabilities(json)
const suffix = state.destination ? state.destination.split('.').pop() : ''
Expand Down
Loading

0 comments on commit f583521

Please sign in to comment.