Sha256: 5c073700c421850c37df07a517ddc5b05cf7429d0e03cbc326f4e80d9f730e18

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

interface unions {
  /// A union of all of the integral types
  union all-integers {
      /// Bool is equivalent to a 1 bit integer
      /// and is treated that way in some languages
      bool,
      u8, u16, u32, u64,
      s8, s16, s32, s64
  }
  union all-floats {
      float32, float64
  }
  union all-text {
      char, string
  }

  // Returns the same case as the input but with 1 added
  add-one-integer: func(num: all-integers) -> all-integers
  // Returns the same case as the input but with 1 added
  add-one-float: func(num: all-floats) -> all-floats
  // Returns the same case as the input but with the first character replaced
  replace-first-char: func(text: all-text, letter: char) -> all-text

  // Returns the index of the case provided
  identify-integer: func(num: all-integers) -> u8
  // Returns the index of the case provided
  identify-float: func(num: all-floats) -> u8
  // Returns the index of the case provided
  identify-text: func(text: all-text) -> u8

  union duplicated-s32 {
      /// The first s32
      s32,
      /// The second s32
      s32,
      /// The third s32
      s32
  }

  // Returns the same case as the input but with 1 added
  add-one-duplicated: func(num: duplicated-s32) -> duplicated-s32

  // Returns the index of the case provided
  identify-duplicated: func(num: duplicated-s32) -> u8

  /// A type containing numeric types that are distinct in most languages
  union distinguishable-num {
      /// A Floating Point Number
      float64,
      /// A Signed Integer
      s64
  }

  // Returns the same case as the input but with 1 added
  add-one-distinguishable-num: func(num: distinguishable-num) -> distinguishable-num

  // Returns the index of the case provided
  identify-distinguishable-num: func(num: distinguishable-num) -> u8
}

world the-unions {
  import import-unions: unions
  export export-unions: unions
  default export unions
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wasmtime-5.0.0 ./ext/cargo-vendor/wasmtime-component-macro-5.0.0/tests/codegen/unions.wit