mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-02 22:48:18 +00:00
Using proper symbol name for reexport (#6021)
Co-authored-by: Kamil Rojewski <kamil.rojewski@gmail.com>
This commit is contained in:
@@ -134,12 +134,14 @@ class JsTsGenerator : public BaseGenerator {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unordered_set<std::string> imported;
|
||||||
|
|
||||||
std::string &code = *code_ptr;
|
std::string &code = *code_ptr;
|
||||||
for (auto it = reexports.begin(); it != reexports.end(); ++it) {
|
for (auto it = reexports.begin(); it != reexports.end(); ++it) {
|
||||||
const auto &file = *it;
|
const auto &file = *it;
|
||||||
const auto basename =
|
const auto basename =
|
||||||
flatbuffers::StripPath(flatbuffers::StripExtension(file.first));
|
flatbuffers::StripPath(flatbuffers::StripExtension(file.first));
|
||||||
if (basename != file_name_) {
|
if (basename != file_name_ && imported.find(file.second.symbol) == imported.end()) {
|
||||||
if (imported_files.find(file.first) == imported_files.end()) {
|
if (imported_files.find(file.first) == imported_files.end()) {
|
||||||
code += GenPrefixedImport(file.first, basename);
|
code += GenPrefixedImport(file.first, basename);
|
||||||
imported_files.emplace(file.first);
|
imported_files.emplace(file.first);
|
||||||
@@ -155,6 +157,8 @@ class JsTsGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
code += file.second.symbol + ";\n";
|
code += file.second.symbol + ";\n";
|
||||||
if (!file.second.target_namespace.empty()) { code += "}\n"; }
|
if (!file.second.target_namespace.empty()) { code += "}\n"; }
|
||||||
|
|
||||||
|
imported.emplace(file.second.symbol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -366,7 +370,7 @@ class JsTsGenerator : public BaseGenerator {
|
|||||||
code += (it + 1) != enum_def.Vals().end() ? ",\n" : "\n";
|
code += (it + 1) != enum_def.Vals().end() ? ",\n" : "\n";
|
||||||
|
|
||||||
if (ev.union_type.struct_def) {
|
if (ev.union_type.struct_def) {
|
||||||
ReexportDescription desc = { ev.name,
|
ReexportDescription desc = { ev.union_type.struct_def->name,
|
||||||
GetNameSpace(*ev.union_type.struct_def),
|
GetNameSpace(*ev.union_type.struct_def),
|
||||||
GetNameSpace(enum_def) };
|
GetNameSpace(enum_def) };
|
||||||
reexports.insert(
|
reexports.insert(
|
||||||
|
|||||||
Reference in New Issue
Block a user