From cfbd4170e04a7ff6bdc456cbce86b901dfc18ef0 Mon Sep 17 00:00:00 2001 From: Ara Ayvazyan Date: Wed, 15 Nov 2017 14:26:20 -0800 Subject: [PATCH] [gbc c++] Do not apply export attrib. to generics Currently, the `--export-attribute` is used to mark all static `bond::Metadata` fields in a compile-time `Schema` object, including when the type is a template, which is not correct. This change has `gbc` skip the attribute in such cases. --- compiler/src/Language/Bond/Codegen/Cpp/Reflection_h.hs | 3 ++- examples/cpp/core/dll/dll.bond | 10 +++++----- examples/cpp/core/dll/using_dll.cpp | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/compiler/src/Language/Bond/Codegen/Cpp/Reflection_h.hs b/compiler/src/Language/Bond/Codegen/Cpp/Reflection_h.hs index 54c653a36e..66e88d8828 100644 --- a/compiler/src/Language/Bond/Codegen/Cpp/Reflection_h.hs +++ b/compiler/src/Language/Bond/Codegen/Cpp/Reflection_h.hs @@ -72,10 +72,11 @@ reflection_h export_attribute cpp file imports declarations = ("_reflection.h", className = CPP.className s - export_attr = optional (\a -> [lt|#{a} + export_attr = onlyNonTemplate $ optional (\a -> [lt|#{a} |]) export_attribute onlyTemplate x = if null declParams then mempty else x + onlyNonTemplate x = if null declParams then x else mempty metadataInitArgs = onlyTemplate [lt||] diff --git a/examples/cpp/core/dll/dll.bond b/examples/cpp/core/dll/dll.bond index 1eee33cd90..8631eae2d0 100644 --- a/examples/cpp/core/dll/dll.bond +++ b/examples/cpp/core/dll/dll.bond @@ -1,13 +1,13 @@ namespace examples.dll -struct Item +struct Item { - 0: string str = "default string value"; - 1: list numbers; + 0: string str = "default string value"; + 1: list numbers; } struct MyStruct { - 0: vector items; - 1: bonded item; + 0: vector> items; + 1: bonded> item; } diff --git a/examples/cpp/core/dll/using_dll.cpp b/examples/cpp/core/dll/using_dll.cpp index 9721b94169..ab2326f5a3 100644 --- a/examples/cpp/core/dll/using_dll.cpp +++ b/examples/cpp/core/dll/using_dll.cpp @@ -29,10 +29,10 @@ int main() obj.items.resize(1); obj.items[0].numbers.push_back(13); - Item item; + Item item; item.numbers.push_back(11); - obj.item = bond::bonded(item); + obj.item = bond::bonded>(item); // Serialize bond::OutputBuffer buffer; @@ -47,7 +47,7 @@ int main() bond::CompactBinaryReader reader(data); bond::Deserialize(reader, obj2); - Item item2; + Item item2; obj2.item.Deserialize(item2);