Skip to content

Instantly share code, notes, and snippets.

@becm
Last active August 1, 2016 21:09
Show Gist options
  • Save becm/370e415a3060c9124f63a04ed852a203 to your computer and use it in GitHub Desktop.
Save becm/370e415a3060c9124f63a04ed852a203 to your computer and use it in GitHub Desktop.
special purpose lua interpreter example
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include <lua-bitop.h>
int interp_run(void)
{
int ret;
lua_State *L = luaL_newstate();
luaL_openlibs(L);
luaL_requiref(L, "bit", luaopen_bit, 1);
ret = luaL_dostring(L, "print(bit.bswap(4))");
lua_close(L);
return ret;
}
project('interp', 'c', default_options : [
'c_std=c11'
])
lua = '5.2'
bit = meson.get_compiler('c').find_library('lua' + lua + '-bitop')
interp = shared_library('interp', 'interp.c',
include_directories : include_directories('/usr/include/lua' + lua),
dependencies : bit,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment