Skip to content

Commit

Permalink
CPPSDK: parameter/result handling for method and events + inner objec…
Browse files Browse the repository at this point in the history
…t handling (#140)
  • Loading branch information
HaseenaSainul authored Oct 25, 2023
1 parent 6d1339b commit 24eedc4
Show file tree
Hide file tree
Showing 110 changed files with 251 additions and 124 deletions.
1 change: 1 addition & 0 deletions languages/cpp/templates/additional-types/boolean.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Boolean()
1 change: 1 addition & 0 deletions languages/cpp/templates/additional-types/integer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Number()
1 change: 1 addition & 0 deletions languages/cpp/templates/additional-types/number.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Float()
1 change: 1 addition & 0 deletions languages/cpp/templates/additional-types/string.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
String()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WPEFramework::Core::ProxyType<${method.result.json}>* proxyResponse = reinterpret_cast<WPEFramework::Core::ProxyType<${method.result.json}>*>(jsonResponse);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${type}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
response
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${type}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}JsonData_${title} elements = (*proxyResponse)->Variants();
${if.namespace.notsame}${info.Title}::${end.if.namespace.notsame}${title} response;
while (elements.Next()) {
response.insert(elements.Label(), elements.Current().${additional.type}.Value());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
auto index((*proxyResponse)->Elements());
${type} response;
while (index.Next() == true) {
response.push_back(index.Current().Value());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${if.namespace.notsame}${info.Title}::${end.if.namespace.notsame}${title} response = (*proxyResponse)->Value();
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${type} response = (*proxyResponse)->Value();
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
${title} response;
${properties}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${type}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${shape} ${if.non.object}response.${property} = (*proxyResponse)->${Property};${end.if.non.object}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${properties}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${shape} ${if.non.object}response.${property.dependency}${property} = (*proxyResponse)->${Property.dependency}${Property};${end.if.non.object}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${shape}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${Title}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${Title}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
auto index((*proxyResponse)->Elements());
${if.namespace.notsame}${info.Title}::${end.if.namespace.notsame}${title} response;
response.first = index.Get(0);
response.second = index.Get(1);
1 change: 0 additions & 1 deletion languages/cpp/templates/json-types/additionalProperties.c

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
using ${title} = WPEFramework::Core::JSON::VariantContainer;
4 changes: 0 additions & 4 deletions languages/cpp/templates/json-types/array.c

This file was deleted.

1 change: 1 addition & 0 deletions languages/cpp/templates/json-types/array.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WPEFramework::Core::JSON::ArrayType<${json.type}>
File renamed without changes.
1 change: 1 addition & 0 deletions languages/cpp/templates/json-types/default.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${shape}
5 changes: 1 addition & 4 deletions languages/cpp/templates/json-types/enum.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
/* ${title} ${description} */
ENUM_CONVERSION_BEGIN(${name})
{ ${NAME}_${key}, _T("${value}") },
ENUM_CONVERSION_END(${name})
using JsonData_${type} = WPEFramework::Core::JSON::EnumType<${type}>;
4 changes: 0 additions & 4 deletions languages/cpp/templates/json-types/enum.h

This file was deleted.

1 change: 0 additions & 1 deletion languages/cpp/templates/json-types/namespace.c

This file was deleted.

1 change: 1 addition & 0 deletions languages/cpp/templates/json-types/namespace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Firebolt::${info.Title}::
1 change: 1 addition & 0 deletions languages/cpp/templates/json-types/null.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WPEFramework::Core::JSON::VariantContainer
File renamed without changes.
8 changes: 4 additions & 4 deletions languages/cpp/templates/json-types/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
${title}()
: WPEFramework::Core::JSON::Container()
{
${properties.register}
${properties.register}
}

${title}(const ${title}& other)
{
${properties.assign}
${properties.assign}
}

${title}& operator=(const ${title}& other)
{
${properties.assign}
${properties.assign}
return (*this);
}

public:
${properties}
${properties}
};
Empty file.
1 change: 1 addition & 0 deletions languages/cpp/templates/json-types/primitive.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${type}
4 changes: 2 additions & 2 deletions languages/cpp/templates/json-types/property-assign.cpp
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Add(_T("${property}"), &${Property});
${Property} = other.${Property}
Add(_T("${property}"), &${Property});
${Property} = other.${Property};
3 changes: 1 addition & 2 deletions languages/cpp/templates/json-types/property-register.cpp
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Add(_T("${property}"), &${Property});

Add(_T("${property}"), &${Property});
1 change: 1 addition & 0 deletions languages/cpp/templates/json-types/ref.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${shape}
File renamed without changes.
File renamed without changes.
25 changes: 0 additions & 25 deletions languages/cpp/templates/json-types/tuple.c

This file was deleted.

1 change: 1 addition & 0 deletions languages/cpp/templates/json-types/tuple.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
using ${title} = WPEFramework::Core::JSON::ArrayType<${json.type}>;
Empty file.
1 change: 1 addition & 0 deletions languages/cpp/templates/json-types/void.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WPEFramework::Core::JSON::VariantContainer
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions languages/cpp/templates/parameter-serialization/array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
WPEFramework::Core::JSON::ArrayType<WPEFramework::Core::JSON::Variant> ${Property};
for (auto& element : ${property}) {
${if.object}${items.with.indent}${end.if.object}${if.non.object}${Property}.Add() = element;${end.if.non.object}
}
WPEFramework::Core::JSON::Variant ${Property}Variant;
${Property}Variant.Array(${Property});
jsonParameters.Set(_T("${property}"), ${Property}Variant);
2 changes: 0 additions & 2 deletions languages/cpp/templates/parameter-serialization/boolean.cpp

This file was deleted.

2 changes: 0 additions & 2 deletions languages/cpp/templates/parameter-serialization/default.cpp

This file was deleted.

3 changes: 3 additions & 0 deletions languages/cpp/templates/parameter-serialization/enum.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}JsonData_${title} jsonValue = ${property}${if.optional}.value()${end.if.optional};
WPEFramework::Core::JSON::Variant ${Property}(jsonValue.Data());
jsonParameters.Set(_T("${property}"), ${Property});
4 changes: 2 additions & 2 deletions languages/cpp/templates/parameter-serialization/generic.cpp
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
WPEFramework::Core::JSON::Variant ${Property} = ${property};
jsonParameters.Set(_T("${property}"), ${Property});
WPEFramework::Core::JSON::Variant ${Property}(${property}${if.optional}.value()${end.if.optional});
jsonParameters.Set(_T("${property}"), ${Property});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}JsonData_${title} ${Property}Container;
${properties}
string ${Property}Str;
${Property}Container.ToString(${Property}Str);
WPEFramework::Core::JSON::VariantContainer ${Property}VariantContainer(${Property}Str);
WPEFramework::Core::JSON::Variant ${Property}Variant = ${Property}VariantContainer;
${Property}.Add() = ${Property}Variant;
8 changes: 7 additions & 1 deletion languages/cpp/templates/parameter-serialization/object.cpp
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
WPEFramework::Core::JSON::Variant ${Property} = ${property};
auto element = ${property};
${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}JsonData_${title} ${Property}Container;
${properties}
string ${Property}Str;
${Property}Container.ToString(${Property}Str);
WPEFramework::Core::JSON::VariantContainer ${Property}VariantContainer(${Property}Str);
WPEFramework::Core::JSON::Variant ${Property} = ${Property}VariantContainer;
jsonParameters.Set(_T("${property}"), ${Property});
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
WPEFramework::Core::JSON::Variant ${Property} = ${property};
jsonParameters.Set(_T("${property}"), ${Property});
${type}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${shape} ${if.non.object}${base.Title}Container.${Property} = element${if.base.optional}.value()${end.if.base.optional}.${property}${if.optional}.value()${end.if.optional};${end.if.non.object}
1 change: 1 addition & 0 deletions languages/cpp/templates/parameter-serialization/ref.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${shape}
2 changes: 0 additions & 2 deletions languages/cpp/templates/parameter-serialization/string.cpp

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${properties}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${shape} ${if.non.object}${title}.${Property.dependency}${Property} = element${if.base.optional}.value()${end.if.base.optional}.${property.dependency}${property}${if.optional}.value()${end.if.optional};${end.if.non.object}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${shape}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${Title}
2 changes: 1 addition & 1 deletion languages/cpp/templates/parameters/optional.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
std::optional<${method.param.type}> ${method.param.name}
const std::optional<${method.param.type}>& ${method.param.name}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${Title} ${property};
1 change: 1 addition & 0 deletions languages/cpp/templates/result-initialization/array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${type} ${property};
1 change: 1 addition & 0 deletions languages/cpp/templates/result-initialization/boolean.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${type} ${property} = false;
1 change: 1 addition & 0 deletions languages/cpp/templates/result-initialization/generic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${type} ${property};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${if.namespace.notsame}${parent.Title}::${end.if.namespace.notsame}
1 change: 1 addition & 0 deletions languages/cpp/templates/result-initialization/number.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${type} ${property} = 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${type}
1 change: 1 addition & 0 deletions languages/cpp/templates/result-initialization/string.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${type} ${property};
1 change: 1 addition & 0 deletions languages/cpp/templates/result-initialization/title.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${Title}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
while (jsonResult.Variants().Next()) {
std::string label = jsonResult.Variants().Label();
${property}.emplace(std::piecewise_construct,
std::forward_as_tuple(label),
std::forward_as_tuple(jsonResult.Variants().Current().${additional.type}));
}
4 changes: 4 additions & 0 deletions languages/cpp/templates/result-instantiation/array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
auto index(jsonResult.Elements());
while (index.Next() == true) {
${if.object}${items.with.indent}${end.if.object}${if.non.object} ${property}.push_back(index.Current().Value());${end.if.non.object}
}
2 changes: 0 additions & 2 deletions languages/cpp/templates/result-instantiation/boolean.cpp

This file was deleted.

1 change: 1 addition & 0 deletions languages/cpp/templates/result-instantiation/generic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${property} = jsonResult.Value();
4 changes: 4 additions & 0 deletions languages/cpp/templates/result-instantiation/object-array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
${type} ${property}Result${level};
${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}JsonData_${title} jsonResult = index.Current();
${properties}
${property}.push_back(${property}Result${level});
7 changes: 3 additions & 4 deletions languages/cpp/templates/result-instantiation/object.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
WPEFramework::Core::ProxyType<FireboltSDK::${info.Title}::${title}>* resultPtr = new WPEFramework::Core::ProxyType<FireboltSDK::${info.Title}::${title}>();
*resultPtr = WPEFramework::Core::ProxyType<FireboltSDK::${info.Title}::${title}>::Create();
*(*resultPtr) = jsonResult;
*${property} = static_cast<${info.Title}_${title}>(resultPtr);
${type} ${property}Result${level};
${properties}
${property} = ${property}Result${level};
1 change: 1 addition & 0 deletions languages/cpp/templates/result-instantiation/property.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${shape} ${if.non.array}${if.non.object}${base.title}Result${level}.${property} = jsonResult.${Property}.Value();${end.if.non.object}${end.if.non.array}
1 change: 1 addition & 0 deletions languages/cpp/templates/result-instantiation/ref.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${shape}
3 changes: 1 addition & 2 deletions languages/cpp/templates/result-instantiation/string.cpp
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
FireboltSDK::JSON::String* strResult = new FireboltSDK::JSON::String(jsonResult);
*value = static_cast<FireboltTypes_StringHandle>(strResult);
${property} = jsonResult.Value().c_str();
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
auto index(jsonResult.${Property}.Elements());
while (index.Next() == true) {
${if.object}${items.with.indent}${end.if.object}${if.non.object} ${property}.push_back(index.Current().Value());${end.if.non.object}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
${type} ${property}Result${level};
${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}JsonData_${title} jsonResult = index.Current();
${properties}
${property}Result.${property}${if.impl.optional}.value()${end.if.impl.optional}.push_back(${property}Result${level});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${properties}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${shape} ${if.non.object}${base.title}Result${level}.${property.dependency}${if.impl.optional}value().${end.if.impl.optional}${property} = jsonResult.${Property.dependency}${Property};${end.if.non.object}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${shape}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${Title}
1 change: 1 addition & 0 deletions languages/cpp/templates/result-instantiation/title.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${Title}
3 changes: 3 additions & 0 deletions languages/cpp/templates/result-instantiation/tuple.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
auto index(jsonResult.Elements());
${property}.first = index.Get(0);
${property}.second = index.Get(1);
2 changes: 1 addition & 1 deletion languages/cpp/templates/types/additionalProperties.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
std::unordered_map<${key}, ${type}> ${title};
using ${title} = std::unordered_map<${key}, ${type}>;
1 change: 1 addition & 0 deletions languages/cpp/templates/types/const.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
std::string
4 changes: 0 additions & 4 deletions languages/cpp/templates/types/default.cpp

This file was deleted.

1 change: 1 addition & 0 deletions languages/cpp/templates/types/default.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${shape}
1 change: 1 addition & 0 deletions languages/cpp/templates/types/items.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${title}${delimiter}, ${end.delimiter}
1 change: 1 addition & 0 deletions languages/cpp/templates/types/null.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void
2 changes: 0 additions & 2 deletions languages/cpp/templates/types/object.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
struct ${title} {

${properties}

};
Loading

0 comments on commit 24eedc4

Please sign in to comment.