mirror of
https://github.com/google/flatbuffers.git
synced 2026-11-13 15:36:21 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e38e7aa00c |
@@ -83,11 +83,6 @@ macro_rules! impl_push_for_endian_scalar {
|
||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||
emplace_scalar::<$ty>(dst, *self);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn alignment() -> PushAlignment {
|
||||
PushAlignment::new(size_of::<$ty>())
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -103,23 +98,3 @@ impl_push_for_endian_scalar!(u64);
|
||||
impl_push_for_endian_scalar!(i64);
|
||||
impl_push_for_endian_scalar!(f32);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2176,6 +2176,7 @@ class JavaGenerator : public BaseGenerator {
|
||||
if (field.deprecated) continue;
|
||||
if (field.value.type.base_type == BASE_TYPE_UTYPE) continue;
|
||||
if (field.value.type.element == BASE_TYPE_UTYPE) continue;
|
||||
const auto get_field = namer_.Method("get", field);
|
||||
|
||||
code += " this." + namer_.Field(field) + " = ";
|
||||
const auto type_name =
|
||||
|
||||
@@ -1141,6 +1141,7 @@ class SwiftGenerator : public BaseGenerator {
|
||||
it != struct_def.fields.vec.end(); ++it) {
|
||||
const auto& field = **it;
|
||||
if (field.deprecated) continue;
|
||||
const auto offset = NumToString(field.value.offset);
|
||||
|
||||
code_.SetValue("FIELDVAR", namer_.Variable(field));
|
||||
code_.SetValue("VALUETYPE", GenerateVerifierType(field));
|
||||
|
||||
Reference in New Issue
Block a user