Skip to content

Commit

Permalink
[gbc c++] Do not apply export attrib. to generics
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ara-ayvazyan authored and chwarr committed Nov 15, 2017
1 parent c586483 commit cfbd417
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion compiler/src/Language/Bond/Codegen/Cpp/Reflection_h.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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|<boost::mpl::list#{classParams} >|]

Expand Down
10 changes: 5 additions & 5 deletions examples/cpp/core/dll/dll.bond
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
namespace examples.dll

struct Item
struct Item<T>
{
0: string str = "default string value";
1: list<uint32> numbers;
0: string str = "default string value";
1: list<T> numbers;
}

struct MyStruct
{
0: vector<Item> items;
1: bonded<Item> item;
0: vector<Item<uint32>> items;
1: bonded<Item<uint32>> item;
}
6 changes: 3 additions & 3 deletions examples/cpp/core/dll/using_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ int main()
obj.items.resize(1);
obj.items[0].numbers.push_back(13);

Item item;
Item<uint32_t> item;

item.numbers.push_back(11);
obj.item = bond::bonded<Item>(item);
obj.item = bond::bonded<Item<uint32_t>>(item);

// Serialize
bond::OutputBuffer buffer;
Expand All @@ -47,7 +47,7 @@ int main()
bond::CompactBinaryReader<bond::InputBuffer> reader(data);
bond::Deserialize(reader, obj2);

Item item2;
Item<uint32_t> item2;

obj2.item.Deserialize(item2);

Expand Down

0 comments on commit cfbd417

Please sign in to comment.