MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / dotnet_aligned_array

Function dotnet_aligned_array

crates/csharp/src/world_generator.rs:960–969  ·  view source on GitHub ↗

We cant use "StructLayout.Pack" as dotnet will use the minimum of the type and the "Pack" field, so for byte it would always use 1 regardless of the "Pack".

(array_size: usize, required_alignment: usize)

Source from the content-addressed store, hash-verified

958// We cant use "StructLayout.Pack" as dotnet will use the minimum of the type and the "Pack" field,
959// so for byte it would always use 1 regardless of the "Pack".
960pub fn dotnet_aligned_array(array_size: usize, required_alignment: usize) -> (usize, String) {
961 let num_elements = array_size.div_ceil(required_alignment);
962 match required_alignment {
963 1 => (num_elements, "byte".to_owned()),
964 2 => (num_elements, "ushort".to_owned()),
965 4 => (num_elements, "uint".to_owned()),
966 8 => (num_elements, "ulong".to_owned()),
967 _ => todo!("unsupported return_area_align {}", required_alignment),
968 }
969}
970
971pub fn wasm_type(ty: WasmType) -> &'static str {
972 match ty {

Callers 3

finishMethod · 0.85
emitMethod · 0.85
return_pointerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected