remeta

所属分类:collect
开发工具:GO
文件大小:0KB
下载次数:0
上传日期:2023-09-14 15:46:08
上 传 者sh-1993
说明:  用于将Go包移植到ReRect编程语言的元编程工具
(A metaprogramming tool for porting Go packages over to the ReRect programming language)

文件列表:
CONTRIBUTING.md (1935, 2023-09-21)
INSTALLATION.md (1872, 2023-09-21)
USER_GUIDE.md (1786, 2023-09-21)
config.go (70, 2023-09-21)
generator.go (6173, 2023-09-21)
go.mod (35, 2023-09-21)
grabber.go (733, 2023-09-21)
main.go (1796, 2023-09-21)
test/ (0, 2023-09-21)
test/test.go (252, 2023-09-21)

remeta logo

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
```go 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) } ``` ```go 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) } ```

近期下载者

相关文件


收藏者