mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-30 09:20:00 +00:00
fix(flatbuffers): use manual impl Default for struct object types (#8947)
* fix(flatbuffers): use manual impl Default for struct object types * fix: handle bool and float zero literals in struct object Default impl * fix: regenerate all test bindings with generate_code.py * fix: data type check on swift build * fix: test large array on struct and enum
This commit is contained in:
@@ -160,11 +160,19 @@ impl<'a> Ability {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct AbilityT {
|
||||
pub id: u32,
|
||||
pub distance: u32,
|
||||
}
|
||||
impl Default for AbilityT {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
id: 0,
|
||||
distance: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AbilityT {
|
||||
pub fn pack(&self) -> Ability {
|
||||
|
||||
@@ -131,12 +131,21 @@ impl<'a> StructOfStructs {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct StructOfStructsT {
|
||||
pub a: AbilityT,
|
||||
pub b: TestT,
|
||||
pub c: AbilityT,
|
||||
}
|
||||
impl Default for StructOfStructsT {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
a: Default::default(),
|
||||
b: Default::default(),
|
||||
c: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl StructOfStructsT {
|
||||
pub fn pack(&self) -> StructOfStructs {
|
||||
|
||||
@@ -99,10 +99,17 @@ impl<'a> StructOfStructsOfStructs {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct StructOfStructsOfStructsT {
|
||||
pub a: StructOfStructsT,
|
||||
}
|
||||
impl Default for StructOfStructsOfStructsT {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
a: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl StructOfStructsOfStructsT {
|
||||
pub fn pack(&self) -> StructOfStructsOfStructs {
|
||||
|
||||
@@ -149,11 +149,19 @@ impl<'a> Test {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct TestT {
|
||||
pub a: i16,
|
||||
pub b: i8,
|
||||
}
|
||||
impl Default for TestT {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
a: 0,
|
||||
b: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TestT {
|
||||
pub fn pack(&self) -> Test {
|
||||
|
||||
@@ -264,7 +264,7 @@ impl<'a> Vec3 {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Vec3T {
|
||||
pub x: f32,
|
||||
pub y: f32,
|
||||
@@ -273,6 +273,18 @@ pub struct Vec3T {
|
||||
pub test2: Color,
|
||||
pub test3: TestT,
|
||||
}
|
||||
impl Default for Vec3T {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
test1: 0.0,
|
||||
test2: Default::default(),
|
||||
test3: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Vec3T {
|
||||
pub fn pack(&self) -> Vec3 {
|
||||
|
||||
@@ -116,10 +116,17 @@ impl<'a> Unused {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct UnusedT {
|
||||
pub a: i32,
|
||||
}
|
||||
impl Default for UnusedT {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
a: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl UnusedT {
|
||||
pub fn pack(&self) -> Unused {
|
||||
|
||||
Reference in New Issue
Block a user