Implement (shared) attribute for C++ (#5157)

* Implement native_shared attribute for C++.

Fixes #5141. See also #5145.

* Refine comment in idl.h

* Also refine docs

* Revert "Also refine docs"

This reverts commit 09dab7b45c.

* Also refine docs again.

* grumble
This commit is contained in:
iceboy
2019-02-11 11:53:45 -08:00
committed by Wouter van Oortmerssen
parent cf47f27164
commit 60e94cf083
4 changed files with 31 additions and 3 deletions

View File

@@ -767,6 +767,9 @@ CheckedError Parser::ParseField(StructDef &struct_def) {
return Error("'key' field must be string or scalar type");
}
}
field->shared = field->attributes.Lookup("shared") != nullptr;
if (field->shared && field->value.type.base_type != BASE_TYPE_STRING)
return Error("shared can only be defined on strings");
auto field_native_custom_alloc =
field->attributes.Lookup("native_custom_alloc");
@@ -777,7 +780,7 @@ CheckedError Parser::ParseField(StructDef &struct_def) {
field->native_inline = field->attributes.Lookup("native_inline") != nullptr;
if (field->native_inline && !IsStruct(field->value.type))
return Error("native_inline can only be defined on structs'");
return Error("native_inline can only be defined on structs");
auto nested = field->attributes.Lookup("nested_flatbuffer");
if (nested) {