mirror of
https://github.com/google/flatbuffers.git
synced 2026-11-07 20:59:10 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5eb190f000 | ||
|
|
f58d5768f1 | ||
|
|
7af1efe4b2 |
@@ -75,6 +75,17 @@ 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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,11 @@ macro_rules! impl_push_for_endian_scalar {
|
|||||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||||
emplace_scalar::<$ty>(dst, *self);
|
emplace_scalar::<$ty>(dst, *self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn alignment() -> PushAlignment {
|
||||||
|
PushAlignment::new(size_of::<$ty>())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -98,3 +103,23 @@ impl_push_for_endian_scalar!(u64);
|
|||||||
impl_push_for_endian_scalar!(i64);
|
impl_push_for_endian_scalar!(i64);
|
||||||
impl_push_for_endian_scalar!(f32);
|
impl_push_for_endian_scalar!(f32);
|
||||||
impl_push_for_endian_scalar!(f64);
|
impl_push_for_endian_scalar!(f64);
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn endian_scalar_push_alignment_matches_wire_size() {
|
||||||
|
assert_eq!(<bool as Push>::alignment().value(), 1);
|
||||||
|
assert_eq!(<u8 as Push>::alignment().value(), 1);
|
||||||
|
assert_eq!(<i8 as Push>::alignment().value(), 1);
|
||||||
|
assert_eq!(<u16 as Push>::alignment().value(), 2);
|
||||||
|
assert_eq!(<i16 as Push>::alignment().value(), 2);
|
||||||
|
assert_eq!(<u32 as Push>::alignment().value(), 4);
|
||||||
|
assert_eq!(<i32 as Push>::alignment().value(), 4);
|
||||||
|
assert_eq!(<f32 as Push>::alignment().value(), 4);
|
||||||
|
assert_eq!(<u64 as Push>::alignment().value(), 8);
|
||||||
|
assert_eq!(<i64 as Push>::alignment().value(), 8);
|
||||||
|
assert_eq!(<f64 as Push>::alignment().value(), 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace Example {
|
|||||||
struct MonsterBinarySchema {
|
struct MonsterBinarySchema {
|
||||||
static const uint8_t *data() {
|
static const uint8_t *data() {
|
||||||
// Buffer containing the binary schema.
|
// Buffer containing the binary schema.
|
||||||
static const uint8_t bfbsData[14520] = {
|
alignas(uint64_t) static const uint8_t bfbsData[14520] = {
|
||||||
0x20,0x00,0x00,0x00,0x42,0x46,0x42,0x53,0x00,0x00,0x00,0x00,0x14,0x00,0x20,0x00,0x04,0x00,0x08,0x00,
|
0x20,0x00,0x00,0x00,0x42,0x46,0x42,0x53,0x00,0x00,0x00,0x00,0x14,0x00,0x20,0x00,0x04,0x00,0x08,0x00,
|
||||||
0x0C,0x00,0x10,0x00,0x14,0x00,0x18,0x00,0x00,0x00,0x1C,0x00,0x14,0x00,0x00,0x00,0x58,0x00,0x00,0x00,
|
0x0C,0x00,0x10,0x00,0x14,0x00,0x18,0x00,0x00,0x00,0x1C,0x00,0x14,0x00,0x00,0x00,0x58,0x00,0x00,0x00,
|
||||||
0x34,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x70,0x0D,0x00,0x00,0x08,0x00,0x00,0x00,
|
0x34,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x70,0x0D,0x00,0x00,0x08,0x00,0x00,0x00,
|
||||||
|
|||||||
Reference in New Issue
Block a user