Skip to content

Commit

Permalink
wit, wit/bindgen: float32->f32, float64->f64
Browse files Browse the repository at this point in the history
  • Loading branch information
ydnar committed Apr 4, 2024
1 parent 478042f commit 857c88c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
5 changes: 2 additions & 3 deletions wit/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func TestTypeSize(t *testing.T) {
{"u32", U32{}, 4, 4},
{"s64", S64{}, 8, 8},
{"u64", U64{}, 8, 8},
{"float32", Float32{}, 4, 4},
{"float64", Float64{}, 8, 8},
{"f32", F32{}, 4, 4},
{"f64", F64{}, 8, 8},
{"char", Char{}, 4, 4},
{"string", String{}, 8, 4},
}
Expand All @@ -86,7 +86,6 @@ func TestTypeSize(t *testing.T) {
if align != tt.align {
t.Errorf("(Type).Align(): expected %d, got %d", tt.align, align)
}

})
}
}
8 changes: 4 additions & 4 deletions wit/bindgen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,10 @@ func (g *generator) primitiveRep(file *gen.File, p wit.Primitive) string {
return "int64"
case wit.U64:
return "uint64"
case wit.Float32:
return "float32"
case wit.Float64:
return "float64"
case wit.F32:
return "f32"
case wit.F64:
return "f64"
case wit.Char:
return "rune"
case wit.String:
Expand Down
20 changes: 10 additions & 10 deletions wit/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -1130,10 +1130,10 @@ func ParseType(s string) (Type, error) {
return S64{}, nil
case "u64":
return U64{}, nil
case "float32":
return Float32{}, nil
case "float64":
return Float64{}, nil
case "f32", "float32": // TODO: remove float32 at some point
return F32{}, nil
case "f64", "float64": // TODO: remove float64 at some point
return F64{}, nil
case "char":
return Char{}, nil
case "string":
Expand Down Expand Up @@ -1216,9 +1216,9 @@ func (_primitive[T]) Flat() []Type {
case int64, uint64:
return []Type{U64{}}
case float32:
return []Type{Float32{}}
return []Type{F32{}}
case float64:
return []Type{Float64{}}
return []Type{F64{}}
case string:
return []Type{U32{}, U32{}}
default:
Expand Down Expand Up @@ -1336,21 +1336,21 @@ type S64 struct{ _primitive[int64] }
// [uint64]: https://pkg.go.dev/builtin#uint64
type U64 struct{ _primitive[uint64] }

// Float32 represents the WIT [primitive type] float32, a 32-bit floating point value.
// F32 represents the WIT [primitive type] f32, a 32-bit floating point value.
// It is equivalent to the Go type [float32].
// It implements the [Node], [ABI], [Type], and [TypeDefKind] interfaces.
//
// [primitive type]: https://component-model.bytecodealliance.org/design/wit.html#primitive-types
// [float32]: https://pkg.go.dev/builtin#float32
type Float32 struct{ _primitive[float32] }
type F32 struct{ _primitive[float32] }

// Float64 represents the WIT [primitive type] float64, a 64-bit floating point value.
// F64 represents the WIT [primitive type] f64, a 64-bit floating point value.
// It is equivalent to the Go type [float64].
// It implements the [Node], [ABI], [Type], and [TypeDefKind] interfaces.
//
// [primitive type]: https://component-model.bytecodealliance.org/design/wit.html#primitive-types
// [float64]: https://pkg.go.dev/builtin#float64
type Float64 struct{ _primitive[float64] }
type F64 struct{ _primitive[float64] }

// Char represents the WIT [primitive type] char, a single Unicode character,
// specifically a [Unicode scalar value]. It is equivalent to the Go type [rune].
Expand Down

0 comments on commit 857c88c

Please sign in to comment.