mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-30 16:00:01 +00:00
Disable RTTI and rework use in idl_gen_ts.cpp (#7474)
This commit is contained in:
@@ -369,6 +369,8 @@ else()
|
|||||||
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
|
$<$<BOOL:${FLATBUFFERS_STRICT_MODE}>:
|
||||||
-Werror # Treat all compiler warnings as errors
|
-Werror # Treat all compiler warnings as errors
|
||||||
|
|
||||||
|
-fno-rtti # Disable runtime type information
|
||||||
|
|
||||||
$<$<CXX_COMPILER_ID:GNU>:
|
$<$<CXX_COMPILER_ID:GNU>:
|
||||||
# False positive string overflow
|
# False positive string overflow
|
||||||
# https://github.com/google/flatbuffers/issues/7366
|
# https://github.com/google/flatbuffers/issues/7366
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ struct ImportDefinition {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum AnnotationType { kParam = 0, kType = 1, kReturns = 2 };
|
enum AnnotationType { kParam = 0, kType = 1, kReturns = 2 };
|
||||||
|
|
||||||
|
template<typename T> bool SupportsObjectAPI() { return false; }
|
||||||
|
|
||||||
|
// Structs can have Object API support.
|
||||||
|
template<> bool SupportsObjectAPI<StructDef>() { return true; }
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace ts {
|
namespace ts {
|
||||||
@@ -712,9 +718,9 @@ class TsGenerator : public BaseGenerator {
|
|||||||
return symbols_expression;
|
return symbols_expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename DefintionT>
|
template<typename DefinitionT>
|
||||||
ImportDefinition AddImport(import_set &imports, const Definition &dependent,
|
ImportDefinition AddImport(import_set &imports, const Definition &dependent,
|
||||||
const DefintionT &dependency) {
|
const DefinitionT &dependency) {
|
||||||
// The unique name of the dependency, fully qualified in its namespace.
|
// The unique name of the dependency, fully qualified in its namespace.
|
||||||
const std::string unique_name = GetTypeName(
|
const std::string unique_name = GetTypeName(
|
||||||
dependency, /*object_api = */ false, /*force_ns_wrap=*/true);
|
dependency, /*object_api = */ false, /*force_ns_wrap=*/true);
|
||||||
@@ -748,8 +754,9 @@ class TsGenerator : public BaseGenerator {
|
|||||||
// Strip the leading //
|
// Strip the leading //
|
||||||
.substr(2);
|
.substr(2);
|
||||||
flat_file_import_declarations_[file][import_name] = name;
|
flat_file_import_declarations_[file][import_name] = name;
|
||||||
|
|
||||||
if (parser_.opts.generate_object_based_api &&
|
if (parser_.opts.generate_object_based_api &&
|
||||||
typeid(dependency) == typeid(StructDef)) {
|
SupportsObjectAPI<DefinitionT>()) {
|
||||||
flat_file_import_declarations_[file][import_name + "T"] = object_name;
|
flat_file_import_declarations_[file][import_name + "T"] = object_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user