Last active
June 26, 2018 18:51
-
-
Save sourcevault/5947542abeed995769daab86789a8064 to your computer and use it in GitHub Desktop.
basic C module in Lua with Luarocks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sleep = require ("sourcevault/sleep") | |
sleep.hello() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <lua.h> | |
int sleep_hello(lua_State* L) { | |
lua_pushliteral(L, "Hello, world!"); | |
return 1; | |
} | |
int luaopen_sleep(lua_State* L) { | |
lua_newtable(L); | |
lua_pushcfunction(L, sleep_hello); | |
lua_setfield(L, -2, "hello"); | |
return 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package = "sourcevault/sleep" | |
version = "1.0-1" | |
source = { | |
url = "." -- not online yet! | |
} | |
build = { | |
type = "builtin", | |
modules = { | |
sourcevault = | |
{sleep = "sleep.c"} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment