├── rust ├── fuzz │ ├── .gitignore │ ├── fuzz_targets │ │ ├── type.rs │ │ ├── function.rs │ │ └── file.rs │ └── Cargo.toml ├── fixtures │ └── random.warp ├── src │ ├── signature.rs │ ├── type │ │ ├── class │ │ │ ├── boolean.rs │ │ │ ├── float.rs │ │ │ ├── character.rs │ │ │ ├── referrer.rs │ │ │ ├── void.rs │ │ │ ├── array.rs │ │ │ ├── integer.rs │ │ │ ├── enumeration.rs │ │ │ ├── pointer.rs │ │ │ └── structure.rs │ │ └── guid.rs │ ├── signature │ │ ├── comment.rs │ │ ├── variable.rs │ │ ├── basic_block.rs │ │ └── constraint.rs │ ├── target.rs │ ├── cached_builder.rs │ ├── gen_flatbuffers │ │ ├── type_bin │ │ │ ├── array_modifiers_generated.rs │ │ │ ├── type_modifiers_generated.rs │ │ │ ├── structure_member_modifiers_generated.rs │ │ │ ├── void_generated.rs │ │ │ ├── type_guid_generated.rs │ │ │ ├── metadata_value_type_generated.rs │ │ │ ├── bit_size_generated.rs │ │ │ ├── bit_shift_generated.rs │ │ │ ├── bit_width_generated.rs │ │ │ ├── bit_offset_generated.rs │ │ │ ├── float_generated.rs │ │ │ ├── boolean_generated.rs │ │ │ ├── location_class_generated.rs │ │ │ ├── pointer_addressing_generated.rs │ │ │ ├── unsigned_bit_offset_generated.rs │ │ │ ├── character_generated.rs │ │ │ ├── register_location_generated.rs │ │ │ ├── stack_location_generated.rs │ │ │ ├── calling_convention_generated.rs │ │ │ ├── union_generated.rs │ │ │ ├── structure_generated.rs │ │ │ ├── integer_generated.rs │ │ │ ├── referrer_generated.rs │ │ │ ├── computed_type_generated.rs │ │ │ ├── enumeration_member_generated.rs │ │ │ ├── union_member_generated.rs │ │ │ └── type_class_generated.rs │ │ ├── symbol_bin │ │ │ ├── symbol_modifiers_generated.rs │ │ │ └── symbol_class_generated.rs │ │ ├── sig_bin │ │ │ ├── function_guid_generated.rs │ │ │ ├── basic_block_guid_generated.rs │ │ │ ├── constraint_guid_generated.rs │ │ │ ├── basic_block_generated.rs │ │ │ ├── constraint_generated.rs │ │ │ └── function_comment_generated.rs │ │ ├── warp │ │ │ ├── chunk_type_generated.rs │ │ │ ├── compression_type_generated.rs │ │ │ ├── file_header_generated.rs │ │ │ └── chunk_generated.rs │ │ └── target_bin │ │ │ └── target_generated.rs │ └── symbol.rs ├── Cargo.toml ├── build.rs ├── tests │ ├── signature.rs │ └── file.rs ├── examples │ ├── dumper.rs │ ├── random.rs │ └── type_builder.rs └── benches │ ├── type.rs │ └── chunk.rs ├── warp_cli ├── Cargo.toml └── src │ ├── utility.rs │ ├── operation.rs │ ├── main.rs │ └── operation │ ├── merge.rs │ └── find.rs ├── Cargo.toml ├── about.toml ├── target.fbs ├── symbol.fbs ├── LICENSE ├── .gitignore ├── warp.fbs ├── signature.fbs ├── .github └── workflows │ └── CI.yaml └── about.hbs /rust/fuzz/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | corpus 3 | artifacts 4 | coverage 5 | -------------------------------------------------------------------------------- /rust/fixtures/random.warp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vector35/warp/HEAD/rust/fixtures/random.warp -------------------------------------------------------------------------------- /rust/src/signature.rs: -------------------------------------------------------------------------------- 1 | pub mod basic_block; 2 | pub mod chunk; 3 | pub mod comment; 4 | pub mod constraint; 5 | pub mod function; 6 | pub mod variable; 7 | -------------------------------------------------------------------------------- /warp_cli/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "warp_cli" 3 | version = "0.1.0" 4 | edition = "2021" 5 | license = "Apache-2.0" 6 | rust-version = "1.83.0" 7 | 8 | [dependencies] 9 | warp = { workspace = true } 10 | clap = { version = "4.5", features = ["derive"] } -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = [ 4 | "rust", 5 | "rust/fuzz", 6 | "warp_cli" 7 | ] 8 | 9 | [workspace.dependencies] 10 | warp = { path = "rust" } 11 | 12 | [profile.release] 13 | panic = "abort" 14 | lto = true 15 | debug = "full" 16 | 17 | [profile.bench] 18 | lto = true 19 | -------------------------------------------------------------------------------- /rust/fuzz/fuzz_targets/type.rs: -------------------------------------------------------------------------------- 1 | #![no_main] 2 | use libfuzzer_sys::fuzz_target; 3 | use warp::r#type::Type; 4 | 5 | fuzz_target!(|data: &[u8]| { 6 | if let Some(ty) = Type::from_bytes(data) { 7 | let ty_bytes = ty.to_bytes(); 8 | Type::from_bytes(&ty_bytes).expect("Failed to round-trip type"); 9 | } 10 | }); 11 | -------------------------------------------------------------------------------- /rust/fuzz/fuzz_targets/function.rs: -------------------------------------------------------------------------------- 1 | #![no_main] 2 | 3 | use libfuzzer_sys::fuzz_target; 4 | use warp::signature::function::Function; 5 | 6 | fuzz_target!(|data: &[u8]| { 7 | if let Some(func) = Function::from_bytes(data) { 8 | let func_bytes = func.to_bytes(); 9 | Function::from_bytes(&func_bytes).expect("Failed to round-trip function"); 10 | } 11 | }); 12 | -------------------------------------------------------------------------------- /about.toml: -------------------------------------------------------------------------------- 1 | # Used in conjuction with `cargo-about` to generate a list of licenses. 2 | accepted = [ 3 | "Apache-2.0", 4 | "MIT", 5 | "Unicode-DFS-2016", 6 | "Unicode-3.0", 7 | "OFL-1.1", 8 | "BSL-1.0", 9 | "BSD-3-Clause", 10 | "BSD-2-Clause", 11 | "LicenseRef-UFL-1.0", 12 | "NOASSERTION", 13 | "ISC", 14 | "Zlib", 15 | "OpenSSL", 16 | "NCSA" 17 | ] -------------------------------------------------------------------------------- /rust/fuzz/fuzz_targets/file.rs: -------------------------------------------------------------------------------- 1 | #![no_main] 2 | 3 | use libfuzzer_sys::fuzz_target; 4 | use warp::WarpFile; 5 | 6 | fuzz_target!(|data: &[u8]| { 7 | if let Some(file) = WarpFile::from_bytes(data) { 8 | let file_bytes = file.to_bytes(); 9 | if WarpFile::from_bytes(&file_bytes).is_none() { 10 | panic!("Failed to round-trip file"); 11 | } 12 | } 13 | }); 14 | -------------------------------------------------------------------------------- /warp_cli/src/utility.rs: -------------------------------------------------------------------------------- 1 | use std::path::Path; 2 | use warp::WarpFile; 3 | 4 | /// Construct an owned file from a path, this means the file owns the buffer, and we have no problems passing it to-from. 5 | pub fn open_file<'fbb>(path: &Path) -> WarpFile<'fbb> { 6 | let file = std::fs::read(path).expect("Unable to read file"); 7 | let file = WarpFile::from_owned_bytes(file).expect("Invalid WARP file"); 8 | file 9 | } 10 | -------------------------------------------------------------------------------- /target.fbs: -------------------------------------------------------------------------------- 1 | namespace TargetBin; 2 | 3 | table Target { 4 | // TODO: Further integration with other tools will likely need a actual mapping for target names. 5 | // The architecture name for the target, this can be implementation specific. 6 | architecture:string; 7 | // The platform name for the target, this can be implementation specific. 8 | platform:string; 9 | // TODO: Extend with target specific information, calling conventions etc... 10 | } -------------------------------------------------------------------------------- /symbol.fbs: -------------------------------------------------------------------------------- 1 | namespace SymbolBin; 2 | 3 | enum SymbolClass : ubyte { 4 | Function, 5 | Data, 6 | Bare 7 | } 8 | 9 | enum SymbolModifiers : ubyte (bit_flags) { 10 | // Function is an import, or otherwise external to the analysis. 11 | External = 0, 12 | // Function is exported 13 | // TODO: This naming is unfortunate. If something is referenced externally 14 | Exported 15 | } 16 | 17 | table Symbol { 18 | name:string; 19 | modifiers:SymbolModifiers; 20 | class:SymbolClass; 21 | } -------------------------------------------------------------------------------- /warp_cli/src/operation.rs: -------------------------------------------------------------------------------- 1 | use clap::Subcommand; 2 | use std::path::Path; 3 | 4 | pub mod find; 5 | pub mod merge; 6 | 7 | pub trait OperationHandler { 8 | fn run(&self, path: &Path); 9 | } 10 | 11 | #[derive(Clone, Debug, Subcommand)] 12 | pub enum Operation { 13 | Find(find::FindOp), 14 | Merge(merge::MergeOp), 15 | } 16 | 17 | impl Operation { 18 | pub fn run(&self, path: &Path) { 19 | match self { 20 | Operation::Find(op) => op.run(path), 21 | Operation::Merge(op) => op.run(path), 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020-2025 Vector 35 Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /warp_cli/src/main.rs: -------------------------------------------------------------------------------- 1 | pub mod operation; 2 | mod utility; 3 | 4 | use crate::operation::Operation; 5 | use clap::Parser; 6 | use std::path::PathBuf; 7 | 8 | /// Command line tools for reading and writing WARP files. 9 | #[derive(Parser, Debug)] 10 | #[command(version, about, long_about = None)] 11 | struct Args { 12 | /// Path of the file to perform the operation on. 13 | #[arg(short, long)] 14 | path: PathBuf, 15 | 16 | /// Operation to perform on the file. 17 | #[command(subcommand)] 18 | operation: Operation, 19 | } 20 | 21 | fn main() { 22 | let args = Args::parse(); 23 | args.operation.run(&args.path); 24 | } 25 | -------------------------------------------------------------------------------- /rust/fuzz/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "warp-fuzz" 3 | version = "0.0.0" 4 | publish = false 5 | edition = "2021" 6 | license = "Apache-2.0" 7 | 8 | [package.metadata] 9 | cargo-fuzz = true 10 | 11 | [dependencies] 12 | libfuzzer-sys = "0.4" 13 | 14 | [dependencies.warp] 15 | path = ".." 16 | 17 | [[bin]] 18 | name = "type" 19 | path = "fuzz_targets/type.rs" 20 | test = false 21 | doc = false 22 | bench = false 23 | 24 | [[bin]] 25 | name = "function" 26 | path = "fuzz_targets/function.rs" 27 | test = false 28 | doc = false 29 | bench = false 30 | 31 | [[bin]] 32 | name = "file" 33 | path = "fuzz_targets/file.rs" 34 | test = false 35 | doc = false 36 | bench = false -------------------------------------------------------------------------------- /rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "warp" 3 | version = "1.0.1" 4 | edition = "2021" 5 | license = "Apache-2.0" 6 | rust-version = "1.83.0" 7 | 8 | [dependencies] 9 | flatbuffers = "25.2.10" 10 | bon = "3.6.4" 11 | uuid = { version = "1.17.0", features = ["v5"]} 12 | flate2 = "1.1.2" 13 | itertools = "0.14" 14 | 15 | [features] 16 | default = [] 17 | gen_flatbuffers = ["dep:flatbuffers-build"] 18 | 19 | [dev-dependencies] 20 | criterion = "0.6.0" 21 | insta = { version = "1.43.1", features = ["yaml"] } 22 | 23 | [build-dependencies] 24 | flatbuffers-build = { git = "https://github.com/emesare/flatbuffers-build", rev = "44410b9", features = ["vendored"], optional = true } 25 | 26 | [[bench]] 27 | name = "type" 28 | harness = false 29 | 30 | [[bench]] 31 | name = "chunk" 32 | harness = false -------------------------------------------------------------------------------- /rust/build.rs: -------------------------------------------------------------------------------- 1 | #[cfg(not(feature = "gen_flatbuffers"))] 2 | pub fn main() {} 3 | 4 | #[cfg(feature = "gen_flatbuffers")] 5 | pub fn main() { 6 | use flatbuffers_build::BuilderOptions; 7 | use std::path::PathBuf; 8 | 9 | // Remove leftover symlink dir. 10 | let _ = std::fs::remove_dir_all("rust/gen_flatbuffers"); 11 | let workspace_dir: PathBuf = std::env::var("CARGO_MANIFEST_DIR").unwrap().into(); 12 | BuilderOptions::new_with_files([ 13 | workspace_dir.join("../type.fbs"), 14 | workspace_dir.join("../symbol.fbs"), 15 | workspace_dir.join("../signature.fbs"), 16 | workspace_dir.join("../target.fbs"), 17 | workspace_dir.join("../warp.fbs"), 18 | ]) 19 | .set_output_path("src/gen_flatbuffers") 20 | .compile() 21 | .expect("flatbuffer compilation failed"); 22 | } 23 | -------------------------------------------------------------------------------- /rust/tests/signature.rs: -------------------------------------------------------------------------------- 1 | use uuid::uuid; 2 | use warp::signature::basic_block::BasicBlockGUID; 3 | use warp::signature::function::FunctionGUID; 4 | 5 | #[test] 6 | fn function_guid_creation() { 7 | // Convert a set of basic blocks into a function guid. This should always be the same. 8 | let bb_guid_0 = BasicBlockGUID::from(uuid!("e930c560-7b77-4f73-8b59-2ef6da75dcd4")); 9 | let bb_guid_1 = BasicBlockGUID::from(uuid!("3a4bf915-666f-44ad-8a7e-a2fea8f3a62a")); 10 | let bb_guid_2 = BasicBlockGUID::from(uuid!("0ffbfcd4-ac77-4b47-9696-006fa040167c")); 11 | let basic_block_guids = [bb_guid_0, bb_guid_1, bb_guid_2]; 12 | 13 | let correct_func_guid = FunctionGUID::from(uuid!("1bef6187-74d9-5ebe-a0eb-4dbe6a97e578")); 14 | let function_guid = FunctionGUID::from_basic_blocks(&basic_block_guids); 15 | assert_eq!(function_guid, correct_func_guid); 16 | } 17 | -------------------------------------------------------------------------------- /rust/src/type/class/boolean.rs: -------------------------------------------------------------------------------- 1 | use crate::cached_builder::CachedFlatBufferBuilder; 2 | use crate::{fb_type as fb, FlatBufferObject}; 3 | use bon::Builder; 4 | use flatbuffers::WIPOffset; 5 | 6 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Builder)] 7 | pub struct BooleanClass { 8 | pub width: Option, 9 | } 10 | 11 | impl BooleanClass { 12 | pub fn size(&self) -> Option { 13 | self.width.map(|w| w as u64) 14 | } 15 | } 16 | 17 | impl FlatBufferObject for BooleanClass { 18 | type FbType<'fbb> = fb::Boolean<'fbb>; 19 | 20 | fn create<'fbb>( 21 | &self, 22 | builder: &mut CachedFlatBufferBuilder<'fbb>, 23 | ) -> WIPOffset> { 24 | fb::Boolean::create( 25 | builder, 26 | &fb::BooleanArgs { 27 | width: self.width.map(Into::into).as_ref(), 28 | }, 29 | ) 30 | } 31 | 32 | fn from_object(value: &Self::FbType<'_>) -> Option { 33 | Some(Self { 34 | width: value.width().map(Into::into), 35 | }) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /rust/src/type/class/float.rs: -------------------------------------------------------------------------------- 1 | use crate::cached_builder::CachedFlatBufferBuilder; 2 | use crate::{fb_type as fb, FlatBufferObject}; 3 | use bon::Builder; 4 | use flatbuffers::WIPOffset; 5 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Builder)] 6 | pub struct FloatClass { 7 | /// Width in bits 8 | pub width: Option, 9 | } 10 | 11 | impl FloatClass { 12 | pub fn size(&self) -> Option { 13 | self.width.map(|w| w as u64) 14 | } 15 | } 16 | 17 | impl FlatBufferObject for FloatClass { 18 | type FbType<'fbb> = fb::Float<'fbb>; 19 | 20 | fn create<'fbb>( 21 | &self, 22 | builder: &mut CachedFlatBufferBuilder<'fbb>, 23 | ) -> WIPOffset> { 24 | fb::Float::create( 25 | builder, 26 | &fb::FloatArgs { 27 | width: self.width.map(Into::into).as_ref(), 28 | }, 29 | ) 30 | } 31 | 32 | fn from_object(value: &Self::FbType<'_>) -> Option { 33 | Some(Self { 34 | width: value.width().map(Into::into), 35 | }) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /rust/src/signature/comment.rs: -------------------------------------------------------------------------------- 1 | use crate::cached_builder::CachedFlatBufferBuilder; 2 | use crate::fb_sig as fb; 3 | use crate::FlatBufferObject; 4 | use flatbuffers::WIPOffset; 5 | 6 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)] 7 | pub struct FunctionComment { 8 | pub offset: i64, 9 | pub text: String, 10 | } 11 | 12 | impl FlatBufferObject for FunctionComment { 13 | type FbType<'fbb> = fb::FunctionComment<'fbb>; 14 | 15 | fn create<'fbb>( 16 | &self, 17 | builder: &mut CachedFlatBufferBuilder<'fbb>, 18 | ) -> WIPOffset> { 19 | let text = builder.create_string(&self.text); 20 | fb::FunctionComment::create( 21 | builder, 22 | &fb::FunctionCommentArgs { 23 | offset: self.offset, 24 | text: Some(text), 25 | }, 26 | ) 27 | } 28 | 29 | fn from_object(value: &Self::FbType<'_>) -> Option { 30 | Some(Self { 31 | offset: value.offset(), 32 | text: value.text().to_string(), 33 | }) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /warp_cli/src/operation/merge.rs: -------------------------------------------------------------------------------- 1 | use crate::operation::OperationHandler; 2 | use crate::utility::open_file; 3 | use clap::Parser; 4 | use std::path::{Path, PathBuf}; 5 | use warp::chunk::{Chunk, CompressionType}; 6 | use warp::{WarpFile, WarpFileHeader}; 7 | 8 | /// Merge all other files into the provided path. 9 | #[derive(Clone, Debug, Parser)] 10 | pub struct MergeOp { 11 | /// Files to be merged into the given path. 12 | #[arg(index = 1)] 13 | unmerged_files: Vec, 14 | } 15 | 16 | impl OperationHandler for MergeOp { 17 | fn run(&self, path: &Path) { 18 | let files: Vec<_> = self 19 | .unmerged_files 20 | .iter() 21 | .map(PathBuf::as_path) 22 | .map(open_file) 23 | .collect(); 24 | let chunks: Vec = files.iter().flat_map(|f| f.chunks.clone()).collect(); 25 | let merged_chunks = Chunk::merge(&chunks, CompressionType::Zstd); 26 | let merged_file = WarpFile::new(WarpFileHeader::new(), merged_chunks); 27 | std::fs::write(path, merged_file.to_bytes()).expect("Failed to write file"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /rust/src/type/class/character.rs: -------------------------------------------------------------------------------- 1 | use crate::cached_builder::CachedFlatBufferBuilder; 2 | use crate::{fb_type as fb, FlatBufferObject}; 3 | use bon::Builder; 4 | use flatbuffers::WIPOffset; 5 | 6 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Builder)] 7 | pub struct CharacterClass { 8 | /// Width in bits 9 | pub width: Option, 10 | } 11 | 12 | impl CharacterClass { 13 | pub fn size(&self) -> Option { 14 | self.width.map(|w| w as u64) 15 | } 16 | } 17 | 18 | impl FlatBufferObject for CharacterClass { 19 | type FbType<'fbb> = fb::Character<'fbb>; 20 | 21 | fn create<'fbb>( 22 | &self, 23 | builder: &mut CachedFlatBufferBuilder<'fbb>, 24 | ) -> WIPOffset> { 25 | fb::Character::create( 26 | builder, 27 | &fb::CharacterArgs { 28 | width: self.width.map(Into::into).as_ref(), 29 | }, 30 | ) 31 | } 32 | 33 | fn from_object(value: &Self::FbType<'_>) -> Option { 34 | Some(Self { 35 | width: value.width().map(Into::into), 36 | }) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and dependencies 2 | /target/ 3 | **/target/ 4 | 5 | # Remove Cargo.lock from gitignore if it's already checked in 6 | Cargo.lock 7 | 8 | # Best practice for something like this, the python scripts are not meant to be "deployed" from this repo state. 9 | poetry.lock 10 | 11 | # These are backup files generated by rustfmt 12 | **/*.rs.bk 13 | 14 | # Temporary files generated by editors 15 | *~ 16 | *.swp 17 | *.swo 18 | 19 | # IntelliJ and CLion directories 20 | .idea/ 21 | *.iml 22 | *.iws 23 | *.ipr 24 | 25 | # MacOS specific ignores 26 | .DS_Store 27 | ._* 28 | 29 | # Rust documentations 30 | /target/doc/ 31 | 32 | # Build files 33 | **/build/ 34 | 35 | # Generated files and directories 36 | generated/ 37 | 38 | # Node.js directories (if any) 39 | /node_modules/ 40 | 41 | # Logs 42 | *.log 43 | 44 | # Output directories 45 | *.out 46 | *.log.* 47 | 48 | **/[Tt]humbs.db 49 | **/[Dd]esktop.ini 50 | 51 | **/ubuntu 52 | **/downloads 53 | **/msvc 54 | **/windows 55 | 56 | **/out 57 | 58 | *.vsix 59 | *.deb 60 | 61 | # cargo-mutants 62 | mutants* 63 | 64 | *.warp 65 | *.sbin 66 | !fixtures/*.warp -------------------------------------------------------------------------------- /rust/src/target.rs: -------------------------------------------------------------------------------- 1 | use crate::cached_builder::CachedFlatBufferBuilder; 2 | use crate::fb_target as fb; 3 | use crate::FlatBufferObject; 4 | use flatbuffers::WIPOffset; 5 | 6 | #[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Default)] 7 | pub struct Target { 8 | pub architecture: Option, 9 | pub platform: Option, 10 | } 11 | 12 | impl FlatBufferObject for Target { 13 | type FbType<'fbb> = fb::Target<'fbb>; 14 | 15 | fn create<'fbb>( 16 | &self, 17 | builder: &mut CachedFlatBufferBuilder<'fbb>, 18 | ) -> WIPOffset> { 19 | let architecture = self.architecture.clone().map(|n| builder.create_string(&n)); 20 | let platform = self.platform.clone().map(|n| builder.create_string(&n)); 21 | fb::Target::create( 22 | builder, 23 | &fb::TargetArgs { 24 | architecture, 25 | platform, 26 | }, 27 | ) 28 | } 29 | 30 | fn from_object(value: &Self::FbType<'_>) -> Option { 31 | Some(Self { 32 | architecture: value.architecture().map(|n| n.to_string()), 33 | platform: value.platform().map(|n| n.to_string()), 34 | }) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /rust/src/type/class/referrer.rs: -------------------------------------------------------------------------------- 1 | use bon::Builder; 2 | 3 | use crate::cached_builder::CachedFlatBufferBuilder; 4 | use crate::r#type::guid::TypeGUID; 5 | use crate::{fb_type as fb, FlatBufferObject}; 6 | use flatbuffers::WIPOffset; 7 | 8 | #[derive(Clone, Debug, PartialEq, Eq, Hash, Builder)] 9 | pub struct ReferrerClass { 10 | pub guid: Option, 11 | pub name: Option, 12 | } 13 | 14 | impl ReferrerClass { 15 | pub fn new(guid: Option, name: Option) -> Self { 16 | Self { guid, name } 17 | } 18 | } 19 | 20 | impl FlatBufferObject for ReferrerClass { 21 | type FbType<'fbb> = fb::Referrer<'fbb>; 22 | 23 | fn create<'fbb>( 24 | &self, 25 | builder: &mut CachedFlatBufferBuilder<'fbb>, 26 | ) -> WIPOffset> { 27 | let guid = self.guid.map(fb::TypeGUID::from); 28 | let name = self.name.as_ref().map(|x| builder.create_string(x)); 29 | fb::Referrer::create( 30 | builder, 31 | &fb::ReferrerArgs { 32 | guid: guid.as_ref(), 33 | name, 34 | }, 35 | ) 36 | } 37 | 38 | fn from_object(value: &Self::FbType<'_>) -> Option { 39 | Some(Self { 40 | guid: value.guid().map(|&s| TypeGUID::from(s)), 41 | name: value.name().map(|x| x.to_owned()), 42 | }) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /rust/examples/dumper.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | use std::fs::File; 3 | use std::io::Read; 4 | use std::path::Path; 5 | use warp::chunk::ChunkKind; 6 | 7 | fn main() -> Result<(), Box> { 8 | let args: Vec = env::args().collect(); 9 | if args.len() < 2 { 10 | eprintln!("Usage: {} ", args[0]); 11 | std::process::exit(1); 12 | } 13 | 14 | let path = Path::new(&args[1]); 15 | let mut file = File::open(path)?; 16 | let mut buffer = Vec::new(); 17 | file.read_to_end(&mut buffer)?; 18 | 19 | let file = warp::WarpFile::from_bytes(&buffer).expect("Failed to parse file"); 20 | 21 | for chunk in file.chunks { 22 | match chunk.kind { 23 | ChunkKind::Signature(sc) => { 24 | println!("=== Signature chunk ==="); 25 | for func in sc.functions() { 26 | println!("{} | {}", func.symbol.name, func.guid); 27 | } 28 | } 29 | ChunkKind::Type(tc) => { 30 | println!("=== Type chunk ==="); 31 | for ty in tc.types() { 32 | println!( 33 | "{} | {}", 34 | ty.ty.name.unwrap_or("ANONYMOUS".to_string()), 35 | ty.guid 36 | ); 37 | } 38 | } 39 | } 40 | } 41 | 42 | Ok(()) 43 | } 44 | -------------------------------------------------------------------------------- /warp.fbs: -------------------------------------------------------------------------------- 1 | include "type.fbs"; 2 | include "symbol.fbs"; 3 | include "signature.fbs"; 4 | include "target.fbs"; 5 | 6 | namespace Warp; 7 | 8 | file_identifier "WARP"; 9 | file_extension "warp"; 10 | 11 | enum ChunkType : ubyte { 12 | Signatures = 0, 13 | Types = 1, 14 | } 15 | 16 | enum CompressionType : ubyte { 17 | None = 0, 18 | Zstd = 1, 19 | } 20 | 21 | table ChunkHeader { 22 | version:ushort; 23 | type:ChunkType; 24 | compression_type:CompressionType; 25 | // Size in bytes of the uncompressed data. 26 | // This is provided so that readers can allocate allocate the size of the chunk before reading. 27 | // Because the size of flatbuffers cannot exceed 2GB we limit size to 32 bits. 28 | size:uint; 29 | // The "target" of the chunk, this is used currently only used as a key for architecture & platform. 30 | target:TargetBin.Target; 31 | } 32 | 33 | table Chunk { 34 | header:ChunkHeader (required); 35 | // TODO: To support more than 2gb we need to make this offset64, however rust fb codegen does not support currently. 36 | data:[ubyte]; 37 | } 38 | 39 | table FileHeader { 40 | version:ushort; 41 | // TODO: Analysis information may want to be guarded behind some metadata. 42 | // TODO: For example, we might want to store the compiler or language here to guard from this information from being read. 43 | } 44 | 45 | // The file format used to store analysis data. 46 | table File { 47 | header:FileHeader (required); 48 | chunks:[Chunk]; 49 | } 50 | 51 | root_type File; -------------------------------------------------------------------------------- /rust/benches/type.rs: -------------------------------------------------------------------------------- 1 | use criterion::{criterion_group, criterion_main, Criterion}; 2 | use warp::mock::{mock_int_type_class, mock_type}; 3 | use warp::r#type::class::{StructureClass, StructureMember, TypeClass}; 4 | use warp::r#type::guid::TypeGUID; 5 | use warp::r#type::Type; 6 | 7 | pub fn void_benchmark(c: &mut Criterion) { 8 | let void_type = Type::builder() 9 | .name("my_void".to_owned()) 10 | .class(TypeClass::Void) 11 | .build(); 12 | 13 | c.bench_function("uuid void", |b| { 14 | b.iter(|| { 15 | let _ = TypeGUID::from(&void_type); 16 | }) 17 | }); 18 | 19 | c.bench_function("computed void", |b| b.iter(|| void_type.to_bytes())); 20 | } 21 | 22 | pub fn struct_benchmark(c: &mut Criterion) { 23 | let int_type = mock_type("my_int", mock_int_type_class(None, false)); 24 | let structure_member = StructureMember::builder() 25 | .name("member") 26 | .ty(int_type) 27 | .offset(0) 28 | .build(); 29 | let struct_class = StructureClass::new(vec![structure_member]); 30 | let struct_type = Type::builder() 31 | .name("my_struct".to_owned()) 32 | .class(TypeClass::Structure(struct_class)) 33 | .build(); 34 | 35 | c.bench_function("uuid struct", |b| { 36 | b.iter(|| { 37 | let _ = TypeGUID::from(&struct_type); 38 | }) 39 | }); 40 | 41 | c.bench_function("computed struct", |b| b.iter(|| struct_type.to_bytes())); 42 | } 43 | 44 | criterion_group!(benches, void_benchmark, struct_benchmark); 45 | criterion_main!(benches); 46 | -------------------------------------------------------------------------------- /signature.fbs: -------------------------------------------------------------------------------- 1 | include "type.fbs"; 2 | include "symbol.fbs"; 3 | 4 | namespace SigBin; 5 | 6 | struct BasicBlockGUID { 7 | value:[ubyte:16]; 8 | } 9 | 10 | struct ConstraintGUID { 11 | value:[ubyte:16]; 12 | } 13 | 14 | struct FunctionGUID { 15 | value:[ubyte:16]; 16 | } 17 | 18 | table BasicBlock { 19 | guid:BasicBlockGUID (required); 20 | // TODO: successors:[BasicBlockGUID]; 21 | // TODO: predecessors:[BasicBlockGUID]; 22 | } 23 | 24 | table Constraint { 25 | guid:ConstraintGUID (required); 26 | // The byte offset from the start of the constrained function. 27 | // A negative number would indicate that the constraint occurs before the start of the function. 28 | offset:long; 29 | } 30 | 31 | table FunctionComment { 32 | offset:int64; 33 | text:string (required); 34 | } 35 | 36 | // TODO: This is extremely naive, cant handle stack slot re-use. 37 | table FunctionVariable { 38 | offset:int64; 39 | name:string; 40 | location:TypeBin.LocationClass (required); 41 | type:TypeBin.Type; 42 | // TODO: Possible value set. (to assert a value) 43 | } 44 | 45 | table Function { 46 | // TODO: Add architecture, this is required to support multi-arch binaries... 47 | // TODO: Make guid a key when https://github.com/google/flatbuffers/issues/8603 is fixed. 48 | guid:FunctionGUID (required); 49 | symbol:SymbolBin.Symbol; 50 | type:TypeBin.Type; 51 | constraints:[Constraint]; 52 | comments:[FunctionComment]; 53 | variables:[FunctionVariable]; 54 | } 55 | 56 | table SignatureChunk { 57 | functions:[Function] (required); 58 | } 59 | 60 | root_type SignatureChunk; -------------------------------------------------------------------------------- /rust/src/cached_builder.rs: -------------------------------------------------------------------------------- 1 | //! A space-optimized flatbuffer builder. 2 | //! 3 | //! By space-optimized we mean we provide records of previously constructed buffer objects to re-use. 4 | //! Currently, this is done for the Type table. However, this could be done in the future for other things. 5 | 6 | use crate::fb_type as fb; 7 | use crate::r#type::Type; 8 | use flatbuffers::{FlatBufferBuilder, WIPOffset}; 9 | use std::collections::HashMap; 10 | use std::ops::{Deref, DerefMut}; 11 | 12 | /// Caches entries that are common to reduce final size of buffer. 13 | pub struct CachedFlatBufferBuilder<'fbb> { 14 | pub builder: FlatBufferBuilder<'fbb>, 15 | /// A cache for deduplicating offsets for `Type` objects. 16 | pub cached_type_offsets: HashMap>>, 17 | } 18 | 19 | impl<'fbb> CachedFlatBufferBuilder<'fbb> { 20 | pub fn new() -> Self { 21 | Self::new_with_builder(FlatBufferBuilder::new()) 22 | } 23 | 24 | /// Creates a new `CachedBufferBuilder` instance, wrapping the provided FlatBufferBuilder. 25 | pub fn new_with_builder(builder: FlatBufferBuilder<'fbb>) -> Self { 26 | Self { 27 | builder, 28 | cached_type_offsets: HashMap::new(), 29 | } 30 | } 31 | } 32 | 33 | impl Default for CachedFlatBufferBuilder<'_> { 34 | fn default() -> Self { 35 | Self::new() 36 | } 37 | } 38 | 39 | impl<'fbb> Deref for CachedFlatBufferBuilder<'fbb> { 40 | type Target = FlatBufferBuilder<'fbb>; 41 | 42 | fn deref(&self) -> &Self::Target { 43 | &self.builder 44 | } 45 | } 46 | 47 | impl DerefMut for CachedFlatBufferBuilder<'_> { 48 | fn deref_mut(&mut self) -> &mut Self::Target { 49 | &mut self.builder 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /rust/src/type/class/void.rs: -------------------------------------------------------------------------------- 1 | use crate::cached_builder::CachedFlatBufferBuilder; 2 | use crate::{fb_type as fb, FlatBufferObject}; 3 | use flatbuffers::WIPOffset; 4 | 5 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] 6 | pub struct VoidClass; 7 | 8 | impl FlatBufferObject for VoidClass { 9 | type FbType<'fbb> = fb::Void<'fbb>; 10 | 11 | fn create<'fbb>( 12 | &self, 13 | builder: &mut CachedFlatBufferBuilder<'fbb>, 14 | ) -> WIPOffset> { 15 | fb::Void::create(builder, &fb::VoidArgs {}) 16 | } 17 | 18 | fn from_object(_value: &Self::FbType<'_>) -> Option { 19 | Some(Self) 20 | } 21 | } 22 | 23 | #[cfg(test)] 24 | mod tests { 25 | use crate::r#type::class::TypeClass; 26 | use crate::r#type::guid::TypeGUID; 27 | use crate::r#type::Type; 28 | use uuid::{uuid, Uuid}; 29 | 30 | const VOID_TYPE_UUID: Uuid = uuid!("c37a394d-750b-5e89-b09e-539859c7a9bd"); 31 | 32 | fn built_void_type() -> Type { 33 | Type::builder() 34 | .name("my_void".to_owned()) 35 | .class(TypeClass::Void) 36 | .build() 37 | } 38 | 39 | #[test] 40 | fn void_guid_v1() { 41 | assert_eq!(TypeGUID::from(VOID_TYPE_UUID), built_void_type().into()); 42 | } 43 | 44 | #[test] 45 | fn void_type() { 46 | assert_eq!( 47 | Type { 48 | name: Some("my_void".to_owned()), 49 | class: TypeClass::Void, 50 | confidence: u8::MAX, 51 | modifiers: Default::default(), 52 | metadata: vec![], 53 | alignment: Default::default(), 54 | ancestors: vec![], 55 | }, 56 | built_void_type() 57 | ) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /.github/workflows/CI.yaml: -------------------------------------------------------------------------------- 1 | name: "CI" 2 | on: 3 | push: 4 | pull_request: 5 | 6 | jobs: 7 | test: 8 | name: cargo test 9 | runs-on: ${{ matrix.os }} 10 | strategy: 11 | matrix: 12 | os: [ ubuntu-latest, windows-latest, macos-latest ] 13 | steps: 14 | - uses: actions/checkout@v4 15 | - uses: actions-rust-lang/setup-rust-toolchain@v1 16 | - run: cargo test 17 | 18 | # Check lints with clippy 19 | clippy: 20 | name: cargo clippy 21 | runs-on: ubuntu-latest 22 | steps: 23 | - uses: actions/checkout@v4 24 | # Ensure clippy is installed 25 | - uses: actions-rust-lang/setup-rust-toolchain@v1 26 | with: 27 | components: clippy 28 | - name: Clippy Check 29 | uses: clechasseur/rs-clippy-check@v4 30 | 31 | # Check formatting with rustfmt 32 | formatting: 33 | name: cargo fmt 34 | runs-on: ubuntu-latest 35 | steps: 36 | - uses: actions/checkout@v4 37 | # Ensure rustfmt is installed and setup problem matcher 38 | - uses: actions-rust-lang/setup-rust-toolchain@v1 39 | with: 40 | components: rustfmt 41 | - name: Rustfmt Check 42 | uses: actions-rust-lang/rustfmt@v1 43 | 44 | # Check licensing and produce a list of licenses 45 | licensing: 46 | runs-on: ubuntu-latest 47 | steps: 48 | - uses: actions/checkout@v4 49 | - name: Install cargo-about 50 | uses: baptiste0928/cargo-install@v3 51 | with: 52 | crate: cargo-about 53 | version: "0.6.4" 54 | - name: Run license check 55 | run: cargo about generate about.hbs > license.html 56 | - name: Archive license file 57 | uses: actions/upload-artifact@v4 58 | with: 59 | name: license 60 | path: license.html -------------------------------------------------------------------------------- /rust/examples/random.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | use warp::chunk::{Chunk, ChunkKind, CompressionType}; 3 | use warp::mock::{mock_function, mock_function_type_class, mock_type}; 4 | use warp::r#type::chunk::TypeChunk; 5 | use warp::signature::chunk::SignatureChunk; 6 | use warp::WarpFileHeader; 7 | 8 | fn main() { 9 | let args: Vec = env::args().collect(); 10 | if args.len() < 2 { 11 | eprintln!("Usage: {} ", args[0]); 12 | std::process::exit(1); 13 | } 14 | let count: u32 = args[1].parse().expect("Valid integer"); 15 | 16 | // Fill out a signature chunk with functions. 17 | let mut functions = Vec::new(); 18 | for i in 0..count { 19 | functions.push(mock_function(&format!("function_{}", i))); 20 | } 21 | let _signature_chunk = SignatureChunk::new(&functions).expect("Failed to create chunk"); 22 | let signature_chunk = Chunk::new( 23 | ChunkKind::Signature(_signature_chunk), 24 | CompressionType::Zstd, 25 | ); 26 | println!("Created signature chunk with {} functions...", count); 27 | 28 | // Fill out a type chunk with types. 29 | let mut types = Vec::new(); 30 | for i in 0..count { 31 | types.push(mock_type( 32 | &format!("type_{}", i), 33 | mock_function_type_class(), 34 | )); 35 | } 36 | let _type_chunk = TypeChunk::new(&types).expect("Failed to create chunk"); 37 | let type_chunk = Chunk::new(ChunkKind::Type(_type_chunk), CompressionType::Zstd); 38 | println!("Created type chunk with {} types...", types.len()); 39 | 40 | let file = warp::WarpFile::new(WarpFileHeader::new(), vec![signature_chunk, type_chunk]); 41 | println!("Created file with {} chunks...", file.chunks.len()); 42 | 43 | std::fs::write("random.warp", file.to_bytes()).expect("Failed to write file"); 44 | } 45 | -------------------------------------------------------------------------------- /rust/src/type/guid.rs: -------------------------------------------------------------------------------- 1 | use crate::fb_type as fb; 2 | use crate::r#type::Type; 3 | use std::fmt::{Debug, Display, Formatter}; 4 | use std::str::FromStr; 5 | use uuid::{uuid, Uuid}; 6 | 7 | pub const NAMESPACE_TYPEBIN: Uuid = uuid!("01929b90-72e6-73e6-9da1-2b6462e407a6"); 8 | 9 | /// This type is marked `repr(transparent)` to the underlying `[u8; 16]` type, so it is safe to use in FFI. 10 | #[repr(transparent)] 11 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)] 12 | pub struct TypeGUID { 13 | guid: Uuid, 14 | } 15 | 16 | impl FromStr for TypeGUID { 17 | type Err = uuid::Error; 18 | 19 | fn from_str(s: &str) -> Result { 20 | Uuid::parse_str(s).map(Into::into) 21 | } 22 | } 23 | 24 | impl From for TypeGUID { 25 | fn from(value: Type) -> Self { 26 | Self::from(&value) 27 | } 28 | } 29 | 30 | impl From<&Type> for TypeGUID { 31 | fn from(value: &Type) -> Self { 32 | Self { 33 | guid: Uuid::new_v5(&NAMESPACE_TYPEBIN, &value.to_bytes()), 34 | } 35 | } 36 | } 37 | 38 | impl From for TypeGUID { 39 | fn from(value: Uuid) -> Self { 40 | Self { guid: value } 41 | } 42 | } 43 | 44 | impl From for TypeGUID { 45 | fn from(value: fb::TypeGUID) -> Self { 46 | Self { 47 | guid: Uuid::from_bytes(value.0), 48 | } 49 | } 50 | } 51 | 52 | impl From<&fb::TypeGUID> for TypeGUID { 53 | fn from(value: &fb::TypeGUID) -> Self { 54 | Self::from(*value) 55 | } 56 | } 57 | 58 | impl From for fb::TypeGUID { 59 | fn from(value: TypeGUID) -> Self { 60 | Self(value.guid.into_bytes()) 61 | } 62 | } 63 | 64 | impl Display for TypeGUID { 65 | fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { 66 | Display::fmt(&self.guid, f) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/array_modifiers_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[allow(non_upper_case_globals)] 13 | mod bitflags_array_modifiers { 14 | flatbuffers::bitflags::bitflags! { 15 | #[derive(Default, Debug, Clone, Copy, PartialEq)] 16 | pub struct ArrayModifiers: u8 { 17 | const NullTerminated = 1; 18 | } 19 | } 20 | } 21 | pub use self::bitflags_array_modifiers::ArrayModifiers; 22 | 23 | impl<'a> flatbuffers::Follow<'a> for ArrayModifiers { 24 | type Inner = Self; 25 | #[inline] 26 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 27 | let b = flatbuffers::read_scalar_at::(buf, loc); 28 | Self::from_bits_retain(b) 29 | } 30 | } 31 | 32 | impl flatbuffers::Push for ArrayModifiers { 33 | type Output = ArrayModifiers; 34 | #[inline] 35 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 36 | flatbuffers::emplace_scalar::(dst, self.bits()); 37 | } 38 | } 39 | 40 | impl flatbuffers::EndianScalar for ArrayModifiers { 41 | type Scalar = u8; 42 | #[inline] 43 | fn to_little_endian(self) -> u8 { 44 | self.bits().to_le() 45 | } 46 | #[inline] 47 | #[allow(clippy::wrong_self_convention)] 48 | fn from_little_endian(v: u8) -> Self { 49 | let b = u8::from_le(v); 50 | Self::from_bits_retain(b) 51 | } 52 | } 53 | 54 | impl<'a> flatbuffers::Verifiable for ArrayModifiers { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | u8::run_verifier(v, pos) 61 | } 62 | } 63 | 64 | impl flatbuffers::SimpleToVerifyInSlice for ArrayModifiers {} 65 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/type_modifiers_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[allow(non_upper_case_globals)] 13 | mod bitflags_type_modifiers { 14 | flatbuffers::bitflags::bitflags! { 15 | #[derive(Default, Debug, Clone, Copy, PartialEq)] 16 | pub struct TypeModifiers: u8 { 17 | const Constant = 1; 18 | const Volatile = 2; 19 | } 20 | } 21 | } 22 | pub use self::bitflags_type_modifiers::TypeModifiers; 23 | 24 | impl<'a> flatbuffers::Follow<'a> for TypeModifiers { 25 | type Inner = Self; 26 | #[inline] 27 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 28 | let b = flatbuffers::read_scalar_at::(buf, loc); 29 | Self::from_bits_retain(b) 30 | } 31 | } 32 | 33 | impl flatbuffers::Push for TypeModifiers { 34 | type Output = TypeModifiers; 35 | #[inline] 36 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 37 | flatbuffers::emplace_scalar::(dst, self.bits()); 38 | } 39 | } 40 | 41 | impl flatbuffers::EndianScalar for TypeModifiers { 42 | type Scalar = u8; 43 | #[inline] 44 | fn to_little_endian(self) -> u8 { 45 | self.bits().to_le() 46 | } 47 | #[inline] 48 | #[allow(clippy::wrong_self_convention)] 49 | fn from_little_endian(v: u8) -> Self { 50 | let b = u8::from_le(v); 51 | Self::from_bits_retain(b) 52 | } 53 | } 54 | 55 | impl<'a> flatbuffers::Verifiable for TypeModifiers { 56 | #[inline] 57 | fn run_verifier( 58 | v: &mut flatbuffers::Verifier, pos: usize 59 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 60 | use self::flatbuffers::Verifiable; 61 | u8::run_verifier(v, pos) 62 | } 63 | } 64 | 65 | impl flatbuffers::SimpleToVerifyInSlice for TypeModifiers {} 66 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/symbol_bin/symbol_modifiers_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[allow(non_upper_case_globals)] 13 | mod bitflags_symbol_modifiers { 14 | flatbuffers::bitflags::bitflags! { 15 | #[derive(Default, Debug, Clone, Copy, PartialEq)] 16 | pub struct SymbolModifiers: u8 { 17 | const External = 1; 18 | const Exported = 2; 19 | } 20 | } 21 | } 22 | pub use self::bitflags_symbol_modifiers::SymbolModifiers; 23 | 24 | impl<'a> flatbuffers::Follow<'a> for SymbolModifiers { 25 | type Inner = Self; 26 | #[inline] 27 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 28 | let b = flatbuffers::read_scalar_at::(buf, loc); 29 | Self::from_bits_retain(b) 30 | } 31 | } 32 | 33 | impl flatbuffers::Push for SymbolModifiers { 34 | type Output = SymbolModifiers; 35 | #[inline] 36 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 37 | flatbuffers::emplace_scalar::(dst, self.bits()); 38 | } 39 | } 40 | 41 | impl flatbuffers::EndianScalar for SymbolModifiers { 42 | type Scalar = u8; 43 | #[inline] 44 | fn to_little_endian(self) -> u8 { 45 | self.bits().to_le() 46 | } 47 | #[inline] 48 | #[allow(clippy::wrong_self_convention)] 49 | fn from_little_endian(v: u8) -> Self { 50 | let b = u8::from_le(v); 51 | Self::from_bits_retain(b) 52 | } 53 | } 54 | 55 | impl<'a> flatbuffers::Verifiable for SymbolModifiers { 56 | #[inline] 57 | fn run_verifier( 58 | v: &mut flatbuffers::Verifier, pos: usize 59 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 60 | use self::flatbuffers::Verifiable; 61 | u8::run_verifier(v, pos) 62 | } 63 | } 64 | 65 | impl flatbuffers::SimpleToVerifyInSlice for SymbolModifiers {} 66 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/structure_member_modifiers_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[allow(non_upper_case_globals)] 13 | mod bitflags_structure_member_modifiers { 14 | flatbuffers::bitflags::bitflags! { 15 | #[derive(Default, Debug, Clone, Copy, PartialEq)] 16 | pub struct StructureMemberModifiers: u8 { 17 | const Internal = 1; 18 | const Flattened = 2; 19 | } 20 | } 21 | } 22 | pub use self::bitflags_structure_member_modifiers::StructureMemberModifiers; 23 | 24 | impl<'a> flatbuffers::Follow<'a> for StructureMemberModifiers { 25 | type Inner = Self; 26 | #[inline] 27 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 28 | let b = flatbuffers::read_scalar_at::(buf, loc); 29 | Self::from_bits_retain(b) 30 | } 31 | } 32 | 33 | impl flatbuffers::Push for StructureMemberModifiers { 34 | type Output = StructureMemberModifiers; 35 | #[inline] 36 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 37 | flatbuffers::emplace_scalar::(dst, self.bits()); 38 | } 39 | } 40 | 41 | impl flatbuffers::EndianScalar for StructureMemberModifiers { 42 | type Scalar = u8; 43 | #[inline] 44 | fn to_little_endian(self) -> u8 { 45 | self.bits().to_le() 46 | } 47 | #[inline] 48 | #[allow(clippy::wrong_self_convention)] 49 | fn from_little_endian(v: u8) -> Self { 50 | let b = u8::from_le(v); 51 | Self::from_bits_retain(b) 52 | } 53 | } 54 | 55 | impl<'a> flatbuffers::Verifiable for StructureMemberModifiers { 56 | #[inline] 57 | fn run_verifier( 58 | v: &mut flatbuffers::Verifier, pos: usize 59 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 60 | use self::flatbuffers::Verifiable; 61 | u8::run_verifier(v, pos) 62 | } 63 | } 64 | 65 | impl flatbuffers::SimpleToVerifyInSlice for StructureMemberModifiers {} 66 | -------------------------------------------------------------------------------- /about.hbs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 37 | Third Party Licenses 38 | 39 | 40 | 41 |
42 |
43 |

Third Party Licenses

44 |

This page lists the licenses of the projects used in warp.

45 |
46 | 47 |

Overview of licenses:

48 |
    49 | {{#each overview}} 50 |
  • {{name}} ({{count}})
  • 51 | {{/each}} 52 |
53 | 54 |

All license text:

55 |
    56 | {{#each licenses}} 57 |
  • 58 |

    {{name}}

    59 |

    Used by:

    60 | 65 |
    {{text}}
    66 |
  • 67 | {{/each}} 68 |
69 |
70 | 71 | 72 | -------------------------------------------------------------------------------- /rust/src/signature/variable.rs: -------------------------------------------------------------------------------- 1 | use crate::cached_builder::CachedFlatBufferBuilder; 2 | use crate::fb_sig as fb; 3 | use crate::gen_flatbuffers::type_bin::LocationClass; 4 | use crate::r#type::class::function::{Location, RegisterLocation, StackLocation}; 5 | use crate::r#type::Type; 6 | use crate::{FlatBufferObject, FlatBufferUnion}; 7 | use flatbuffers::WIPOffset; 8 | 9 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] 10 | pub struct FunctionVariable { 11 | pub offset: i64, 12 | pub location: Location, 13 | pub name: Option, 14 | pub ty: Option, 15 | } 16 | 17 | impl FlatBufferObject for FunctionVariable { 18 | type FbType<'fbb> = fb::FunctionVariable<'fbb>; 19 | 20 | fn create<'fbb>( 21 | &self, 22 | builder: &mut CachedFlatBufferBuilder<'fbb>, 23 | ) -> WIPOffset> { 24 | let location_type = self.location.ty(); 25 | let location = self.location.create(builder); 26 | let ty = self.ty.as_ref().map(|t| t.create(builder)); 27 | let name = self.name.as_ref().map(|n| builder.create_string(n)); 28 | fb::FunctionVariable::create( 29 | builder, 30 | &fb::FunctionVariableArgs { 31 | offset: self.offset, 32 | name, 33 | location_type, 34 | location: Some(location), 35 | type_: ty, 36 | }, 37 | ) 38 | } 39 | 40 | fn from_object(value: &Self::FbType<'_>) -> Option { 41 | let location = match value.location_type() { 42 | LocationClass::RegisterLocation => { 43 | let register_loc = value.location_as_register_location()?; 44 | Location::Register(RegisterLocation::from_object(®ister_loc)?) 45 | } 46 | LocationClass::StackLocation => { 47 | let stack_loc = value.location_as_stack_location()?; 48 | Location::Stack(StackLocation::from_object(&stack_loc)?) 49 | } 50 | // NOTE: Unknown location class, probable malformed data. 51 | _ => return None, 52 | }; 53 | 54 | let ty = value.type_().and_then(|ty| Type::from_object(&ty)); 55 | Some(Self { 56 | offset: value.offset(), 57 | location, 58 | name: value.name().map(|s| s.to_string()), 59 | ty, 60 | }) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /rust/benches/chunk.rs: -------------------------------------------------------------------------------- 1 | use criterion::{criterion_group, criterion_main, Criterion}; 2 | use std::str::FromStr; 3 | use warp::chunk::{Chunk, ChunkKind, CompressionType}; 4 | use warp::mock::{mock_function, mock_function_type_class, mock_type}; 5 | use warp::r#type::chunk::TypeChunk; 6 | use warp::signature::chunk::SignatureChunk; 7 | use warp::signature::function::FunctionGUID; 8 | use warp::{WarpFile, WarpFileHeader}; 9 | 10 | pub fn chunk_benchmark(c: &mut Criterion) { 11 | let count = 10000; 12 | // Fill out a signature chunk with functions. 13 | let mut functions = Vec::new(); 14 | for i in 0..count { 15 | functions.push(mock_function(&format!("function_{}", i))); 16 | } 17 | let mut _signature_chunk = SignatureChunk::new(&functions).expect("Failed to create chunk"); 18 | let signature_chunk = Chunk::new( 19 | ChunkKind::Signature(_signature_chunk.clone()), 20 | CompressionType::None, 21 | ); 22 | 23 | // Fill out a type chunk with types. 24 | let mut types = Vec::new(); 25 | for i in 0..count { 26 | types.push(mock_type( 27 | &format!("type_{}", i), 28 | mock_function_type_class(), 29 | )); 30 | } 31 | let _type_chunk = TypeChunk::new(&types).expect("Failed to create chunk"); 32 | let type_chunk = Chunk::new(ChunkKind::Type(_type_chunk), CompressionType::Zstd); 33 | let file = WarpFile::new( 34 | WarpFileHeader::new(), 35 | vec![signature_chunk.clone(), type_chunk], 36 | ); 37 | c.bench_function("file to bytes", |b| { 38 | b.iter(|| { 39 | file.to_bytes(); 40 | }) 41 | }); 42 | 43 | let known_function = functions.get(326).expect("Failed to get function 326").guid; 44 | c.bench_function("find known function", |b| { 45 | b.iter(|| { 46 | _signature_chunk 47 | .raw_functions_with_guid(&known_function) 48 | .count() 49 | }) 50 | }); 51 | 52 | let unknown_function = FunctionGUID::from_str("467aae0d-84d4-4804-90d2-a62159502367") 53 | .expect("Failed to get unknown function GUID"); 54 | c.bench_function("find unknown function", |b| { 55 | b.iter(|| { 56 | _signature_chunk 57 | .raw_functions_with_guid(&unknown_function) 58 | .count() 59 | }) 60 | }); 61 | } 62 | 63 | criterion_group!(benches, chunk_benchmark); 64 | criterion_main!(benches); 65 | -------------------------------------------------------------------------------- /rust/src/type/class/array.rs: -------------------------------------------------------------------------------- 1 | use bon::bon; 2 | use std::hash::Hash; 3 | 4 | use crate::cached_builder::CachedFlatBufferBuilder; 5 | use crate::r#type::Type; 6 | use crate::{fb_type as fb, FlatBufferObject}; 7 | use flatbuffers::WIPOffset; 8 | 9 | // We re-export bit flags as there is no need to wrap them. 10 | pub use fb::ArrayModifiers; 11 | 12 | #[derive(Clone, Debug, PartialEq)] 13 | pub struct ArrayClass { 14 | pub length: Option, 15 | pub member_type: Box, 16 | pub modifiers: ArrayModifiers, 17 | } 18 | 19 | #[bon] 20 | impl ArrayClass { 21 | #[builder] 22 | pub fn new(length: Option, member_type: Type, modifiers: Option) -> Self { 23 | Self { 24 | length, 25 | member_type: Box::new(member_type), 26 | modifiers: modifiers.unwrap_or_default(), 27 | } 28 | } 29 | } 30 | 31 | impl ArrayClass { 32 | pub fn size(&self) -> Option { 33 | Some(self.length? * self.member_type.size()?) 34 | } 35 | } 36 | 37 | impl FlatBufferObject for ArrayClass { 38 | type FbType<'fbb> = fb::Array<'fbb>; 39 | 40 | fn create<'fbb>( 41 | &self, 42 | builder: &mut CachedFlatBufferBuilder<'fbb>, 43 | ) -> WIPOffset> { 44 | let member_type = self.member_type.create(builder); 45 | fb::Array::create( 46 | builder, 47 | &fb::ArrayArgs { 48 | type_: Some(member_type), 49 | // NOTE: 0 means the array is dynamically sized. 50 | // TODO: Is this correct? 51 | length: self.length.unwrap_or(0), 52 | modifiers: self.modifiers, 53 | }, 54 | ) 55 | } 56 | 57 | fn from_object(value: &Self::FbType<'_>) -> Option { 58 | let class = Self { 59 | length: match value.length() { 60 | 0 => None, 61 | len => Some(len), 62 | }, 63 | member_type: Box::new(Type::from_object(&value.type_())?), 64 | modifiers: value.modifiers(), 65 | }; 66 | 67 | Some(class) 68 | } 69 | } 70 | 71 | impl Eq for ArrayClass {} 72 | 73 | impl Hash for ArrayClass { 74 | fn hash(&self, state: &mut H) { 75 | self.length.hash(state); 76 | self.member_type.hash(state); 77 | // NOTE: Flatbuffers currently do not add Hash impl for bitfields. 78 | self.modifiers.bits().hash(state); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /rust/src/type/class/integer.rs: -------------------------------------------------------------------------------- 1 | use crate::cached_builder::CachedFlatBufferBuilder; 2 | use crate::{fb_type as fb, FlatBufferObject}; 3 | use bon::Builder; 4 | use flatbuffers::WIPOffset; 5 | 6 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Builder)] 7 | pub struct IntegerClass { 8 | /// Width in bits 9 | pub width: Option, 10 | pub signed: bool, 11 | } 12 | 13 | impl IntegerClass { 14 | pub fn size(&self) -> Option { 15 | self.width.map(|w| w as u64) 16 | } 17 | } 18 | 19 | impl FlatBufferObject for IntegerClass { 20 | type FbType<'fbb> = fb::Integer<'fbb>; 21 | 22 | fn create<'fbb>( 23 | &self, 24 | builder: &mut CachedFlatBufferBuilder<'fbb>, 25 | ) -> WIPOffset> { 26 | fb::Integer::create( 27 | builder, 28 | &fb::IntegerArgs { 29 | width: self.width.map(Into::into).as_ref(), 30 | signed: self.signed, 31 | }, 32 | ) 33 | } 34 | 35 | fn from_object(value: &Self::FbType<'_>) -> Option { 36 | Some(Self { 37 | width: value.width().map(Into::into), 38 | signed: value.signed(), 39 | }) 40 | } 41 | } 42 | 43 | #[cfg(test)] 44 | mod tests { 45 | use crate::r#type::class::{IntegerClass, TypeClass}; 46 | use crate::r#type::guid::TypeGUID; 47 | use crate::r#type::Type; 48 | use uuid::{uuid, Uuid}; 49 | 50 | const INT_TYPE_UUID: Uuid = uuid!("ec8805ad-b101-5d8c-a033-c94610d036c1"); 51 | 52 | fn built_int_type() -> Type { 53 | let int_class = IntegerClass::builder().width(64).signed(true).build(); 54 | Type::builder() 55 | .name("my_int".to_owned()) 56 | .class(int_class) 57 | .build() 58 | } 59 | 60 | #[test] 61 | fn int_guid_v1() { 62 | assert_eq!(TypeGUID::from(INT_TYPE_UUID), built_int_type().into()); 63 | } 64 | 65 | #[test] 66 | fn int_type() { 67 | assert_eq!( 68 | Type { 69 | name: Some("my_int".to_owned()), 70 | class: TypeClass::Integer(IntegerClass { 71 | width: Some(64), 72 | signed: true 73 | }), 74 | confidence: u8::MAX, 75 | modifiers: Default::default(), 76 | metadata: vec![], 77 | alignment: Default::default(), 78 | ancestors: vec![], 79 | }, 80 | built_int_type() 81 | ) 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /rust/tests/file.rs: -------------------------------------------------------------------------------- 1 | use warp::chunk::{Chunk, ChunkKind, CompressionType}; 2 | use warp::mock::mock_function; 3 | use warp::signature::chunk::SignatureChunk; 4 | use warp::{WarpFile, WarpFileHeader}; 5 | 6 | #[test] 7 | fn test_file_creation() { 8 | // Construct a signature chunk to check for on file creation. 9 | let func_0 = mock_function("func_0"); 10 | let func_1 = mock_function("func_1"); 11 | let func_2 = mock_function("func_2"); 12 | let funcs = vec![func_0, func_1, func_2]; 13 | let signature_chunk = SignatureChunk::new(&funcs).expect("Failed to create signature chunk"); 14 | let chunk_kind = ChunkKind::Signature(signature_chunk.clone()); 15 | let chunk = Chunk::new(chunk_kind.clone(), CompressionType::None); 16 | let compressed_chunk = Chunk::new(chunk_kind, CompressionType::Zstd); 17 | let chunks = vec![chunk, compressed_chunk]; 18 | 19 | // Create the file and check the contents. 20 | let file_header = WarpFileHeader::new(); 21 | let file = WarpFile::new(file_header, chunks); 22 | assert_eq!(file.header.version, 1); 23 | assert_eq!(file.chunks.len(), 2); 24 | assert_eq!( 25 | file.chunks[0].kind, 26 | ChunkKind::Signature(signature_chunk.clone()) 27 | ); 28 | assert_eq!( 29 | file.chunks[1].kind, 30 | ChunkKind::Signature(signature_chunk.clone()) 31 | ); 32 | 33 | // Read the file back and check the contents. 34 | let file_bytes = file.to_bytes(); 35 | let file_read = WarpFile::from_bytes(&file_bytes).expect("Failed to read file"); 36 | assert_eq!(file_read.header.version, 1); 37 | assert_eq!( 38 | file_read.chunks.len(), 39 | 2, 40 | "Both uncompressed and compressed chunk should have been read" 41 | ); 42 | assert_eq!( 43 | file_read.chunks[0].kind, 44 | ChunkKind::Signature(signature_chunk.clone()) 45 | ); 46 | assert_eq!( 47 | file_read.chunks[1].kind, 48 | ChunkKind::Signature(signature_chunk.clone()) 49 | ); 50 | } 51 | 52 | #[test] 53 | fn test_file_format_regression() { 54 | // Test that the "../fixtures/random.warp" file can be read. 55 | // This file was created with a previous version of Warp and should still be readable. 56 | // If this test fails, it means the format has changed in a backwards incompatible way. 57 | let file_bytes = include_bytes!("../fixtures/random.warp"); 58 | let _file_read = 59 | WarpFile::from_bytes(file_bytes).expect("Failed to read file, format must have changed!"); 60 | insta::assert_debug_snapshot!(_file_read); 61 | } 62 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/void_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum VoidOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Void<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Void<'a> { 20 | type Inner = Void<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Void<'a> { 28 | 29 | #[inline] 30 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 31 | Void { _tab: table } 32 | } 33 | #[allow(unused_mut)] 34 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 35 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 36 | _args: &'args VoidArgs 37 | ) -> flatbuffers::WIPOffset> { 38 | let mut builder = VoidBuilder::new(_fbb); 39 | builder.finish() 40 | } 41 | 42 | } 43 | 44 | impl flatbuffers::Verifiable for Void<'_> { 45 | #[inline] 46 | fn run_verifier( 47 | v: &mut flatbuffers::Verifier, pos: usize 48 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 49 | use self::flatbuffers::Verifiable; 50 | v.visit_table(pos)? 51 | .finish(); 52 | Ok(()) 53 | } 54 | } 55 | pub struct VoidArgs { 56 | } 57 | impl<'a> Default for VoidArgs { 58 | #[inline] 59 | fn default() -> Self { 60 | VoidArgs { 61 | } 62 | } 63 | } 64 | 65 | pub struct VoidBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 66 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 67 | start_: flatbuffers::WIPOffset, 68 | } 69 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> VoidBuilder<'a, 'b, A> { 70 | #[inline] 71 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> VoidBuilder<'a, 'b, A> { 72 | let start = _fbb.start_table(); 73 | VoidBuilder { 74 | fbb_: _fbb, 75 | start_: start, 76 | } 77 | } 78 | #[inline] 79 | pub fn finish(self) -> flatbuffers::WIPOffset> { 80 | let o = self.fbb_.end_table(self.start_); 81 | flatbuffers::WIPOffset::new(o.value()) 82 | } 83 | } 84 | 85 | impl core::fmt::Debug for Void<'_> { 86 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 87 | let mut ds = f.debug_struct("Void"); 88 | ds.finish() 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /warp_cli/src/operation/find.rs: -------------------------------------------------------------------------------- 1 | use crate::operation::OperationHandler; 2 | use crate::utility::open_file; 3 | use clap::Parser; 4 | use std::path::Path; 5 | use warp::chunk::{Chunk, ChunkKind}; 6 | use warp::r#type::chunk::TypeChunk; 7 | use warp::r#type::ComputedType; 8 | use warp::signature::chunk::SignatureChunk; 9 | use warp::signature::function::Function; 10 | 11 | // TODO: Filter by chunk type. 12 | /// Find an item in the file given a set of filters like name. 13 | #[derive(Clone, Debug, Parser)] 14 | pub struct FindOp { 15 | /// Find any item with the given string. 16 | /// 17 | /// NOTE: This lookup is currently done 18 | #[arg(index = 1)] 19 | any: Option, 20 | } 21 | 22 | impl FindOp { 23 | pub fn dump_function(&self, function: &Function) { 24 | println!("Function: {function:?}"); 25 | } 26 | 27 | pub fn dump_type(&self, ty: &ComputedType) { 28 | println!("Type: {ty:?}"); 29 | } 30 | 31 | pub fn find_in_signature(&self, func: &Function) -> bool { 32 | let str = format!("{func:?}"); 33 | str.contains(self.any.as_deref().unwrap_or("")) 34 | } 35 | 36 | pub fn find_in_signature_chunk(&self, sc: &SignatureChunk) -> Vec { 37 | sc.functions() 38 | .filter(|f| self.find_in_signature(f)) 39 | .collect() 40 | } 41 | 42 | pub fn find_in_computed_type(&self, computed_ty: &ComputedType) -> bool { 43 | let str = format!("{computed_ty:?}"); 44 | str.contains(self.any.as_deref().unwrap_or("")) 45 | } 46 | 47 | pub fn find_in_type_chunk(&self, tc: &TypeChunk) -> Vec { 48 | tc.types() 49 | .filter(|ct| self.find_in_computed_type(ct)) 50 | .collect() 51 | } 52 | 53 | pub fn find_in_chunk(&self, chunk: &Chunk) { 54 | match &chunk.kind { 55 | ChunkKind::Signature(sc) => { 56 | for found_func in self.find_in_signature_chunk(sc) { 57 | self.dump_function(&found_func) 58 | } 59 | } 60 | ChunkKind::Type(tc) => { 61 | for found_ty in self.find_in_type_chunk(tc) { 62 | self.dump_type(&found_ty) 63 | } 64 | } 65 | } 66 | } 67 | } 68 | 69 | impl OperationHandler for FindOp { 70 | fn run(&self, path: &Path) { 71 | let file = open_file(path); 72 | for chunk in file.chunks { 73 | println!( 74 | "Searching in chunk ({}, 0x{:x} bytes)", 75 | chunk.header.chunk_type.variant_name().unwrap_or_default(), 76 | chunk.header.size 77 | ); 78 | self.find_in_chunk(&chunk); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /rust/src/symbol.rs: -------------------------------------------------------------------------------- 1 | use crate::{fb_symbol as fb, FlatBufferObject}; 2 | use flatbuffers::WIPOffset; 3 | use std::hash::Hash; 4 | 5 | use crate::cached_builder::CachedFlatBufferBuilder; 6 | pub use fb::SymbolClass; 7 | pub use fb::SymbolModifiers; 8 | 9 | #[derive(Clone, Debug, PartialEq)] 10 | pub struct Symbol { 11 | pub name: String, 12 | pub modifiers: SymbolModifiers, 13 | pub class: SymbolClass, 14 | } 15 | 16 | impl Symbol { 17 | pub fn new(name: impl Into, class: SymbolClass, modifiers: SymbolModifiers) -> Self { 18 | Self { 19 | name: name.into(), 20 | modifiers, 21 | class, 22 | } 23 | } 24 | } 25 | 26 | impl FlatBufferObject for Symbol { 27 | type FbType<'fbb> = fb::Symbol<'fbb>; 28 | 29 | fn create<'fbb>( 30 | &self, 31 | builder: &mut CachedFlatBufferBuilder<'fbb>, 32 | ) -> WIPOffset> { 33 | let name = builder.create_string(&self.name); 34 | 35 | fb::Symbol::create( 36 | builder, 37 | &fb::SymbolArgs { 38 | name: Some(name), 39 | modifiers: self.modifiers, 40 | class: self.class, 41 | }, 42 | ) 43 | } 44 | 45 | fn from_object(value: &Self::FbType<'_>) -> Option { 46 | let sym = Self { 47 | name: value.name()?.to_string(), 48 | modifiers: value.modifiers(), 49 | class: value.class(), 50 | }; 51 | 52 | Some(sym) 53 | } 54 | } 55 | 56 | impl Eq for Symbol {} 57 | 58 | impl Hash for Symbol { 59 | fn hash(&self, state: &mut H) { 60 | self.name.hash(state); 61 | self.modifiers.bits().hash(state); 62 | self.class.hash(state); 63 | } 64 | } 65 | 66 | impl Ord for Symbol { 67 | fn cmp(&self, other: &Self) -> std::cmp::Ordering { 68 | // NOTE: Flatbuffers currently do not add Ord impl for bitfields. 69 | self.name 70 | .cmp(&other.name) 71 | .then(self.modifiers.bits().cmp(&other.modifiers.bits())) 72 | .then(self.class.cmp(&other.class)) 73 | } 74 | } 75 | 76 | impl PartialOrd for Symbol { 77 | fn partial_cmp(&self, other: &Self) -> Option { 78 | Some(self.cmp(other)) 79 | } 80 | } 81 | 82 | #[cfg(test)] 83 | mod tests { 84 | use super::*; 85 | 86 | #[test] 87 | fn it_works() { 88 | let mut builder = CachedFlatBufferBuilder::new(); 89 | let symbol = Symbol { 90 | name: "".to_string(), 91 | modifiers: SymbolModifiers::empty(), 92 | class: SymbolClass::Data, 93 | }; 94 | let _created_symbol = symbol.create(&mut builder); 95 | // TODO: Add actual tests. 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/type_guid_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | // struct TypeGUID, aligned to 1 13 | #[repr(transparent)] 14 | #[derive(Clone, Copy, PartialEq)] 15 | pub struct TypeGUID(pub [u8; 16]); 16 | impl Default for TypeGUID { 17 | fn default() -> Self { 18 | Self([0; 16]) 19 | } 20 | } 21 | impl core::fmt::Debug for TypeGUID { 22 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 23 | f.debug_struct("TypeGUID") 24 | .field("value", &self.value()) 25 | .finish() 26 | } 27 | } 28 | 29 | impl flatbuffers::SimpleToVerifyInSlice for TypeGUID {} 30 | impl<'a> flatbuffers::Follow<'a> for TypeGUID { 31 | type Inner = &'a TypeGUID; 32 | #[inline] 33 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 34 | <&'a TypeGUID>::follow(buf, loc) 35 | } 36 | } 37 | impl<'a> flatbuffers::Follow<'a> for &'a TypeGUID { 38 | type Inner = &'a TypeGUID; 39 | #[inline] 40 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 41 | flatbuffers::follow_cast_ref::(buf, loc) 42 | } 43 | } 44 | impl<'b> flatbuffers::Push for TypeGUID { 45 | type Output = TypeGUID; 46 | #[inline] 47 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 48 | let src = ::core::slice::from_raw_parts(self as *const TypeGUID as *const u8, ::size()); 49 | dst.copy_from_slice(src); 50 | } 51 | #[inline] 52 | fn alignment() -> flatbuffers::PushAlignment { 53 | flatbuffers::PushAlignment::new(1) 54 | } 55 | } 56 | 57 | impl<'a> flatbuffers::Verifiable for TypeGUID { 58 | #[inline] 59 | fn run_verifier( 60 | v: &mut flatbuffers::Verifier, pos: usize 61 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 62 | use self::flatbuffers::Verifiable; 63 | v.in_buffer::(pos) 64 | } 65 | } 66 | 67 | impl<'a> TypeGUID { 68 | #[allow(clippy::too_many_arguments)] 69 | pub fn new( 70 | value: &[u8; 16], 71 | ) -> Self { 72 | let mut s = Self([0; 16]); 73 | s.set_value(value); 74 | s 75 | } 76 | 77 | pub fn value(&'a self) -> flatbuffers::Array<'a, u8, 16> { 78 | // Safety: 79 | // Created from a valid Table for this object 80 | // Which contains a valid array in this slot 81 | unsafe { flatbuffers::Array::follow(&self.0, 0) } 82 | } 83 | 84 | pub fn set_value(&mut self, items: &[u8; 16]) { 85 | // Safety: 86 | // Created from a valid Table for this object 87 | // Which contains a valid array in this slot 88 | unsafe { flatbuffers::emplace_scalar_array(&mut self.0, 0, items) }; 89 | } 90 | 91 | } 92 | 93 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/sig_bin/function_guid_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | // struct FunctionGUID, aligned to 1 13 | #[repr(transparent)] 14 | #[derive(Clone, Copy, PartialEq)] 15 | pub struct FunctionGUID(pub [u8; 16]); 16 | impl Default for FunctionGUID { 17 | fn default() -> Self { 18 | Self([0; 16]) 19 | } 20 | } 21 | impl core::fmt::Debug for FunctionGUID { 22 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 23 | f.debug_struct("FunctionGUID") 24 | .field("value", &self.value()) 25 | .finish() 26 | } 27 | } 28 | 29 | impl flatbuffers::SimpleToVerifyInSlice for FunctionGUID {} 30 | impl<'a> flatbuffers::Follow<'a> for FunctionGUID { 31 | type Inner = &'a FunctionGUID; 32 | #[inline] 33 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 34 | <&'a FunctionGUID>::follow(buf, loc) 35 | } 36 | } 37 | impl<'a> flatbuffers::Follow<'a> for &'a FunctionGUID { 38 | type Inner = &'a FunctionGUID; 39 | #[inline] 40 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 41 | flatbuffers::follow_cast_ref::(buf, loc) 42 | } 43 | } 44 | impl<'b> flatbuffers::Push for FunctionGUID { 45 | type Output = FunctionGUID; 46 | #[inline] 47 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 48 | let src = ::core::slice::from_raw_parts(self as *const FunctionGUID as *const u8, ::size()); 49 | dst.copy_from_slice(src); 50 | } 51 | #[inline] 52 | fn alignment() -> flatbuffers::PushAlignment { 53 | flatbuffers::PushAlignment::new(1) 54 | } 55 | } 56 | 57 | impl<'a> flatbuffers::Verifiable for FunctionGUID { 58 | #[inline] 59 | fn run_verifier( 60 | v: &mut flatbuffers::Verifier, pos: usize 61 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 62 | use self::flatbuffers::Verifiable; 63 | v.in_buffer::(pos) 64 | } 65 | } 66 | 67 | impl<'a> FunctionGUID { 68 | #[allow(clippy::too_many_arguments)] 69 | pub fn new( 70 | value: &[u8; 16], 71 | ) -> Self { 72 | let mut s = Self([0; 16]); 73 | s.set_value(value); 74 | s 75 | } 76 | 77 | pub fn value(&'a self) -> flatbuffers::Array<'a, u8, 16> { 78 | // Safety: 79 | // Created from a valid Table for this object 80 | // Which contains a valid array in this slot 81 | unsafe { flatbuffers::Array::follow(&self.0, 0) } 82 | } 83 | 84 | pub fn set_value(&mut self, items: &[u8; 16]) { 85 | // Safety: 86 | // Created from a valid Table for this object 87 | // Which contains a valid array in this slot 88 | unsafe { flatbuffers::emplace_scalar_array(&mut self.0, 0, items) }; 89 | } 90 | 91 | } 92 | 93 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/sig_bin/basic_block_guid_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | // struct BasicBlockGUID, aligned to 1 13 | #[repr(transparent)] 14 | #[derive(Clone, Copy, PartialEq)] 15 | pub struct BasicBlockGUID(pub [u8; 16]); 16 | impl Default for BasicBlockGUID { 17 | fn default() -> Self { 18 | Self([0; 16]) 19 | } 20 | } 21 | impl core::fmt::Debug for BasicBlockGUID { 22 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 23 | f.debug_struct("BasicBlockGUID") 24 | .field("value", &self.value()) 25 | .finish() 26 | } 27 | } 28 | 29 | impl flatbuffers::SimpleToVerifyInSlice for BasicBlockGUID {} 30 | impl<'a> flatbuffers::Follow<'a> for BasicBlockGUID { 31 | type Inner = &'a BasicBlockGUID; 32 | #[inline] 33 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 34 | <&'a BasicBlockGUID>::follow(buf, loc) 35 | } 36 | } 37 | impl<'a> flatbuffers::Follow<'a> for &'a BasicBlockGUID { 38 | type Inner = &'a BasicBlockGUID; 39 | #[inline] 40 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 41 | flatbuffers::follow_cast_ref::(buf, loc) 42 | } 43 | } 44 | impl<'b> flatbuffers::Push for BasicBlockGUID { 45 | type Output = BasicBlockGUID; 46 | #[inline] 47 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 48 | let src = ::core::slice::from_raw_parts(self as *const BasicBlockGUID as *const u8, ::size()); 49 | dst.copy_from_slice(src); 50 | } 51 | #[inline] 52 | fn alignment() -> flatbuffers::PushAlignment { 53 | flatbuffers::PushAlignment::new(1) 54 | } 55 | } 56 | 57 | impl<'a> flatbuffers::Verifiable for BasicBlockGUID { 58 | #[inline] 59 | fn run_verifier( 60 | v: &mut flatbuffers::Verifier, pos: usize 61 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 62 | use self::flatbuffers::Verifiable; 63 | v.in_buffer::(pos) 64 | } 65 | } 66 | 67 | impl<'a> BasicBlockGUID { 68 | #[allow(clippy::too_many_arguments)] 69 | pub fn new( 70 | value: &[u8; 16], 71 | ) -> Self { 72 | let mut s = Self([0; 16]); 73 | s.set_value(value); 74 | s 75 | } 76 | 77 | pub fn value(&'a self) -> flatbuffers::Array<'a, u8, 16> { 78 | // Safety: 79 | // Created from a valid Table for this object 80 | // Which contains a valid array in this slot 81 | unsafe { flatbuffers::Array::follow(&self.0, 0) } 82 | } 83 | 84 | pub fn set_value(&mut self, items: &[u8; 16]) { 85 | // Safety: 86 | // Created from a valid Table for this object 87 | // Which contains a valid array in this slot 88 | unsafe { flatbuffers::emplace_scalar_array(&mut self.0, 0, items) }; 89 | } 90 | 91 | } 92 | 93 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/sig_bin/constraint_guid_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | // struct ConstraintGUID, aligned to 1 13 | #[repr(transparent)] 14 | #[derive(Clone, Copy, PartialEq)] 15 | pub struct ConstraintGUID(pub [u8; 16]); 16 | impl Default for ConstraintGUID { 17 | fn default() -> Self { 18 | Self([0; 16]) 19 | } 20 | } 21 | impl core::fmt::Debug for ConstraintGUID { 22 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 23 | f.debug_struct("ConstraintGUID") 24 | .field("value", &self.value()) 25 | .finish() 26 | } 27 | } 28 | 29 | impl flatbuffers::SimpleToVerifyInSlice for ConstraintGUID {} 30 | impl<'a> flatbuffers::Follow<'a> for ConstraintGUID { 31 | type Inner = &'a ConstraintGUID; 32 | #[inline] 33 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 34 | <&'a ConstraintGUID>::follow(buf, loc) 35 | } 36 | } 37 | impl<'a> flatbuffers::Follow<'a> for &'a ConstraintGUID { 38 | type Inner = &'a ConstraintGUID; 39 | #[inline] 40 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 41 | flatbuffers::follow_cast_ref::(buf, loc) 42 | } 43 | } 44 | impl<'b> flatbuffers::Push for ConstraintGUID { 45 | type Output = ConstraintGUID; 46 | #[inline] 47 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 48 | let src = ::core::slice::from_raw_parts(self as *const ConstraintGUID as *const u8, ::size()); 49 | dst.copy_from_slice(src); 50 | } 51 | #[inline] 52 | fn alignment() -> flatbuffers::PushAlignment { 53 | flatbuffers::PushAlignment::new(1) 54 | } 55 | } 56 | 57 | impl<'a> flatbuffers::Verifiable for ConstraintGUID { 58 | #[inline] 59 | fn run_verifier( 60 | v: &mut flatbuffers::Verifier, pos: usize 61 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 62 | use self::flatbuffers::Verifiable; 63 | v.in_buffer::(pos) 64 | } 65 | } 66 | 67 | impl<'a> ConstraintGUID { 68 | #[allow(clippy::too_many_arguments)] 69 | pub fn new( 70 | value: &[u8; 16], 71 | ) -> Self { 72 | let mut s = Self([0; 16]); 73 | s.set_value(value); 74 | s 75 | } 76 | 77 | pub fn value(&'a self) -> flatbuffers::Array<'a, u8, 16> { 78 | // Safety: 79 | // Created from a valid Table for this object 80 | // Which contains a valid array in this slot 81 | unsafe { flatbuffers::Array::follow(&self.0, 0) } 82 | } 83 | 84 | pub fn set_value(&mut self, items: &[u8; 16]) { 85 | // Safety: 86 | // Created from a valid Table for this object 87 | // Which contains a valid array in this slot 88 | unsafe { flatbuffers::emplace_scalar_array(&mut self.0, 0, items) }; 89 | } 90 | 91 | } 92 | 93 | -------------------------------------------------------------------------------- /rust/src/signature/basic_block.rs: -------------------------------------------------------------------------------- 1 | use crate::cached_builder::CachedFlatBufferBuilder; 2 | use crate::{fb_sig as fb, FlatBufferObject}; 3 | use flatbuffers::WIPOffset; 4 | use std::fmt::{Display, Formatter}; 5 | use std::str::FromStr; 6 | use uuid::uuid; 7 | use uuid::Uuid; 8 | 9 | pub const NAMESPACE_BASICBLOCK: Uuid = uuid!("0192a178-7a5f-7936-8653-3cbaa7d6afe7"); 10 | 11 | /// This type is marked `repr(transparent)` to the underlying `[u8; 16]` type, so it is safe to use in FFI. 12 | #[repr(transparent)] 13 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] 14 | pub struct BasicBlockGUID { 15 | guid: Uuid, 16 | } 17 | 18 | impl BasicBlockGUID { 19 | pub fn as_bytes(&self) -> &[u8] { 20 | self.guid.as_bytes() 21 | } 22 | } 23 | 24 | impl FromStr for BasicBlockGUID { 25 | type Err = uuid::Error; 26 | 27 | fn from_str(s: &str) -> Result { 28 | Uuid::parse_str(s).map(Into::into) 29 | } 30 | } 31 | 32 | impl From<&[u8]> for BasicBlockGUID { 33 | fn from(value: &[u8]) -> Self { 34 | Self { 35 | guid: Uuid::new_v5(&NAMESPACE_BASICBLOCK, value), 36 | } 37 | } 38 | } 39 | 40 | impl From for BasicBlockGUID { 41 | fn from(value: Uuid) -> Self { 42 | Self { guid: value } 43 | } 44 | } 45 | 46 | impl From for BasicBlockGUID { 47 | fn from(value: fb::BasicBlockGUID) -> Self { 48 | Self { 49 | guid: Uuid::from_bytes(value.0), 50 | } 51 | } 52 | } 53 | 54 | impl From for fb::BasicBlockGUID { 55 | fn from(value: BasicBlockGUID) -> Self { 56 | Self(value.guid.into_bytes()) 57 | } 58 | } 59 | 60 | impl Display for BasicBlockGUID { 61 | fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { 62 | Display::fmt(&self.guid, f) 63 | } 64 | } 65 | 66 | #[derive(Clone, Debug, Eq, PartialEq, Hash)] 67 | pub struct BasicBlock { 68 | pub guid: BasicBlockGUID, 69 | } 70 | 71 | impl BasicBlock { 72 | pub fn new(guid: BasicBlockGUID) -> Self { 73 | Self { guid } 74 | } 75 | 76 | pub fn from_bytes(buf: &[u8]) -> Option { 77 | flatbuffers::root::(buf) 78 | .ok() 79 | .and_then(|b| BasicBlock::from_object(&b)) 80 | } 81 | } 82 | 83 | impl FlatBufferObject for BasicBlock { 84 | type FbType<'fbb> = fb::BasicBlock<'fbb>; 85 | 86 | fn create<'fbb>( 87 | &self, 88 | builder: &mut CachedFlatBufferBuilder<'fbb>, 89 | ) -> WIPOffset> { 90 | fb::BasicBlock::create( 91 | builder, 92 | &fb::BasicBlockArgs { 93 | guid: Some(&self.guid.into()), 94 | }, 95 | ) 96 | } 97 | 98 | fn from_object(value: &Self::FbType<'_>) -> Option { 99 | let bb = Self { 100 | guid: BasicBlockGUID::from(*value.guid()), 101 | }; 102 | 103 | Some(bb) 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /rust/src/type/class/enumeration.rs: -------------------------------------------------------------------------------- 1 | use bon::Builder; 2 | 3 | use crate::cached_builder::CachedFlatBufferBuilder; 4 | use crate::r#type::Type; 5 | use crate::{fb_type as fb, FlatBufferObject}; 6 | use flatbuffers::WIPOffset; 7 | 8 | #[derive(Clone, Debug, PartialEq, Eq, Hash, Builder)] 9 | #[builder(on(String, into))] 10 | pub struct EnumerationMember { 11 | pub name: Option, 12 | pub constant: u64, 13 | } 14 | 15 | impl FlatBufferObject for EnumerationMember { 16 | type FbType<'fbb> = fb::EnumerationMember<'fbb>; 17 | 18 | fn create<'fbb>( 19 | &self, 20 | builder: &mut CachedFlatBufferBuilder<'fbb>, 21 | ) -> WIPOffset> { 22 | let name = self.name.as_ref().map(|n| builder.create_string(n)); 23 | fb::EnumerationMember::create( 24 | builder, 25 | &fb::EnumerationMemberArgs { 26 | name, 27 | constant: self.constant, 28 | }, 29 | ) 30 | } 31 | 32 | fn from_object(value: &Self::FbType<'_>) -> Option { 33 | Some(Self { 34 | name: value.name().map(str::to_string), 35 | constant: value.constant(), 36 | }) 37 | } 38 | } 39 | 40 | #[derive(Clone, Debug, PartialEq, Eq, Hash, Builder)] 41 | pub struct EnumerationClass { 42 | pub member_type: Box, 43 | pub members: Vec, 44 | } 45 | 46 | impl EnumerationClass { 47 | pub fn new(member_type: Type, members: Vec) -> Self { 48 | Self { 49 | member_type: Box::new(member_type), 50 | members, 51 | } 52 | } 53 | } 54 | 55 | impl EnumerationClass { 56 | pub fn size(&self) -> Option { 57 | self.member_type.size() 58 | } 59 | } 60 | 61 | impl FlatBufferObject for EnumerationClass { 62 | type FbType<'fbb> = fb::Enumeration<'fbb>; 63 | 64 | fn create<'fbb>( 65 | &self, 66 | builder: &mut CachedFlatBufferBuilder<'fbb>, 67 | ) -> WIPOffset> { 68 | let enum_type = self.member_type.create(builder); 69 | // Resolve then create all member constants. Take the prior constant when `None`. 70 | let created_members: Vec<_> = self 71 | .members 72 | .iter() 73 | .map(|member| member.create(builder)) 74 | .collect(); 75 | let enum_members = builder.create_vector(&created_members); 76 | fb::Enumeration::create( 77 | builder, 78 | &fb::EnumerationArgs { 79 | member_type: Some(enum_type), 80 | members: Some(enum_members), 81 | }, 82 | ) 83 | } 84 | 85 | fn from_object(value: &Self::FbType<'_>) -> Option { 86 | let class = Self { 87 | member_type: Box::new(Type::from_object(&value.member_type())?), 88 | members: value 89 | .members()? 90 | .iter() 91 | .flat_map(|member| EnumerationMember::from_object(&member)) 92 | .collect(), 93 | }; 94 | 95 | Some(class) 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/warp/chunk_type_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 13 | pub const ENUM_MIN_CHUNK_TYPE: u8 = 0; 14 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 15 | pub const ENUM_MAX_CHUNK_TYPE: u8 = 1; 16 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 17 | #[allow(non_camel_case_types)] 18 | pub const ENUM_VALUES_CHUNK_TYPE: [ChunkType; 2] = [ 19 | ChunkType::Signatures, 20 | ChunkType::Types, 21 | ]; 22 | 23 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] 24 | #[repr(transparent)] 25 | pub struct ChunkType(pub u8); 26 | #[allow(non_upper_case_globals)] 27 | impl ChunkType { 28 | pub const Signatures: Self = Self(0); 29 | pub const Types: Self = Self(1); 30 | 31 | pub const ENUM_MIN: u8 = 0; 32 | pub const ENUM_MAX: u8 = 1; 33 | pub const ENUM_VALUES: &'static [Self] = &[ 34 | Self::Signatures, 35 | Self::Types, 36 | ]; 37 | /// Returns the variant's name or "" if unknown. 38 | pub fn variant_name(self) -> Option<&'static str> { 39 | match self { 40 | Self::Signatures => Some("Signatures"), 41 | Self::Types => Some("Types"), 42 | _ => None, 43 | } 44 | } 45 | } 46 | impl core::fmt::Debug for ChunkType { 47 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 48 | if let Some(name) = self.variant_name() { 49 | f.write_str(name) 50 | } else { 51 | f.write_fmt(format_args!("", self.0)) 52 | } 53 | } 54 | } 55 | impl<'a> flatbuffers::Follow<'a> for ChunkType { 56 | type Inner = Self; 57 | #[inline] 58 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 59 | let b = flatbuffers::read_scalar_at::(buf, loc); 60 | Self(b) 61 | } 62 | } 63 | 64 | impl flatbuffers::Push for ChunkType { 65 | type Output = ChunkType; 66 | #[inline] 67 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 68 | flatbuffers::emplace_scalar::(dst, self.0); 69 | } 70 | } 71 | 72 | impl flatbuffers::EndianScalar for ChunkType { 73 | type Scalar = u8; 74 | #[inline] 75 | fn to_little_endian(self) -> u8 { 76 | self.0.to_le() 77 | } 78 | #[inline] 79 | #[allow(clippy::wrong_self_convention)] 80 | fn from_little_endian(v: u8) -> Self { 81 | let b = u8::from_le(v); 82 | Self(b) 83 | } 84 | } 85 | 86 | impl<'a> flatbuffers::Verifiable for ChunkType { 87 | #[inline] 88 | fn run_verifier( 89 | v: &mut flatbuffers::Verifier, pos: usize 90 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 91 | use self::flatbuffers::Verifiable; 92 | u8::run_verifier(v, pos) 93 | } 94 | } 95 | 96 | impl flatbuffers::SimpleToVerifyInSlice for ChunkType {} 97 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/warp/compression_type_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 13 | pub const ENUM_MIN_COMPRESSION_TYPE: u8 = 0; 14 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 15 | pub const ENUM_MAX_COMPRESSION_TYPE: u8 = 1; 16 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 17 | #[allow(non_camel_case_types)] 18 | pub const ENUM_VALUES_COMPRESSION_TYPE: [CompressionType; 2] = [ 19 | CompressionType::None, 20 | CompressionType::Zstd, 21 | ]; 22 | 23 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] 24 | #[repr(transparent)] 25 | pub struct CompressionType(pub u8); 26 | #[allow(non_upper_case_globals)] 27 | impl CompressionType { 28 | pub const None: Self = Self(0); 29 | pub const Zstd: Self = Self(1); 30 | 31 | pub const ENUM_MIN: u8 = 0; 32 | pub const ENUM_MAX: u8 = 1; 33 | pub const ENUM_VALUES: &'static [Self] = &[ 34 | Self::None, 35 | Self::Zstd, 36 | ]; 37 | /// Returns the variant's name or "" if unknown. 38 | pub fn variant_name(self) -> Option<&'static str> { 39 | match self { 40 | Self::None => Some("None"), 41 | Self::Zstd => Some("Zstd"), 42 | _ => None, 43 | } 44 | } 45 | } 46 | impl core::fmt::Debug for CompressionType { 47 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 48 | if let Some(name) = self.variant_name() { 49 | f.write_str(name) 50 | } else { 51 | f.write_fmt(format_args!("", self.0)) 52 | } 53 | } 54 | } 55 | impl<'a> flatbuffers::Follow<'a> for CompressionType { 56 | type Inner = Self; 57 | #[inline] 58 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 59 | let b = flatbuffers::read_scalar_at::(buf, loc); 60 | Self(b) 61 | } 62 | } 63 | 64 | impl flatbuffers::Push for CompressionType { 65 | type Output = CompressionType; 66 | #[inline] 67 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 68 | flatbuffers::emplace_scalar::(dst, self.0); 69 | } 70 | } 71 | 72 | impl flatbuffers::EndianScalar for CompressionType { 73 | type Scalar = u8; 74 | #[inline] 75 | fn to_little_endian(self) -> u8 { 76 | self.0.to_le() 77 | } 78 | #[inline] 79 | #[allow(clippy::wrong_self_convention)] 80 | fn from_little_endian(v: u8) -> Self { 81 | let b = u8::from_le(v); 82 | Self(b) 83 | } 84 | } 85 | 86 | impl<'a> flatbuffers::Verifiable for CompressionType { 87 | #[inline] 88 | fn run_verifier( 89 | v: &mut flatbuffers::Verifier, pos: usize 90 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 91 | use self::flatbuffers::Verifiable; 92 | u8::run_verifier(v, pos) 93 | } 94 | } 95 | 96 | impl flatbuffers::SimpleToVerifyInSlice for CompressionType {} 97 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/metadata_value_type_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 13 | pub const ENUM_MIN_METADATA_VALUE_TYPE: u8 = 0; 14 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 15 | pub const ENUM_MAX_METADATA_VALUE_TYPE: u8 = 1; 16 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 17 | #[allow(non_camel_case_types)] 18 | pub const ENUM_VALUES_METADATA_VALUE_TYPE: [MetadataValueType; 2] = [ 19 | MetadataValueType::Raw, 20 | MetadataValueType::String, 21 | ]; 22 | 23 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] 24 | #[repr(transparent)] 25 | pub struct MetadataValueType(pub u8); 26 | #[allow(non_upper_case_globals)] 27 | impl MetadataValueType { 28 | pub const Raw: Self = Self(0); 29 | pub const String: Self = Self(1); 30 | 31 | pub const ENUM_MIN: u8 = 0; 32 | pub const ENUM_MAX: u8 = 1; 33 | pub const ENUM_VALUES: &'static [Self] = &[ 34 | Self::Raw, 35 | Self::String, 36 | ]; 37 | /// Returns the variant's name or "" if unknown. 38 | pub fn variant_name(self) -> Option<&'static str> { 39 | match self { 40 | Self::Raw => Some("Raw"), 41 | Self::String => Some("String"), 42 | _ => None, 43 | } 44 | } 45 | } 46 | impl core::fmt::Debug for MetadataValueType { 47 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 48 | if let Some(name) = self.variant_name() { 49 | f.write_str(name) 50 | } else { 51 | f.write_fmt(format_args!("", self.0)) 52 | } 53 | } 54 | } 55 | impl<'a> flatbuffers::Follow<'a> for MetadataValueType { 56 | type Inner = Self; 57 | #[inline] 58 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 59 | let b = flatbuffers::read_scalar_at::(buf, loc); 60 | Self(b) 61 | } 62 | } 63 | 64 | impl flatbuffers::Push for MetadataValueType { 65 | type Output = MetadataValueType; 66 | #[inline] 67 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 68 | flatbuffers::emplace_scalar::(dst, self.0); 69 | } 70 | } 71 | 72 | impl flatbuffers::EndianScalar for MetadataValueType { 73 | type Scalar = u8; 74 | #[inline] 75 | fn to_little_endian(self) -> u8 { 76 | self.0.to_le() 77 | } 78 | #[inline] 79 | #[allow(clippy::wrong_self_convention)] 80 | fn from_little_endian(v: u8) -> Self { 81 | let b = u8::from_le(v); 82 | Self(b) 83 | } 84 | } 85 | 86 | impl<'a> flatbuffers::Verifiable for MetadataValueType { 87 | #[inline] 88 | fn run_verifier( 89 | v: &mut flatbuffers::Verifier, pos: usize 90 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 91 | use self::flatbuffers::Verifiable; 92 | u8::run_verifier(v, pos) 93 | } 94 | } 95 | 96 | impl flatbuffers::SimpleToVerifyInSlice for MetadataValueType {} 97 | -------------------------------------------------------------------------------- /rust/src/type/class/pointer.rs: -------------------------------------------------------------------------------- 1 | use crate::cached_builder::CachedFlatBufferBuilder; 2 | use crate::r#type::Type; 3 | use crate::{fb_type as fb, FlatBufferObject}; 4 | use bon::bon; 5 | use flatbuffers::WIPOffset; 6 | 7 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Default)] 8 | pub enum PointerAddressing { 9 | #[default] 10 | Absolute = 0, 11 | RelativeBase, 12 | RelativeSelf, 13 | } 14 | 15 | impl TryFrom for PointerAddressing { 16 | // TODO: Actual error type 17 | type Error = (); 18 | 19 | fn try_from(value: fb::PointerAddressing) -> Result { 20 | match value { 21 | fb::PointerAddressing::Absolute => Ok(PointerAddressing::Absolute), 22 | fb::PointerAddressing::RelativeBase => Ok(PointerAddressing::RelativeBase), 23 | fb::PointerAddressing::RelativeSelf => Ok(PointerAddressing::RelativeSelf), 24 | _ => Err(()), 25 | } 26 | } 27 | } 28 | 29 | impl From for fb::PointerAddressing { 30 | fn from(value: PointerAddressing) -> Self { 31 | match value { 32 | PointerAddressing::Absolute => Self::Absolute, 33 | PointerAddressing::RelativeBase => Self::RelativeBase, 34 | PointerAddressing::RelativeSelf => Self::RelativeSelf, 35 | } 36 | } 37 | } 38 | 39 | #[derive(Clone, Debug, PartialEq, Eq, Hash)] 40 | pub struct PointerClass { 41 | pub width: Option, 42 | pub child_type: Box, 43 | pub addressing: PointerAddressing, 44 | // TODO: Pointer modifiers etc... 45 | } 46 | 47 | #[bon] 48 | impl PointerClass { 49 | #[builder] 50 | pub fn new( 51 | width: Option, 52 | child_type: Type, 53 | addressing: Option, 54 | ) -> Self { 55 | Self { 56 | width, 57 | child_type: Box::new(child_type), 58 | addressing: addressing.unwrap_or_default(), 59 | } 60 | } 61 | } 62 | 63 | impl PointerClass { 64 | pub fn size(&self) -> Option { 65 | self.width.map(|w| w as u64) 66 | } 67 | } 68 | 69 | impl FlatBufferObject for PointerClass { 70 | type FbType<'fbb> = fb::Pointer<'fbb>; 71 | 72 | fn create<'fbb>( 73 | &self, 74 | builder: &mut CachedFlatBufferBuilder<'fbb>, 75 | ) -> WIPOffset> { 76 | let child_type = self.child_type.create(builder); 77 | fb::Pointer::create( 78 | builder, 79 | &fb::PointerArgs { 80 | width: self.width.map(Into::into).as_ref(), 81 | // TODO: Shift 82 | shift: None, 83 | child: Some(child_type), 84 | 85 | addressing: self.addressing.into(), 86 | // TODO: Offset 87 | offset: None, 88 | }, 89 | ) 90 | } 91 | 92 | fn from_object(value: &Self::FbType<'_>) -> Option { 93 | let class = Self { 94 | width: value.width().map(Into::into), 95 | child_type: Box::new(Type::from_object(&value.child()?)?), 96 | addressing: value.addressing().try_into().ok()?, 97 | }; 98 | 99 | Some(class) 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/symbol_bin/symbol_class_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 13 | pub const ENUM_MIN_SYMBOL_CLASS: u8 = 0; 14 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 15 | pub const ENUM_MAX_SYMBOL_CLASS: u8 = 2; 16 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 17 | #[allow(non_camel_case_types)] 18 | pub const ENUM_VALUES_SYMBOL_CLASS: [SymbolClass; 3] = [ 19 | SymbolClass::Function, 20 | SymbolClass::Data, 21 | SymbolClass::Bare, 22 | ]; 23 | 24 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] 25 | #[repr(transparent)] 26 | pub struct SymbolClass(pub u8); 27 | #[allow(non_upper_case_globals)] 28 | impl SymbolClass { 29 | pub const Function: Self = Self(0); 30 | pub const Data: Self = Self(1); 31 | pub const Bare: Self = Self(2); 32 | 33 | pub const ENUM_MIN: u8 = 0; 34 | pub const ENUM_MAX: u8 = 2; 35 | pub const ENUM_VALUES: &'static [Self] = &[ 36 | Self::Function, 37 | Self::Data, 38 | Self::Bare, 39 | ]; 40 | /// Returns the variant's name or "" if unknown. 41 | pub fn variant_name(self) -> Option<&'static str> { 42 | match self { 43 | Self::Function => Some("Function"), 44 | Self::Data => Some("Data"), 45 | Self::Bare => Some("Bare"), 46 | _ => None, 47 | } 48 | } 49 | } 50 | impl core::fmt::Debug for SymbolClass { 51 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 52 | if let Some(name) = self.variant_name() { 53 | f.write_str(name) 54 | } else { 55 | f.write_fmt(format_args!("", self.0)) 56 | } 57 | } 58 | } 59 | impl<'a> flatbuffers::Follow<'a> for SymbolClass { 60 | type Inner = Self; 61 | #[inline] 62 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 63 | let b = flatbuffers::read_scalar_at::(buf, loc); 64 | Self(b) 65 | } 66 | } 67 | 68 | impl flatbuffers::Push for SymbolClass { 69 | type Output = SymbolClass; 70 | #[inline] 71 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 72 | flatbuffers::emplace_scalar::(dst, self.0); 73 | } 74 | } 75 | 76 | impl flatbuffers::EndianScalar for SymbolClass { 77 | type Scalar = u8; 78 | #[inline] 79 | fn to_little_endian(self) -> u8 { 80 | self.0.to_le() 81 | } 82 | #[inline] 83 | #[allow(clippy::wrong_self_convention)] 84 | fn from_little_endian(v: u8) -> Self { 85 | let b = u8::from_le(v); 86 | Self(b) 87 | } 88 | } 89 | 90 | impl<'a> flatbuffers::Verifiable for SymbolClass { 91 | #[inline] 92 | fn run_verifier( 93 | v: &mut flatbuffers::Verifier, pos: usize 94 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 95 | use self::flatbuffers::Verifiable; 96 | u8::run_verifier(v, pos) 97 | } 98 | } 99 | 100 | impl flatbuffers::SimpleToVerifyInSlice for SymbolClass {} 101 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/bit_size_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | // struct BitSize, aligned to 8 13 | #[repr(transparent)] 14 | #[derive(Clone, Copy, PartialEq)] 15 | pub struct BitSize(pub [u8; 8]); 16 | impl Default for BitSize { 17 | fn default() -> Self { 18 | Self([0; 8]) 19 | } 20 | } 21 | impl core::fmt::Debug for BitSize { 22 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 23 | f.debug_struct("BitSize") 24 | .field("value", &self.value()) 25 | .finish() 26 | } 27 | } 28 | 29 | impl flatbuffers::SimpleToVerifyInSlice for BitSize {} 30 | impl<'a> flatbuffers::Follow<'a> for BitSize { 31 | type Inner = &'a BitSize; 32 | #[inline] 33 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 34 | <&'a BitSize>::follow(buf, loc) 35 | } 36 | } 37 | impl<'a> flatbuffers::Follow<'a> for &'a BitSize { 38 | type Inner = &'a BitSize; 39 | #[inline] 40 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 41 | flatbuffers::follow_cast_ref::(buf, loc) 42 | } 43 | } 44 | impl<'b> flatbuffers::Push for BitSize { 45 | type Output = BitSize; 46 | #[inline] 47 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 48 | let src = ::core::slice::from_raw_parts(self as *const BitSize as *const u8, ::size()); 49 | dst.copy_from_slice(src); 50 | } 51 | #[inline] 52 | fn alignment() -> flatbuffers::PushAlignment { 53 | flatbuffers::PushAlignment::new(8) 54 | } 55 | } 56 | 57 | impl<'a> flatbuffers::Verifiable for BitSize { 58 | #[inline] 59 | fn run_verifier( 60 | v: &mut flatbuffers::Verifier, pos: usize 61 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 62 | use self::flatbuffers::Verifiable; 63 | v.in_buffer::(pos) 64 | } 65 | } 66 | 67 | impl<'a> BitSize { 68 | #[allow(clippy::too_many_arguments)] 69 | pub fn new( 70 | value: u64, 71 | ) -> Self { 72 | let mut s = Self([0; 8]); 73 | s.set_value(value); 74 | s 75 | } 76 | 77 | pub fn value(&self) -> u64 { 78 | let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); 79 | // Safety: 80 | // Created from a valid Table for this object 81 | // Which contains a valid value in this slot 82 | EndianScalar::from_little_endian(unsafe { 83 | core::ptr::copy_nonoverlapping( 84 | self.0[0..].as_ptr(), 85 | mem.as_mut_ptr() as *mut u8, 86 | core::mem::size_of::<::Scalar>(), 87 | ); 88 | mem.assume_init() 89 | }) 90 | } 91 | 92 | pub fn set_value(&mut self, x: u64) { 93 | let x_le = x.to_little_endian(); 94 | // Safety: 95 | // Created from a valid Table for this object 96 | // Which contains a valid value in this slot 97 | unsafe { 98 | core::ptr::copy_nonoverlapping( 99 | &x_le as *const _ as *const u8, 100 | self.0[0..].as_mut_ptr(), 101 | core::mem::size_of::<::Scalar>(), 102 | ); 103 | } 104 | } 105 | 106 | } 107 | 108 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/bit_shift_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | // struct BitShift, aligned to 8 13 | #[repr(transparent)] 14 | #[derive(Clone, Copy, PartialEq)] 15 | pub struct BitShift(pub [u8; 8]); 16 | impl Default for BitShift { 17 | fn default() -> Self { 18 | Self([0; 8]) 19 | } 20 | } 21 | impl core::fmt::Debug for BitShift { 22 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 23 | f.debug_struct("BitShift") 24 | .field("value", &self.value()) 25 | .finish() 26 | } 27 | } 28 | 29 | impl flatbuffers::SimpleToVerifyInSlice for BitShift {} 30 | impl<'a> flatbuffers::Follow<'a> for BitShift { 31 | type Inner = &'a BitShift; 32 | #[inline] 33 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 34 | <&'a BitShift>::follow(buf, loc) 35 | } 36 | } 37 | impl<'a> flatbuffers::Follow<'a> for &'a BitShift { 38 | type Inner = &'a BitShift; 39 | #[inline] 40 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 41 | flatbuffers::follow_cast_ref::(buf, loc) 42 | } 43 | } 44 | impl<'b> flatbuffers::Push for BitShift { 45 | type Output = BitShift; 46 | #[inline] 47 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 48 | let src = ::core::slice::from_raw_parts(self as *const BitShift as *const u8, ::size()); 49 | dst.copy_from_slice(src); 50 | } 51 | #[inline] 52 | fn alignment() -> flatbuffers::PushAlignment { 53 | flatbuffers::PushAlignment::new(8) 54 | } 55 | } 56 | 57 | impl<'a> flatbuffers::Verifiable for BitShift { 58 | #[inline] 59 | fn run_verifier( 60 | v: &mut flatbuffers::Verifier, pos: usize 61 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 62 | use self::flatbuffers::Verifiable; 63 | v.in_buffer::(pos) 64 | } 65 | } 66 | 67 | impl<'a> BitShift { 68 | #[allow(clippy::too_many_arguments)] 69 | pub fn new( 70 | value: i64, 71 | ) -> Self { 72 | let mut s = Self([0; 8]); 73 | s.set_value(value); 74 | s 75 | } 76 | 77 | pub fn value(&self) -> i64 { 78 | let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); 79 | // Safety: 80 | // Created from a valid Table for this object 81 | // Which contains a valid value in this slot 82 | EndianScalar::from_little_endian(unsafe { 83 | core::ptr::copy_nonoverlapping( 84 | self.0[0..].as_ptr(), 85 | mem.as_mut_ptr() as *mut u8, 86 | core::mem::size_of::<::Scalar>(), 87 | ); 88 | mem.assume_init() 89 | }) 90 | } 91 | 92 | pub fn set_value(&mut self, x: i64) { 93 | let x_le = x.to_little_endian(); 94 | // Safety: 95 | // Created from a valid Table for this object 96 | // Which contains a valid value in this slot 97 | unsafe { 98 | core::ptr::copy_nonoverlapping( 99 | &x_le as *const _ as *const u8, 100 | self.0[0..].as_mut_ptr(), 101 | core::mem::size_of::<::Scalar>(), 102 | ); 103 | } 104 | } 105 | 106 | } 107 | 108 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/bit_width_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | // struct BitWidth, aligned to 2 13 | #[repr(transparent)] 14 | #[derive(Clone, Copy, PartialEq)] 15 | pub struct BitWidth(pub [u8; 2]); 16 | impl Default for BitWidth { 17 | fn default() -> Self { 18 | Self([0; 2]) 19 | } 20 | } 21 | impl core::fmt::Debug for BitWidth { 22 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 23 | f.debug_struct("BitWidth") 24 | .field("value", &self.value()) 25 | .finish() 26 | } 27 | } 28 | 29 | impl flatbuffers::SimpleToVerifyInSlice for BitWidth {} 30 | impl<'a> flatbuffers::Follow<'a> for BitWidth { 31 | type Inner = &'a BitWidth; 32 | #[inline] 33 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 34 | <&'a BitWidth>::follow(buf, loc) 35 | } 36 | } 37 | impl<'a> flatbuffers::Follow<'a> for &'a BitWidth { 38 | type Inner = &'a BitWidth; 39 | #[inline] 40 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 41 | flatbuffers::follow_cast_ref::(buf, loc) 42 | } 43 | } 44 | impl<'b> flatbuffers::Push for BitWidth { 45 | type Output = BitWidth; 46 | #[inline] 47 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 48 | let src = ::core::slice::from_raw_parts(self as *const BitWidth as *const u8, ::size()); 49 | dst.copy_from_slice(src); 50 | } 51 | #[inline] 52 | fn alignment() -> flatbuffers::PushAlignment { 53 | flatbuffers::PushAlignment::new(2) 54 | } 55 | } 56 | 57 | impl<'a> flatbuffers::Verifiable for BitWidth { 58 | #[inline] 59 | fn run_verifier( 60 | v: &mut flatbuffers::Verifier, pos: usize 61 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 62 | use self::flatbuffers::Verifiable; 63 | v.in_buffer::(pos) 64 | } 65 | } 66 | 67 | impl<'a> BitWidth { 68 | #[allow(clippy::too_many_arguments)] 69 | pub fn new( 70 | value: u16, 71 | ) -> Self { 72 | let mut s = Self([0; 2]); 73 | s.set_value(value); 74 | s 75 | } 76 | 77 | pub fn value(&self) -> u16 { 78 | let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); 79 | // Safety: 80 | // Created from a valid Table for this object 81 | // Which contains a valid value in this slot 82 | EndianScalar::from_little_endian(unsafe { 83 | core::ptr::copy_nonoverlapping( 84 | self.0[0..].as_ptr(), 85 | mem.as_mut_ptr() as *mut u8, 86 | core::mem::size_of::<::Scalar>(), 87 | ); 88 | mem.assume_init() 89 | }) 90 | } 91 | 92 | pub fn set_value(&mut self, x: u16) { 93 | let x_le = x.to_little_endian(); 94 | // Safety: 95 | // Created from a valid Table for this object 96 | // Which contains a valid value in this slot 97 | unsafe { 98 | core::ptr::copy_nonoverlapping( 99 | &x_le as *const _ as *const u8, 100 | self.0[0..].as_mut_ptr(), 101 | core::mem::size_of::<::Scalar>(), 102 | ); 103 | } 104 | } 105 | 106 | } 107 | 108 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/bit_offset_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | // struct BitOffset, aligned to 8 13 | #[repr(transparent)] 14 | #[derive(Clone, Copy, PartialEq)] 15 | pub struct BitOffset(pub [u8; 8]); 16 | impl Default for BitOffset { 17 | fn default() -> Self { 18 | Self([0; 8]) 19 | } 20 | } 21 | impl core::fmt::Debug for BitOffset { 22 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 23 | f.debug_struct("BitOffset") 24 | .field("value", &self.value()) 25 | .finish() 26 | } 27 | } 28 | 29 | impl flatbuffers::SimpleToVerifyInSlice for BitOffset {} 30 | impl<'a> flatbuffers::Follow<'a> for BitOffset { 31 | type Inner = &'a BitOffset; 32 | #[inline] 33 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 34 | <&'a BitOffset>::follow(buf, loc) 35 | } 36 | } 37 | impl<'a> flatbuffers::Follow<'a> for &'a BitOffset { 38 | type Inner = &'a BitOffset; 39 | #[inline] 40 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 41 | flatbuffers::follow_cast_ref::(buf, loc) 42 | } 43 | } 44 | impl<'b> flatbuffers::Push for BitOffset { 45 | type Output = BitOffset; 46 | #[inline] 47 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 48 | let src = ::core::slice::from_raw_parts(self as *const BitOffset as *const u8, ::size()); 49 | dst.copy_from_slice(src); 50 | } 51 | #[inline] 52 | fn alignment() -> flatbuffers::PushAlignment { 53 | flatbuffers::PushAlignment::new(8) 54 | } 55 | } 56 | 57 | impl<'a> flatbuffers::Verifiable for BitOffset { 58 | #[inline] 59 | fn run_verifier( 60 | v: &mut flatbuffers::Verifier, pos: usize 61 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 62 | use self::flatbuffers::Verifiable; 63 | v.in_buffer::(pos) 64 | } 65 | } 66 | 67 | impl<'a> BitOffset { 68 | #[allow(clippy::too_many_arguments)] 69 | pub fn new( 70 | value: i64, 71 | ) -> Self { 72 | let mut s = Self([0; 8]); 73 | s.set_value(value); 74 | s 75 | } 76 | 77 | pub fn value(&self) -> i64 { 78 | let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); 79 | // Safety: 80 | // Created from a valid Table for this object 81 | // Which contains a valid value in this slot 82 | EndianScalar::from_little_endian(unsafe { 83 | core::ptr::copy_nonoverlapping( 84 | self.0[0..].as_ptr(), 85 | mem.as_mut_ptr() as *mut u8, 86 | core::mem::size_of::<::Scalar>(), 87 | ); 88 | mem.assume_init() 89 | }) 90 | } 91 | 92 | pub fn set_value(&mut self, x: i64) { 93 | let x_le = x.to_little_endian(); 94 | // Safety: 95 | // Created from a valid Table for this object 96 | // Which contains a valid value in this slot 97 | unsafe { 98 | core::ptr::copy_nonoverlapping( 99 | &x_le as *const _ as *const u8, 100 | self.0[0..].as_mut_ptr(), 101 | core::mem::size_of::<::Scalar>(), 102 | ); 103 | } 104 | } 105 | 106 | } 107 | 108 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/float_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum FloatOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Float<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Float<'a> { 20 | type Inner = Float<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Float<'a> { 28 | pub const VT_WIDTH: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | Float { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args FloatArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = FloatBuilder::new(_fbb); 40 | if let Some(x) = args.width { builder.add_width(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn width(&self) -> Option<&'a BitWidth> { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::(Float::VT_WIDTH, None)} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for Float<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::("width", Self::VT_WIDTH, false)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct FloatArgs<'a> { 67 | pub width: Option<&'a BitWidth>, 68 | } 69 | impl<'a> Default for FloatArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | FloatArgs { 73 | width: None, 74 | } 75 | } 76 | } 77 | 78 | pub struct FloatBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> FloatBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_width(&mut self, width: &BitWidth) { 85 | self.fbb_.push_slot_always::<&BitWidth>(Float::VT_WIDTH, width); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> FloatBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | FloatBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | flatbuffers::WIPOffset::new(o.value()) 99 | } 100 | } 101 | 102 | impl core::fmt::Debug for Float<'_> { 103 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 104 | let mut ds = f.debug_struct("Float"); 105 | ds.field("width", &self.width()); 106 | ds.finish() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/boolean_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum BooleanOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Boolean<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Boolean<'a> { 20 | type Inner = Boolean<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Boolean<'a> { 28 | pub const VT_WIDTH: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | Boolean { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args BooleanArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = BooleanBuilder::new(_fbb); 40 | if let Some(x) = args.width { builder.add_width(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn width(&self) -> Option<&'a BitWidth> { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::(Boolean::VT_WIDTH, None)} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for Boolean<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::("width", Self::VT_WIDTH, false)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct BooleanArgs<'a> { 67 | pub width: Option<&'a BitWidth>, 68 | } 69 | impl<'a> Default for BooleanArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | BooleanArgs { 73 | width: None, 74 | } 75 | } 76 | } 77 | 78 | pub struct BooleanBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> BooleanBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_width(&mut self, width: &BitWidth) { 85 | self.fbb_.push_slot_always::<&BitWidth>(Boolean::VT_WIDTH, width); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> BooleanBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | BooleanBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | flatbuffers::WIPOffset::new(o.value()) 99 | } 100 | } 101 | 102 | impl core::fmt::Debug for Boolean<'_> { 103 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 104 | let mut ds = f.debug_struct("Boolean"); 105 | ds.field("width", &self.width()); 106 | ds.finish() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/location_class_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 13 | pub const ENUM_MIN_LOCATION_CLASS: u8 = 0; 14 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 15 | pub const ENUM_MAX_LOCATION_CLASS: u8 = 2; 16 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 17 | #[allow(non_camel_case_types)] 18 | pub const ENUM_VALUES_LOCATION_CLASS: [LocationClass; 3] = [ 19 | LocationClass::NONE, 20 | LocationClass::RegisterLocation, 21 | LocationClass::StackLocation, 22 | ]; 23 | 24 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] 25 | #[repr(transparent)] 26 | pub struct LocationClass(pub u8); 27 | #[allow(non_upper_case_globals)] 28 | impl LocationClass { 29 | pub const NONE: Self = Self(0); 30 | pub const RegisterLocation: Self = Self(1); 31 | pub const StackLocation: Self = Self(2); 32 | 33 | pub const ENUM_MIN: u8 = 0; 34 | pub const ENUM_MAX: u8 = 2; 35 | pub const ENUM_VALUES: &'static [Self] = &[ 36 | Self::NONE, 37 | Self::RegisterLocation, 38 | Self::StackLocation, 39 | ]; 40 | /// Returns the variant's name or "" if unknown. 41 | pub fn variant_name(self) -> Option<&'static str> { 42 | match self { 43 | Self::NONE => Some("NONE"), 44 | Self::RegisterLocation => Some("RegisterLocation"), 45 | Self::StackLocation => Some("StackLocation"), 46 | _ => None, 47 | } 48 | } 49 | } 50 | impl core::fmt::Debug for LocationClass { 51 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 52 | if let Some(name) = self.variant_name() { 53 | f.write_str(name) 54 | } else { 55 | f.write_fmt(format_args!("", self.0)) 56 | } 57 | } 58 | } 59 | impl<'a> flatbuffers::Follow<'a> for LocationClass { 60 | type Inner = Self; 61 | #[inline] 62 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 63 | let b = flatbuffers::read_scalar_at::(buf, loc); 64 | Self(b) 65 | } 66 | } 67 | 68 | impl flatbuffers::Push for LocationClass { 69 | type Output = LocationClass; 70 | #[inline] 71 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 72 | flatbuffers::emplace_scalar::(dst, self.0); 73 | } 74 | } 75 | 76 | impl flatbuffers::EndianScalar for LocationClass { 77 | type Scalar = u8; 78 | #[inline] 79 | fn to_little_endian(self) -> u8 { 80 | self.0.to_le() 81 | } 82 | #[inline] 83 | #[allow(clippy::wrong_self_convention)] 84 | fn from_little_endian(v: u8) -> Self { 85 | let b = u8::from_le(v); 86 | Self(b) 87 | } 88 | } 89 | 90 | impl<'a> flatbuffers::Verifiable for LocationClass { 91 | #[inline] 92 | fn run_verifier( 93 | v: &mut flatbuffers::Verifier, pos: usize 94 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 95 | use self::flatbuffers::Verifiable; 96 | u8::run_verifier(v, pos) 97 | } 98 | } 99 | 100 | impl flatbuffers::SimpleToVerifyInSlice for LocationClass {} 101 | pub struct LocationClassUnionTableOffset {} 102 | 103 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/pointer_addressing_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 13 | pub const ENUM_MIN_POINTER_ADDRESSING: i8 = 0; 14 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 15 | pub const ENUM_MAX_POINTER_ADDRESSING: i8 = 2; 16 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 17 | #[allow(non_camel_case_types)] 18 | pub const ENUM_VALUES_POINTER_ADDRESSING: [PointerAddressing; 3] = [ 19 | PointerAddressing::Absolute, 20 | PointerAddressing::RelativeBase, 21 | PointerAddressing::RelativeSelf, 22 | ]; 23 | 24 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] 25 | #[repr(transparent)] 26 | pub struct PointerAddressing(pub i8); 27 | #[allow(non_upper_case_globals)] 28 | impl PointerAddressing { 29 | pub const Absolute: Self = Self(0); 30 | pub const RelativeBase: Self = Self(1); 31 | pub const RelativeSelf: Self = Self(2); 32 | 33 | pub const ENUM_MIN: i8 = 0; 34 | pub const ENUM_MAX: i8 = 2; 35 | pub const ENUM_VALUES: &'static [Self] = &[ 36 | Self::Absolute, 37 | Self::RelativeBase, 38 | Self::RelativeSelf, 39 | ]; 40 | /// Returns the variant's name or "" if unknown. 41 | pub fn variant_name(self) -> Option<&'static str> { 42 | match self { 43 | Self::Absolute => Some("Absolute"), 44 | Self::RelativeBase => Some("RelativeBase"), 45 | Self::RelativeSelf => Some("RelativeSelf"), 46 | _ => None, 47 | } 48 | } 49 | } 50 | impl core::fmt::Debug for PointerAddressing { 51 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 52 | if let Some(name) = self.variant_name() { 53 | f.write_str(name) 54 | } else { 55 | f.write_fmt(format_args!("", self.0)) 56 | } 57 | } 58 | } 59 | impl<'a> flatbuffers::Follow<'a> for PointerAddressing { 60 | type Inner = Self; 61 | #[inline] 62 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 63 | let b = flatbuffers::read_scalar_at::(buf, loc); 64 | Self(b) 65 | } 66 | } 67 | 68 | impl flatbuffers::Push for PointerAddressing { 69 | type Output = PointerAddressing; 70 | #[inline] 71 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 72 | flatbuffers::emplace_scalar::(dst, self.0); 73 | } 74 | } 75 | 76 | impl flatbuffers::EndianScalar for PointerAddressing { 77 | type Scalar = i8; 78 | #[inline] 79 | fn to_little_endian(self) -> i8 { 80 | self.0.to_le() 81 | } 82 | #[inline] 83 | #[allow(clippy::wrong_self_convention)] 84 | fn from_little_endian(v: i8) -> Self { 85 | let b = i8::from_le(v); 86 | Self(b) 87 | } 88 | } 89 | 90 | impl<'a> flatbuffers::Verifiable for PointerAddressing { 91 | #[inline] 92 | fn run_verifier( 93 | v: &mut flatbuffers::Verifier, pos: usize 94 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 95 | use self::flatbuffers::Verifiable; 96 | i8::run_verifier(v, pos) 97 | } 98 | } 99 | 100 | impl flatbuffers::SimpleToVerifyInSlice for PointerAddressing {} 101 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/warp/file_header_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum FileHeaderOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct FileHeader<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for FileHeader<'a> { 20 | type Inner = FileHeader<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> FileHeader<'a> { 28 | pub const VT_VERSION: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | FileHeader { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args FileHeaderArgs 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = FileHeaderBuilder::new(_fbb); 40 | builder.add_version(args.version); 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn version(&self) -> u16 { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::(FileHeader::VT_VERSION, Some(0)).unwrap()} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for FileHeader<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::("version", Self::VT_VERSION, false)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct FileHeaderArgs { 67 | pub version: u16, 68 | } 69 | impl<'a> Default for FileHeaderArgs { 70 | #[inline] 71 | fn default() -> Self { 72 | FileHeaderArgs { 73 | version: 0, 74 | } 75 | } 76 | } 77 | 78 | pub struct FileHeaderBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> FileHeaderBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_version(&mut self, version: u16) { 85 | self.fbb_.push_slot::(FileHeader::VT_VERSION, version, 0); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> FileHeaderBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | FileHeaderBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | flatbuffers::WIPOffset::new(o.value()) 99 | } 100 | } 101 | 102 | impl core::fmt::Debug for FileHeader<'_> { 103 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 104 | let mut ds = f.debug_struct("FileHeader"); 105 | ds.field("version", &self.version()); 106 | ds.finish() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/unsigned_bit_offset_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | // struct UnsignedBitOffset, aligned to 8 13 | #[repr(transparent)] 14 | #[derive(Clone, Copy, PartialEq)] 15 | pub struct UnsignedBitOffset(pub [u8; 8]); 16 | impl Default for UnsignedBitOffset { 17 | fn default() -> Self { 18 | Self([0; 8]) 19 | } 20 | } 21 | impl core::fmt::Debug for UnsignedBitOffset { 22 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 23 | f.debug_struct("UnsignedBitOffset") 24 | .field("value", &self.value()) 25 | .finish() 26 | } 27 | } 28 | 29 | impl flatbuffers::SimpleToVerifyInSlice for UnsignedBitOffset {} 30 | impl<'a> flatbuffers::Follow<'a> for UnsignedBitOffset { 31 | type Inner = &'a UnsignedBitOffset; 32 | #[inline] 33 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 34 | <&'a UnsignedBitOffset>::follow(buf, loc) 35 | } 36 | } 37 | impl<'a> flatbuffers::Follow<'a> for &'a UnsignedBitOffset { 38 | type Inner = &'a UnsignedBitOffset; 39 | #[inline] 40 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 41 | flatbuffers::follow_cast_ref::(buf, loc) 42 | } 43 | } 44 | impl<'b> flatbuffers::Push for UnsignedBitOffset { 45 | type Output = UnsignedBitOffset; 46 | #[inline] 47 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 48 | let src = ::core::slice::from_raw_parts(self as *const UnsignedBitOffset as *const u8, ::size()); 49 | dst.copy_from_slice(src); 50 | } 51 | #[inline] 52 | fn alignment() -> flatbuffers::PushAlignment { 53 | flatbuffers::PushAlignment::new(8) 54 | } 55 | } 56 | 57 | impl<'a> flatbuffers::Verifiable for UnsignedBitOffset { 58 | #[inline] 59 | fn run_verifier( 60 | v: &mut flatbuffers::Verifier, pos: usize 61 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 62 | use self::flatbuffers::Verifiable; 63 | v.in_buffer::(pos) 64 | } 65 | } 66 | 67 | impl<'a> UnsignedBitOffset { 68 | #[allow(clippy::too_many_arguments)] 69 | pub fn new( 70 | value: u64, 71 | ) -> Self { 72 | let mut s = Self([0; 8]); 73 | s.set_value(value); 74 | s 75 | } 76 | 77 | pub fn value(&self) -> u64 { 78 | let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); 79 | // Safety: 80 | // Created from a valid Table for this object 81 | // Which contains a valid value in this slot 82 | EndianScalar::from_little_endian(unsafe { 83 | core::ptr::copy_nonoverlapping( 84 | self.0[0..].as_ptr(), 85 | mem.as_mut_ptr() as *mut u8, 86 | core::mem::size_of::<::Scalar>(), 87 | ); 88 | mem.assume_init() 89 | }) 90 | } 91 | 92 | pub fn set_value(&mut self, x: u64) { 93 | let x_le = x.to_little_endian(); 94 | // Safety: 95 | // Created from a valid Table for this object 96 | // Which contains a valid value in this slot 97 | unsafe { 98 | core::ptr::copy_nonoverlapping( 99 | &x_le as *const _ as *const u8, 100 | self.0[0..].as_mut_ptr(), 101 | core::mem::size_of::<::Scalar>(), 102 | ); 103 | } 104 | } 105 | 106 | } 107 | 108 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/character_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum CharacterOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Character<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Character<'a> { 20 | type Inner = Character<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Character<'a> { 28 | pub const VT_WIDTH: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | Character { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args CharacterArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = CharacterBuilder::new(_fbb); 40 | if let Some(x) = args.width { builder.add_width(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn width(&self) -> Option<&'a BitWidth> { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::(Character::VT_WIDTH, None)} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for Character<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::("width", Self::VT_WIDTH, false)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct CharacterArgs<'a> { 67 | pub width: Option<&'a BitWidth>, 68 | } 69 | impl<'a> Default for CharacterArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | CharacterArgs { 73 | width: None, 74 | } 75 | } 76 | } 77 | 78 | pub struct CharacterBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> CharacterBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_width(&mut self, width: &BitWidth) { 85 | self.fbb_.push_slot_always::<&BitWidth>(Character::VT_WIDTH, width); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> CharacterBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | CharacterBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | flatbuffers::WIPOffset::new(o.value()) 99 | } 100 | } 101 | 102 | impl core::fmt::Debug for Character<'_> { 103 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 104 | let mut ds = f.debug_struct("Character"); 105 | ds.field("width", &self.width()); 106 | ds.finish() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/register_location_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum RegisterLocationOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct RegisterLocation<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for RegisterLocation<'a> { 20 | type Inner = RegisterLocation<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> RegisterLocation<'a> { 28 | pub const VT_ID: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | RegisterLocation { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args RegisterLocationArgs 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = RegisterLocationBuilder::new(_fbb); 40 | builder.add_id(args.id); 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn id(&self) -> u64 { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::(RegisterLocation::VT_ID, Some(0)).unwrap()} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for RegisterLocation<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::("id", Self::VT_ID, false)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct RegisterLocationArgs { 67 | pub id: u64, 68 | } 69 | impl<'a> Default for RegisterLocationArgs { 70 | #[inline] 71 | fn default() -> Self { 72 | RegisterLocationArgs { 73 | id: 0, 74 | } 75 | } 76 | } 77 | 78 | pub struct RegisterLocationBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> RegisterLocationBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_id(&mut self, id: u64) { 85 | self.fbb_.push_slot::(RegisterLocation::VT_ID, id, 0); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> RegisterLocationBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | RegisterLocationBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | flatbuffers::WIPOffset::new(o.value()) 99 | } 100 | } 101 | 102 | impl core::fmt::Debug for RegisterLocation<'_> { 103 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 104 | let mut ds = f.debug_struct("RegisterLocation"); 105 | ds.field("id", &self.id()); 106 | ds.finish() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/sig_bin/basic_block_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum BasicBlockOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct BasicBlock<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for BasicBlock<'a> { 20 | type Inner = BasicBlock<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> BasicBlock<'a> { 28 | pub const VT_GUID: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | BasicBlock { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args BasicBlockArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = BasicBlockBuilder::new(_fbb); 40 | if let Some(x) = args.guid { builder.add_guid(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn guid(&self) -> &'a BasicBlockGUID { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::(BasicBlock::VT_GUID, None).unwrap()} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for BasicBlock<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::("guid", Self::VT_GUID, true)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct BasicBlockArgs<'a> { 67 | pub guid: Option<&'a BasicBlockGUID>, 68 | } 69 | impl<'a> Default for BasicBlockArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | BasicBlockArgs { 73 | guid: None, // required field 74 | } 75 | } 76 | } 77 | 78 | pub struct BasicBlockBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> BasicBlockBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_guid(&mut self, guid: &BasicBlockGUID) { 85 | self.fbb_.push_slot_always::<&BasicBlockGUID>(BasicBlock::VT_GUID, guid); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> BasicBlockBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | BasicBlockBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | self.fbb_.required(o, BasicBlock::VT_GUID,"guid"); 99 | flatbuffers::WIPOffset::new(o.value()) 100 | } 101 | } 102 | 103 | impl core::fmt::Debug for BasicBlock<'_> { 104 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 105 | let mut ds = f.debug_struct("BasicBlock"); 106 | ds.field("guid", &self.guid()); 107 | ds.finish() 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/stack_location_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum StackLocationOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct StackLocation<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for StackLocation<'a> { 20 | type Inner = StackLocation<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> StackLocation<'a> { 28 | pub const VT_OFFSET: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | StackLocation { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args StackLocationArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = StackLocationBuilder::new(_fbb); 40 | if let Some(x) = args.offset { builder.add_offset(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn offset(&self) -> &'a BitOffset { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::(StackLocation::VT_OFFSET, None).unwrap()} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for StackLocation<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::("offset", Self::VT_OFFSET, true)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct StackLocationArgs<'a> { 67 | pub offset: Option<&'a BitOffset>, 68 | } 69 | impl<'a> Default for StackLocationArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | StackLocationArgs { 73 | offset: None, // required field 74 | } 75 | } 76 | } 77 | 78 | pub struct StackLocationBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> StackLocationBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_offset(&mut self, offset: &BitOffset) { 85 | self.fbb_.push_slot_always::<&BitOffset>(StackLocation::VT_OFFSET, offset); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> StackLocationBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | StackLocationBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | self.fbb_.required(o, StackLocation::VT_OFFSET,"offset"); 99 | flatbuffers::WIPOffset::new(o.value()) 100 | } 101 | } 102 | 103 | impl core::fmt::Debug for StackLocation<'_> { 104 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 105 | let mut ds = f.debug_struct("StackLocation"); 106 | ds.field("offset", &self.offset()); 107 | ds.finish() 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/calling_convention_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum CallingConventionOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct CallingConvention<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for CallingConvention<'a> { 20 | type Inner = CallingConvention<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> CallingConvention<'a> { 28 | pub const VT_NAME: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | CallingConvention { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args CallingConventionArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = CallingConventionBuilder::new(_fbb); 40 | if let Some(x) = args.name { builder.add_name(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn name(&self) -> Option<&'a str> { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::>(CallingConvention::VT_NAME, None)} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for CallingConvention<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::>("name", Self::VT_NAME, false)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct CallingConventionArgs<'a> { 67 | pub name: Option>, 68 | } 69 | impl<'a> Default for CallingConventionArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | CallingConventionArgs { 73 | name: None, 74 | } 75 | } 76 | } 77 | 78 | pub struct CallingConventionBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> CallingConventionBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { 85 | self.fbb_.push_slot_always::>(CallingConvention::VT_NAME, name); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> CallingConventionBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | CallingConventionBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | flatbuffers::WIPOffset::new(o.value()) 99 | } 100 | } 101 | 102 | impl core::fmt::Debug for CallingConvention<'_> { 103 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 104 | let mut ds = f.debug_struct("CallingConvention"); 105 | ds.field("name", &self.name()); 106 | ds.finish() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/union_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum UnionOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Union<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Union<'a> { 20 | type Inner = Union<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Union<'a> { 28 | pub const VT_MEMBERS: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | Union { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args UnionArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = UnionBuilder::new(_fbb); 40 | if let Some(x) = args.members { builder.add_members(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn members(&self) -> Option>>> { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::>>>(Union::VT_MEMBERS, None)} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for Union<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::>>>("members", Self::VT_MEMBERS, false)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct UnionArgs<'a> { 67 | pub members: Option>>>>, 68 | } 69 | impl<'a> Default for UnionArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | UnionArgs { 73 | members: None, 74 | } 75 | } 76 | } 77 | 78 | pub struct UnionBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> UnionBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_members(&mut self, members: flatbuffers::WIPOffset>>>) { 85 | self.fbb_.push_slot_always::>(Union::VT_MEMBERS, members); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> UnionBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | UnionBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | flatbuffers::WIPOffset::new(o.value()) 99 | } 100 | } 101 | 102 | impl core::fmt::Debug for Union<'_> { 103 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 104 | let mut ds = f.debug_struct("Union"); 105 | ds.field("members", &self.members()); 106 | ds.finish() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/structure_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum StructureOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Structure<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Structure<'a> { 20 | type Inner = Structure<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Structure<'a> { 28 | pub const VT_MEMBERS: flatbuffers::VOffsetT = 4; 29 | 30 | #[inline] 31 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 32 | Structure { _tab: table } 33 | } 34 | #[allow(unused_mut)] 35 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 36 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 37 | args: &'args StructureArgs<'args> 38 | ) -> flatbuffers::WIPOffset> { 39 | let mut builder = StructureBuilder::new(_fbb); 40 | if let Some(x) = args.members { builder.add_members(x); } 41 | builder.finish() 42 | } 43 | 44 | 45 | #[inline] 46 | pub fn members(&self) -> Option>>> { 47 | // Safety: 48 | // Created from valid Table for this object 49 | // which contains a valid value in this slot 50 | unsafe { self._tab.get::>>>(Structure::VT_MEMBERS, None)} 51 | } 52 | } 53 | 54 | impl flatbuffers::Verifiable for Structure<'_> { 55 | #[inline] 56 | fn run_verifier( 57 | v: &mut flatbuffers::Verifier, pos: usize 58 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 59 | use self::flatbuffers::Verifiable; 60 | v.visit_table(pos)? 61 | .visit_field::>>>("members", Self::VT_MEMBERS, false)? 62 | .finish(); 63 | Ok(()) 64 | } 65 | } 66 | pub struct StructureArgs<'a> { 67 | pub members: Option>>>>, 68 | } 69 | impl<'a> Default for StructureArgs<'a> { 70 | #[inline] 71 | fn default() -> Self { 72 | StructureArgs { 73 | members: None, 74 | } 75 | } 76 | } 77 | 78 | pub struct StructureBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 79 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 80 | start_: flatbuffers::WIPOffset, 81 | } 82 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> StructureBuilder<'a, 'b, A> { 83 | #[inline] 84 | pub fn add_members(&mut self, members: flatbuffers::WIPOffset>>>) { 85 | self.fbb_.push_slot_always::>(Structure::VT_MEMBERS, members); 86 | } 87 | #[inline] 88 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> StructureBuilder<'a, 'b, A> { 89 | let start = _fbb.start_table(); 90 | StructureBuilder { 91 | fbb_: _fbb, 92 | start_: start, 93 | } 94 | } 95 | #[inline] 96 | pub fn finish(self) -> flatbuffers::WIPOffset> { 97 | let o = self.fbb_.end_table(self.start_); 98 | flatbuffers::WIPOffset::new(o.value()) 99 | } 100 | } 101 | 102 | impl core::fmt::Debug for Structure<'_> { 103 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 104 | let mut ds = f.debug_struct("Structure"); 105 | ds.field("members", &self.members()); 106 | ds.finish() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/integer_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum IntegerOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Integer<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Integer<'a> { 20 | type Inner = Integer<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Integer<'a> { 28 | pub const VT_WIDTH: flatbuffers::VOffsetT = 4; 29 | pub const VT_SIGNED: flatbuffers::VOffsetT = 6; 30 | 31 | #[inline] 32 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 33 | Integer { _tab: table } 34 | } 35 | #[allow(unused_mut)] 36 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 37 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 38 | args: &'args IntegerArgs<'args> 39 | ) -> flatbuffers::WIPOffset> { 40 | let mut builder = IntegerBuilder::new(_fbb); 41 | if let Some(x) = args.width { builder.add_width(x); } 42 | builder.add_signed(args.signed); 43 | builder.finish() 44 | } 45 | 46 | 47 | #[inline] 48 | pub fn width(&self) -> Option<&'a BitWidth> { 49 | // Safety: 50 | // Created from valid Table for this object 51 | // which contains a valid value in this slot 52 | unsafe { self._tab.get::(Integer::VT_WIDTH, None)} 53 | } 54 | #[inline] 55 | pub fn signed(&self) -> bool { 56 | // Safety: 57 | // Created from valid Table for this object 58 | // which contains a valid value in this slot 59 | unsafe { self._tab.get::(Integer::VT_SIGNED, Some(false)).unwrap()} 60 | } 61 | } 62 | 63 | impl flatbuffers::Verifiable for Integer<'_> { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | v.visit_table(pos)? 70 | .visit_field::("width", Self::VT_WIDTH, false)? 71 | .visit_field::("signed", Self::VT_SIGNED, false)? 72 | .finish(); 73 | Ok(()) 74 | } 75 | } 76 | pub struct IntegerArgs<'a> { 77 | pub width: Option<&'a BitWidth>, 78 | pub signed: bool, 79 | } 80 | impl<'a> Default for IntegerArgs<'a> { 81 | #[inline] 82 | fn default() -> Self { 83 | IntegerArgs { 84 | width: None, 85 | signed: false, 86 | } 87 | } 88 | } 89 | 90 | pub struct IntegerBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 91 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 92 | start_: flatbuffers::WIPOffset, 93 | } 94 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> IntegerBuilder<'a, 'b, A> { 95 | #[inline] 96 | pub fn add_width(&mut self, width: &BitWidth) { 97 | self.fbb_.push_slot_always::<&BitWidth>(Integer::VT_WIDTH, width); 98 | } 99 | #[inline] 100 | pub fn add_signed(&mut self, signed: bool) { 101 | self.fbb_.push_slot::(Integer::VT_SIGNED, signed, false); 102 | } 103 | #[inline] 104 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> IntegerBuilder<'a, 'b, A> { 105 | let start = _fbb.start_table(); 106 | IntegerBuilder { 107 | fbb_: _fbb, 108 | start_: start, 109 | } 110 | } 111 | #[inline] 112 | pub fn finish(self) -> flatbuffers::WIPOffset> { 113 | let o = self.fbb_.end_table(self.start_); 114 | flatbuffers::WIPOffset::new(o.value()) 115 | } 116 | } 117 | 118 | impl core::fmt::Debug for Integer<'_> { 119 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 120 | let mut ds = f.debug_struct("Integer"); 121 | ds.field("width", &self.width()); 122 | ds.field("signed", &self.signed()); 123 | ds.finish() 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/referrer_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum ReferrerOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Referrer<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Referrer<'a> { 20 | type Inner = Referrer<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Referrer<'a> { 28 | pub const VT_GUID: flatbuffers::VOffsetT = 4; 29 | pub const VT_NAME: flatbuffers::VOffsetT = 6; 30 | 31 | #[inline] 32 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 33 | Referrer { _tab: table } 34 | } 35 | #[allow(unused_mut)] 36 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 37 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 38 | args: &'args ReferrerArgs<'args> 39 | ) -> flatbuffers::WIPOffset> { 40 | let mut builder = ReferrerBuilder::new(_fbb); 41 | if let Some(x) = args.name { builder.add_name(x); } 42 | if let Some(x) = args.guid { builder.add_guid(x); } 43 | builder.finish() 44 | } 45 | 46 | 47 | #[inline] 48 | pub fn guid(&self) -> Option<&'a TypeGUID> { 49 | // Safety: 50 | // Created from valid Table for this object 51 | // which contains a valid value in this slot 52 | unsafe { self._tab.get::(Referrer::VT_GUID, None)} 53 | } 54 | #[inline] 55 | pub fn name(&self) -> Option<&'a str> { 56 | // Safety: 57 | // Created from valid Table for this object 58 | // which contains a valid value in this slot 59 | unsafe { self._tab.get::>(Referrer::VT_NAME, None)} 60 | } 61 | } 62 | 63 | impl flatbuffers::Verifiable for Referrer<'_> { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | v.visit_table(pos)? 70 | .visit_field::("guid", Self::VT_GUID, false)? 71 | .visit_field::>("name", Self::VT_NAME, false)? 72 | .finish(); 73 | Ok(()) 74 | } 75 | } 76 | pub struct ReferrerArgs<'a> { 77 | pub guid: Option<&'a TypeGUID>, 78 | pub name: Option>, 79 | } 80 | impl<'a> Default for ReferrerArgs<'a> { 81 | #[inline] 82 | fn default() -> Self { 83 | ReferrerArgs { 84 | guid: None, 85 | name: None, 86 | } 87 | } 88 | } 89 | 90 | pub struct ReferrerBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 91 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 92 | start_: flatbuffers::WIPOffset, 93 | } 94 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ReferrerBuilder<'a, 'b, A> { 95 | #[inline] 96 | pub fn add_guid(&mut self, guid: &TypeGUID) { 97 | self.fbb_.push_slot_always::<&TypeGUID>(Referrer::VT_GUID, guid); 98 | } 99 | #[inline] 100 | pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { 101 | self.fbb_.push_slot_always::>(Referrer::VT_NAME, name); 102 | } 103 | #[inline] 104 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ReferrerBuilder<'a, 'b, A> { 105 | let start = _fbb.start_table(); 106 | ReferrerBuilder { 107 | fbb_: _fbb, 108 | start_: start, 109 | } 110 | } 111 | #[inline] 112 | pub fn finish(self) -> flatbuffers::WIPOffset> { 113 | let o = self.fbb_.end_table(self.start_); 114 | flatbuffers::WIPOffset::new(o.value()) 115 | } 116 | } 117 | 118 | impl core::fmt::Debug for Referrer<'_> { 119 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 120 | let mut ds = f.debug_struct("Referrer"); 121 | ds.field("guid", &self.guid()); 122 | ds.field("name", &self.name()); 123 | ds.finish() 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/sig_bin/constraint_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum ConstraintOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Constraint<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Constraint<'a> { 20 | type Inner = Constraint<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Constraint<'a> { 28 | pub const VT_GUID: flatbuffers::VOffsetT = 4; 29 | pub const VT_OFFSET: flatbuffers::VOffsetT = 6; 30 | 31 | #[inline] 32 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 33 | Constraint { _tab: table } 34 | } 35 | #[allow(unused_mut)] 36 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 37 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 38 | args: &'args ConstraintArgs<'args> 39 | ) -> flatbuffers::WIPOffset> { 40 | let mut builder = ConstraintBuilder::new(_fbb); 41 | builder.add_offset(args.offset); 42 | if let Some(x) = args.guid { builder.add_guid(x); } 43 | builder.finish() 44 | } 45 | 46 | 47 | #[inline] 48 | pub fn guid(&self) -> &'a ConstraintGUID { 49 | // Safety: 50 | // Created from valid Table for this object 51 | // which contains a valid value in this slot 52 | unsafe { self._tab.get::(Constraint::VT_GUID, None).unwrap()} 53 | } 54 | #[inline] 55 | pub fn offset(&self) -> i64 { 56 | // Safety: 57 | // Created from valid Table for this object 58 | // which contains a valid value in this slot 59 | unsafe { self._tab.get::(Constraint::VT_OFFSET, Some(0)).unwrap()} 60 | } 61 | } 62 | 63 | impl flatbuffers::Verifiable for Constraint<'_> { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | v.visit_table(pos)? 70 | .visit_field::("guid", Self::VT_GUID, true)? 71 | .visit_field::("offset", Self::VT_OFFSET, false)? 72 | .finish(); 73 | Ok(()) 74 | } 75 | } 76 | pub struct ConstraintArgs<'a> { 77 | pub guid: Option<&'a ConstraintGUID>, 78 | pub offset: i64, 79 | } 80 | impl<'a> Default for ConstraintArgs<'a> { 81 | #[inline] 82 | fn default() -> Self { 83 | ConstraintArgs { 84 | guid: None, // required field 85 | offset: 0, 86 | } 87 | } 88 | } 89 | 90 | pub struct ConstraintBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 91 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 92 | start_: flatbuffers::WIPOffset, 93 | } 94 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ConstraintBuilder<'a, 'b, A> { 95 | #[inline] 96 | pub fn add_guid(&mut self, guid: &ConstraintGUID) { 97 | self.fbb_.push_slot_always::<&ConstraintGUID>(Constraint::VT_GUID, guid); 98 | } 99 | #[inline] 100 | pub fn add_offset(&mut self, offset: i64) { 101 | self.fbb_.push_slot::(Constraint::VT_OFFSET, offset, 0); 102 | } 103 | #[inline] 104 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ConstraintBuilder<'a, 'b, A> { 105 | let start = _fbb.start_table(); 106 | ConstraintBuilder { 107 | fbb_: _fbb, 108 | start_: start, 109 | } 110 | } 111 | #[inline] 112 | pub fn finish(self) -> flatbuffers::WIPOffset> { 113 | let o = self.fbb_.end_table(self.start_); 114 | self.fbb_.required(o, Constraint::VT_GUID,"guid"); 115 | flatbuffers::WIPOffset::new(o.value()) 116 | } 117 | } 118 | 119 | impl core::fmt::Debug for Constraint<'_> { 120 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 121 | let mut ds = f.debug_struct("Constraint"); 122 | ds.field("guid", &self.guid()); 123 | ds.field("offset", &self.offset()); 124 | ds.finish() 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /rust/src/type/class/structure.rs: -------------------------------------------------------------------------------- 1 | use bon::{bon, Builder}; 2 | use std::hash::Hash; 3 | 4 | use crate::cached_builder::CachedFlatBufferBuilder; 5 | use crate::r#type::Type; 6 | use crate::{fb_type as fb, FlatBufferObject}; 7 | use flatbuffers::WIPOffset; 8 | 9 | // We re-export bit flags as there is no need to wrap them. 10 | pub use fb::StructureMemberModifiers; 11 | 12 | #[derive(Clone, Debug, PartialEq)] 13 | pub struct StructureMember { 14 | pub name: Option, 15 | pub offset: u64, 16 | pub ty: Box, 17 | pub modifiers: StructureMemberModifiers, 18 | } 19 | 20 | #[bon] 21 | impl StructureMember { 22 | #[builder] 23 | pub fn new>( 24 | name: Option, 25 | offset: u64, 26 | ty: Type, 27 | modifiers: Option, 28 | ) -> Self { 29 | Self { 30 | name: name.map(Into::into), 31 | offset, 32 | ty: Box::new(ty), 33 | modifiers: modifiers.unwrap_or_default(), 34 | } 35 | } 36 | } 37 | 38 | impl StructureMember { 39 | fn size(&self) -> Option { 40 | self.ty.size() 41 | } 42 | } 43 | 44 | impl FlatBufferObject for StructureMember { 45 | type FbType<'fbb> = fb::StructureMember<'fbb>; 46 | 47 | fn create<'fbb>( 48 | &self, 49 | builder: &mut CachedFlatBufferBuilder<'fbb>, 50 | ) -> WIPOffset> { 51 | let name = self.name.as_ref().map(|n| builder.create_string(n)); 52 | let member_type = self.ty.create(builder); 53 | fb::StructureMember::create( 54 | builder, 55 | &fb::StructureMemberArgs { 56 | name, 57 | offset: Some(&self.offset.into()), 58 | type_: Some(member_type), 59 | modifiers: self.modifiers, 60 | }, 61 | ) 62 | } 63 | 64 | fn from_object(value: &Self::FbType<'_>) -> Option { 65 | let member = Self { 66 | name: value.name().map(str::to_string), 67 | offset: value.offset().into(), 68 | ty: Box::new(Type::from_object(&value.type_())?), 69 | modifiers: value.modifiers(), 70 | }; 71 | 72 | Some(member) 73 | } 74 | } 75 | 76 | impl Eq for StructureMember {} 77 | 78 | impl Hash for StructureMember { 79 | fn hash(&self, state: &mut H) { 80 | self.name.hash(state); 81 | self.offset.hash(state); 82 | self.ty.hash(state); 83 | // NOTE: Flatbuffers currently do not add Hash impl for bitfields. 84 | self.modifiers.bits().hash(state); 85 | } 86 | } 87 | 88 | #[derive(Clone, Debug, PartialEq, Eq, Hash, Builder)] 89 | pub struct StructureClass { 90 | pub members: Vec, 91 | } 92 | 93 | impl StructureClass { 94 | pub fn new(members: Vec) -> Self { 95 | Self { members } 96 | } 97 | 98 | pub fn size(&self) -> Option { 99 | self.members.iter().fold(None, |size, member| { 100 | // If an unknown member size is encountered, the structure size has to be unknown. 101 | Some((member.offset + member.size()?).max(size.unwrap_or(0))) 102 | }) 103 | } 104 | } 105 | 106 | impl FlatBufferObject for StructureClass { 107 | type FbType<'fbb> = fb::Structure<'fbb>; 108 | 109 | fn create<'fbb>( 110 | &self, 111 | builder: &mut CachedFlatBufferBuilder<'fbb>, 112 | ) -> WIPOffset> { 113 | let created_members: Vec<_> = self 114 | .members 115 | .iter() 116 | .map(|member| member.create(builder)) 117 | .collect(); 118 | let struct_members = builder.create_vector(&created_members); 119 | fb::Structure::create( 120 | builder, 121 | &fb::StructureArgs { 122 | members: Some(struct_members), 123 | }, 124 | ) 125 | } 126 | 127 | fn from_object(value: &Self::FbType<'_>) -> Option { 128 | let class = Self { 129 | members: value 130 | .members() 131 | .unwrap_or_default() 132 | .iter() 133 | .flat_map(|value| FlatBufferObject::from_object(&value)) 134 | .collect(), 135 | }; 136 | 137 | Some(class) 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /rust/examples/type_builder.rs: -------------------------------------------------------------------------------- 1 | use warp::r#type::class::{ 2 | ArrayClass, BooleanClass, EnumerationClass, EnumerationMember, FunctionClass, FunctionMember, 3 | IntegerClass, PointerClass, StructureClass, StructureMember, TypeClass, UnionClass, 4 | UnionMember, 5 | }; 6 | use warp::r#type::Type; 7 | 8 | fn main() { 9 | let void_type = Type::builder() 10 | .name("my_void".to_owned()) 11 | .class(TypeClass::Void) 12 | .build(); 13 | dbg!(&void_type); 14 | 15 | let bool_class = BooleanClass::builder().width(8).build(); 16 | let bool_type = Type::builder() 17 | .name("my_bool".to_owned()) 18 | .class(bool_class) 19 | .build(); 20 | dbg!(&bool_type); 21 | 22 | let int_class = IntegerClass::builder().width(8).signed(false).build(); 23 | let int_type = Type::builder() 24 | .name("my_int".to_owned()) 25 | .class(int_class) 26 | .build(); 27 | dbg!(&int_type); 28 | 29 | let ptr_class = PointerClass::builder() 30 | .width(8) 31 | .child_type(void_type.clone()) 32 | .build(); 33 | let ptr_type = Type::builder() 34 | .name("my_ptr".to_owned()) 35 | .class(ptr_class) 36 | .build(); 37 | dbg!(&ptr_type); 38 | 39 | let array_class = ArrayClass::builder() 40 | .length(4) 41 | .member_type(void_type.clone()) 42 | .build(); 43 | let array_type = Type::builder() 44 | .name("my_array".to_owned()) 45 | .class(array_class) 46 | .build(); 47 | dbg!(&array_type); 48 | 49 | let enum_class = EnumerationClass::new( 50 | int_type.clone(), 51 | vec![ 52 | EnumerationMember::builder().name("one").constant(1).build(), 53 | EnumerationMember::builder().name("two").constant(2).build(), 54 | EnumerationMember::builder() 55 | .name("five") 56 | .constant(5) 57 | .build(), 58 | EnumerationMember::builder().constant(6).build(), 59 | ], 60 | ); 61 | let enum_type = Type::builder() 62 | .name("my_enum".to_owned()) 63 | .class(enum_class) 64 | .build(); 65 | dbg!(&enum_type); 66 | 67 | let union_class = UnionClass::new(vec![ 68 | UnionMember::new("int".to_owned(), int_type.clone()), 69 | UnionMember::new("bool".to_owned(), bool_type.clone()), 70 | UnionMember::new("ptr".to_owned(), ptr_type.clone()), 71 | UnionMember::new("enum".to_owned(), enum_type.clone()), 72 | UnionMember::new("array".to_owned(), array_type.clone()), 73 | ]); 74 | let union_type = Type::builder() 75 | .name("my_union".to_owned()) 76 | .class(union_class) 77 | .build(); 78 | dbg!(&union_type); 79 | 80 | let struct_class = StructureClass::new(vec![ 81 | StructureMember::builder() 82 | .name("int") 83 | .ty(int_type.clone()) 84 | .offset(0) 85 | .build(), 86 | StructureMember::builder() 87 | .name("bool") 88 | .ty(bool_type.clone()) 89 | .offset(64) 90 | .build(), 91 | StructureMember::builder() 92 | .name("pointer") 93 | .ty(ptr_type.clone()) 94 | .offset(72) 95 | .build(), 96 | StructureMember::builder() 97 | .name("enum") 98 | .ty(enum_type.clone()) 99 | .offset(136) 100 | .build(), 101 | StructureMember::builder() 102 | .name("array") 103 | .ty(array_type.clone()) 104 | .offset(200) 105 | .build(), 106 | ]); 107 | let struct_type = Type::builder() 108 | .name("my_struct".to_owned()) 109 | .class(struct_class) 110 | .build(); 111 | dbg!(&struct_type); 112 | 113 | let func_class = FunctionClass::new( 114 | None, 115 | vec![ 116 | FunctionMember::builder() 117 | .name("param_0") 118 | .ty(int_type.clone()) 119 | .build(), 120 | FunctionMember::builder() 121 | .name("param_1") 122 | .ty(bool_type.clone()) 123 | .build(), 124 | ], 125 | vec![], 126 | ); 127 | let func_type = Type::builder() 128 | .name("my_func".to_owned()) 129 | .class(func_class) 130 | .build(); 131 | dbg!(&func_type); 132 | } 133 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/computed_type_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum ComputedTypeOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct ComputedType<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for ComputedType<'a> { 20 | type Inner = ComputedType<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> ComputedType<'a> { 28 | pub const VT_GUID: flatbuffers::VOffsetT = 4; 29 | pub const VT_TYPE_: flatbuffers::VOffsetT = 6; 30 | 31 | #[inline] 32 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 33 | ComputedType { _tab: table } 34 | } 35 | #[allow(unused_mut)] 36 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 37 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 38 | args: &'args ComputedTypeArgs<'args> 39 | ) -> flatbuffers::WIPOffset> { 40 | let mut builder = ComputedTypeBuilder::new(_fbb); 41 | if let Some(x) = args.type_ { builder.add_type_(x); } 42 | if let Some(x) = args.guid { builder.add_guid(x); } 43 | builder.finish() 44 | } 45 | 46 | 47 | #[inline] 48 | pub fn guid(&self) -> &'a TypeGUID { 49 | // Safety: 50 | // Created from valid Table for this object 51 | // which contains a valid value in this slot 52 | unsafe { self._tab.get::(ComputedType::VT_GUID, None).unwrap()} 53 | } 54 | #[inline] 55 | pub fn type_(&self) -> Option> { 56 | // Safety: 57 | // Created from valid Table for this object 58 | // which contains a valid value in this slot 59 | unsafe { self._tab.get::>(ComputedType::VT_TYPE_, None)} 60 | } 61 | } 62 | 63 | impl flatbuffers::Verifiable for ComputedType<'_> { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | v.visit_table(pos)? 70 | .visit_field::("guid", Self::VT_GUID, true)? 71 | .visit_field::>("type_", Self::VT_TYPE_, false)? 72 | .finish(); 73 | Ok(()) 74 | } 75 | } 76 | pub struct ComputedTypeArgs<'a> { 77 | pub guid: Option<&'a TypeGUID>, 78 | pub type_: Option>>, 79 | } 80 | impl<'a> Default for ComputedTypeArgs<'a> { 81 | #[inline] 82 | fn default() -> Self { 83 | ComputedTypeArgs { 84 | guid: None, // required field 85 | type_: None, 86 | } 87 | } 88 | } 89 | 90 | pub struct ComputedTypeBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 91 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 92 | start_: flatbuffers::WIPOffset, 93 | } 94 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ComputedTypeBuilder<'a, 'b, A> { 95 | #[inline] 96 | pub fn add_guid(&mut self, guid: &TypeGUID) { 97 | self.fbb_.push_slot_always::<&TypeGUID>(ComputedType::VT_GUID, guid); 98 | } 99 | #[inline] 100 | pub fn add_type_(&mut self, type_: flatbuffers::WIPOffset>) { 101 | self.fbb_.push_slot_always::>(ComputedType::VT_TYPE_, type_); 102 | } 103 | #[inline] 104 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ComputedTypeBuilder<'a, 'b, A> { 105 | let start = _fbb.start_table(); 106 | ComputedTypeBuilder { 107 | fbb_: _fbb, 108 | start_: start, 109 | } 110 | } 111 | #[inline] 112 | pub fn finish(self) -> flatbuffers::WIPOffset> { 113 | let o = self.fbb_.end_table(self.start_); 114 | self.fbb_.required(o, ComputedType::VT_GUID,"guid"); 115 | flatbuffers::WIPOffset::new(o.value()) 116 | } 117 | } 118 | 119 | impl core::fmt::Debug for ComputedType<'_> { 120 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 121 | let mut ds = f.debug_struct("ComputedType"); 122 | ds.field("guid", &self.guid()); 123 | ds.field("type_", &self.type_()); 124 | ds.finish() 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/sig_bin/function_comment_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum FunctionCommentOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct FunctionComment<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for FunctionComment<'a> { 20 | type Inner = FunctionComment<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> FunctionComment<'a> { 28 | pub const VT_OFFSET: flatbuffers::VOffsetT = 4; 29 | pub const VT_TEXT: flatbuffers::VOffsetT = 6; 30 | 31 | #[inline] 32 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 33 | FunctionComment { _tab: table } 34 | } 35 | #[allow(unused_mut)] 36 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 37 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 38 | args: &'args FunctionCommentArgs<'args> 39 | ) -> flatbuffers::WIPOffset> { 40 | let mut builder = FunctionCommentBuilder::new(_fbb); 41 | builder.add_offset(args.offset); 42 | if let Some(x) = args.text { builder.add_text(x); } 43 | builder.finish() 44 | } 45 | 46 | 47 | #[inline] 48 | pub fn offset(&self) -> i64 { 49 | // Safety: 50 | // Created from valid Table for this object 51 | // which contains a valid value in this slot 52 | unsafe { self._tab.get::(FunctionComment::VT_OFFSET, Some(0)).unwrap()} 53 | } 54 | #[inline] 55 | pub fn text(&self) -> &'a str { 56 | // Safety: 57 | // Created from valid Table for this object 58 | // which contains a valid value in this slot 59 | unsafe { self._tab.get::>(FunctionComment::VT_TEXT, None).unwrap()} 60 | } 61 | } 62 | 63 | impl flatbuffers::Verifiable for FunctionComment<'_> { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | v.visit_table(pos)? 70 | .visit_field::("offset", Self::VT_OFFSET, false)? 71 | .visit_field::>("text", Self::VT_TEXT, true)? 72 | .finish(); 73 | Ok(()) 74 | } 75 | } 76 | pub struct FunctionCommentArgs<'a> { 77 | pub offset: i64, 78 | pub text: Option>, 79 | } 80 | impl<'a> Default for FunctionCommentArgs<'a> { 81 | #[inline] 82 | fn default() -> Self { 83 | FunctionCommentArgs { 84 | offset: 0, 85 | text: None, // required field 86 | } 87 | } 88 | } 89 | 90 | pub struct FunctionCommentBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 91 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 92 | start_: flatbuffers::WIPOffset, 93 | } 94 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> FunctionCommentBuilder<'a, 'b, A> { 95 | #[inline] 96 | pub fn add_offset(&mut self, offset: i64) { 97 | self.fbb_.push_slot::(FunctionComment::VT_OFFSET, offset, 0); 98 | } 99 | #[inline] 100 | pub fn add_text(&mut self, text: flatbuffers::WIPOffset<&'b str>) { 101 | self.fbb_.push_slot_always::>(FunctionComment::VT_TEXT, text); 102 | } 103 | #[inline] 104 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> FunctionCommentBuilder<'a, 'b, A> { 105 | let start = _fbb.start_table(); 106 | FunctionCommentBuilder { 107 | fbb_: _fbb, 108 | start_: start, 109 | } 110 | } 111 | #[inline] 112 | pub fn finish(self) -> flatbuffers::WIPOffset> { 113 | let o = self.fbb_.end_table(self.start_); 114 | self.fbb_.required(o, FunctionComment::VT_TEXT,"text"); 115 | flatbuffers::WIPOffset::new(o.value()) 116 | } 117 | } 118 | 119 | impl core::fmt::Debug for FunctionComment<'_> { 120 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 121 | let mut ds = f.debug_struct("FunctionComment"); 122 | ds.field("offset", &self.offset()); 123 | ds.field("text", &self.text()); 124 | ds.finish() 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/enumeration_member_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum EnumerationMemberOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct EnumerationMember<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for EnumerationMember<'a> { 20 | type Inner = EnumerationMember<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> EnumerationMember<'a> { 28 | pub const VT_NAME: flatbuffers::VOffsetT = 4; 29 | pub const VT_CONSTANT: flatbuffers::VOffsetT = 6; 30 | 31 | #[inline] 32 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 33 | EnumerationMember { _tab: table } 34 | } 35 | #[allow(unused_mut)] 36 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 37 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 38 | args: &'args EnumerationMemberArgs<'args> 39 | ) -> flatbuffers::WIPOffset> { 40 | let mut builder = EnumerationMemberBuilder::new(_fbb); 41 | builder.add_constant(args.constant); 42 | if let Some(x) = args.name { builder.add_name(x); } 43 | builder.finish() 44 | } 45 | 46 | 47 | #[inline] 48 | pub fn name(&self) -> Option<&'a str> { 49 | // Safety: 50 | // Created from valid Table for this object 51 | // which contains a valid value in this slot 52 | unsafe { self._tab.get::>(EnumerationMember::VT_NAME, None)} 53 | } 54 | #[inline] 55 | pub fn constant(&self) -> u64 { 56 | // Safety: 57 | // Created from valid Table for this object 58 | // which contains a valid value in this slot 59 | unsafe { self._tab.get::(EnumerationMember::VT_CONSTANT, Some(0)).unwrap()} 60 | } 61 | } 62 | 63 | impl flatbuffers::Verifiable for EnumerationMember<'_> { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | v.visit_table(pos)? 70 | .visit_field::>("name", Self::VT_NAME, false)? 71 | .visit_field::("constant", Self::VT_CONSTANT, false)? 72 | .finish(); 73 | Ok(()) 74 | } 75 | } 76 | pub struct EnumerationMemberArgs<'a> { 77 | pub name: Option>, 78 | pub constant: u64, 79 | } 80 | impl<'a> Default for EnumerationMemberArgs<'a> { 81 | #[inline] 82 | fn default() -> Self { 83 | EnumerationMemberArgs { 84 | name: None, 85 | constant: 0, 86 | } 87 | } 88 | } 89 | 90 | pub struct EnumerationMemberBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 91 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 92 | start_: flatbuffers::WIPOffset, 93 | } 94 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> EnumerationMemberBuilder<'a, 'b, A> { 95 | #[inline] 96 | pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { 97 | self.fbb_.push_slot_always::>(EnumerationMember::VT_NAME, name); 98 | } 99 | #[inline] 100 | pub fn add_constant(&mut self, constant: u64) { 101 | self.fbb_.push_slot::(EnumerationMember::VT_CONSTANT, constant, 0); 102 | } 103 | #[inline] 104 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> EnumerationMemberBuilder<'a, 'b, A> { 105 | let start = _fbb.start_table(); 106 | EnumerationMemberBuilder { 107 | fbb_: _fbb, 108 | start_: start, 109 | } 110 | } 111 | #[inline] 112 | pub fn finish(self) -> flatbuffers::WIPOffset> { 113 | let o = self.fbb_.end_table(self.start_); 114 | flatbuffers::WIPOffset::new(o.value()) 115 | } 116 | } 117 | 118 | impl core::fmt::Debug for EnumerationMember<'_> { 119 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 120 | let mut ds = f.debug_struct("EnumerationMember"); 121 | ds.field("name", &self.name()); 122 | ds.field("constant", &self.constant()); 123 | ds.finish() 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/target_bin/target_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum TargetOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Target<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Target<'a> { 20 | type Inner = Target<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Target<'a> { 28 | pub const VT_ARCHITECTURE: flatbuffers::VOffsetT = 4; 29 | pub const VT_PLATFORM: flatbuffers::VOffsetT = 6; 30 | 31 | #[inline] 32 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 33 | Target { _tab: table } 34 | } 35 | #[allow(unused_mut)] 36 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 37 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 38 | args: &'args TargetArgs<'args> 39 | ) -> flatbuffers::WIPOffset> { 40 | let mut builder = TargetBuilder::new(_fbb); 41 | if let Some(x) = args.platform { builder.add_platform(x); } 42 | if let Some(x) = args.architecture { builder.add_architecture(x); } 43 | builder.finish() 44 | } 45 | 46 | 47 | #[inline] 48 | pub fn architecture(&self) -> Option<&'a str> { 49 | // Safety: 50 | // Created from valid Table for this object 51 | // which contains a valid value in this slot 52 | unsafe { self._tab.get::>(Target::VT_ARCHITECTURE, None)} 53 | } 54 | #[inline] 55 | pub fn platform(&self) -> Option<&'a str> { 56 | // Safety: 57 | // Created from valid Table for this object 58 | // which contains a valid value in this slot 59 | unsafe { self._tab.get::>(Target::VT_PLATFORM, None)} 60 | } 61 | } 62 | 63 | impl flatbuffers::Verifiable for Target<'_> { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | v.visit_table(pos)? 70 | .visit_field::>("architecture", Self::VT_ARCHITECTURE, false)? 71 | .visit_field::>("platform", Self::VT_PLATFORM, false)? 72 | .finish(); 73 | Ok(()) 74 | } 75 | } 76 | pub struct TargetArgs<'a> { 77 | pub architecture: Option>, 78 | pub platform: Option>, 79 | } 80 | impl<'a> Default for TargetArgs<'a> { 81 | #[inline] 82 | fn default() -> Self { 83 | TargetArgs { 84 | architecture: None, 85 | platform: None, 86 | } 87 | } 88 | } 89 | 90 | pub struct TargetBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 91 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 92 | start_: flatbuffers::WIPOffset, 93 | } 94 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TargetBuilder<'a, 'b, A> { 95 | #[inline] 96 | pub fn add_architecture(&mut self, architecture: flatbuffers::WIPOffset<&'b str>) { 97 | self.fbb_.push_slot_always::>(Target::VT_ARCHITECTURE, architecture); 98 | } 99 | #[inline] 100 | pub fn add_platform(&mut self, platform: flatbuffers::WIPOffset<&'b str>) { 101 | self.fbb_.push_slot_always::>(Target::VT_PLATFORM, platform); 102 | } 103 | #[inline] 104 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TargetBuilder<'a, 'b, A> { 105 | let start = _fbb.start_table(); 106 | TargetBuilder { 107 | fbb_: _fbb, 108 | start_: start, 109 | } 110 | } 111 | #[inline] 112 | pub fn finish(self) -> flatbuffers::WIPOffset> { 113 | let o = self.fbb_.end_table(self.start_); 114 | flatbuffers::WIPOffset::new(o.value()) 115 | } 116 | } 117 | 118 | impl core::fmt::Debug for Target<'_> { 119 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 120 | let mut ds = f.debug_struct("Target"); 121 | ds.field("architecture", &self.architecture()); 122 | ds.field("platform", &self.platform()); 123 | ds.finish() 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/union_member_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum UnionMemberOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct UnionMember<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for UnionMember<'a> { 20 | type Inner = UnionMember<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> UnionMember<'a> { 28 | pub const VT_NAME: flatbuffers::VOffsetT = 4; 29 | pub const VT_TYPE_: flatbuffers::VOffsetT = 6; 30 | 31 | #[inline] 32 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 33 | UnionMember { _tab: table } 34 | } 35 | #[allow(unused_mut)] 36 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 37 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 38 | args: &'args UnionMemberArgs<'args> 39 | ) -> flatbuffers::WIPOffset> { 40 | let mut builder = UnionMemberBuilder::new(_fbb); 41 | if let Some(x) = args.type_ { builder.add_type_(x); } 42 | if let Some(x) = args.name { builder.add_name(x); } 43 | builder.finish() 44 | } 45 | 46 | 47 | #[inline] 48 | pub fn name(&self) -> Option<&'a str> { 49 | // Safety: 50 | // Created from valid Table for this object 51 | // which contains a valid value in this slot 52 | unsafe { self._tab.get::>(UnionMember::VT_NAME, None)} 53 | } 54 | #[inline] 55 | pub fn type_(&self) -> Type<'a> { 56 | // Safety: 57 | // Created from valid Table for this object 58 | // which contains a valid value in this slot 59 | unsafe { self._tab.get::>(UnionMember::VT_TYPE_, None).unwrap()} 60 | } 61 | } 62 | 63 | impl flatbuffers::Verifiable for UnionMember<'_> { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | v.visit_table(pos)? 70 | .visit_field::>("name", Self::VT_NAME, false)? 71 | .visit_field::>("type_", Self::VT_TYPE_, true)? 72 | .finish(); 73 | Ok(()) 74 | } 75 | } 76 | pub struct UnionMemberArgs<'a> { 77 | pub name: Option>, 78 | pub type_: Option>>, 79 | } 80 | impl<'a> Default for UnionMemberArgs<'a> { 81 | #[inline] 82 | fn default() -> Self { 83 | UnionMemberArgs { 84 | name: None, 85 | type_: None, // required field 86 | } 87 | } 88 | } 89 | 90 | pub struct UnionMemberBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 91 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 92 | start_: flatbuffers::WIPOffset, 93 | } 94 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> UnionMemberBuilder<'a, 'b, A> { 95 | #[inline] 96 | pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { 97 | self.fbb_.push_slot_always::>(UnionMember::VT_NAME, name); 98 | } 99 | #[inline] 100 | pub fn add_type_(&mut self, type_: flatbuffers::WIPOffset>) { 101 | self.fbb_.push_slot_always::>(UnionMember::VT_TYPE_, type_); 102 | } 103 | #[inline] 104 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> UnionMemberBuilder<'a, 'b, A> { 105 | let start = _fbb.start_table(); 106 | UnionMemberBuilder { 107 | fbb_: _fbb, 108 | start_: start, 109 | } 110 | } 111 | #[inline] 112 | pub fn finish(self) -> flatbuffers::WIPOffset> { 113 | let o = self.fbb_.end_table(self.start_); 114 | self.fbb_.required(o, UnionMember::VT_TYPE_,"type_"); 115 | flatbuffers::WIPOffset::new(o.value()) 116 | } 117 | } 118 | 119 | impl core::fmt::Debug for UnionMember<'_> { 120 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 121 | let mut ds = f.debug_struct("UnionMember"); 122 | ds.field("name", &self.name()); 123 | ds.field("type_", &self.type_()); 124 | ds.finish() 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/warp/chunk_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | pub enum ChunkOffset {} 13 | #[derive(Copy, Clone, PartialEq)] 14 | 15 | pub struct Chunk<'a> { 16 | pub _tab: flatbuffers::Table<'a>, 17 | } 18 | 19 | impl<'a> flatbuffers::Follow<'a> for Chunk<'a> { 20 | type Inner = Chunk<'a>; 21 | #[inline] 22 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 23 | Self { _tab: flatbuffers::Table::new(buf, loc) } 24 | } 25 | } 26 | 27 | impl<'a> Chunk<'a> { 28 | pub const VT_HEADER: flatbuffers::VOffsetT = 4; 29 | pub const VT_DATA: flatbuffers::VOffsetT = 6; 30 | 31 | #[inline] 32 | pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { 33 | Chunk { _tab: table } 34 | } 35 | #[allow(unused_mut)] 36 | pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>( 37 | _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>, 38 | args: &'args ChunkArgs<'args> 39 | ) -> flatbuffers::WIPOffset> { 40 | let mut builder = ChunkBuilder::new(_fbb); 41 | if let Some(x) = args.data { builder.add_data(x); } 42 | if let Some(x) = args.header { builder.add_header(x); } 43 | builder.finish() 44 | } 45 | 46 | 47 | #[inline] 48 | pub fn header(&self) -> ChunkHeader<'a> { 49 | // Safety: 50 | // Created from valid Table for this object 51 | // which contains a valid value in this slot 52 | unsafe { self._tab.get::>(Chunk::VT_HEADER, None).unwrap()} 53 | } 54 | #[inline] 55 | pub fn data(&self) -> Option> { 56 | // Safety: 57 | // Created from valid Table for this object 58 | // which contains a valid value in this slot 59 | unsafe { self._tab.get::>>(Chunk::VT_DATA, None)} 60 | } 61 | } 62 | 63 | impl flatbuffers::Verifiable for Chunk<'_> { 64 | #[inline] 65 | fn run_verifier( 66 | v: &mut flatbuffers::Verifier, pos: usize 67 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 68 | use self::flatbuffers::Verifiable; 69 | v.visit_table(pos)? 70 | .visit_field::>("header", Self::VT_HEADER, true)? 71 | .visit_field::>>("data", Self::VT_DATA, false)? 72 | .finish(); 73 | Ok(()) 74 | } 75 | } 76 | pub struct ChunkArgs<'a> { 77 | pub header: Option>>, 78 | pub data: Option>>, 79 | } 80 | impl<'a> Default for ChunkArgs<'a> { 81 | #[inline] 82 | fn default() -> Self { 83 | ChunkArgs { 84 | header: None, // required field 85 | data: None, 86 | } 87 | } 88 | } 89 | 90 | pub struct ChunkBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { 91 | fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, 92 | start_: flatbuffers::WIPOffset, 93 | } 94 | impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ChunkBuilder<'a, 'b, A> { 95 | #[inline] 96 | pub fn add_header(&mut self, header: flatbuffers::WIPOffset>) { 97 | self.fbb_.push_slot_always::>(Chunk::VT_HEADER, header); 98 | } 99 | #[inline] 100 | pub fn add_data(&mut self, data: flatbuffers::WIPOffset>) { 101 | self.fbb_.push_slot_always::>(Chunk::VT_DATA, data); 102 | } 103 | #[inline] 104 | pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ChunkBuilder<'a, 'b, A> { 105 | let start = _fbb.start_table(); 106 | ChunkBuilder { 107 | fbb_: _fbb, 108 | start_: start, 109 | } 110 | } 111 | #[inline] 112 | pub fn finish(self) -> flatbuffers::WIPOffset> { 113 | let o = self.fbb_.end_table(self.start_); 114 | self.fbb_.required(o, Chunk::VT_HEADER,"header"); 115 | flatbuffers::WIPOffset::new(o.value()) 116 | } 117 | } 118 | 119 | impl core::fmt::Debug for Chunk<'_> { 120 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 121 | let mut ds = f.debug_struct("Chunk"); 122 | ds.field("header", &self.header()); 123 | ds.field("data", &self.data()); 124 | ds.finish() 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /rust/src/gen_flatbuffers/type_bin/type_class_generated.rs: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | // @generated 3 | extern crate alloc; 4 | extern crate flatbuffers; 5 | use alloc::boxed::Box; 6 | use alloc::string::{String, ToString}; 7 | use alloc::vec::Vec; 8 | use core::mem; 9 | use core::cmp::Ordering; 10 | use self::flatbuffers::{EndianScalar, Follow}; 11 | use super::*; 12 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 13 | pub const ENUM_MIN_TYPE_CLASS: u8 = 0; 14 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 15 | pub const ENUM_MAX_TYPE_CLASS: u8 = 12; 16 | #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] 17 | #[allow(non_camel_case_types)] 18 | pub const ENUM_VALUES_TYPE_CLASS: [TypeClass; 13] = [ 19 | TypeClass::NONE, 20 | TypeClass::Void, 21 | TypeClass::Boolean, 22 | TypeClass::Integer, 23 | TypeClass::Character, 24 | TypeClass::Float, 25 | TypeClass::Pointer, 26 | TypeClass::Array, 27 | TypeClass::Structure, 28 | TypeClass::Enumeration, 29 | TypeClass::Union, 30 | TypeClass::Function, 31 | TypeClass::Referrer, 32 | ]; 33 | 34 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] 35 | #[repr(transparent)] 36 | pub struct TypeClass(pub u8); 37 | #[allow(non_upper_case_globals)] 38 | impl TypeClass { 39 | pub const NONE: Self = Self(0); 40 | pub const Void: Self = Self(1); 41 | pub const Boolean: Self = Self(2); 42 | pub const Integer: Self = Self(3); 43 | pub const Character: Self = Self(4); 44 | pub const Float: Self = Self(5); 45 | pub const Pointer: Self = Self(6); 46 | pub const Array: Self = Self(7); 47 | pub const Structure: Self = Self(8); 48 | pub const Enumeration: Self = Self(9); 49 | pub const Union: Self = Self(10); 50 | pub const Function: Self = Self(11); 51 | pub const Referrer: Self = Self(12); 52 | 53 | pub const ENUM_MIN: u8 = 0; 54 | pub const ENUM_MAX: u8 = 12; 55 | pub const ENUM_VALUES: &'static [Self] = &[ 56 | Self::NONE, 57 | Self::Void, 58 | Self::Boolean, 59 | Self::Integer, 60 | Self::Character, 61 | Self::Float, 62 | Self::Pointer, 63 | Self::Array, 64 | Self::Structure, 65 | Self::Enumeration, 66 | Self::Union, 67 | Self::Function, 68 | Self::Referrer, 69 | ]; 70 | /// Returns the variant's name or "" if unknown. 71 | pub fn variant_name(self) -> Option<&'static str> { 72 | match self { 73 | Self::NONE => Some("NONE"), 74 | Self::Void => Some("Void"), 75 | Self::Boolean => Some("Boolean"), 76 | Self::Integer => Some("Integer"), 77 | Self::Character => Some("Character"), 78 | Self::Float => Some("Float"), 79 | Self::Pointer => Some("Pointer"), 80 | Self::Array => Some("Array"), 81 | Self::Structure => Some("Structure"), 82 | Self::Enumeration => Some("Enumeration"), 83 | Self::Union => Some("Union"), 84 | Self::Function => Some("Function"), 85 | Self::Referrer => Some("Referrer"), 86 | _ => None, 87 | } 88 | } 89 | } 90 | impl core::fmt::Debug for TypeClass { 91 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 92 | if let Some(name) = self.variant_name() { 93 | f.write_str(name) 94 | } else { 95 | f.write_fmt(format_args!("", self.0)) 96 | } 97 | } 98 | } 99 | impl<'a> flatbuffers::Follow<'a> for TypeClass { 100 | type Inner = Self; 101 | #[inline] 102 | unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 103 | let b = flatbuffers::read_scalar_at::(buf, loc); 104 | Self(b) 105 | } 106 | } 107 | 108 | impl flatbuffers::Push for TypeClass { 109 | type Output = TypeClass; 110 | #[inline] 111 | unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { 112 | flatbuffers::emplace_scalar::(dst, self.0); 113 | } 114 | } 115 | 116 | impl flatbuffers::EndianScalar for TypeClass { 117 | type Scalar = u8; 118 | #[inline] 119 | fn to_little_endian(self) -> u8 { 120 | self.0.to_le() 121 | } 122 | #[inline] 123 | #[allow(clippy::wrong_self_convention)] 124 | fn from_little_endian(v: u8) -> Self { 125 | let b = u8::from_le(v); 126 | Self(b) 127 | } 128 | } 129 | 130 | impl<'a> flatbuffers::Verifiable for TypeClass { 131 | #[inline] 132 | fn run_verifier( 133 | v: &mut flatbuffers::Verifier, pos: usize 134 | ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 135 | use self::flatbuffers::Verifiable; 136 | u8::run_verifier(v, pos) 137 | } 138 | } 139 | 140 | impl flatbuffers::SimpleToVerifyInSlice for TypeClass {} 141 | pub struct TypeClassUnionTableOffset {} 142 | 143 | -------------------------------------------------------------------------------- /rust/src/signature/constraint.rs: -------------------------------------------------------------------------------- 1 | use crate::cached_builder::CachedFlatBufferBuilder; 2 | use crate::signature::function::FunctionGUID; 3 | use crate::symbol::Symbol; 4 | use crate::{fb_sig as fb, FlatBufferObject}; 5 | use flatbuffers::WIPOffset; 6 | use std::fmt::{Display, Formatter}; 7 | use std::str::FromStr; 8 | use uuid::{uuid, Uuid}; 9 | 10 | pub const NAMESPACE_CONSTRAINT: Uuid = uuid!("019701f3-e89c-7afa-9181-371a5e98a576"); 11 | 12 | /// For a [`Constraint`] which is unrelated (represented as `None`), we use [`i64::MAX`] when storing in the flatbuffer. 13 | pub const UNRELATED_OFFSET: i64 = i64::MAX; 14 | 15 | /// This type is marked `repr(transparent)` to the underlying `[u8; 16]` type, so it is safe to use in FFI. 16 | #[repr(transparent)] 17 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)] 18 | pub struct ConstraintGUID { 19 | pub guid: Uuid, 20 | } 21 | 22 | impl ConstraintGUID { 23 | // TODO: From value 24 | // TODO: From string 25 | 26 | pub fn from_function_guid(guid: &FunctionGUID) -> Self { 27 | // TODO: Should we prefix the bytes with some tag so that function guid cant collide with something else? 28 | let guid = Uuid::new_v5(&NAMESPACE_CONSTRAINT, guid.as_bytes()); 29 | ConstraintGUID { guid } 30 | } 31 | 32 | pub fn from_symbol(symbol: &Symbol) -> Self { 33 | // TODO: Should we prefix the bytes with some tag so that symbol cant collide with something else? 34 | let guid = Uuid::new_v5(&NAMESPACE_CONSTRAINT, symbol.name.as_bytes()); 35 | ConstraintGUID { guid } 36 | } 37 | 38 | pub fn from_value(value: u64) -> Self { 39 | // TODO: Should we prefix the bytes with some tag so that value cant collide with something else? 40 | let guid = Uuid::new_v5(&NAMESPACE_CONSTRAINT, &value.to_le_bytes()); 41 | ConstraintGUID { guid } 42 | } 43 | } 44 | 45 | impl FromStr for ConstraintGUID { 46 | type Err = uuid::Error; 47 | 48 | fn from_str(s: &str) -> Result { 49 | Uuid::parse_str(s).map(Into::into) 50 | } 51 | } 52 | 53 | impl TryFrom<&str> for ConstraintGUID { 54 | type Error = uuid::Error; 55 | 56 | fn try_from(value: &str) -> Result { 57 | Self::from_str(value) 58 | } 59 | } 60 | 61 | impl From<&[u8]> for ConstraintGUID { 62 | fn from(value: &[u8]) -> Self { 63 | Self { 64 | guid: Uuid::new_v5(&NAMESPACE_CONSTRAINT, value), 65 | } 66 | } 67 | } 68 | 69 | impl From for ConstraintGUID { 70 | fn from(value: Uuid) -> Self { 71 | Self { guid: value } 72 | } 73 | } 74 | 75 | impl From for ConstraintGUID { 76 | fn from(value: fb::ConstraintGUID) -> Self { 77 | Self { 78 | guid: Uuid::from_bytes(value.0), 79 | } 80 | } 81 | } 82 | 83 | impl From for fb::ConstraintGUID { 84 | fn from(value: ConstraintGUID) -> Self { 85 | Self(value.guid.into_bytes()) 86 | } 87 | } 88 | 89 | impl Display for ConstraintGUID { 90 | fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { 91 | Display::fmt(&self.guid, f) 92 | } 93 | } 94 | 95 | // TODO: Add a wrapper container type for the hashset and provided helpers 96 | #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] 97 | pub struct Constraint { 98 | pub guid: ConstraintGUID, 99 | pub offset: Option, 100 | } 101 | 102 | impl Constraint { 103 | pub fn from_function(guid: &FunctionGUID, offset: Option) -> Self { 104 | Self { 105 | guid: ConstraintGUID::from_function_guid(guid), 106 | offset, 107 | } 108 | } 109 | 110 | pub fn from_symbol(symbol: &Symbol, offset: Option) -> Self { 111 | Self { 112 | guid: ConstraintGUID::from_symbol(symbol), 113 | offset, 114 | } 115 | } 116 | } 117 | 118 | impl FlatBufferObject for Constraint { 119 | type FbType<'fbb> = fb::Constraint<'fbb>; 120 | 121 | fn create<'fbb>( 122 | &self, 123 | builder: &mut CachedFlatBufferBuilder<'fbb>, 124 | ) -> WIPOffset> { 125 | fb::Constraint::create( 126 | builder, 127 | &fb::ConstraintArgs { 128 | guid: Some(&self.guid.into()), 129 | offset: self.offset.unwrap_or(UNRELATED_OFFSET), 130 | }, 131 | ) 132 | } 133 | 134 | fn from_object(value: &Self::FbType<'_>) -> Option { 135 | let constraint = Self { 136 | guid: ConstraintGUID::from(*value.guid()), 137 | offset: match value.offset() { 138 | UNRELATED_OFFSET => None, 139 | _ => Some(value.offset()), 140 | }, 141 | }; 142 | 143 | Some(constraint) 144 | } 145 | } 146 | --------------------------------------------------------------------------------