mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-03 20:31:23 +00:00
Referring to types from other namespaces in C++ now works correctly.
Previously, it would ignore the fact that the type comes from a different namespace. Now they are pre-declared in their own namespace, and referenced with a qualified name if necessary. Bug: 16851682 Change-Id: I5cb625b86d28e7436b9e93c70a0fa16a600d9884 Tested: on Linux
This commit is contained in:
@@ -647,6 +647,7 @@ StructDef *Parser::LookupCreateStruct(const std::string &name) {
|
||||
structs_.Add(name, struct_def);
|
||||
struct_def->name = name;
|
||||
struct_def->predecl = true;
|
||||
struct_def->defined_namespace = namespaces_.back();
|
||||
}
|
||||
return struct_def;
|
||||
}
|
||||
@@ -838,9 +839,10 @@ bool Parser::Parse(const char *source, const char *filepath) {
|
||||
while (token_ != kTokenEof) {
|
||||
if (token_ == kTokenNameSpace) {
|
||||
Next();
|
||||
name_space_.clear();
|
||||
auto ns = new Namespace();
|
||||
namespaces_.push_back(ns);
|
||||
for (;;) {
|
||||
name_space_.push_back(attribute_);
|
||||
ns->components.push_back(attribute_);
|
||||
Expect(kTokenIdentifier);
|
||||
if (!IsNext('.')) break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user