From 1c2d0a5011fbeb6edb92cb12fe8fab02fe9eed39 Mon Sep 17 00:00:00 2001 From: HaseenaSainul Date: Wed, 13 Dec 2023 06:33:11 -0500 Subject: [PATCH] CPPSDK: PropertyDependency macro updates + removed Add() property for container, instead use assignment --- .../sub-property/anyOfSchemaShape.cpp | 2 +- .../callback-context-instantiation/sub-property/const.cpp | 2 +- .../callback-context-instantiation/sub-property/generic.cpp | 2 +- .../sub-property/property.cpp | 2 +- .../sub-property/anyOfSchemaShape.cpp | 6 +++--- .../callback-result-instantiation/sub-property/const.cpp | 6 +++--- .../callback-result-instantiation/sub-property/object.cpp | 2 +- .../callback-result-instantiation/sub-property/property.cpp | 6 +++--- .../sub-property/anyOfSchemaShape.cpp | 4 ++-- .../parameter-serialization/sub-property/array.cpp | 4 ++-- .../parameter-serialization/sub-property/const.cpp | 4 ++-- .../parameter-serialization/sub-property/property.cpp | 4 ++-- .../result-instantiation/sub-property/anyOfSchemaShape.cpp | 6 +++--- .../templates/result-instantiation/sub-property/object.cpp | 2 +- .../result-instantiation/sub-property/property.cpp | 6 +++--- src/macrofier/types.mjs | 2 +- 16 files changed, 30 insertions(+), 30 deletions(-) diff --git a/languages/cpp/templates/callback-context-instantiation/sub-property/anyOfSchemaShape.cpp b/languages/cpp/templates/callback-context-instantiation/sub-property/anyOfSchemaShape.cpp index f8d48279..c1981c75 100644 --- a/languages/cpp/templates/callback-context-instantiation/sub-property/anyOfSchemaShape.cpp +++ b/languages/cpp/templates/callback-context-instantiation/sub-property/anyOfSchemaShape.cpp @@ -1,3 +1,3 @@ string ${property}Str; - response.${Property.dependency}${Property}.ToString(${property}Str); + response${Property.dependency}.${Property}.ToString(${property}Str); ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = ${property}Str; diff --git a/languages/cpp/templates/callback-context-instantiation/sub-property/const.cpp b/languages/cpp/templates/callback-context-instantiation/sub-property/const.cpp index 41bc1feb..fe8fb5a0 100644 --- a/languages/cpp/templates/callback-context-instantiation/sub-property/const.cpp +++ b/languages/cpp/templates/callback-context-instantiation/sub-property/const.cpp @@ -1 +1 @@ - ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = response.${Property.dependency}${Property}; + ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = response${Property.dependency}.${Property}; diff --git a/languages/cpp/templates/callback-context-instantiation/sub-property/generic.cpp b/languages/cpp/templates/callback-context-instantiation/sub-property/generic.cpp index 41bc1feb..fe8fb5a0 100644 --- a/languages/cpp/templates/callback-context-instantiation/sub-property/generic.cpp +++ b/languages/cpp/templates/callback-context-instantiation/sub-property/generic.cpp @@ -1 +1 @@ - ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = response.${Property.dependency}${Property}; + ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = response${Property.dependency}.${Property}; diff --git a/languages/cpp/templates/callback-context-instantiation/sub-property/property.cpp b/languages/cpp/templates/callback-context-instantiation/sub-property/property.cpp index 4276ebc4..1616b444 100644 --- a/languages/cpp/templates/callback-context-instantiation/sub-property/property.cpp +++ b/languages/cpp/templates/callback-context-instantiation/sub-property/property.cpp @@ -1 +1 @@ -${shape} ${if.non.const}${if.non.anyOf}${if.non.array}${if.non.object}${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = response.${Property.dependency}${Property};${end.if.non.object}${end.if.non.array}${end.if.non.anyOf}${end.if.non.const} \ No newline at end of file +${shape} ${if.non.const}${if.non.anyOf}${if.non.array}${if.non.object}${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = response${Property.dependency}.${Property};${end.if.non.object}${end.if.non.array}${end.if.non.anyOf}${end.if.non.const} \ No newline at end of file diff --git a/languages/cpp/templates/callback-result-instantiation/sub-property/anyOfSchemaShape.cpp b/languages/cpp/templates/callback-result-instantiation/sub-property/anyOfSchemaShape.cpp index 0c62eef4..25269b21 100644 --- a/languages/cpp/templates/callback-result-instantiation/sub-property/anyOfSchemaShape.cpp +++ b/languages/cpp/templates/callback-result-instantiation/sub-property/anyOfSchemaShape.cpp @@ -1,7 +1,7 @@ - ${if.optional}if (proxyResponse->${Property.dependency}${Property}.IsSet()) { + ${if.optional}if ((*proxyResponse)${Property.dependency}.${Property}.IsSet()) { string ${property}Str; - proxyResponse->${Property.dependency}${Property}.ToString(${property}Str); + (*proxyResponse)${Property.dependency}.${Property}.ToString(${property}Str); ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = ${property}Str; }${end.if.optional}${if.non.optional}string ${property}Str; - proxyResponse->${Property.dependency}${Property}.ToString(${property}Str); + (*proxyResponse)${Property.dependency}.${Property}.ToString(${property}Str); ${base.title}${property.dependency}.${property} = ${property}Str;${end.if.non.optional} diff --git a/languages/cpp/templates/callback-result-instantiation/sub-property/const.cpp b/languages/cpp/templates/callback-result-instantiation/sub-property/const.cpp index b005a326..d7969951 100644 --- a/languages/cpp/templates/callback-result-instantiation/sub-property/const.cpp +++ b/languages/cpp/templates/callback-result-instantiation/sub-property/const.cpp @@ -1,3 +1,3 @@ - ${if.optional}if (proxyResponse->${Property.dependency}${Property}.IsSet()) { - ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = proxyResponse->${Property.dependency}${Property}; - }${end.if.optional}${if.non.optional}${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = proxyResponse->${Property.dependency}${Property};${end.if.non.optional} \ No newline at end of file + ${if.optional}if ((*proxyResponse)${Property.dependency}.${Property}.IsSet()) { + ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = (*proxyResponse)${Property.dependency}.${Property}; + }${end.if.optional}${if.non.optional}${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = (*proxyResponse)${Property.dependency}.${Property};${end.if.non.optional} \ No newline at end of file diff --git a/languages/cpp/templates/callback-result-instantiation/sub-property/object.cpp b/languages/cpp/templates/callback-result-instantiation/sub-property/object.cpp index cd86ff1a..f41b4a30 100644 --- a/languages/cpp/templates/callback-result-instantiation/sub-property/object.cpp +++ b/languages/cpp/templates/callback-result-instantiation/sub-property/object.cpp @@ -1,4 +1,4 @@ -${if.optional} if (proxyResponse->${Property.dependency}IsSet()) { +${if.optional} if ((*proxyResponse)${Property.dependency}.IsSet()) { ${base.title}${property.dependency} = std::make_optional<${type}>(); ${properties} }${end.if.optional}${if.non.optional} { diff --git a/languages/cpp/templates/callback-result-instantiation/sub-property/property.cpp b/languages/cpp/templates/callback-result-instantiation/sub-property/property.cpp index f8bfa268..8cd83ce0 100644 --- a/languages/cpp/templates/callback-result-instantiation/sub-property/property.cpp +++ b/languages/cpp/templates/callback-result-instantiation/sub-property/property.cpp @@ -1,3 +1,3 @@ -${shape} ${if.non.const}${if.non.anyOf}${if.non.array}${if.non.object}${if.optional}if (proxyResponse->${Property.dependency}${Property}.IsSet()) { - ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = proxyResponse->${Property.dependency}${Property}; - }${end.if.optional}${if.non.optional}${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = proxyResponse->${Property.dependency}${Property};${end.if.non.optional}${end.if.non.object}${end.if.non.array}${end.if.non.anyOf}${end.if.non.const} +${shape} ${if.non.const}${if.non.anyOf}${if.non.array}${if.non.object}${if.optional}if ((*proxyResponse)${Property.dependency}.${Property}.IsSet()) { + ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = (*proxyResponse)${Property.dependency}.${Property}; + }${end.if.optional}${if.non.optional}${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = (*proxyResponse)${Property.dependency}.${Property};${end.if.non.optional}${end.if.non.object}${end.if.non.array}${end.if.non.anyOf}${end.if.non.const} diff --git a/languages/cpp/templates/parameter-serialization/sub-property/anyOfSchemaShape.cpp b/languages/cpp/templates/parameter-serialization/sub-property/anyOfSchemaShape.cpp index 7ac47b35..5e750f10 100644 --- a/languages/cpp/templates/parameter-serialization/sub-property/anyOfSchemaShape.cpp +++ b/languages/cpp/templates/parameter-serialization/sub-property/anyOfSchemaShape.cpp @@ -1,3 +1,3 @@ ${if.optional}if (element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.has_value()) { - ${base.title}Container.${Property.dependency}${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.value(); - }${end.if.optional}${if.non.optional}${base.title}Container.${Property.dependency}${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property};${end.if.non.optional} \ No newline at end of file + ${base.title}Container${Property.dependency}.${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.value(); + }${end.if.optional}${if.non.optional}${base.title}Container${Property.dependency}.${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property};${end.if.non.optional} \ No newline at end of file diff --git a/languages/cpp/templates/parameter-serialization/sub-property/array.cpp b/languages/cpp/templates/parameter-serialization/sub-property/array.cpp index cf5bb5f2..331d59a8 100644 --- a/languages/cpp/templates/parameter-serialization/sub-property/array.cpp +++ b/languages/cpp/templates/parameter-serialization/sub-property/array.cpp @@ -4,10 +4,10 @@ for (auto& element : ${property}) { ${if.object}${items.with.indent}${end.if.object}${if.non.object} ${property}Array.Add() = element;${end.if.non.object} } - ${base.title}Container.${Property.dependency}Add(_T("${property}"), &${property}Array); + ${base.title}Container${Property.dependency}.${Property} = ${property}Array; }${end.if.impl.array.optional}${if.impl.array.non.optional}WPEFramework::Core::JSON::ArrayType<${json.type}> ${property}Array; ${type} ${property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}; for (auto& element : ${property}) { ${if.object}${items.with.indent}${end.if.object}${if.non.object} ${property}Array.Add() = element;${end.if.non.object} } - ${base.title}Container.${Property.dependency}Add(_T("${property}"), &${property}Array);${end.if.impl.array.non.optional} + ${base.title}Container${Property.dependency}.${Property} = ${property}Array;${end.if.impl.array.non.optional} diff --git a/languages/cpp/templates/parameter-serialization/sub-property/const.cpp b/languages/cpp/templates/parameter-serialization/sub-property/const.cpp index fa81c8f4..0d25c572 100644 --- a/languages/cpp/templates/parameter-serialization/sub-property/const.cpp +++ b/languages/cpp/templates/parameter-serialization/sub-property/const.cpp @@ -1,3 +1,3 @@ ${if.optional}if (element${property.dependency}.${property}.has_value()) { - ${base.title}Container.${Property.dependency}${Property} = element${property.dependency}.${property}.value(); - }${end.if.optional}${if.non.optional}${base.title}Container.${Property.dependency}${Property} = element${property.dependency}.${property};${end.if.non.optional} \ No newline at end of file + ${base.title}Container${Property.dependency}.${Property} = element${property.dependency}.${property}.value(); + }${end.if.optional}${if.non.optional}${base.title}Container${Property.dependency}.${Property} = element${property.dependency}.${property};${end.if.non.optional} \ No newline at end of file diff --git a/languages/cpp/templates/parameter-serialization/sub-property/property.cpp b/languages/cpp/templates/parameter-serialization/sub-property/property.cpp index b7341e97..e52679d3 100644 --- a/languages/cpp/templates/parameter-serialization/sub-property/property.cpp +++ b/languages/cpp/templates/parameter-serialization/sub-property/property.cpp @@ -1,3 +1,3 @@ ${shape} ${if.non.const}${if.non.anyOf}${if.non.array}${if.non.object}${if.optional}if (element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.has_value()) { - ${base.title}Container.${Property.dependency}${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.value(); - }${end.if.optional}${if.non.optional}${base.title}Container.${Property.dependency}${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property};${end.if.non.optional}${end.if.non.object}${end.if.non.array}${end.if.non.anyOf}${end.if.non.const} \ No newline at end of file + ${base.title}Container${Property.dependency}.${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.value(); + }${end.if.optional}${if.non.optional}${base.title}Container${Property.dependency}.${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property};${end.if.non.optional}${end.if.non.object}${end.if.non.array}${end.if.non.anyOf}${end.if.non.const} \ No newline at end of file diff --git a/languages/cpp/templates/result-instantiation/sub-property/anyOfSchemaShape.cpp b/languages/cpp/templates/result-instantiation/sub-property/anyOfSchemaShape.cpp index 75d9be83..4398ae8b 100644 --- a/languages/cpp/templates/result-instantiation/sub-property/anyOfSchemaShape.cpp +++ b/languages/cpp/templates/result-instantiation/sub-property/anyOfSchemaShape.cpp @@ -1,7 +1,7 @@ - ${if.optional}if (jsonResult.${Property.dependency}${Property}.IsSet()) { + ${if.optional}if (jsonResult${Property.dependency}.${Property}.IsSet()) { string ${property}Str; - jsonResult.${Property.dependency}${Property}.ToString(${property}Str); + jsonResult${Property.dependency}.${Property}.ToString(${property}Str); ${base.title}Result${level}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = ${property}Str; }${end.if.optional}${if.non.optional}string ${property}Str; - jsonResult.${Property.dependency}${Property}.ToString(${property}Str); + jsonResult${Property.dependency}.${Property}.ToString(${property}Str); ${base.title}Result${level}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = ${property}Str;${end.if.non.optional} diff --git a/languages/cpp/templates/result-instantiation/sub-property/object.cpp b/languages/cpp/templates/result-instantiation/sub-property/object.cpp index bb793a66..4d789f75 100644 --- a/languages/cpp/templates/result-instantiation/sub-property/object.cpp +++ b/languages/cpp/templates/result-instantiation/sub-property/object.cpp @@ -1,4 +1,4 @@ -${if.optional} if (jsonResult.${Property.dependency}IsSet()) { +${if.optional} if (jsonResult${Property.dependency}.IsSet()) { ${base.title}Result${level}${property.dependency} = std::make_optional<${type}>(); ${properties} }${end.if.optional}${if.non.optional} { diff --git a/languages/cpp/templates/result-instantiation/sub-property/property.cpp b/languages/cpp/templates/result-instantiation/sub-property/property.cpp index 83d14805..98f5fbb4 100644 --- a/languages/cpp/templates/result-instantiation/sub-property/property.cpp +++ b/languages/cpp/templates/result-instantiation/sub-property/property.cpp @@ -1,3 +1,3 @@ -${shape} ${if.non.anyOf}${if.non.array}${if.non.object}${if.optional}if (jsonResult.${Property.dependency}${Property}.IsSet()) { - ${base.title}Result${level}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = jsonResult.${Property.dependency}${Property}; - }${end.if.optional}${if.non.optional}${base.title}Result${level}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = jsonResult.${Property.dependency}${Property};${end.if.non.optional}${end.if.non.object}${end.if.non.array}${end.if.non.anyOf} +${shape} ${if.non.anyOf}${if.non.array}${if.non.object}${if.optional}if (jsonResult${Property.dependency}.${Property}.IsSet()) { + ${base.title}Result${level}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = jsonResult${Property.dependency}.${Property}; + }${end.if.optional}${if.non.optional}${base.title}Result${level}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = jsonResult${Property.dependency}.${Property};${end.if.non.optional}${end.if.non.object}${end.if.non.array}${end.if.non.anyOf} diff --git a/src/macrofier/types.mjs b/src/macrofier/types.mjs index b8b76016..435db418 100644 --- a/src/macrofier/types.mjs +++ b/src/macrofier/types.mjs @@ -319,7 +319,7 @@ const insertObjectMacros = (content, schema, module, title, property, options) = .replace(/\$\{if\.impl.optional\}(.*?)\$\{end\.if\.impl.optional\}/gms, schema.required && schema.required.includes(name) ? '' : '$1') .replace(/\$\{if\.impl.non.optional\}(.*?)\$\{end\.if\.impl.non.optional\}/gms, schema.required && schema.required.includes(name) ? '$1' : '') .replace(/\$\{property.dependency\}/g, ((options.level > 0) ? '${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}' : '') + objSeparator + name) - .replace(/\$\{Property.dependency\}/g, ((options.level > 0) ? '${Property.dependency}' : '') + capitalize(name) + (objSeparator)) + .replace(/\$\{Property.dependency\}/g, ((options.level > 0) ? '${Property.dependency}' : '') + (objSeparator) + capitalize(name)) } else { if (options2.level <= 1) {