mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-10 07:06:26 +00:00
Rust reflection: simplify dependencies, fix Android build compatibility (#8512)
* flatbuffers Rust reflection: replace num with num-traits num crate is a wrapper over num-traits and a few other crates, that reexports the APIs from all of them. We only need num-traits. Signed-off-by: Marcin Radomski <dextero@google.com> * Rust reflection: drop dependency on stdint crate We only use it to get intmax_t for deriving alignment, which is an alias for `core::ffi::c_long` [1]. We can use that directly instead. [1] https://docs.rs/stdint/1.0.0/stdint/type.intmax_t.html Signed-off-by: Marcin Radomski <dextero@google.com> * Rust reflection: drop dependency on escape_string crate It's used to format a string used for debugging only, so we might as well use the builtin Debug representation of a string. Signed-off-by: Marcin Radomski <dextero@google.com> * Rust codegen: add derives on generated bitflags Otherwise it limits the use of structs generated for reflection.fbs in Rust reflection API. Signed-off-by: Marcin Radomski <dextero@google.com> * Rust flatbuffers: update bitflags dependency to 2.8 Signed-off-by: Marcin Radomski <dextero@google.com> * Rust codegen: use bitflags v2 API for converting from bits from_bits_unchecked was replaced with safe from_bits_retain. Signed-off-by: Marcin Radomski <dextero@google.com> * Regenerate Rust code after idl change Signed-off-by: Marcin Radomski <dextero@google.com> * Regenerate reflection_generated.rs With flatc --rust ../../../reflection/reflection.fbs Signed-off-by: Marcin Radomski <dextero@google.com> * ts/BUILD.bazel: add missing import Found by Buildifire presubmit: Function "sh_binary" is not global anymore and needs to be loaded from "@rules_shell//shell:sh_binary.bzl". Signed-off-by: Marcin Radomski <dextero@google.com> * Update expected value in generated_code_debug_prints_correctly test In bitflags v2, the debug string representation of enum values is different than it was in v1: Blue -> Color(Blue) (empty) -> LongEnum(0x0) This change adjusts the expected test value. Signed-off-by: Marcin Radomski <dextero@google.com> * Fix tests build on Swift 5.8 grpc-swift 1.4.1 depends on swift-nio-ssl 2.14.0+ [1]. swift-nio-ssl 2.29.1 published on 2025-01-30, introduced some code [2] that uses a "switch expression syntax" supported since Swift 5.9 [3]. Attempts to compile it with Swift 5.8 cause build errors. swift-nio-ssl project doesn't seem to support Swift 5.8. A commit from 2024-10-29 removes a "deprecated reference to a Swift 5.8 pipeline" [4]. swift-nio-ssl 2.29.0 is the last version that can be compiled with Swift 5.8. This commit pins it to that exact version. [1]66e27d7e84/Package.swift (L33)[2]3cb4d5ad12 (diff-bc1db1321ff689c2819245dcce1a3080554f0fc13f81b8d326c97e7d42717c8fR54)[3] https://github.com/swiftlang/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md [4]8a6b89d9a4--------- Signed-off-by: Marcin Radomski <dextero@google.com> Co-authored-by: Marcin Radomski <dextero@google.com>
This commit is contained in:
@@ -1767,19 +1767,19 @@ mod write_and_read_examples {
|
||||
assert_eq!(
|
||||
format!("{:.5?}", &m),
|
||||
"Monster { pos: Some(Vec3 { x: 1.00000, y: 2.00000, z: 3.00000, \
|
||||
test1: 3.00000, test2: Green, test3: Test { a: 5, b: 6 } }), \
|
||||
mana: 150, hp: 80, name: \"MyMonster\", \
|
||||
inventory: Some([0, 1, 2, 3, 4]), color: Blue, test_type: Monster, \
|
||||
test: Monster { pos: None, mana: 150, hp: 100, name: \"Fred\", \
|
||||
inventory: None, color: Blue, test_type: NONE, test: None, \
|
||||
test4: None, testarrayofstring: None, testarrayoftables: None, \
|
||||
enemy: None, testnestedflatbuffer: None, testempty: None, \
|
||||
testbool: false, testhashs32_fnv1: 0, testhashu32_fnv1: 0, \
|
||||
testhashs64_fnv1: 0, testhashu64_fnv1: 0, testhashs32_fnv1a: 0, \
|
||||
testhashu32_fnv1a: 0, testhashs64_fnv1a: 0, testhashu64_fnv1a: 0, \
|
||||
testarrayofbools: None, testf: 3.14159, testf2: 3.00000, testf3: 0.00000, \
|
||||
testarrayofstring2: None, testarrayofsortedstruct: None, flex: None, \
|
||||
test5: None, vector_of_longs: None, vector_of_doubles: None, \
|
||||
test1: 3.00000, test2: Color(Green), test3: Test { a: 5, b: 6 } \
|
||||
}), mana: 150, hp: 80, name: \"MyMonster\", inventory: Some([0, 1, \
|
||||
2, 3, 4]), color: Color(Blue), test_type: Monster, test: Monster { \
|
||||
pos: None, mana: 150, hp: 100, name: \"Fred\", inventory: None, \
|
||||
color: Color(Blue), test_type: NONE, test: None, test4: None, \
|
||||
testarrayofstring: None, testarrayoftables: None, enemy: None, \
|
||||
testnestedflatbuffer: None, testempty: None, testbool: false, \
|
||||
testhashs32_fnv1: 0, testhashu32_fnv1: 0, testhashs64_fnv1: 0, \
|
||||
testhashu64_fnv1: 0, testhashs32_fnv1a: 0, testhashu32_fnv1a: 0, \
|
||||
testhashs64_fnv1a: 0, testhashu64_fnv1a: 0, testarrayofbools: \
|
||||
None, testf: 3.14159, testf2: 3.00000, testf3: 0.00000, \
|
||||
testarrayofstring2: None, testarrayofsortedstruct: None, flex: \
|
||||
None, test5: None, vector_of_longs: None, vector_of_doubles: None, \
|
||||
parent_namespace_test: None, vector_of_referrables: None, \
|
||||
single_weak_reference: 0, vector_of_weak_references: None, \
|
||||
vector_of_strong_referrables: None, co_owning_reference: 0, \
|
||||
@@ -1787,22 +1787,22 @@ mod write_and_read_examples {
|
||||
vector_of_non_owning_references: None, any_unique_type: NONE, \
|
||||
any_unique: None, any_ambiguous_type: NONE, any_ambiguous: None, \
|
||||
vector_of_enums: None, signed_enum: None, \
|
||||
testrequirednestedflatbuffer: None, scalar_key_sorted_tables: None, \
|
||||
native_inline: None, long_enum_non_enum_default: (empty), \
|
||||
long_enum_normal_default: LongOne, nan_default: NaN, inf_default: \
|
||||
inf, positive_inf_default: inf, infinity_default: inf, \
|
||||
positive_infinity_default: inf, negative_inf_default: -inf, \
|
||||
negative_infinity_default: -inf, double_inf_default: inf }, \
|
||||
test4: Some([Test { a: 10, b: 20 }, Test { a: 30, b: 40 }]), \
|
||||
testarrayofstring: Some([\"test1\", \"test2\"]), \
|
||||
testarrayoftables: None, enemy: None, testnestedflatbuffer: None, \
|
||||
testempty: None, testbool: false, testhashs32_fnv1: 0, \
|
||||
testhashu32_fnv1: 0, testhashs64_fnv1: 0, testhashu64_fnv1: 0, \
|
||||
testhashs32_fnv1a: 0, testhashu32_fnv1a: 0, testhashs64_fnv1a: 0, \
|
||||
testhashu64_fnv1a: 0, testarrayofbools: None, testf: 3.14159, \
|
||||
testf2: 3.00000, testf3: 0.00000, testarrayofstring2: None, \
|
||||
testarrayofsortedstruct: None, flex: None, test5: None, \
|
||||
vector_of_longs: None, vector_of_doubles: None, \
|
||||
testrequirednestedflatbuffer: None, scalar_key_sorted_tables: \
|
||||
None, native_inline: None, long_enum_non_enum_default: \
|
||||
LongEnum(0x0), long_enum_normal_default: LongEnum(LongOne), \
|
||||
nan_default: NaN, inf_default: inf, positive_inf_default: inf, \
|
||||
infinity_default: inf, positive_infinity_default: inf, \
|
||||
negative_inf_default: -inf, negative_infinity_default: -inf, \
|
||||
double_inf_default: inf }, test4: Some([Test { a: 10, b: 20 }, \
|
||||
Test { a: 30, b: 40 }]), testarrayofstring: Some([\"test1\", \
|
||||
\"test2\"]), testarrayoftables: None, enemy: None, \
|
||||
testnestedflatbuffer: None, testempty: None, testbool: false, \
|
||||
testhashs32_fnv1: 0, testhashu32_fnv1: 0, testhashs64_fnv1: 0, \
|
||||
testhashu64_fnv1: 0, testhashs32_fnv1a: 0, testhashu32_fnv1a: 0, \
|
||||
testhashs64_fnv1a: 0, testhashu64_fnv1a: 0, testarrayofbools: \
|
||||
None, testf: 3.14159, testf2: 3.00000, testf3: 0.00000, \
|
||||
testarrayofstring2: None, testarrayofsortedstruct: None, flex: \
|
||||
None, test5: None, vector_of_longs: None, vector_of_doubles: None, \
|
||||
parent_namespace_test: None, vector_of_referrables: None, \
|
||||
single_weak_reference: 0, vector_of_weak_references: None, \
|
||||
vector_of_strong_referrables: None, co_owning_reference: 0, \
|
||||
@@ -1810,12 +1810,13 @@ mod write_and_read_examples {
|
||||
vector_of_non_owning_references: None, any_unique_type: NONE, \
|
||||
any_unique: None, any_ambiguous_type: NONE, any_ambiguous: None, \
|
||||
vector_of_enums: None, signed_enum: None, \
|
||||
testrequirednestedflatbuffer: None, scalar_key_sorted_tables: None, \
|
||||
native_inline: None, long_enum_non_enum_default: (empty), \
|
||||
long_enum_normal_default: LongOne, nan_default: NaN, inf_default: \
|
||||
inf, positive_inf_default: inf, infinity_default: inf, \
|
||||
positive_infinity_default: inf, negative_inf_default: -inf, \
|
||||
negative_infinity_default: -inf, double_inf_default: inf }"
|
||||
testrequirednestedflatbuffer: None, scalar_key_sorted_tables: \
|
||||
None, native_inline: None, long_enum_non_enum_default: \
|
||||
LongEnum(0x0), long_enum_normal_default: LongEnum(LongOne), \
|
||||
nan_default: NaN, inf_default: inf, positive_inf_default: inf, \
|
||||
infinity_default: inf, positive_infinity_default: inf, \
|
||||
negative_inf_default: -inf, negative_infinity_default: -inf, \
|
||||
double_inf_default: inf }"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user