diff --git a/languages/cpp/templates/callback-parameter-serialization/generic.cpp b/languages/cpp/templates/callback-parameter-serialization/generic.cpp new file mode 100644 index 00000000..530005ca --- /dev/null +++ b/languages/cpp/templates/callback-parameter-serialization/generic.cpp @@ -0,0 +1 @@ + WPEFramework::Core::ProxyType<${method.result.json}>* proxyResponse = reinterpret_cast*>(jsonResponse); \ No newline at end of file diff --git a/languages/cpp/templates/callback-parameter-serialization/primitive.cpp b/languages/cpp/templates/callback-parameter-serialization/primitive.cpp new file mode 100644 index 00000000..23bbace7 --- /dev/null +++ b/languages/cpp/templates/callback-parameter-serialization/primitive.cpp @@ -0,0 +1 @@ +${type} \ No newline at end of file diff --git a/languages/cpp/templates/callback-parameter-serialization/ref.h b/languages/cpp/templates/callback-parameter-serialization/ref.h new file mode 100644 index 00000000..4da5b5d9 --- /dev/null +++ b/languages/cpp/templates/callback-parameter-serialization/ref.h @@ -0,0 +1 @@ +${shape} \ No newline at end of file diff --git a/languages/cpp/templates/callback-response-instantiation/generic.cpp b/languages/cpp/templates/callback-response-instantiation/generic.cpp new file mode 100644 index 00000000..c8f3f090 --- /dev/null +++ b/languages/cpp/templates/callback-response-instantiation/generic.cpp @@ -0,0 +1 @@ +response \ No newline at end of file diff --git a/languages/cpp/templates/callback-response-instantiation/primitive.cpp b/languages/cpp/templates/callback-response-instantiation/primitive.cpp new file mode 100644 index 00000000..23bbace7 --- /dev/null +++ b/languages/cpp/templates/callback-response-instantiation/primitive.cpp @@ -0,0 +1 @@ +${type} \ No newline at end of file diff --git a/languages/cpp/templates/callback-response-instantiation/ref.h b/languages/cpp/templates/callback-response-instantiation/ref.h new file mode 100644 index 00000000..4da5b5d9 --- /dev/null +++ b/languages/cpp/templates/callback-response-instantiation/ref.h @@ -0,0 +1 @@ +${shape} \ No newline at end of file diff --git a/languages/cpp/templates/callback-result-instantiation/additionalProperties.cpp b/languages/cpp/templates/callback-result-instantiation/additionalProperties.cpp new file mode 100644 index 00000000..a304af7e --- /dev/null +++ b/languages/cpp/templates/callback-result-instantiation/additionalProperties.cpp @@ -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()); + } \ No newline at end of file diff --git a/languages/cpp/templates/callback-result-instantiation/array.cpp b/languages/cpp/templates/callback-result-instantiation/array.cpp new file mode 100644 index 00000000..603644e3 --- /dev/null +++ b/languages/cpp/templates/callback-result-instantiation/array.cpp @@ -0,0 +1,5 @@ + auto index((*proxyResponse)->Elements()); + ${type} response; + while (index.Next() == true) { + response.push_back(index.Current().Value()); + } diff --git a/languages/cpp/templates/callback-result-instantiation/enum.cpp b/languages/cpp/templates/callback-result-instantiation/enum.cpp new file mode 100644 index 00000000..30fdf717 --- /dev/null +++ b/languages/cpp/templates/callback-result-instantiation/enum.cpp @@ -0,0 +1 @@ + ${if.namespace.notsame}${info.Title}::${end.if.namespace.notsame}${title} response = (*proxyResponse)->Value(); \ No newline at end of file diff --git a/languages/cpp/templates/callback-result-instantiation/generic.cpp b/languages/cpp/templates/callback-result-instantiation/generic.cpp new file mode 100644 index 00000000..8c7a2fea --- /dev/null +++ b/languages/cpp/templates/callback-result-instantiation/generic.cpp @@ -0,0 +1 @@ + ${type} response = (*proxyResponse)->Value(); \ No newline at end of file diff --git a/languages/cpp/templates/callback-result-instantiation/object.cpp b/languages/cpp/templates/callback-result-instantiation/object.cpp new file mode 100644 index 00000000..8722a92e --- /dev/null +++ b/languages/cpp/templates/callback-result-instantiation/object.cpp @@ -0,0 +1,2 @@ + ${title} response; +${properties} \ No newline at end of file diff --git a/languages/cpp/templates/callback-result-instantiation/primitive.cpp b/languages/cpp/templates/callback-result-instantiation/primitive.cpp new file mode 100644 index 00000000..23bbace7 --- /dev/null +++ b/languages/cpp/templates/callback-result-instantiation/primitive.cpp @@ -0,0 +1 @@ +${type} \ No newline at end of file diff --git a/languages/cpp/templates/callback-result-instantiation/property.cpp b/languages/cpp/templates/callback-result-instantiation/property.cpp new file mode 100644 index 00000000..31648b06 --- /dev/null +++ b/languages/cpp/templates/callback-result-instantiation/property.cpp @@ -0,0 +1 @@ +${shape} ${if.non.object}response.${property} = (*proxyResponse)->${Property};${end.if.non.object} \ No newline at end of file diff --git a/languages/cpp/templates/callback-result-instantiation/ref.h b/languages/cpp/templates/callback-result-instantiation/ref.h new file mode 100644 index 00000000..4da5b5d9 --- /dev/null +++ b/languages/cpp/templates/callback-result-instantiation/ref.h @@ -0,0 +1 @@ +${shape} \ No newline at end of file diff --git a/languages/cpp/templates/callback-result-instantiation/sub-property/object-separator.cpp b/languages/cpp/templates/callback-result-instantiation/sub-property/object-separator.cpp new file mode 100644 index 00000000..945c9b46 --- /dev/null +++ b/languages/cpp/templates/callback-result-instantiation/sub-property/object-separator.cpp @@ -0,0 +1 @@ +. \ 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 new file mode 100644 index 00000000..c4569c3e --- /dev/null +++ b/languages/cpp/templates/callback-result-instantiation/sub-property/object.cpp @@ -0,0 +1 @@ +${properties} \ No newline at end of file diff --git a/languages/cpp/templates/callback-result-instantiation/sub-property/property.cpp b/languages/cpp/templates/callback-result-instantiation/sub-property/property.cpp new file mode 100644 index 00000000..1f8541f2 --- /dev/null +++ b/languages/cpp/templates/callback-result-instantiation/sub-property/property.cpp @@ -0,0 +1 @@ +${shape} ${if.non.object}response.${property.dependency}${property} = (*proxyResponse)->${Property.dependency}${Property};${end.if.non.object} \ No newline at end of file diff --git a/languages/cpp/templates/callback-result-instantiation/sub-property/ref.h b/languages/cpp/templates/callback-result-instantiation/sub-property/ref.h new file mode 100644 index 00000000..4da5b5d9 --- /dev/null +++ b/languages/cpp/templates/callback-result-instantiation/sub-property/ref.h @@ -0,0 +1 @@ +${shape} \ No newline at end of file diff --git a/languages/cpp/templates/callback-result-instantiation/sub-property/title.cpp b/languages/cpp/templates/callback-result-instantiation/sub-property/title.cpp new file mode 100644 index 00000000..2a420b4b --- /dev/null +++ b/languages/cpp/templates/callback-result-instantiation/sub-property/title.cpp @@ -0,0 +1 @@ +${Title} \ No newline at end of file diff --git a/languages/cpp/templates/callback-result-instantiation/title.cpp b/languages/cpp/templates/callback-result-instantiation/title.cpp new file mode 100644 index 00000000..2a420b4b --- /dev/null +++ b/languages/cpp/templates/callback-result-instantiation/title.cpp @@ -0,0 +1 @@ +${Title} \ No newline at end of file diff --git a/languages/cpp/templates/callback-result-instantiation/tuple.cpp b/languages/cpp/templates/callback-result-instantiation/tuple.cpp new file mode 100644 index 00000000..76dde980 --- /dev/null +++ b/languages/cpp/templates/callback-result-instantiation/tuple.cpp @@ -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); \ No newline at end of file diff --git a/languages/cpp/templates/json-types/additionalProperties.c b/languages/cpp/templates/json-types/additionalProperties.c deleted file mode 100644 index b814e5fb..00000000 --- a/languages/cpp/templates/json-types/additionalProperties.c +++ /dev/null @@ -1 +0,0 @@ -// need cpp code to init, get, set, clear additional properties... \ No newline at end of file diff --git a/languages/cpp/templates/json-types/additionalProperties.cpp b/languages/cpp/templates/json-types/additionalProperties.cpp new file mode 100644 index 00000000..3466cdce --- /dev/null +++ b/languages/cpp/templates/json-types/additionalProperties.cpp @@ -0,0 +1 @@ + using ${title} = WPEFramework::Core::JSON::VariantContainer; \ No newline at end of file diff --git a/languages/cpp/templates/json-types/anyOf.c b/languages/cpp/templates/json-types/anyOf.c index a2682179..fc121f63 100644 --- a/languages/cpp/templates/json-types/anyOf.c +++ b/languages/cpp/templates/json-types/anyOf.c @@ -1 +1 @@ -/* AnyOf is not supported in C: ${title} */ \ No newline at end of file +WPEFramework::Core::JSON::VariantContainer \ No newline at end of file diff --git a/languages/cpp/templates/json-types/anyOfSchemaShape.h b/languages/cpp/templates/json-types/anyOfSchemaShape.h new file mode 100644 index 00000000..9a53ff94 --- /dev/null +++ b/languages/cpp/templates/json-types/anyOfSchemaShape.h @@ -0,0 +1 @@ + /* anyOf schema shape is supported right now */ diff --git a/languages/cpp/templates/json-types/array.c b/languages/cpp/templates/json-types/array.c index 508a9eac..4ab0d5ac 100644 --- a/languages/cpp/templates/json-types/array.c +++ b/languages/cpp/templates/json-types/array.c @@ -1,4 +1 @@ -uint32_t ${info.Title}_${Title}Array_Size(${type} handle); -${type} ${title}Array_Get(${type} handle, uint32_t index); -void ${info.Title}_${Title}Array_Add(${propertyType} handle, ${valueType} value); -void ${info.Title}_${Title}Array_Clear(${propertyType} handle); +WPEFramework::Core::JSON::ArrayType<${json.type}> \ No newline at end of file diff --git a/languages/cpp/templates/json-types/enum.cpp b/languages/cpp/templates/json-types/enum.cpp index 6776b41a..9acb1ea5 100644 --- a/languages/cpp/templates/json-types/enum.cpp +++ b/languages/cpp/templates/json-types/enum.cpp @@ -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}>; diff --git a/languages/cpp/templates/json-types/enum.h b/languages/cpp/templates/json-types/enum.h deleted file mode 100644 index 92108c75..00000000 --- a/languages/cpp/templates/json-types/enum.h +++ /dev/null @@ -1,4 +0,0 @@ -/* ${title} ${description} */ -typedef enum { - ${NAME}_${key}, -} ${name}; diff --git a/languages/cpp/templates/json-types/namespace.c b/languages/cpp/templates/json-types/namespace.c index 8ea9d7de..c63c1089 100644 --- a/languages/cpp/templates/json-types/namespace.c +++ b/languages/cpp/templates/json-types/namespace.c @@ -1 +1 @@ -FireboltSDK::${info.Title}:: \ No newline at end of file +Firebolt::${info.Title}:: \ No newline at end of file diff --git a/languages/cpp/templates/json-types/float.c b/languages/cpp/templates/json-types/number.c similarity index 100% rename from languages/cpp/templates/json-types/float.c rename to languages/cpp/templates/json-types/number.c diff --git a/languages/cpp/templates/json-types/object.cpp b/languages/cpp/templates/json-types/object.cpp index db24d12c..43c667d3 100644 --- a/languages/cpp/templates/json-types/object.cpp +++ b/languages/cpp/templates/json-types/object.cpp @@ -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} }; diff --git a/languages/cpp/templates/json-types/primitive.c b/languages/cpp/templates/json-types/primitive.c index e69de29b..23bbace7 100644 --- a/languages/cpp/templates/json-types/primitive.c +++ b/languages/cpp/templates/json-types/primitive.c @@ -0,0 +1 @@ +${type} \ No newline at end of file diff --git a/languages/cpp/templates/json-types/property-assign.cpp b/languages/cpp/templates/json-types/property-assign.cpp index 88795136..36bdbf83 100644 --- a/languages/cpp/templates/json-types/property-assign.cpp +++ b/languages/cpp/templates/json-types/property-assign.cpp @@ -1,2 +1,2 @@ - Add(_T("${property}"), &${Property}); - ${Property} = other.${Property} + Add(_T("${property}"), &${Property}); + ${Property} = other.${Property}; diff --git a/languages/cpp/templates/json-types/property-register.cpp b/languages/cpp/templates/json-types/property-register.cpp index 400b4fd5..01e2a7e0 100644 --- a/languages/cpp/templates/json-types/property-register.cpp +++ b/languages/cpp/templates/json-types/property-register.cpp @@ -1,2 +1 @@ - Add(_T("${property}"), &${Property}); - \ No newline at end of file + Add(_T("${property}"), &${Property}); \ No newline at end of file diff --git a/languages/cpp/templates/json-types/tuple.c b/languages/cpp/templates/json-types/tuple.c deleted file mode 100644 index db24d12c..00000000 --- a/languages/cpp/templates/json-types/tuple.c +++ /dev/null @@ -1,25 +0,0 @@ - class ${title}: public WPEFramework::Core::JSON::Container { - public: - ~${title}() override = default; - - public: - ${title}() - : WPEFramework::Core::JSON::Container() - { - ${properties.register} - } - - ${title}(const ${title}& other) - { - ${properties.assign} - } - - ${title}& operator=(const ${title}& other) - { - ${properties.assign} - return (*this); - } - - public: - ${properties} - }; diff --git a/languages/cpp/templates/json-types/tuple.cpp b/languages/cpp/templates/json-types/tuple.cpp new file mode 100644 index 00000000..f734872b --- /dev/null +++ b/languages/cpp/templates/json-types/tuple.cpp @@ -0,0 +1 @@ + using ${title} = WPEFramework::Core::JSON::ArrayType<${json.type}>; \ No newline at end of file diff --git a/languages/cpp/templates/parameter-serialization/array.cpp b/languages/cpp/templates/parameter-serialization/array.cpp new file mode 100644 index 00000000..43b6b532 --- /dev/null +++ b/languages/cpp/templates/parameter-serialization/array.cpp @@ -0,0 +1,7 @@ + WPEFramework::Core::JSON::ArrayType ${Property}; + for (auto& element: ${property}) { + ${Property}.Add() = element; + } + WPEFramework::Core::JSON::Variant ${Property}Variant; + ${Property}Variant.Array(${Property}); + jsonParameters.Set(_T("${property}"), ${Property}Variant); diff --git a/languages/cpp/templates/parameter-serialization/enum.cpp b/languages/cpp/templates/parameter-serialization/enum.cpp new file mode 100644 index 00000000..cb20df92 --- /dev/null +++ b/languages/cpp/templates/parameter-serialization/enum.cpp @@ -0,0 +1,3 @@ + ${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}JsonData_${title} jsonValue = ${property}; + WPEFramework::Core::JSON::Variant ${Property}(jsonValue.Data()); + jsonParameters.Set(_T("${property}"), ${Property}); \ No newline at end of file diff --git a/languages/cpp/templates/parameter-serialization/generic.cpp b/languages/cpp/templates/parameter-serialization/generic.cpp new file mode 100644 index 00000000..b2f6b0cd --- /dev/null +++ b/languages/cpp/templates/parameter-serialization/generic.cpp @@ -0,0 +1,2 @@ + WPEFramework::Core::JSON::Variant ${Property}(${property}); + jsonParameters.Set(_T("${property}"), ${Property}); diff --git a/languages/cpp/templates/parameter-serialization/object.cpp b/languages/cpp/templates/parameter-serialization/object.cpp index f924ac94..20340a12 100644 --- a/languages/cpp/templates/parameter-serialization/object.cpp +++ b/languages/cpp/templates/parameter-serialization/object.cpp @@ -1,2 +1,7 @@ - WPEFramework::Core::JSON::Variant ${Property} = ${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}); diff --git a/languages/cpp/templates/parameter-serialization/primitive.cpp b/languages/cpp/templates/parameter-serialization/primitive.cpp index f924ac94..23bbace7 100644 --- a/languages/cpp/templates/parameter-serialization/primitive.cpp +++ b/languages/cpp/templates/parameter-serialization/primitive.cpp @@ -1,2 +1 @@ - WPEFramework::Core::JSON::Variant ${Property} = ${property}; - jsonParameters.Set(_T("${property}"), ${Property}); +${type} \ No newline at end of file diff --git a/languages/cpp/templates/parameter-serialization/property.cpp b/languages/cpp/templates/parameter-serialization/property.cpp new file mode 100644 index 00000000..f019a685 --- /dev/null +++ b/languages/cpp/templates/parameter-serialization/property.cpp @@ -0,0 +1 @@ +${shape} ${if.non.object}${title}.${Property} = ${base.title}.${property};${end.if.non.object} diff --git a/languages/cpp/templates/parameter-serialization/sub-property/object-separator.cpp b/languages/cpp/templates/parameter-serialization/sub-property/object-separator.cpp new file mode 100644 index 00000000..945c9b46 --- /dev/null +++ b/languages/cpp/templates/parameter-serialization/sub-property/object-separator.cpp @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/languages/cpp/templates/parameter-serialization/sub-property/object.cpp b/languages/cpp/templates/parameter-serialization/sub-property/object.cpp new file mode 100644 index 00000000..c4569c3e --- /dev/null +++ b/languages/cpp/templates/parameter-serialization/sub-property/object.cpp @@ -0,0 +1 @@ +${properties} \ 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 new file mode 100644 index 00000000..c19bd088 --- /dev/null +++ b/languages/cpp/templates/parameter-serialization/sub-property/property.cpp @@ -0,0 +1 @@ +${shape} ${if.non.object}${title}.${Property.dependency}${Property} = ${base.title}.${property.dependency}${property};${end.if.non.object} diff --git a/languages/cpp/templates/parameter-serialization/sub-property/ref.h b/languages/cpp/templates/parameter-serialization/sub-property/ref.h new file mode 100644 index 00000000..4da5b5d9 --- /dev/null +++ b/languages/cpp/templates/parameter-serialization/sub-property/ref.h @@ -0,0 +1 @@ +${shape} \ No newline at end of file diff --git a/languages/cpp/templates/parameter-serialization/sub-property/title.cpp b/languages/cpp/templates/parameter-serialization/sub-property/title.cpp new file mode 100644 index 00000000..e2e80c7c --- /dev/null +++ b/languages/cpp/templates/parameter-serialization/sub-property/title.cpp @@ -0,0 +1 @@ +${Title} diff --git a/languages/cpp/templates/parameters/object.h b/languages/cpp/templates/parameters/nonprimitive.h similarity index 100% rename from languages/cpp/templates/parameters/object.h rename to languages/cpp/templates/parameters/nonprimitive.h diff --git a/languages/cpp/templates/parameters/optional.h b/languages/cpp/templates/parameters/optional.h index 69cb4659..d21cf868 100644 --- a/languages/cpp/templates/parameters/optional.h +++ b/languages/cpp/templates/parameters/optional.h @@ -1 +1 @@ -std::optional<${method.param.type}> ${method.param.name} \ No newline at end of file +const std::optional<${method.param.type}>& ${method.param.name} \ No newline at end of file diff --git a/languages/cpp/templates/parameters/result-null.h b/languages/cpp/templates/parameters/result-null.h deleted file mode 100644 index e69de29b..00000000 diff --git a/languages/cpp/templates/parameters/result.h b/languages/cpp/templates/parameters/result.h deleted file mode 100644 index 3c96807b..00000000 --- a/languages/cpp/templates/parameters/result.h +++ /dev/null @@ -1 +0,0 @@ -${method.param.type}& ${method.param.name} \ No newline at end of file diff --git a/languages/cpp/templates/result-initialization/boolean.cpp b/languages/cpp/templates/result-initialization/boolean.cpp new file mode 100644 index 00000000..23bbf1be --- /dev/null +++ b/languages/cpp/templates/result-initialization/boolean.cpp @@ -0,0 +1 @@ + ${type} ${property} = false; \ No newline at end of file diff --git a/languages/cpp/templates/result-initialization/generic.cpp b/languages/cpp/templates/result-initialization/generic.cpp new file mode 100644 index 00000000..1bcce663 --- /dev/null +++ b/languages/cpp/templates/result-initialization/generic.cpp @@ -0,0 +1 @@ + ${type} ${property}; \ No newline at end of file diff --git a/languages/cpp/templates/result-initialization/namespace.cpp b/languages/cpp/templates/result-initialization/namespace.cpp new file mode 100644 index 00000000..b3afde8a --- /dev/null +++ b/languages/cpp/templates/result-initialization/namespace.cpp @@ -0,0 +1 @@ +${if.namespace.notsame}${parent.Title}::${end.if.namespace.notsame} \ No newline at end of file diff --git a/languages/cpp/templates/result-initialization/number.cpp b/languages/cpp/templates/result-initialization/number.cpp new file mode 100644 index 00000000..6e34ae51 --- /dev/null +++ b/languages/cpp/templates/result-initialization/number.cpp @@ -0,0 +1 @@ + ${type} ${property} = 0; \ No newline at end of file diff --git a/languages/cpp/templates/result-initialization/primitive.cpp b/languages/cpp/templates/result-initialization/primitive.cpp new file mode 100644 index 00000000..23bbace7 --- /dev/null +++ b/languages/cpp/templates/result-initialization/primitive.cpp @@ -0,0 +1 @@ +${type} \ No newline at end of file diff --git a/languages/cpp/templates/result-initialization/string.cpp b/languages/cpp/templates/result-initialization/string.cpp new file mode 100644 index 00000000..2f0629ac --- /dev/null +++ b/languages/cpp/templates/result-initialization/string.cpp @@ -0,0 +1 @@ + ${type} ${property}; diff --git a/languages/cpp/templates/result-initialization/title.cpp b/languages/cpp/templates/result-initialization/title.cpp new file mode 100644 index 00000000..2a420b4b --- /dev/null +++ b/languages/cpp/templates/result-initialization/title.cpp @@ -0,0 +1 @@ +${Title} \ No newline at end of file diff --git a/languages/cpp/templates/result-instantiation/additionalProperties.cpp b/languages/cpp/templates/result-instantiation/additionalProperties.cpp new file mode 100644 index 00000000..af41c4a6 --- /dev/null +++ b/languages/cpp/templates/result-instantiation/additionalProperties.cpp @@ -0,0 +1,3 @@ + while (jsonResult.Variants().Next()) { + ${property}.insert(elements.Label(), elements.Current().${additional.type}.Value()); + } \ No newline at end of file diff --git a/languages/cpp/templates/result-instantiation/array.cpp b/languages/cpp/templates/result-instantiation/array.cpp new file mode 100644 index 00000000..464dea4a --- /dev/null +++ b/languages/cpp/templates/result-instantiation/array.cpp @@ -0,0 +1,4 @@ + auto index(jsonResult.Elements()); + while (index.Next() == true) { + ${property}.push_back(index.Current().Value()); + } diff --git a/languages/cpp/templates/result-instantiation/generic.cpp b/languages/cpp/templates/result-instantiation/generic.cpp new file mode 100644 index 00000000..8949a5fb --- /dev/null +++ b/languages/cpp/templates/result-instantiation/generic.cpp @@ -0,0 +1 @@ + ${property} = jsonResult.Value(); \ No newline at end of file diff --git a/languages/cpp/templates/result-instantiation/object.cpp b/languages/cpp/templates/result-instantiation/object.cpp index dcf0b333..c4569c3e 100644 --- a/languages/cpp/templates/result-instantiation/object.cpp +++ b/languages/cpp/templates/result-instantiation/object.cpp @@ -1,4 +1 @@ - WPEFramework::Core::ProxyType* resultPtr = new WPEFramework::Core::ProxyType(); - *resultPtr = WPEFramework::Core::ProxyType::Create(); - *(*resultPtr) = jsonResult; - *${property} = static_cast<${info.Title}_${title}>(resultPtr); +${properties} \ No newline at end of file diff --git a/languages/cpp/templates/result-instantiation/property.cpp b/languages/cpp/templates/result-instantiation/property.cpp new file mode 100644 index 00000000..3b54922c --- /dev/null +++ b/languages/cpp/templates/result-instantiation/property.cpp @@ -0,0 +1 @@ +${shape} ${if.non.object}${base.title}.${property} = jsonResult.${Property}.Value();${end.if.non.object} \ No newline at end of file diff --git a/languages/cpp/templates/result-instantiation/string.cpp b/languages/cpp/templates/result-instantiation/string.cpp index b6c9dcb5..886728a4 100644 --- a/languages/cpp/templates/result-instantiation/string.cpp +++ b/languages/cpp/templates/result-instantiation/string.cpp @@ -1,2 +1 @@ - FireboltSDK::JSON::String* strResult = new FireboltSDK::JSON::String(jsonResult); - *value = static_cast(strResult); + ${property} = jsonResult.Value().c_str(); \ No newline at end of file diff --git a/languages/cpp/templates/result-instantiation/sub-property/object-separator.cpp b/languages/cpp/templates/result-instantiation/sub-property/object-separator.cpp new file mode 100644 index 00000000..945c9b46 --- /dev/null +++ b/languages/cpp/templates/result-instantiation/sub-property/object-separator.cpp @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/languages/cpp/templates/result-instantiation/sub-property/object.cpp b/languages/cpp/templates/result-instantiation/sub-property/object.cpp new file mode 100644 index 00000000..c4569c3e --- /dev/null +++ b/languages/cpp/templates/result-instantiation/sub-property/object.cpp @@ -0,0 +1 @@ +${properties} \ No newline at end of file diff --git a/languages/cpp/templates/result-instantiation/sub-property/property.cpp b/languages/cpp/templates/result-instantiation/sub-property/property.cpp new file mode 100644 index 00000000..668f442c --- /dev/null +++ b/languages/cpp/templates/result-instantiation/sub-property/property.cpp @@ -0,0 +1 @@ +${shape} ${if.non.object}${base.title}.${property.dependency}${property} = jsonResult.${Property.dependency}${Property};${end.if.non.object} diff --git a/languages/cpp/templates/result-instantiation/sub-property/ref.h b/languages/cpp/templates/result-instantiation/sub-property/ref.h new file mode 100644 index 00000000..4da5b5d9 --- /dev/null +++ b/languages/cpp/templates/result-instantiation/sub-property/ref.h @@ -0,0 +1 @@ +${shape} \ No newline at end of file diff --git a/languages/cpp/templates/result-instantiation/sub-property/title.cpp b/languages/cpp/templates/result-instantiation/sub-property/title.cpp new file mode 100644 index 00000000..e2e80c7c --- /dev/null +++ b/languages/cpp/templates/result-instantiation/sub-property/title.cpp @@ -0,0 +1 @@ +${Title} diff --git a/languages/cpp/templates/result-instantiation/title.cpp b/languages/cpp/templates/result-instantiation/title.cpp new file mode 100644 index 00000000..2a420b4b --- /dev/null +++ b/languages/cpp/templates/result-instantiation/title.cpp @@ -0,0 +1 @@ +${Title} \ No newline at end of file diff --git a/languages/cpp/templates/result-instantiation/tuple.cpp b/languages/cpp/templates/result-instantiation/tuple.cpp new file mode 100644 index 00000000..58f79f1d --- /dev/null +++ b/languages/cpp/templates/result-instantiation/tuple.cpp @@ -0,0 +1,3 @@ + auto index(jsonResult.Elements()); + ${property}.first = index.Get(0); + ${property}.second = index.Get(1); \ No newline at end of file diff --git a/languages/cpp/templates/types/additionalProperties.h b/languages/cpp/templates/types/additionalProperties.h index baa50800..8ed6273c 100644 --- a/languages/cpp/templates/types/additionalProperties.h +++ b/languages/cpp/templates/types/additionalProperties.h @@ -1 +1 @@ -${title} value; \ No newline at end of file +using ${title} = std::unordered_map<${key}, ${type}>; \ No newline at end of file diff --git a/languages/cpp/templates/types/additionalPropertiesKey.h b/languages/cpp/templates/types/additionalPropertiesKey.h new file mode 100644 index 00000000..9c1a95b6 --- /dev/null +++ b/languages/cpp/templates/types/additionalPropertiesKey.h @@ -0,0 +1 @@ +std::string diff --git a/languages/cpp/templates/types/anyOf.c b/languages/cpp/templates/types/anyOf.c index bd2ba3e5..c6d1c815 100644 --- a/languages/cpp/templates/types/anyOf.c +++ b/languages/cpp/templates/types/anyOf.c @@ -1 +1 @@ -/* AnyOf is not supported in CPP: ${title} */ \ No newline at end of file +std::string \ No newline at end of file diff --git a/languages/cpp/templates/types/anyOfSchemaShape.h b/languages/cpp/templates/types/anyOfSchemaShape.h new file mode 100644 index 00000000..9a53ff94 --- /dev/null +++ b/languages/cpp/templates/types/anyOfSchemaShape.h @@ -0,0 +1 @@ + /* anyOf schema shape is supported right now */ diff --git a/languages/cpp/templates/types/const.h b/languages/cpp/templates/types/const.h index e69de29b..c6d1c815 100644 --- a/languages/cpp/templates/types/const.h +++ b/languages/cpp/templates/types/const.h @@ -0,0 +1 @@ +std::string \ No newline at end of file diff --git a/languages/cpp/templates/types/default.cpp b/languages/cpp/templates/types/default.cpp deleted file mode 100644 index 1f1fe89d..00000000 --- a/languages/cpp/templates/types/default.cpp +++ /dev/null @@ -1,4 +0,0 @@ -/* - * ${title} - ${description} - */ -${shape} diff --git a/languages/cpp/templates/types/default.h b/languages/cpp/templates/types/default.h new file mode 100644 index 00000000..a034b220 --- /dev/null +++ b/languages/cpp/templates/types/default.h @@ -0,0 +1 @@ +${shape} diff --git a/languages/cpp/templates/types/items.h b/languages/cpp/templates/types/items.h new file mode 100644 index 00000000..52268157 --- /dev/null +++ b/languages/cpp/templates/types/items.h @@ -0,0 +1 @@ +${title}${delimiter}, ${end.delimiter} \ No newline at end of file diff --git a/languages/cpp/templates/types/null.h b/languages/cpp/templates/types/null.h index e69de29b..ab6cc8f6 100644 --- a/languages/cpp/templates/types/null.h +++ b/languages/cpp/templates/types/null.h @@ -0,0 +1 @@ +void \ No newline at end of file diff --git a/languages/cpp/templates/types/object.h b/languages/cpp/templates/types/object.h index c7877332..88d35c97 100644 --- a/languages/cpp/templates/types/object.h +++ b/languages/cpp/templates/types/object.h @@ -1,5 +1,3 @@ struct ${title} { - ${properties} - }; \ No newline at end of file diff --git a/languages/cpp/templates/types/tuple.h b/languages/cpp/templates/types/tuple.h index ce217a83..b00d2610 100644 --- a/languages/cpp/templates/types/tuple.h +++ b/languages/cpp/templates/types/tuple.h @@ -1,2 +1,2 @@ /* ${title} */ -std::pair<${type},${type}> ${title}; +std::pair<${items}> ${title}; diff --git a/src/macrofier/engine.mjs b/src/macrofier/engine.mjs index 500bc3b1..889dfb34 100644 --- a/src/macrofier/engine.mjs +++ b/src/macrofier/engine.mjs @@ -1193,13 +1193,14 @@ function insertMethodMacros(template, methodObj, json, templates, examples = {}) const pullsParamsType = pullsParams ? types.getSchemaShape(pullsParams, json, { destination: state.destination, templateDir: state.typeTemplateDir, section: state.section }) : '' const serializedParams = flattenedMethod.params.map(param => types.getSchemaShape(param.schema, json, { templateDir: 'parameter-serialization', property: param.name, destination: state.destination, section: state.section, level: 1, skipTitleOnce: true })).join('\n') const resultInst = types.getSchemaShape(flattenedMethod.result.schema, json, { templateDir: 'result-instantiation', property: flattenedMethod.result.name, destination: state.destination, section: state.section, level: 1, skipTitleOnce: true }) // w/out level: 1, getSchemaShape skips anonymous types, like primitives + const resultInit = types.getSchemaShape(flattenedMethod.result.schema, json, { templateDir: 'result-initialization', property: flattenedMethod.result.name, destination: state.destination, section: state.section, level: 1, skipTitleOnce: true }) // w/out level: 1, getSchemaShape skips anonymous types, like primitives const serializedEventParams = event ? flattenedMethod.params.filter(p => p.name !== 'listen').map(param => types.getSchemaShape(param.schema, json, {templateDir: 'parameter-serialization', property: param.name, destination: state.destination, section: state.section, level: 1, skipTitleOnce: true })).join('\n') : '' // this was wrong... check when we merge if it was fixed - const callbackSerializedParams = event ? types.getSchemaShape(event.result.schema, json, { templateDir: 'parameter-serialization', property: result.name, destination: state.destination, section: state.section, level: 1, skipTitleOnce: true }) : '' - const callbackResultInst = event ? types.getSchemaShape(event, json, { name: event.name, templateDir: 'result-instantiation' }) : '' -// const callbackResponseInst = event ? types.getSchemaInstantiation(event, json, event.name, { instantiationType: 'callback.response' }) : '' + const callbackSerializedParams = event ? types.getSchemaShape(event.result.schema, json, { templateDir: 'callback-parameter-serialization', property: result.name, destination: state.destination, section: state.section, level: 1, skipTitleOnce: true }) : '' + + const callbackResultInst = event ? types.getSchemaShape(event.result.schema, json, { templateDir: 'callback-result-instantiation', property: result.name, destination: state.destination, section: state.section, level: 1, skipTitleOnce: true }) : '' // hmm... how is this different from callbackSerializedParams? i guess they get merged? - const callbackResponseInst = event ? types.getSchemaShape(event.result.schema, json, { templateDir: 'parameter-serialization', property: result.name, destination: state.destination, section: state.section, level: 1, skipTitleOnce: true }) : '' + const callbackResponseInst = event ? types.getSchemaShape(event.result.schema, json, { templateDir: 'callback-response-instantiation', property: result.name, destination: state.destination, section: state.section, level: 1, skipTitleOnce: true }) : '' const resultType = result.schema ? types.getSchemaType(result.schema, json, { name: result.name, templateDir: state.typeTemplateDir }) : '' const resultJsonType = result.schema ? types.getSchemaType(result.schema, json, { name: result.name, templateDir: 'json-types' }) : '' const resultParams = generateResultParams(result.schema, json, templates, { name: result.name}) @@ -1306,7 +1307,7 @@ function insertMethodMacros(template, methodObj, json, templates, examples = {}) .replace(/\$\{method\.pulls\.params.type\}/g, pullsParams ? pullsParams.title : '') .replace(/\$\{method\.pulls\.params\}/g, pullsParamsType) .replace(/\$\{method\.pulls\.param\.type\}/g, pullsForParamType) - .replace(/\$\{method\.pulls\.param\.json.type\}/g, pullsForParamJsonType) + .replace(/\$\{method\.pulls\.param\.json\.type\}/g, pullsForParamJsonType) .replace(/\$\{method\.setter\.for\}/g, setterFor) .replace(/\$\{method\.puller\}/g, pullerTemplate) // must be last!! .replace(/\$\{method\.setter\}/g, setterTemplate) // must be last!! diff --git a/src/macrofier/types.mjs b/src/macrofier/types.mjs index d6e53788..7bbf8b6a 100644 --- a/src/macrofier/types.mjs +++ b/src/macrofier/types.mjs @@ -87,7 +87,7 @@ const getXSchemaGroup = (schema, module) => { return group } -function insertSchemaMacros(content, schema, module, name, parent, property, recursive = true) { +function insertSchemaMacros(content, schema, module, name, parent, property, recursive = true, overrideRule = false, templateDir = 'types') { const title = name || schema.title || '' let moduleTitle = getXSchemaGroup(schema, module) @@ -97,7 +97,7 @@ function insertSchemaMacros(content, schema, module, name, parent, property, rec .replace(/\$\{TITLE\}/g, title.toUpperCase()) .replace(/\$\{property\}/g, property) .replace(/\$\{Property\}/g, capitalize(property)) - .replace(/\$\{if\.namespace\.notsame}(.*?)\$\{end\.if\.namespace\.notsame\}/g, (module.info.title !== parent) ? '$1' : '') + .replace(/\$\{if\.namespace\.notsame}(.*?)\$\{end\.if\.namespace\.notsame\}/g, (module.info.title !== (parent || moduleTitle)) ? '$1' : '') .replace(/\$\{parent\.title\}/g, parent) .replace(/\$\{parent\.Title\}/g, capitalize(parent)) .replace(/\$\{description\}/g, schema.description ? schema.description : '') @@ -109,14 +109,14 @@ function insertSchemaMacros(content, schema, module, name, parent, property, rec .replace(/\$\{info.TITLE\}/g, moduleTitle.toUpperCase()) if (recursive) { - content = content.replace(/\$\{type\}/g, getSchemaType(schema, module, { name: title, destination: state.destination, section: state.section, code: false, namespace: true })) + content = content.replace(/\$\{type\}/g, getSchemaType(schema, module, { templateDir: templateDir, destination: state.destination, section: state.section, code: false, namespace: true })) } return content } // TODO using JSON.stringify probably won't work for many languages... const insertConstMacros = (content, schema, module, name) => { - content = content.replace(/\$\{value\}/g, JSON.stringify(schema.const)) + content = content.replace(/\$\{value\}/g, (typeof schema.const === 'string' ? `'${schema.const}'` : schema.const)) return content } @@ -169,12 +169,18 @@ const insertObjectMacros = (content, schema, module, title, property, options) = if (schema.properties) { Object.entries(schema.properties).forEach(([name, prop], i) => { options2.property = name + let localizedProp = localizeDependencies(prop, module) + const subProperty = getTemplate(path.join(options2.templateDir, 'sub-property/object')) + options2.templateDir += subProperty ? '/sub-property' : '' + const objSeparator = getTemplate(path.join(options2.templateDir, 'object-separator')) + const schemaShape = getSchemaShape(prop, module, options2) + const type = getSchemaType(prop, module, options2) // don't push properties w/ unsupported types if (type) { - properties.push((i !== 0 ? indent : '') + template + let replacedTemplate = template .replace(/(^\s+)/g, '$1'.repeat(options2.level)) .replace(/\$\{property\}/g, name) .replace(/\$\{Property\}/g, capitalize(name)) @@ -184,7 +190,17 @@ const insertObjectMacros = (content, schema, module, title, property, options) = .replace(/\$\{description\}/g, prop.description || '') .replace(/\$\{summary\}/g, prop.description ? prop.description.split('\n')[0] : '') .replace(/\$\{delimiter\}(.*?)\$\{end.delimiter\}/gms, i === schema.properties.length - 1 ? '' : '$1') - .replace(/\$\{if\.optional\}(.*?)\$\{end\.if\.optional\}/gms, schema.required && schema.required.includes(name) ? '' : '$1')) + .replace(/\$\{if\.optional\}(.*?)\$\{end\.if\.optional\}/gms, schema.required && schema.required.includes(name) ? '' : '$1') + .replace(/\$\{if\.non\.object\}(.*?)\$\{end\.if\.non\.object\}/gms, (localizedProp.type === 'object') ? '' : '$1') + if (localizedProp.type === 'object') { + let baseTitle = title || schema.title + replacedTemplate = replacedTemplate + + .replace(/\$\{property.dependency\}/g, ((options.level > 1) ? '${property.dependency}' : '') + name + objSeparator) + .replace(/\$\{Property.dependency\}/g, ((options.level > 1) ? '${Property.dependency}' : '') + capitalize(name) + objSeparator) + .replace(/\$\{base.title\}/g, ((options.level <= 1) ? (baseTitle ? (baseTitle)[0].toLowerCase() + (baseTitle).substr(1) : '') : '')).trimEnd() + } + properties.push((i !== 0 ? indent : '') + replacedTemplate) } }) } @@ -199,7 +215,7 @@ const insertObjectMacros = (content, schema, module, title, property, options) = } // TODO: add language config feature for 'unknown' type let type; // = { type: "null" } - + if (schema.additionalProperties && (typeof schema.additionalProperties === 'object')) { type = schema.additionalProperties } @@ -212,7 +228,7 @@ const insertObjectMacros = (content, schema, module, title, property, options) = } }) } - + if (type) { options2.property = prop const schemaShape = getSchemaShape(type, module, options2) @@ -240,7 +256,7 @@ const insertObjectMacros = (content, schema, module, title, property, options) = } const insertArrayMacros = (content, schema, module, name) => { - return content + return content.replace(/\$\{json\.type\}/g, getSchemaType(schema.items, module, { templateDir: 'json-types', destination: state.destination, section: state.section, code: false, namespace: true })) } const insertTupleMacros = (content, schema, module, title, options) => { @@ -267,13 +283,13 @@ const insertTupleMacros = (content, schema, module, title, options) => { .replace(/\$\{if\.optional\}(.*?)\$\{end\.if\.optional\}/gms, '') } - content = content.replace(/\$\{properties\}/g, schema.items.map((prop, i) => doMacroWork(propTemplate, prop, i, propIndent)).join('\n')) - content = content.replace(/\$\{items\}/g, schema.items.map((prop, i) => doMacroWork(itemsTemplate, prop, i, itemsIndent)).join('\n')) - + content = content.replace(/\$\{properties\}/g, schema.items.map((prop, i) => doMacroWork(propTemplate, prop, i, propIndent)).join(tupleDelimiter)) + content = content.replace(/\$\{items\}/g, schema.items.map((prop, i) => doMacroWork(itemsTemplate, prop, i, itemsIndent)).join(tupleDelimiter)) + content = content.replace(/\$\{json\.type\}/g, getSchemaType(schema.items[0], module, { templateDir: 'json-types', destination: state.destination, section: state.section, code: false, namespace: true })) return content } -const getPrimitiveType = (type, templateDir) => { +const getPrimitiveType = (type, templateDir = 'types') => { const template = getTemplate(path.join(templateDir, type)) return primitives[type] || template } @@ -319,12 +335,12 @@ function getSchemaShape(schema = {}, module = {}, { templateDir = 'types', name if (level === 0 && !schema.title) { return '' } - + const suffix = destination && ('.' + destination.split('.').pop()) || '' - const theTitle = insertSchemaMacros(getTemplate(path.join(templateDir, 'title' + suffix)), schema, module, schema.title || name, parent, property, false) + const theTitle = insertSchemaMacros(getTemplate(path.join(templateDir, 'title' + suffix)), schema, module, schema.title || name, parent, property, false, templateDir) let result = level === 0 ? getTemplate(path.join(templateDir, 'default' + suffix)) : '${shape}' - + let genericTemplate = getTemplate(path.join(templateDir, 'generic' + suffix)) if (enums && level === 0 && schema.type === "string" && Array.isArray(schema.enum)) { result = getTemplate(path.join(templateDir, 'enum' + suffix)) return insertSchemaMacros(insertEnumMacros(result, schema, module, theTitle), schema, module, theTitle, parent, property) @@ -394,19 +410,19 @@ function getSchemaShape(schema = {}, module = {}, { templateDir = 'types', name } else if (schema.type === "array" && schema.items && isSupportedTuple(schema)) { // tuple - const shape = insertTupleMacros(getTemplate(path.join(templateDir, 'tuple' + suffix)), schema, module, theTitle, { level, templateDir, descriptions, destination, section, enums }) + const shape = insertTupleMacros(getTemplate(path.join(templateDir, 'tuple' + suffix)) || genericTemplate, schema, module, theTitle, { level, templateDir, descriptions, destination, section, enums }) result = result.replace(/\$\{shape\}/g, shape) - return insertSchemaMacros(result, schema, module, theTitle, parent, property) + return insertSchemaMacros(result, schema, module, theTitle, parent, property, true, templateDir) } else if (schema.type === "array" && schema.items && !Array.isArray(schema.items)) { // array const items = getSchemaShape(schema.items, module, { templateDir, name, parent, property, level, summary, descriptions, destination, enums: false }) - const shape = insertArrayMacros(getTemplate(path.join(templateDir, 'array' + suffix)), schema, module, items) + const shape = insertArrayMacros(getTemplate(path.join(templateDir, 'array' + suffix)) || genericTemplate, schema, module, items) result = result.replace(/\$\{shape\}/g, shape) - return insertSchemaMacros(result, schema, module, items, parent, property) + return insertSchemaMacros(result, schema, module, items, parent, property, true, templateDir) } else if (schema.type) { - const shape = insertPrimitiveMacros(getTemplate(path.join(templateDir, 'primitive' + suffix)), schema, module, theTitle, templateDir) + const shape = insertPrimitiveMacros(getTemplate(path.join(templateDir, 'primitive' + suffix) || genericTemplate), schema, module, theTitle, templateDir) result = result.replace(/\$\{shape\}/g, shape) if (level > 0) { return insertSchemaMacros(result, schema, module, theTitle, parent, property) @@ -471,7 +487,7 @@ function getSchemaType(schema, module, { destination, templateDir = 'types', lin const suffix = destination && ('.' + destination.split('.').pop()) || '' const namespaceStr = namespace ? getTemplate(path.join(templateDir, 'namespace' + suffix)) : '' - const theTitle = insertSchemaMacros(namespaceStr + getTemplate(path.join(templateDir, 'title' + suffix)), schema, module, schema.title || '', getXSchemaGroup(schema, module), '', false) + const theTitle = insertSchemaMacros(namespaceStr + getTemplate(path.join(templateDir, 'title' + suffix)), schema, module, schema.title, getXSchemaGroup(schema, module), '', false, templateDir) const allocatedProxy = event || result const title = schema.type === "object" || schema.enum ? true : false @@ -502,7 +518,7 @@ function getSchemaType(schema, module, { destination, templateDir = 'types', lin } } else if (schema.const) { - return (typeof schema.const === 'string' ? `'${schema.const}'` : schema.const) + return insertConstMacros(getTemplate(path.join(templateDir, 'const' + suffix)), schema, module) } else if (schema['x-method']) { const target = JSON.parse(JSON.stringify(module.methods.find(m => m.name === schema['x-method'].split('.').pop()))) @@ -572,7 +588,8 @@ function getSchemaType(schema, module, { destination, templateDir = 'types', lin } // Normal Array else if (!isTuple(schema)) { - template = insertArrayMacros(getTemplate(path.join(templateDir, 'array')), schema, module) + const baseDir = (templateDir !== 'json-types' ? 'types': templateDir) + template = insertArrayMacros(getTemplate(path.join(baseDir, 'array')), schema, module) template = insertSchemaMacros(template, schema.items, module, getSchemaType(schema.items, module, {destination, templateDir, link, title, code, asPath, event, result, expandEnums, baseUrl, namespace }), '', '', true) } else { @@ -616,7 +633,8 @@ function getSchemaType(schema, module, { destination, templateDir = 'types', lin else if (schema.type) { // TODO: this assumes that when type is an array of types, that it's one other primative & 'null', which isn't necessarily true. const schemaType = !Array.isArray(schema.type) ? schema.type : schema.type.find(t => t !== 'null') - const primitive = getPrimitiveType(schemaType, templateDir) + const baseDir = (templateDir !== 'json-types' ? 'types': templateDir) + const primitive = getPrimitiveType(schemaType, baseDir) const type = allocatedProxy ? allocatedPrimitiveProxies[schemaType] || primitive : primitive return wrap(type, code ? '`' : '') }