components: Fix support for 0-sized flags (#4560)
This commit goes through and updates support in the various argument passing routines to support 0-sized flags. A bit of a degenerate case but clarified in WebAssembly/component-model#76 as intentional.
This commit is contained in:
@@ -48,6 +48,8 @@ impl From<DiscriminantSize> for usize {
|
||||
|
||||
/// Represents the number of bytes required to store a flags value in the component model
|
||||
pub enum FlagsSize {
|
||||
/// There are no flags
|
||||
Size0,
|
||||
/// Flags can fit in a u8
|
||||
Size1,
|
||||
/// Flags can fit in a u16
|
||||
@@ -59,7 +61,9 @@ pub enum FlagsSize {
|
||||
impl FlagsSize {
|
||||
/// Calculate the size needed to represent a value with the specified number of flags.
|
||||
pub fn from_count(count: usize) -> FlagsSize {
|
||||
if count <= 8 {
|
||||
if count == 0 {
|
||||
FlagsSize::Size0
|
||||
} else if count <= 8 {
|
||||
FlagsSize::Size1
|
||||
} else if count <= 16 {
|
||||
FlagsSize::Size2
|
||||
|
||||
Reference in New Issue
Block a user