Automatically generate Go package bindings for ReRect!
Remeta uses Go's parser and some metaprogramming magic to quickly generate easy to read bindings
Installation User Guide Contributing
Go module | ReRect bindings |
---|---|
package test
type Vector3 struct {
x int
y int
z int
}
func Vector3Add(v1, v2 Vector3) Vector3 {
return Vector3{
x: v1.x + v2.x,
y: v1.y + v2.y,
z: v1.z + v2.z,
}
}
func (v1 Vector3) Add(v2 Vector3) Vector3 {
return Vector3Add(v1, v2)
} |
package gopackages
import (
"bytespace.network/rerect/compunit"
"bytespace.network/rerect/eval_objects"
"bytespace.network/rerect/symbols"
_origin "bytespace.network/rerect/go_packages/test"
)
func LoadTest() {
test := registerPackage("test")
Vector3TypeSymbol := symbols.NewTypeSymbol(
"Vector3",
[]*symbols.TypeSymbol{},
symbols.CON,
0,
nil,
)
Vector3Container := symbols.NewContainerSymbol(
test, "Vector3", Vector3TypeSymbol,
)
Vector3Container.Fields = append(
Vector3Container.Fields,
symbols.NewFieldSymbol(
Vector3Container, "x",
compunit.GlobalDataTypeRegister["int"],
),
)
Vector3Container.Fields = append(
Vector3Container.Fields,
symbols.NewFieldSymbol(
Vector3Container, "y",
compunit.GlobalDataTypeRegister["int"],
),
)
Vector3Container.Fields = append(
Vector3Container.Fields,
symbols.NewFieldSymbol(
Vector3Container, "z",
compunit.GlobalDataTypeRegister["int"],
),
)
symbols.NewVMFunctionSymbol(
test,
"Vector3Add",
compunit.GlobalDataTypeRegister["Vector3"],
[]*symbols.ParameterSymbol{
symbols.NewParameterSymbol(
"v1",
0,
compunit.GlobalDataTypeRegister["Vector3"],
),
},
Vector3Add,
)
symbols.NewVMFunctionSymbol(
test,
"Add",
compunit.GlobalDataTypeRegister["Vector3"],
[]*symbols.ParameterSymbol{
symbols.NewParameterSymbol(
"v2",
0,
compunit.GlobalDataTypeRegister["Vector3"],
),
},
Add,
)
}
func Vector3Add(args []any) any {
v1 := args[0].(Vector3)
v2 := args[0].(Vector3)
return _origin.Vector3Add(v1, v2)
}
func Vector3_Add(instance any, args []any) any {
v2 := args[0].(Vector3)
return Add(v2)
} |