Skip to content

Commit

Permalink
CPPSDK: callback generation + types: with generation changes + templa…
Browse files Browse the repository at this point in the history
…te updates
  • Loading branch information
HaseenaSainul committed Nov 13, 2023
1 parent 195bce4 commit c19dda8
Show file tree
Hide file tree
Showing 105 changed files with 270 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if (strcmp(elements.Label(), "${property}") == 0) {
${if.namespace.notsame}${info.Title}::${end.if.namespace.notsame}JsonData_${title}::Iterator elements = elements.Current().Variants();
while (elements.Next()) {
${property}.insert(elements.Label(), elements.Current().${additional.type};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${property};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if (strcmp(elements.Label(), "${property}") == 0) {
auto index(element.Current().Elements());
while (index.Next() == true) {
${property}.push_back(index.Current().Value());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if (strcmp(elements.Label(), "${property}") == 0) {
${property} = WPEFramework::Core::EnumerateType<${if.namespace.notsame}${info.Title}::${end.if.namespace.notsame}${title}>(elements.Current().String().c_str(), false).Value();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if (strcmp(elements.Label(), "${property}") == 0) {
${property} = elements.Current().Value();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${if.namespace.notsame}${parent.Title}::${end.if.namespace.notsame}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if (strcmp(elements.Label(), "${property}") == 0) {
WPEFramework::Core::JSON::VariantContainer container = elements.Current().Object();
std::string strContainer;
container.ToString(strContainer);
${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}JsonData_${title} response;
response.FromString(strContainer);
${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.const}${if.non.anyOf}${if.non.array}${if.non.object}${base.title}.${property} = response.${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
@@ -0,0 +1 @@
${shape}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if (strcmp(elements.Label(), "${property}") == 0) {
${property} = elements.Current().Value().c_str();
}
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,3 @@
string ${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
@@ -0,0 +1,5 @@
${if.impl.array.optional}${base.title}.${property} = std::make_optional<${type}>();${end.if.impl.array.optional}
auto index(response.${Property}.Elements());
while (index.Next() == true) {
${if.object}${items.with.indent}${end.if.object}${if.non.object} ${base.title}.${property}${if.impl.array.optional}.value()${end.if.impl.array.optional}.push_back(index.Current().Value());${end.if.non.object}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${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
@@ -0,0 +1 @@
${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
@@ -0,0 +1 @@
${if.namespace.notsame}${parent.Title}::${end.if.namespace.notsame}
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}
${base.title}.${property}${if.impl.array.optional}.value()${end.if.impl.array.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,3 @@
${if.impl.optional}
${base.title}${property.dependency} = std::make_optional<${type}>();${end.if.impl.optional}
${properties}
Original file line number Diff line number Diff line change
@@ -0,0 +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}
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 @@
if (strcmp(elements.Label(), "${property}") == 0) {
${property}.first = elements.Current().Get(0);
${property}.second = elements.Current().Get(1);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${if.namespace.notsame}${parent.Title}::${end.if.namespace.notsame}${title} ${property};
1 change: 1 addition & 0 deletions languages/cpp/templates/callback-initialization/anyOf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{property};
1 change: 1 addition & 0 deletions languages/cpp/templates/callback-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/callback-initialization/enum.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${if.namespace.notsame}${parent.Title}::${end.if.namespace.notsame}${title} ${property};
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 @@
std::string ${property};
1 change: 1 addition & 0 deletions languages/cpp/templates/callback-initialization/object.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${if.namespace.notsame}${parent.Title}::${end.if.namespace.notsame}${title} ${property};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${type}
1 change: 1 addition & 0 deletions languages/cpp/templates/callback-initialization/title.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${Title}
12 changes: 12 additions & 0 deletions languages/cpp/templates/callback-instantiation/generic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
WPEFramework::Core::JSON::VariantContainer::Iterator elements = proxyResponse->Variants();
while (elements.Next()) {
${callback.result.instantiation}
else if (strcmp(elements.Label(), "context") == 0) {
WPEFramework::Core::JSON::VariantContainer::Iterator params = elements.Current().Object().Variants();
while (params.Next()) {
${callback.param.instantiation.with.indent}
}
} else {
ASSERT(false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${property}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
response
${property}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
${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;
${if.namespace.notsame}${info.Title}::${end.if.namespace.notsame}JsonData_${title}::Iterator elements = proxyResponse->Variants();
while (elements.Next()) {
response.insert(elements.Label(), elements.Current().${additional.type}.Value());
}
${if.not.default} ${namespace}${key} key = WPEFramework::Core::EnumerateType<${namespace}${key}>(elements.Label(), false).Value();${end.if.not.default}${if.default} ${key} key = elements.Label();${end.if.default}
${property}.emplace(std::piecewise_construct,
std::forward_as_tuple(key),
std::forward_as_tuple(elements.Current().${additional.type}));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${property};
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
auto index((*proxyResponse)->Elements());
${type} response;
auto index(proxyResponse->Elements());
while (index.Next() == true) {
response.push_back(index.Current().Value());
}
${property}.push_back(index.Current().Value());
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
${type} response = (*proxyResponse)->Value();
${property} = proxyResponse->Value();
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${if.namespace.notsame}${parent.Title}::${end.if.namespace.notsame}
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
${title} response;
${properties}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
${shape} ${if.non.object}response.${property} = (*proxyResponse)->${Property};${end.if.non.object}
${shape} ${if.non.const}${if.non.anyOf}${if.non.array}${if.non.object}${base.title}.${property} = proxyResponse->${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
@@ -0,0 +1 @@
${Title}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
string ${property}Str;
proxyResponse->${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
@@ -0,0 +1,5 @@
${if.impl.array.optional}${base.title}.${property} = std::make_optional<${type}>();${end.if.impl.array.optional}
auto index(proxyResponse->${Property}.Elements());
while (index.Next() == true) {
${if.object}${items.with.indent}${end.if.object}${if.non.object} ${base.title}.${property}${if.impl.array.optional}.value()${end.if.impl.array.optional}.push_back(index.Current().Value());${end.if.non.object}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = proxyResponse->${Property.dependency}${Property};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${if.namespace.notsame}${parent.Title}::${end.if.namespace.notsame}
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}response.${property}${if.impl.array.optional}.value()${end.if.impl.array.optional}.push_back(${property}Result${level});
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
${if.impl.optional}
${base.title}${property.dependency} = std::make_optional<${type}>();${end.if.impl.optional}
${properties}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
${shape} ${if.non.object}response.${property.dependency}${property} = (*proxyResponse)->${Property.dependency}${Property};${end.if.non.object}
${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} = proxyResponse->${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,4 +1,2 @@
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);
${property}.first = proxyResponse->Get(0);
${property}.second = proxyResponse->Get(1);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WPEFramework::Core::ProxyType<WPEFramework::Core::JSON::VariantContainer>& proxyResponse = *(reinterpret_cast<WPEFramework::Core::ProxyType<WPEFramework::Core::JSON::VariantContainer>*>(jsonResponse));
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 @@
${shape}
1 change: 1 addition & 0 deletions languages/cpp/templates/callback-serialization/generic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WPEFramework::Core::ProxyType<WPEFramework::Core::JSON::VariantContainer>& proxyResponse = *(reinterpret_cast<WPEFramework::Core::ProxyType<WPEFramework::Core::JSON::VariantContainer>*>(jsonResponse));
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions languages/cpp/templates/declarations/calls-metrics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 1 addition & 1 deletion languages/cpp/templates/json-types/anyOfSchemaShape.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/* anyOf schema shape is not supported right now */
/* anyOf schema shape is not supported right now */
1 change: 1 addition & 0 deletions languages/cpp/templates/json-types/const.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FireboltSDK::JSON::String
2 changes: 1 addition & 1 deletion languages/cpp/templates/json-types/integer.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
WPEFramework::Core::JSON::DecSInt32
WPEFramework::Core::JSON::DecSInt32
14 changes: 8 additions & 6 deletions languages/cpp/templates/methods/event.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/* ${method.rpc.name} - ${method.description} */
static void ${method.name}InnerCallback( void* notification, const void* userData, void* jsonResponse )
{
${event.callback.params.serialization}
ASSERT(proxyResponse->IsValid() == true);
${event.callback.serialization}
ASSERT(proxyResponse.IsValid() == true);

if (proxyResponse->IsValid() == true) {
${event.callback.result.instantiation}
proxyResponse->Release();
if (proxyResponse.IsValid() == true) {
${event.callback.initialization}

${event.callback.instantiation}
proxyResponse.Release();

I${info.Title}::I${method.Name}Notification& notifier = *(reinterpret_cast<I${info.Title}::I${method.Name}Notification*>(notification));
notifier.${method.name}(${event.callback.response.instantiation});
Expand All @@ -32,4 +34,4 @@
if (err != nullptr) {
*err = status;
}
}
}
2 changes: 1 addition & 1 deletion languages/cpp/templates/methods/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
}

return ${method.result.name};
}${method.setter}
}${method.setter}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}${title} map = ${property}${if.impl.optional}.value()${end.if.impl.optional};
WPEFramework::Core::JSON::Variant ${property}Variant;
for (auto element: map) {
WPEFramework::Core::JSON::Variant jsonElement = element.second;
WPEFramework::Core::JSON::VariantContainer jsonContainer;
jsonContainer.Set(element.first.c_str(), jsonElement);
${property}Variant = jsonContainer;
}
jsonParameters.Set(_T("${property}"), ${property}Variant);
2 changes: 1 addition & 1 deletion languages/cpp/templates/parameter-serialization/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
}
WPEFramework::Core::JSON::Variant ${Property}Variant;
${Property}Variant.Array(${Property});
jsonParameters.Set(_T("${property}"), ${Property}Variant);
jsonParameters.Set(_T("${property}"), ${Property}Variant);
2 changes: 1 addition & 1 deletion languages/cpp/templates/parameter-serialization/enum.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +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});
jsonParameters.Set(_T("${property}"), ${Property});
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
WPEFramework::Core::JSON::Variant ${Property}(${property}${if.optional}.value()${end.if.optional});
jsonParameters.Set(_T("${property}"), ${Property});
jsonParameters.Set(_T("${property}"), ${Property});
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
WPEFramework::Core::JSON::Variant ${Property}(${property}${if.optional}.value()${end.if.optional});
jsonParameters.Set(_T("${property}"), ${Property});
2 changes: 1 addition & 1 deletion languages/cpp/templates/parameter-serialization/object.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
auto element = ${property};
auto element = ${property}${if.impl.optional}.value()${end.if.impl.optional};
${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}JsonData_${title} ${Property}Container;
${properties}
string ${Property}Str;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +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}
${shape} ${if.non.const}${if.non.anyOf}${if.non.array}${if.non.object}${base.Title}Container.${Property} = element.${property}${if.optional}.value()${end.if.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
@@ -0,0 +1 @@
${Title}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${base.Title}Container.${Property.dependency}${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}${if.optional}.value()${end.if.optional};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
WPEFramework::Core::JSON::ArrayType<WPEFramework::Core::JSON::Variant> ${Property};
${type} ${property} = element.${property}${if.impl.array.optional}.value()${end.if.impl.array.optional};
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);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${base.Title}Container.${Property.dependency}${Property} = element${property.dependency}.${property}${if.optional}.value()${end.if.optional};
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;
Original file line number Diff line number Diff line change
@@ -1 +1 @@
${properties}
${properties}
Original file line number Diff line number Diff line change
@@ -1 +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}
${shape} ${if.non.const}${if.non.anyOf}${if.non.array}${if.non.object}${base.Title}Container.${Property.dependency}${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}${if.optional}.value()${end.if.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 +1 @@
${Title}
${Title}
1 change: 1 addition & 0 deletions languages/cpp/templates/parameter-serialization/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
@@ -1 +1 @@
${Title} ${property};
${if.namespace.notsame}${parent.Title}::${end.if.namespace.notsame}${Title} ${property};
1 change: 1 addition & 0 deletions languages/cpp/templates/result-initialization/anyOf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
std::string ${property};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${if.namespace.notsame}${parent.Title}::${end.if.namespace.notsame}${Title} ${property};
1 change: 1 addition & 0 deletions languages/cpp/templates/result-initialization/ref.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${shape}
Loading

0 comments on commit c19dda8

Please sign in to comment.