test_luajit.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // package main
  2. // import "git.wecise.com/wecise/odbserver/lua"
  3. // import "fmt"
  4. // func test(L *lua.State) int {
  5. // fmt.Println("hello world! come from go!")
  6. // return 0
  7. // }
  8. // func test2(L *lua.State) int {
  9. // arg := L.CheckInteger(-1)
  10. // argfrombottom := L.CheckInteger(1)
  11. // fmt.Print("test2 arg: ")
  12. // fmt.Println(arg)
  13. // fmt.Print("from bottom: ")
  14. // fmt.Println(argfrombottom)
  15. // return 0
  16. // }
  17. // func main() {
  18. // L := lua.NewState()
  19. // defer L.Close()
  20. // L.OpenLibs()
  21. // L.GetField(lua.LUA_GLOBALSINDEX, "print")
  22. // L.PushString("Hello World!")
  23. // L.Call(1, 0)
  24. // L.PushGoFunction(test)
  25. // L.PushGoFunction(test)
  26. // L.PushGoFunction(test)
  27. // L.PushGoFunction(test)
  28. // L.PushGoFunction(test2)
  29. // L.PushInteger(42)
  30. // L.Call(1, 0)
  31. // L.Call(0, 0)
  32. // L.Call(0, 0)
  33. // L.Call(0, 0)
  34. // // this will fail as we didn't register test2 function
  35. // err := L.DoString("test2(42)")
  36. // fmt.Printf("Ciao %v\n", err)
  37. // }