Guest User

like that?

a guest
Jun 18th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.43 KB | None | 0 0
  1. import
  2.   lua
  3.  
  4.  
  5. proc NimMain() {.importc.}
  6.  
  7. proc get_hello*(state: PState): cint {.cdecl, exportc, dynlib.} =
  8.   state.pushstring("Hello!")
  9.  
  10.   return 1
  11.  
  12. let
  13.   test* = [
  14.     Treg(name: "get_hello", `func`: get_hello),
  15.     Treg(name: "", `func`: nil)
  16.   ]
  17.  
  18. proc luaopen_test*(state: PState): cint {.cdecl, exportc, dynlib.} =
  19.   NimMain()
  20.   state.openlib(cstring"test", unsafeAddr(test[0]), cint(test.len-1))
  21.  
  22.   return 1
Advertisement
Add Comment
Please, Sign In to add comment