mirror of
https://github.com/google/flatbuffers.git
synced 2026-11-08 13:19:10 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f4f0497ea |
@@ -75,17 +75,6 @@ extension Array where Element == Package.Dependency {
|
|||||||
.package(
|
.package(
|
||||||
url: "https://github.com/grpc/grpc-swift-nio-transport.git",
|
url: "https://github.com/grpc/grpc-swift-nio-transport.git",
|
||||||
from: "2.0.0"),
|
from: "2.0.0"),
|
||||||
// swift-crypto arrives through grpc-swift-nio-transport -> swift-nio-ssl
|
|
||||||
// and is otherwise resolved afresh on every build, because this package
|
|
||||||
// ships no Package.resolved. 5.x asks for swift-tools-version 6.2, so only
|
|
||||||
// the 6.2 CI job selects it - and then fails to compile it, because 5.x
|
|
||||||
// uses `@nonexhaustive`, which the 6.2.x toolchains do not accept yet.
|
|
||||||
// Stay on the last 4.x release that still builds with every toolchain in
|
|
||||||
// the Swift CI matrix (4.3.0 declares swift-tools-version 6.0; 4.4+ asks
|
|
||||||
// for 6.1 and would drop the 6.0 job).
|
|
||||||
.package(
|
|
||||||
url: "https://github.com/apple/swift-crypto.git",
|
|
||||||
"4.0.0" ..< "4.4.0"),
|
|
||||||
]
|
]
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -504,6 +504,7 @@ grpc::string GenerateInterface(grpc_generator::File* file,
|
|||||||
const grpc::string& filename) {
|
const grpc::string& filename) {
|
||||||
grpc::string output;
|
grpc::string output;
|
||||||
|
|
||||||
|
std::set<grpc::string> generated_functions;
|
||||||
std::map<grpc::string, grpc::string> vars;
|
std::map<grpc::string, grpc::string> vars;
|
||||||
|
|
||||||
vars["PATH"] = file->package();
|
vars["PATH"] = file->package();
|
||||||
|
|||||||
@@ -722,6 +722,8 @@ void BinaryAnnotator::BuildTable(const uint64_t table_offset,
|
|||||||
BinaryRegionComment offset_field_comment;
|
BinaryRegionComment offset_field_comment;
|
||||||
offset_field_comment.type = BinaryRegionCommentType::TableOffsetField;
|
offset_field_comment.type = BinaryRegionCommentType::TableOffsetField;
|
||||||
offset_field_comment.name = field->name()->c_str();
|
offset_field_comment.name = field->name()->c_str();
|
||||||
|
const std::string offset_prefix =
|
||||||
|
"offset to field `" + std::string(field->name()->c_str()) + "`";
|
||||||
|
|
||||||
// Validate any field that isn't inline (i.e., non-structs).
|
// Validate any field that isn't inline (i.e., non-structs).
|
||||||
if (!IsInlineField(field)) {
|
if (!IsInlineField(field)) {
|
||||||
|
|||||||
@@ -2737,6 +2737,7 @@ class CppGenerator : public BaseGenerator {
|
|||||||
if (!field.IsScalarOptional()) {
|
if (!field.IsScalarOptional()) {
|
||||||
const bool is_scalar = IsScalar(type.base_type);
|
const bool is_scalar = IsScalar(type.base_type);
|
||||||
std::string accessor;
|
std::string accessor;
|
||||||
|
std::string offset_size = "";
|
||||||
if (is_scalar) {
|
if (is_scalar) {
|
||||||
accessor = "GetField<";
|
accessor = "GetField<";
|
||||||
} else if (IsStruct(type)) {
|
} else if (IsStruct(type)) {
|
||||||
@@ -2814,6 +2815,7 @@ class CppGenerator : public BaseGenerator {
|
|||||||
|
|
||||||
void GenTableFieldType(const FieldDef& field) {
|
void GenTableFieldType(const FieldDef& field) {
|
||||||
const auto& type = field.value.type;
|
const auto& type = field.value.type;
|
||||||
|
const auto offset_str = GenFieldOffsetName(field);
|
||||||
if (!field.IsScalarOptional()) {
|
if (!field.IsScalarOptional()) {
|
||||||
std::string afterptr = " *" + NullableExtension();
|
std::string afterptr = " *" + NullableExtension();
|
||||||
code_.SetValue("FIELD_TYPE",
|
code_.SetValue("FIELD_TYPE",
|
||||||
|
|||||||
@@ -1149,6 +1149,8 @@ static bool GenerateDart(const Parser& parser, const std::string& path,
|
|||||||
|
|
||||||
static std::string DartMakeRule(const Parser& parser, const std::string& path,
|
static std::string DartMakeRule(const Parser& parser, const std::string& path,
|
||||||
const std::string& file_name) {
|
const std::string& file_name) {
|
||||||
|
auto filebase =
|
||||||
|
flatbuffers::StripPath(flatbuffers::StripExtension(file_name));
|
||||||
dart::DartGenerator generator(parser, path, file_name);
|
dart::DartGenerator generator(parser, path, file_name);
|
||||||
auto make_rule = generator.Filename("") + ": ";
|
auto make_rule = generator.Filename("") + ": ";
|
||||||
|
|
||||||
|
|||||||
@@ -966,6 +966,8 @@ class KotlinGenerator : public BaseGenerator {
|
|||||||
auto bbgetter = ByteBufferGetter(field.value.type, "bb");
|
auto bbgetter = ByteBufferGetter(field.value.type, "bb");
|
||||||
auto ucast = CastToUsigned(field);
|
auto ucast = CastToUsigned(field);
|
||||||
auto offset_val = NumToString(field.value.offset);
|
auto offset_val = NumToString(field.value.offset);
|
||||||
|
auto offset_prefix =
|
||||||
|
"val o = __offset(" + offset_val + "); return o != 0 ? ";
|
||||||
auto value_base_type = field.value.type.base_type;
|
auto value_base_type = field.value.type.base_type;
|
||||||
// Most field accessors need to retrieve and test the field offset
|
// Most field accessors need to retrieve and test the field offset
|
||||||
// first, this is the offset value for that:
|
// first, this is the offset value for that:
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ class KotlinKMPGenerator : public BaseGenerator {
|
|||||||
|
|
||||||
std::string code =
|
std::string code =
|
||||||
"// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n";
|
"// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n";
|
||||||
|
auto qualified = ns.GetFullyQualifiedName("");
|
||||||
std::string namespace_name = namer_.Namespace(ns);
|
std::string namespace_name = namer_.Namespace(ns);
|
||||||
if (!namespace_name.empty()) {
|
if (!namespace_name.empty()) {
|
||||||
code += "package " + namespace_name;
|
code += "package " + namespace_name;
|
||||||
@@ -340,6 +341,7 @@ class KotlinKMPGenerator : public BaseGenerator {
|
|||||||
std::string GenDefaultBufferValue(const FieldDef& field) const {
|
std::string GenDefaultBufferValue(const FieldDef& field) const {
|
||||||
auto& value = field.value;
|
auto& value = field.value;
|
||||||
auto base_type = value.type.base_type;
|
auto base_type = value.type.base_type;
|
||||||
|
auto field_name = field.name;
|
||||||
std::string suffix = IsScalar(base_type) ? LiteralSuffix(value.type) : "";
|
std::string suffix = IsScalar(base_type) ? LiteralSuffix(value.type) : "";
|
||||||
if (field.IsScalarOptional()) {
|
if (field.IsScalarOptional()) {
|
||||||
return "null";
|
return "null";
|
||||||
@@ -371,6 +373,7 @@ class KotlinKMPGenerator : public BaseGenerator {
|
|||||||
std::string GenDefaultValue(const FieldDef& field) const {
|
std::string GenDefaultValue(const FieldDef& field) const {
|
||||||
auto& value = field.value;
|
auto& value = field.value;
|
||||||
auto base_type = value.type.base_type;
|
auto base_type = value.type.base_type;
|
||||||
|
auto field_name = field.name;
|
||||||
std::string suffix = LiteralSuffix(value.type);
|
std::string suffix = LiteralSuffix(value.type);
|
||||||
if (field.IsScalarOptional()) {
|
if (field.IsScalarOptional()) {
|
||||||
return "null";
|
return "null";
|
||||||
@@ -1079,6 +1082,8 @@ class KotlinKMPGenerator : public BaseGenerator {
|
|||||||
auto return_type = GetterReturnType(field);
|
auto return_type = GetterReturnType(field);
|
||||||
auto bbgetter = ByteBufferGetter(field.value.type, "bb");
|
auto bbgetter = ByteBufferGetter(field.value.type, "bb");
|
||||||
auto offset_val = NumToString(field.value.offset);
|
auto offset_val = NumToString(field.value.offset);
|
||||||
|
auto offset_prefix =
|
||||||
|
"val o = offset(" + offset_val + "); return o != 0 ? ";
|
||||||
auto value_base_type = field.value.type.base_type;
|
auto value_base_type = field.value.type.base_type;
|
||||||
// Most field accessors need to retrieve and test the field offset
|
// Most field accessors need to retrieve and test the field offset
|
||||||
// first, this is the offset value for that:
|
// first, this is the offset value for that:
|
||||||
|
|||||||
@@ -2010,6 +2010,8 @@ class PythonGenerator : public BaseGenerator {
|
|||||||
void InitializeFromPackedBuf(const StructDef& struct_def,
|
void InitializeFromPackedBuf(const StructDef& struct_def,
|
||||||
std::string* code_ptr) const {
|
std::string* code_ptr) const {
|
||||||
auto& code = *code_ptr;
|
auto& code = *code_ptr;
|
||||||
|
const auto struct_var = namer_.Variable(struct_def);
|
||||||
|
const auto struct_type = namer_.Type(struct_def);
|
||||||
|
|
||||||
code += GenIndents(1) + "@classmethod";
|
code += GenIndents(1) + "@classmethod";
|
||||||
code += GenIndents(1) + "def InitFromPackedBuf(cls, buf, pos=0):";
|
code += GenIndents(1) + "def InitFromPackedBuf(cls, buf, pos=0):";
|
||||||
|
|||||||
@@ -787,6 +787,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GenTableReaderFields(const FieldDef& field) {
|
void GenTableReaderFields(const FieldDef& field) {
|
||||||
|
const auto offset = NumToString(field.value.offset);
|
||||||
const auto field_field = namer_.Field(field);
|
const auto field_field = namer_.Field(field);
|
||||||
const auto type = GenType(field.value.type);
|
const auto type = GenType(field.value.type);
|
||||||
code_.SetValue("FIELDVAR", namer_.Variable(field));
|
code_.SetValue("FIELDVAR", namer_.Variable(field));
|
||||||
@@ -1381,6 +1382,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
const auto& field = **it;
|
const auto& field = **it;
|
||||||
if (field.deprecated) continue;
|
if (field.deprecated) continue;
|
||||||
|
|
||||||
|
const auto type = GenType(field.value.type);
|
||||||
code_.SetValue("FIELDVAR", namer_.Variable(field));
|
code_.SetValue("FIELDVAR", namer_.Variable(field));
|
||||||
if (IsArray(field.value.type)) {
|
if (IsArray(field.value.type)) {
|
||||||
code_.SetValue(
|
code_.SetValue(
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
SkipDir::OutputPathAndTrailingPathSeparator);
|
SkipDir::OutputPathAndTrailingPathSeparator);
|
||||||
symbolic_name = definition.defined_namespace->components.back();
|
symbolic_name = definition.defined_namespace->components.back();
|
||||||
} else {
|
} else {
|
||||||
|
auto def_mod_name = namer_.File(definition, SkipFile::SuffixAndExtension);
|
||||||
symbolic_name = file_name_;
|
symbolic_name = file_name_;
|
||||||
filepath = path_ + symbolic_name + ".ts";
|
filepath = path_ + symbolic_name + ".ts";
|
||||||
}
|
}
|
||||||
@@ -285,10 +286,12 @@ class TsGenerator : public BaseGenerator {
|
|||||||
auto base_name =
|
auto base_name =
|
||||||
namer_.Directories(it.second.ns->components, SkipDir::OutputPath) +
|
namer_.Directories(it.second.ns->components, SkipDir::OutputPath) +
|
||||||
base_file_name;
|
base_file_name;
|
||||||
|
auto ts_file_path = base_name + ".ts";
|
||||||
auto base_name_rel = std::string("./");
|
auto base_name_rel = std::string("./");
|
||||||
base_name_rel +=
|
base_name_rel +=
|
||||||
namer_.Directories(rel_components, SkipDir::OutputPath);
|
namer_.Directories(rel_components, SkipDir::OutputPath);
|
||||||
base_name_rel += base_file_name;
|
base_name_rel += base_file_name;
|
||||||
|
auto ts_file_path_rel = base_name_rel + ".ts";
|
||||||
auto type_name = def.first;
|
auto type_name = def.first;
|
||||||
auto fully_qualified_type_name =
|
auto fully_qualified_type_name =
|
||||||
it.second.ns->GetFullyQualifiedName(type_name);
|
it.second.ns->GetFullyQualifiedName(type_name);
|
||||||
@@ -308,6 +311,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
const auto child_ns_level = it.second.ns->components.size() + 1;
|
const auto child_ns_level = it.second.ns->components.size() + 1;
|
||||||
for (const auto& it2 : ns_defs_) {
|
for (const auto& it2 : ns_defs_) {
|
||||||
if (it2.second.ns->components.size() != child_ns_level) continue;
|
if (it2.second.ns->components.size() != child_ns_level) continue;
|
||||||
|
auto ts_file_path = it2.second.path + ".ts";
|
||||||
code += "export * as " + it2.second.symbolic_name + " from './";
|
code += "export * as " + it2.second.symbolic_name + " from './";
|
||||||
int count = it2.second.ns->components.size() > 1 ? 2 : 1;
|
int count = it2.second.ns->components.size() > 1 ? 2 : 1;
|
||||||
std::vector<std::string> rel_path;
|
std::vector<std::string> rel_path;
|
||||||
@@ -1172,6 +1176,7 @@ class TsGenerator : public BaseGenerator {
|
|||||||
if (union_type.enum_def) {
|
if (union_type.enum_def) {
|
||||||
const auto& enum_def = *union_type.enum_def;
|
const auto& enum_def = *union_type.enum_def;
|
||||||
const auto enum_type = AddImport(imports, dependent, enum_def).name;
|
const auto enum_type = AddImport(imports, dependent, enum_def).name;
|
||||||
|
const std::string union_accessor = "this." + field_name;
|
||||||
|
|
||||||
const auto union_has_string = UnionHasStringType(enum_def);
|
const auto union_has_string = UnionHasStringType(enum_def);
|
||||||
const auto field_binded_method = "this." + field_name + ".bind(this)";
|
const auto field_binded_method = "this." + field_name + ".bind(this)";
|
||||||
|
|||||||
Reference in New Issue
Block a user