Skip to content

Commit

Permalink
CPPSDK: PropertyDependency macro updates + removed Add() property for…
Browse files Browse the repository at this point in the history
… container, instead use assignment
  • Loading branch information
HaseenaSainul committed Dec 13, 2023
1 parent 23d644e commit 1c2d0a5
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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};
Original file line number Diff line number Diff line change
@@ -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};
Original file line number Diff line number Diff line change
@@ -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}
${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}
Original file line number Diff line number Diff line change
@@ -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}
Original file line number Diff line number Diff line change
@@ -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}
${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}
Original file line number Diff line number Diff line change
@@ -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} {
Expand Down
Original file line number Diff line number Diff line change
@@ -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}
Original file line number Diff line number Diff line change
@@ -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}
${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}
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Original file line number Diff line number Diff line change
@@ -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}
${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}
Original file line number Diff line number Diff line change
@@ -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}
${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}
Original file line number Diff line number Diff line change
@@ -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}
Original file line number Diff line number Diff line change
@@ -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} {
Expand Down
Original file line number Diff line number Diff line change
@@ -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}
2 changes: 1 addition & 1 deletion src/macrofier/types.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1c2d0a5

Please sign in to comment.