48 lines
753 B
Go
48 lines
753 B
Go
package main
|
|
|
|
// compile: CGO_LDFLAGS_ALLOW=".*" CGO_ENABLED=1 go build -buildmode=c-shared
|
|
|
|
/*
|
|
#cgo LDFLAGS: "-Wl,--version-script=${SRCDIR}/script.exp"
|
|
|
|
int gmod13_open(void* L);
|
|
int gmod13_close(void* L);
|
|
|
|
int glib_test(void* L);
|
|
*/
|
|
import "C"
|
|
|
|
import (
|
|
"fmt"
|
|
"unsafe"
|
|
|
|
"code.gurenya.net/gmod/glib"
|
|
)
|
|
|
|
type State = unsafe.Pointer
|
|
|
|
//export glib_test
|
|
func glib_test(L State) C.int {
|
|
fmt.Println("Hello from glib_test function!")
|
|
|
|
return 0
|
|
}
|
|
|
|
//export gmod13_open
|
|
func gmod13_open(L State) C.int {
|
|
fmt.Println("Hello from binary module!")
|
|
|
|
glib.PushFunc(L, C.glib_test)
|
|
glib.SetGlobal(L, "glib_test")
|
|
return 0
|
|
}
|
|
|
|
//export gmod13_close
|
|
func gmod13_close(L State) C.int {
|
|
fmt.Println("Goodbye from binary module!")
|
|
|
|
return 0
|
|
}
|
|
|
|
func main() {}
|