-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started implementation for private flags in rust (#7269)
Adds flag to the cpp to fix bad annotations in all the languages Addresses comments to the PR, and fixes logic for leaking annotations
- Loading branch information
1 parent
967df08
commit 11a1988
Showing
13 changed files
with
924 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
enum AB:byte (private) { | ||
A, | ||
B, | ||
} | ||
|
||
struct Object (private) { | ||
value: int; | ||
} | ||
|
||
union Any (private) { Game, Annotations } | ||
|
||
table Game (private) { | ||
value: int; | ||
} | ||
|
||
table Annotations (private) { | ||
value: int; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// automatically generated by the FlatBuffers compiler, do not modify | ||
extern crate alloc; | ||
extern crate flatbuffers; | ||
use alloc::boxed::Box; | ||
use alloc::string::{String, ToString}; | ||
use alloc::vec::Vec; | ||
use core::mem; | ||
use core::cmp::Ordering; | ||
use self::flatbuffers::{EndianScalar, Follow}; | ||
use super::*; | ||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] | ||
pub const ENUM_MIN_AB: i8 = 0; | ||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] | ||
pub const ENUM_MAX_AB: i8 = 1; | ||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] | ||
#[allow(non_camel_case_types)] | ||
pub const ENUM_VALUES_AB: [AB; 2] = [ | ||
AB::A, | ||
AB::B, | ||
]; | ||
|
||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] | ||
#[repr(transparent)] | ||
pub(crate) struct AB(pub i8); | ||
#[allow(non_upper_case_globals)] | ||
impl AB { | ||
pub const A: Self = Self(0); | ||
pub const B: Self = Self(1); | ||
|
||
pub const ENUM_MIN: i8 = 0; | ||
pub const ENUM_MAX: i8 = 1; | ||
pub const ENUM_VALUES: &'static [Self] = &[ | ||
Self::A, | ||
Self::B, | ||
]; | ||
/// Returns the variant's name or "" if unknown. | ||
pub fn variant_name(self) -> Option<&'static str> { | ||
match self { | ||
Self::A => Some("A"), | ||
Self::B => Some("B"), | ||
_ => None, | ||
} | ||
} | ||
} | ||
impl core::fmt::Debug for AB { | ||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { | ||
if let Some(name) = self.variant_name() { | ||
f.write_str(name) | ||
} else { | ||
f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0)) | ||
} | ||
} | ||
} | ||
impl<'a> flatbuffers::Follow<'a> for AB { | ||
type Inner = Self; | ||
#[inline] | ||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { | ||
let b = unsafe { | ||
flatbuffers::read_scalar_at::<i8>(buf, loc) | ||
}; | ||
Self(b) | ||
} | ||
} | ||
|
||
impl flatbuffers::Push for AB { | ||
type Output = AB; | ||
#[inline] | ||
fn push(&self, dst: &mut [u8], _rest: &[u8]) { | ||
unsafe { flatbuffers::emplace_scalar::<i8>(dst, self.0); } | ||
} | ||
} | ||
|
||
impl flatbuffers::EndianScalar for AB { | ||
#[inline] | ||
fn to_little_endian(self) -> Self { | ||
let b = i8::to_le(self.0); | ||
Self(b) | ||
} | ||
#[inline] | ||
#[allow(clippy::wrong_self_convention)] | ||
fn from_little_endian(self) -> Self { | ||
let b = i8::from_le(self.0); | ||
Self(b) | ||
} | ||
} | ||
|
||
impl<'a> flatbuffers::Verifiable for AB { | ||
#[inline] | ||
fn run_verifier( | ||
v: &mut flatbuffers::Verifier, pos: usize | ||
) -> Result<(), flatbuffers::InvalidFlatbuffer> { | ||
use self::flatbuffers::Verifiable; | ||
i8::run_verifier(v, pos) | ||
} | ||
} | ||
|
||
impl flatbuffers::SimpleToVerifyInSlice for AB {} |
Oops, something went wrong.