void render_tiger_main_window::_init_lua() {
    g_lua_state = luaL_newstate();
    luaL_openlibs(g_lua_state);

    luaL_requiref(g_lua_state, "rendertiger.msg", lua_global_msg, 0);
    luaL_requiref(g_lua_state, "rendertiger.vertex_buffer", lua_dx11_vertex_buffer, 0);
}
Beispiel #2
0
    void open_libraries(Args&&... args) {
        static_assert(are_same<lib, Args...>::value, "all types must be libraries");
        if(sizeof...(args) == 0) {
            luaL_openlibs(L.get());
            return;
        }

        lib libraries[1 + sizeof...(args)] = { lib::count, std::forward<Args>(args)... };

        for(auto&& library : libraries) {
            switch(library) {
            case lib::base:
                luaL_requiref(L.get(), "base", luaopen_base, 1);
                lua_pop(L.get(), 1);
                break;
            case lib::package:
                luaL_requiref(L.get(), "package", luaopen_package, 1);
                lua_pop(L.get(), 1);
                break;
            case lib::coroutine:
                luaL_requiref(L.get(), "coroutine", luaopen_coroutine, 1);
                lua_pop(L.get(), 1);
                break;
            case lib::string:
                luaL_requiref(L.get(), "string", luaopen_string, 1);
                lua_pop(L.get(), 1);
                break;
            case lib::table:
                luaL_requiref(L.get(), "table", luaopen_table, 1);
                lua_pop(L.get(), 1);
                break;
            case lib::math:
                luaL_requiref(L.get(), "math", luaopen_math, 1);
                lua_pop(L.get(), 1);
                break;
            case lib::bit32:
                luaL_requiref(L.get(), "bit32", luaopen_bit32, 1);
                lua_pop(L.get(), 1);
                break;
            case lib::io:
                luaL_requiref(L.get(), "io", luaopen_io, 1);
                lua_pop(L.get(), 1);
                break;
            case lib::os:
                luaL_requiref(L.get(), "os", luaopen_os, 1);
                lua_pop(L.get(), 1);
                break;
            case lib::debug:
                luaL_requiref(L.get(), "debug", luaopen_debug, 1);
                lua_pop(L.get(), 1);
                break;
            case lib::count:
                break;
            }
        }
    }
Beispiel #3
0
static void openlibs(lua_State *L) {
  luaL_requiref(L, "_G", luaopen_base, 1);
  luaL_requiref(L, "package", luaopen_package, 1);
  lua_pop(L, 2);
  registerlib(L, "io", luaopen_io);
  registerlib(L, "os", luaopen_os);
  registerlib(L, "table", luaopen_table);
  registerlib(L, "string", luaopen_string);
  registerlib(L, "math", luaopen_math);
  registerlib(L, "debug", luaopen_debug);
}
Beispiel #4
0
int main()
{
	//lua_State* L = lua_open();
	lua_State* L = luaL_newstate();

	//luaopen_base(L);
	luaL_requiref(L, "_G", luaopen_base, 1);
    lua_pop(L, 1);

	//luaopen_string(L);
	luaL_requiref(L, "string", luaopen_string, 1);
    lua_pop(L, 1);

    lua_tinker::beginmodule(L);
	  lua_tinker::def(L, "TestFunc", &TestFunc);
	  lua_tinker::def(L, "TestFunc2", &TestFunc2);

	  lua_tinker::class_add<TestClass>(L, "TestClass");
	  lua_tinker::class_def<TestClass>(L, "TestFunc", &TestClass::TestFunc);
	  lua_tinker::class_def<TestClass>(L, "TestFunc2", &TestClass::TestFunc2);

	  TestClass g_test;
	  lua_tinker::set(L, "g_test", &g_test);
    lua_tinker::endmodule(L);

	lua_tinker::dofile(L, "sample6.lua");

	lua_newthread(L);
	lua_getglobal(L, "ThreadTest");

/*
	printf("* lua_resume() 호출\n");
	lua_resume(L, 0);

	printf("* lua_resume() 호출\n");
	lua_resume(L, 0);

	printf("* lua_resume() 호출\n");
	lua_resume(L, 0);

	printf("* lua_resume() 호출\n");
	lua_resume(L, 0);

	printf("* lua_resume() 호출\n");
	lua_resume(L, 0);
*/

	lua_close(L);

	return 0;
}
static void openlibs(lua_State *L) {
#if LUA_VERSION_NUM == 502
  luaL_requiref(L, "base",    luaopen_base, 0);
  luaL_requiref(L, "package", luaopen_package, 1);
  lua_pop(L, 2);
#elif LUA_VERSION_NUM == 501
  lua_cpcall(L, luaopen_base, NULL);
  lua_cpcall(L, luaopen_package, NULL);
#else
unsupported_lua_version
#endif

  registerlibs(L, libs);
}
Beispiel #6
0
static int pmain(lua_State *L)
{
	//int argc = (int)lua_tointeger(L, 1);
	char **argv = (char **)lua_touserdata(L, 2);

	luaL_checkversion(L);

	//Stop collector during initialization
	lua_gc(L, LUA_GCSTOP, 0);

	//Open standard libraries
	luaL_openlibs(L);

	//TODO: Open Other libs here:

	//We use the require function here instead of opening the
	//library directly as this will register the return value
	//from the luaopen_lfs call with require's internal database of loaded modules.
	//Thus subsequent calls to require from a script will return this table
	luaL_requiref(L, "lfs", luaopen_lfs, 0);

	//Restart the GC
	lua_gc(L, LUA_GCRESTART, 0);

	//This script gets ALL the args, so we set the num passed to the C program to 0
	if (handle_script(L, argv, 0) != LUA_OK) return 0;

	//Signal no errors
	lua_pushboolean(L, 1);
	return 1;
}
Beispiel #7
0
int main(int argc, char** argv) {
	lua_State* L = luaL_newstate();

	luaL_openlibs(L);


	luaL_requiref(L, "sqlite3", luaopen_sqlite3, 1);
	lua_pop(L, 1);  /* remove lib */

	/* add open functions from 'preloadedlibs' into 'package.preload' table */
	luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");

	lua_pushcfunction(L, luaopen_sqlite3);
	lua_setfield(L, -2, "sqlite3");
	lua_pop(L, 1);  /* remove _PRELOAD table */



	/* luaL_dofile(L, "test.lua"); */
	luaL_loadfile(L, "test.lua");
	lua_call(L, 0, LUA_MULTRET);

	lua_close(L);
	return EXIT_SUCCESS;
}
Beispiel #8
0
//-------------------------------------------------------------------------------------------------
void LuaWorker::init()
{
    if (m_luaState!=NULL)
        throw std::runtime_error("LUA is already initialized");

    m_luaState = luaL_newstate();
    if (m_luaState == NULL)
        throw std::runtime_error("Can't create LUA state");

    // folgender code stammt aus linit.c:
    const luaL_Reg lualibs[] = {
                                {"base",          luaopen_base},
                                {LUA_LOADLIBNAME, luaopen_package},
                                {LUA_TABLIBNAME,  luaopen_table},
                                {LUA_IOLIBNAME,   luaopen_io},
                                {LUA_OSLIBNAME,   luaopen_os},
                                {LUA_STRLIBNAME,  luaopen_string},
                                {LUA_MATHLIBNAME, luaopen_math},
                                {LUA_DBLIBNAME,   luaopen_debug},
                                {NULL, NULL}
                               };

    const luaL_Reg *lib = lualibs;
    for (lib = lualibs; lib->func; lib++)
    {
        luaL_requiref(m_luaState, lib->name, lib->func, 1);
        lua_pop(m_luaState, 1);  /* remove lib */
    }
}
Beispiel #9
0
extern "C" int luaopen_luview(lua_State *L)
{
  lua_newtable(L);

  LuaCppObject::Init(L);
  LuaCppObject::Register<GpuInformation>(L);
  LuaCppObject::Register<Window>(L);

  LuaCppObject::Register<DataSource>(L);
  LuaCppObject::Register<GridSource2D>(L);
  LuaCppObject::Register<ParametricVertexSource3D>(L);
  LuaCppObject::Register<BoundingBox>(L);
  LuaCppObject::Register<ShaderProgram>(L);
  LuaCppObject::Register<ImagePlane>(L);
  LuaCppObject::Register<MatplotlibColormaps>(L);

  LuaCppObject::Register<Tesselation3D>(L);
  LuaCppObject::Register<SegmentsEnsemble>(L);
  LuaCppObject::Register<ParametricSurface>(L);
  LuaCppObject::Register<TrianglesEnsemble>(L);

  luaL_requiref(L, "hdf5", luaopen_hdf5, false);

  return 1;
}
Beispiel #10
0
LUAMOD_API int openBarrierAPI(lua_State* L) {
	//the local table
	luaL_newlib(L, barrierLib);

	//get the parent table
	luaL_requiref(L, TORTUGA_ENTITY_API, openEntityAPI, false);

	//merge the parent table into the local table
	lua_pushnil(L);	//first key
	while(lua_next(L, -2)) {
		//copy the key-value pair
		lua_pushvalue(L, -2);
		lua_pushvalue(L, -2);

		//push the copy to the local table
		lua_settable(L, -6);

		//pop the original value before continuing
		lua_pop(L, 1);
	}

	//remove the parent table, leaving the expanded local table
	lua_pop(L, 1);

	return 1;
}
Beispiel #11
0
GameScriptParser::GameScriptParser()
: m_pCurrentMap(NULL)
{
    CHUD::getSingleton().addListener(this);
    clearIdMap();

    lua_state = luaL_newstate();

    // load Lua libraries

    static const luaL_Reg lualibs[] =
    {
        {"base", luaopen_base},
        {"io", luaopen_io},
        {NULL, NULL}
    };
    const luaL_Reg *lib = lualibs;
    for(; lib->func != NULL; lib++)
    {
        luaL_requiref(lua_state, lib->name, lib->func, 1);
        lua_settop(lua_state, 0);
    }

    registerCFunctionsToLua();
}
Beispiel #12
0
int 
scheduler_start(lua_State *L) {
	luaL_checktype(L,1,LUA_TTABLE);
	hive_createenv(L);
	struct global_queue * gmq = lua_newuserdata(L, sizeof(*gmq));
	globalmq_init(gmq);

	lua_pushvalue(L,-1);
	hive_setenv(L, "message_queue");

	lua_State *sL;

	sL = scheduler_newtask(L);
	luaL_requiref(sL, "cell.system", cell_system_lib, 0);
	lua_pop(sL,1);
	struct cell * sys = cell_new(sL, "system.lua");
	if (sys == NULL) {
		return 0;
	}
	scheduler_starttask(sL);
	lua_getfield(L,1, "thread");
	int thread = luaL_optinteger(L, -1, DEFAULT_THREAD);
	lua_pop(L,1);

	struct timer * t = lua_newuserdata(L, sizeof(*t));
	timer_init(t,sys,gmq);

	_start(gmq,thread,t);
	cell_close(sys);

	return 0;
}
Beispiel #13
0
// Run uscript
uscript_t *uscript_run(editor_t *editor, char *path) {
    lua_State *L;
    uscript_t *uscript;
    L = luaL_newstate();
    luaL_openlibs(L);
    luaL_requiref(L, "mle", luaopen_mle, 1);

    uscript = calloc(1, sizeof(uscript_t));
    uscript->editor = editor;
    uscript->L = L;

    lua_pushpointer(L, (void*)uscript);
    lua_setglobal(L, MLE_USCRIPT_KEY);
    lua_pop(L, 1);

    lua_getglobal(L, "_G");
    lua_pushcfunction(L, _uscript_write);
    lua_setfield(L, -2, "print");
    lua_pop(L, 1);

    lua_atpanic(L, _uscript_panic);


    luaL_loadfile(L, path); // TODO err

    lua_pcall(L, 0, 0, 0);
    return uscript;
}
Beispiel #14
0
static void TenshiRuntime_openlibs_phase2(lua_State *L) {
  const luaL_Reg *lib;
  for (lib = tenshi_loadedlibs_phase2; lib->func; lib++) {
    luaL_requiref(L, lib->name, lib->func, 1);
    lua_pop(L, 1);  /* remove lib */
  }
}
Beispiel #15
0
static int ldbus_connection_set_timeout_functions(lua_State *L) {
	ldbus_timeout_udata *data;

	DBusConnection *connection = check_DBusConnection(L, 1);
	lua_settop(L, 4);
	/* Place a table below the 3 callback argument */
	lua_createtable(L, 0, 3);
	lua_insert(L, 2);
	/* Insert in reverse order */
	lua_rawseti(L, 2, DBUS_LUA_FUNC_TOGGLE);
	lua_rawseti(L, 2, DBUS_LUA_FUNC_REMOVE);
	lua_rawseti(L, 2, DBUS_LUA_FUNC_ADD);

	/* make sure ldbus.watch has been loaded */
	luaL_requiref(L, "ldbus.timeout", lua_open_ldbus_timeout, FALSE);
	lua_pop(L, 1);

	if ((data = malloc(sizeof(ldbus_timeout_udata))) == NULL) return luaL_error(L, LDBUS_NO_MEMORY);
	data->L = L;
	data->ref = luaL_ref(L, LUA_REGISTRYINDEX);

	if (!dbus_connection_set_timeout_functions(connection,
			ldbus_timeout_add_function, ldbus_timeout_remove_function, ldbus_timeout_toggled_function,
			(void *)data, ldbus_timeout_free_data_function)) {
		free(data);
		return luaL_error(L, LDBUS_NO_MEMORY);
	};
	lua_pushboolean(L, TRUE);
	return 1;
}
Beispiel #16
0
lua_State *nlua_newstate () {
  const luaL_Reg *reg = numlua_libs;
  lua_State *L = luaL_newstate();
  for (; reg->func; reg++) {
#if LUA_VERSION_NUM <= 501
    lua_pushcfunction(L, reg->func);
    lua_pushstring(L, reg->name);
    lua_call(L, 1, 0);
#else
    luaL_requiref(L, reg->name, reg->func, 1); /* set in global table */
    lua_pop(L, 1); /* remove lib */
#endif
  }
#ifndef NLWS_NO_NUMLUA
  /* require numlua */
  lua_getglobal(L, "require");
  lua_pushvalue(L, -1);
  lua_pushliteral(L, "luarocks.loader");
  lua_call(L, 1, 0);
  lua_pushliteral(L, "numlua.seeall");
  lua_call(L, 1, 0);
  /* TODO: plots */
#endif
  /* new "print" and "dostring" */
  lua_pushlightuserdata(L, (void *) L);
  lua_newtable(L); /* msg buffer */
  lua_pushvalue(L, -1);
  lua_pushcclosure(L, state_print, 1);
  lua_setglobal(L, "print");
  lua_pushcclosure(L, state_dostring, 1);
  lua_rawset(L, LUA_REGISTRYINDEX); /* REG[light(L)] = dostring */
  return L;
}
Beispiel #17
0
// We specifically expose only a subset of the normal Lua standard library.
// This function loads only the functions we want.
static void TenshiRuntime_openlibs_phase1(lua_State *L) {
  const luaL_Reg *lib;
  for (lib = tenshi_loadedlibs_phase1; lib->func; lib++) {
    luaL_requiref(L, lib->name, lib->func, 1);
    lua_pop(L, 1);  /* remove lib */
    lua_gc(L, LUA_GCCOLLECT, 0);
  }
}
Beispiel #18
0
void LoadExLib(lua_State* ls)
{
    const luaL_Reg *lib;
    for (lib = lrExLib; lib->func; lib++) {
        luaL_requiref(ls, lib->name, lib->func, 1);
        lua_pop(ls, 1);  /* remove lib */
    }
}
Beispiel #19
0
void load_httpc_lib(lua_State *L) {
	if (!isHttpcInitialized) {
		httpcInit(0x1000);
		isHttpcInitialized = true;
	}
	
	luaL_requiref(L, "ctr.httpc", luaopen_httpc_lib, false);
}
Beispiel #20
0
static lua_State *lua_env_new () {
    lua_State *L = luaL_newstate ();
    luaL_openlibs (L);
    char const *rpath_code = "package.cpath = package.cpath .. '/data/local/tmp/xmono/lualibs/lib?.so'\n"
                             "package.path = package.path .. '/data/local/tmp/xmono/lualibs/?.lua'\n";
    if (luaL_dostring (L, rpath_code)) {
        char const *err = lua_tostring (L, -1);
        LOGE ("%s", err);
        lua_close (L);
        return 0;
    }
    luaL_requiref (L, "mono", luaopen_mono, 1);
    lua_pop (L, 1);
    luaL_requiref (L, "xmono", luaopen_xmono, 1);
    lua_pop (L, 1);
    return L;
}
Beispiel #21
0
LUALIB_API void luaL_openlibs(lua_State *L) {
	const luaL_Reg *lib;
	/* "require" functions from 'loadedlibs' and set results to global table */
	for (lib = loadedlibs; lib->func; lib++) {
		luaL_requiref(L, lib->name, lib->func, 1);
		lua_pop(L, 1);  /* remove lib */
	}
}
Beispiel #22
0
int main()
{
    lua_State* L = luaL_newstate();
    luaL_openlibs(L);
    luaL_requiref(L, "LuaTest", luaTest, 0);
    luaL_dofile(L, "a.lua");
    return 0;
}
Beispiel #23
0
static int
init_cb(struct snlua *l, struct skynet_context *ctx, const char * args, size_t sz) {
	lua_State *L = l->L;
	l->ctx = ctx;
	lua_gc(L, LUA_GCSTOP, 0);
	lua_pushboolean(L, 1);  /* signal for libraries to ignore env. vars. */
	lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
	luaL_openlibs(L);
	lua_pushlightuserdata(L, ctx);
	lua_setfield(L, LUA_REGISTRYINDEX, "skynet_context");
	luaL_requiref(L, "skynet.codecache", codecache , 0);
	lua_pop(L,1);

	const char *path = optstring(ctx, "lua_path","./lualib/?.lua;./lualib/?/init.lua");
	lua_pushstring(L, path);
	lua_setglobal(L, "LUA_PATH");
	const char *cpath = optstring(ctx, "lua_cpath","./luaclib/?.so");
	lua_pushstring(L, cpath);
	lua_setglobal(L, "LUA_CPATH");
	const char *service = optstring(ctx, "luaservice", "./service/?.lua");
	lua_pushstring(L, service);
	lua_setglobal(L, "LUA_SERVICE");
	const char *preload = skynet_command(ctx, "GETENV", "preload");
	lua_pushstring(L, preload);
	lua_setglobal(L, "LUA_PRELOAD");

	lua_pushcfunction(L, traceback);
	assert(lua_gettop(L) == 1);

	const char * loader = optstring(ctx, "lualoader", "./lualib/loader.lua");

	int r = luaL_loadfile(L,loader);
	if (r != LUA_OK) {
		skynet_error(ctx, "Can't load %s : %s", loader, lua_tostring(L, -1));
		report_launcher_error(ctx);
		return 1;
	}
	lua_pushlstring(L, args, sz);
	r = lua_pcall(L,1,0,1);
	if (r != LUA_OK) {
		skynet_error(ctx, "lua loader error : %s", lua_tostring(L, -1));
		report_launcher_error(ctx);
		return 1;
	}
	lua_settop(L,0);
	if (lua_getfield(L, LUA_REGISTRYINDEX, "memlimit") == LUA_TNUMBER) {
		size_t limit = lua_tointeger(L, -1);
		l->mem_limit = limit;
		skynet_error(ctx, "Set memory limit to %.2f M", (float)limit / (1024 * 1024));
		lua_pushnil(L);
		lua_setfield(L, LUA_REGISTRYINDEX, "memlimit");
	}
	lua_pop(L, 1);

	lua_gc(L, LUA_GCRESTART, 0);

	return 0;
}
Beispiel #24
0
struct game *
ejoy2d_game() {
	struct game *G = (struct game *)malloc(sizeof(*G));
	lua_State *L = luaL_newstate();
	checkluaversion(L);
	lua_pushliteral(L, OS_STRING);
	lua_setglobal(L , "OS");

	G->L = L;
	G->real_time = 0;
	G->logic_time = 0;
	lua_atpanic(L, _panic);
	luaL_openlibs(L);
	luaL_requiref(L, "ejoy2d.shader.c", ejoy2d_shader, 0);
	luaL_requiref(L, "ejoy2d.framework", ejoy2d_framework, 0);
	luaL_requiref(L, "ejoy2d.ppm", ejoy2d_ppm, 0);
	luaL_requiref(L, "ejoy2d.spritepack.c", ejoy2d_spritepack, 0);
	luaL_requiref(L, "ejoy2d.sprite.c", ejoy2d_sprite, 0);
	luaL_requiref(L, "ejoy2d.matrix.c", ejoy2d_matrix, 0);
	luaL_requiref(L, "ejoy2d.particle.c", ejoy2d_particle, 0);

	lua_settop(L,0);

	shader_init();
	label_load();

	return G;
}
Beispiel #25
0
int luaopen_systemd_journal_core (lua_State *L) {
	static const luaL_Reg lib[] = {
		{"sendv", sendv},
		{"perror", _perror},
		{"stream_fd", stream_fd},
		{"open", journal_open},
		{"open_directory", journal_open_directory},
		{"open_files", journal_open_files},
		{"open_container", journal_open_container},
		{NULL, NULL}
	};

	/* ensure ID128_METATABLE is loaded */
	luaL_requiref(L, "systemd.id128.core", luaopen_systemd_id128_core, 0);

	luaL_newlib(L, lib);

	/* Even with compat-5.2, Lua 5.1 doesn't have an easy way to make your own file objects */
	/* Set up function environment for stream_fd for 5.1 so handle gets closed correctly */
	#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM == 501
	lua_getfield(L, -1, "stream_fd");
	lua_createtable(L, 0, 1);
	lua_pushcfunction(L, &io_fclose);
	lua_setfield(L, -2, "__close");
	lua_setfenv(L, -2);
	lua_pop(L, 1);
	#endif

	lua_createtable(L, 0, 3);
	lua_pushnumber(L, SD_JOURNAL_NOP); lua_setfield(L, -2, "NOP");
	lua_pushnumber(L, SD_JOURNAL_APPEND); lua_setfield(L, -2, "APPEND");
	lua_pushnumber(L, SD_JOURNAL_INVALIDATE); lua_setfield(L, -2, "INVALIDATE");
	lua_setfield(L, -2, "WAKEUP");

	if (luaL_newmetatable(L, JOURNAL_METATABLE) != 0) {
		lua_pushcfunction(L, journal_close);
		lua_setfield(L, -2, "__gc");
		lua_pushcfunction(L, journal_tostring);
		lua_setfield(L, -2, "__tostring");
		luaL_newlib(L, journal_methods);
		lua_setfield(L, -2, "__index");
	}
	/* Expose journal methods */
	lua_getfield(L, -1, "__index");
	lua_setfield(L, -3, "JOURNAL_METHODS");

	lua_pop(L, 1);

	lua_createtable(L, 0, 4);
	lua_pushnumber(L, SD_JOURNAL_LOCAL_ONLY); lua_setfield(L, -2, "LOCAL_ONLY");
	lua_pushnumber(L, SD_JOURNAL_RUNTIME_ONLY); lua_setfield(L, -2, "RUNTIME_ONLY");
	lua_pushnumber(L, SD_JOURNAL_SYSTEM); lua_setfield(L, -2, "SYSTEM");
	lua_pushnumber(L, SD_JOURNAL_CURRENT_USER); lua_setfield(L, -2, "CURRENT_USER");
	lua_setfield(L, -2, "OPEN");

	return 1;
}
Beispiel #26
0
int pixel_init(lua_State *L) {
	luaL_checkversion(L);
	luaL_requiref(L, "pixel.framework", pixel_framework, 0);
	luaL_requiref(L, "pixel.texture", pixel_texture, 0);
	luaL_requiref(L, "pixel.shader", pixel_shader, 0);
	luaL_requiref(L, "pixel.renderbuffer", pixel_renderbuffer, 0);
	luaL_requiref(L, "pixel.matrix", pixel_matrix, 0);
	luaL_requiref(L, "pixel.color", pixel_color, 0);
	luaL_requiref(L, "pixel.geometry", pixel_geometry, 0);
	luaL_requiref(L, "pixel.sprite", pixel_sprite, 0);
	luaL_requiref(L, "pixel.spritepack", pixel_spritepack, 0);
	luaL_requiref(L, "pixel.particle", pixel_particle, 0);
	lua_settop(L, 0);
	shader_init();
	texture_init();
	label_init(0);
	return 0;
}
Beispiel #27
0
void LuaExtender::openLibs(lua_State* plua_state)
{
    std::vector<LuaLib>::iterator it;
    for (it = libs_.begin(); it != libs_.end(); ++it)
    {
        luaL_requiref(plua_state, (*it).first.c_str(), (*it).second, 1);
        lua_pop(plua_state, 1);  /* remove lib */
    }
}
Beispiel #28
0
/* Adapted from linit.c */
static void lluas_openlibs(lua_State* L) {
  const luaL_Reg* lib;

  for (lib = lluas_libraries; lib->func; ++lib) {
    luaL_requiref(L, lib->name, lib->func, 1);
    lua_pop(L, 1);
  }

  open_module_mg(L);
}
Beispiel #29
0
void load_gfx_lib(lua_State *L) {
	if (!isGfxInitialized) {
		sf2d_init();
		sftd_init();
	}

	isGfxInitialized = true;

	luaL_requiref(L, "ctr.gfx", luaopen_gfx_lib, 0);
}
LUALIB_API void lua_openexlibs(lua_State *L)
{
	const luaL_Reg *lib;

	for(lib = lua_exlibs; lib->func; lib++)
	{
		luaL_requiref(L, lib->name, lib->func, 1);
		lua_pop(L, 1);  /* remove lib */
	}
}