Skip to content

Commit

Permalink
CPP: update based on merge with next branch
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Mar 5, 2024
1 parent 80acfba commit 326dfae
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
${if.optional}if (proxyResponse->${Property}.IsSet()) {
${base.title}.${property} = std::make_optional<${type}>();
auto index(proxyResponse->${Property}.Elements());
${if.optional}if ((*proxyResponse)${Property.dependency}.${Property}.IsSet()) {
${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = std::make_optional<${type}>();
auto index((*proxyResponse)${Property.dependency}.${Property}.Elements());
while (index.Next() == true) {
${if.object}${items.with.indent}${end.if.object}${if.non.object} ${base.title}.${property}.value().push_back(index.Current().Value());${end.if.non.object}
${if.object}${items.with.indent}${end.if.object}${if.non.object} ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.value().push_back(index.Current().Value());${end.if.non.object}
}
}${end.if.optional}${if.non.optional}auto index(proxyResponse->${Property}.Elements());
}${end.if.optional}${if.non.optional}auto index((*proxyResponse)${Property.dependency}.${Property}.Elements());
while (index.Next() == true) {
${if.object}${items.with.indent}${end.if.object}${if.non.object} ${base.title}.${property}.value().push_back(index.Current().Value());${end.if.non.object}
${if.object}${items.with.indent}${end.if.object}${if.non.object} ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.value().push_back(index.Current().Value());${end.if.non.object}
}${end.if.non.optional}
1 change: 1 addition & 0 deletions languages/cpp/templates/methods/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
${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.name}");
${if.params}JsonObject jsonParameters;${end.if.params}
${if.params}${method.params.serialization}${end.if.params}
${method.result.json} jsonResult;
${method.result.initialization}
Expand Down
3 changes: 1 addition & 2 deletions languages/cpp/templates/sdk/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ done
GetVersion()
{
PackagePath=${SdkPath}/../../../../../../package-lock.json
InputKey="name\": \"@firebolt-js/openrpc"
InputKey="\"@firebolt-js/openrpc"
LineNo="$(grep -n "${InputKey}" ${PackagePath} | head -n 1 | cut -d: -f1)"
VersionLine=$((LineNo++))
eval "array=(`sed -n "${LineNo}p" < ${PackagePath} | sed 's/\"/\n/g'`)"
Version=${array[2]}
}
Expand Down
2 changes: 1 addition & 1 deletion languages/javascript/templates/declarations/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
*
${method.params.annotations}${if.deprecated} * @deprecated ${method.deprecation}
${end.if.deprecated} */
function ${method.name}(${method.signature.params}): Promise<${method.result.type}>
function ${method.name}(${method.signature.params}): Promise<${method.result.type}>
1 change: 0 additions & 1 deletion languages/javascript/templates/schemas/default.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/**
* ${schema.description}
*/

${schema.shape}
5 changes: 1 addition & 4 deletions languages/javascript/templates/types/default.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
/*
* ${title} - ${description}
*/
type ${title} = ${shape}
type ${title} = ${shape}
3 changes: 0 additions & 3 deletions languages/javascript/templates/types/enum.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
* ${title} - ${description}
*/
${title}: {
${key}: '${value}',
},
3 changes: 0 additions & 3 deletions languages/javascript/templates/types/enum.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
* ${title} - ${description}
*/
enum ${title} {
${key} = '${value}',
}
2 changes: 1 addition & 1 deletion languages/javascript/templates/types/property.mjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
${property}${if.optional}?${end.if.optional}: ${title} // ${summary}
${property}${if.optional}?${end.if.optional}: ${title} // ${summary}
10 changes: 4 additions & 6 deletions src/macrofier/types.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import deepmerge from 'deepmerge'
import { getPath, localizeDependencies } from '../shared/json-schema.mjs'
import { getPath, localizeDependencies, getSafeEnumKeyName } from '../shared/json-schema.mjs'
import path from "path"

let convertTuplesToArraysOrObjects = false
Expand Down Expand Up @@ -69,8 +69,6 @@ const indent = (str, padding) => {
}
}

const safeName = value => value.split(':').pop().replace(/[\.\-]/g, '_').replace(/\+/g, '_plus').replace(/([a-z])([A-Z0-9])/g, '$1_$2').toUpperCase()

// TODO: This is what's left of getMethodSignatureParams. We need to figure out / handle C's `FireboltTypes_StringHandle`
function getMethodSignatureParams(method, module, { destination, callback }) {
const paramOptional = getTemplate('/parameters/optional')
Expand Down Expand Up @@ -215,7 +213,7 @@ const insertEnumMacros = (content, schema, module, name, suffix, templateDir = "
if (!value) {
value = getTemplate(path.join(templateDir, 'unset' + suffix))
}
value ? values.push(template[i].replace(/\$\{key\}/g, safeName(value))
value ? values.push(template[i].replace(/\$\{key\}/g, getSafeEnumKeyName(value))
.replace(/\$\{value\}/g, value)) : ''
})
template[i] = values.map((value, id) => {
Expand Down Expand Up @@ -401,8 +399,8 @@ const insertObjectMacros = (content, schema, module, title, property, options) =
options2.property = prop
const schemaShape = getSchemaShape(type, module, options2)
properties.push(template
.replace(/\$\{property\}/g, safeName(prop))
.replace(/\$\{Property\}/g, capitalize(safeName(prop)))
.replace(/\$\{property\}/g, getSafeEnumKeyName(prop))
.replace(/\$\{Property\}/g, capitalize(getSafeEnumKeyName(prop)))
.replace(/\$\{parent\.title\}/g, title)
.replace(/\$\{title\}/g, getSchemaType(type, module, options2))
.replace(/\$\{shape\}/g, schemaShape)
Expand Down

0 comments on commit 326dfae

Please sign in to comment.