예제 #1
0
 lua_State *lua_worker_init() {
     lua_State *L = lua_open();
     
     luaL_openlibs(L);
     luaopen_marshal(L);
     
     return L;
 }
예제 #2
0
AsyncWorkerThread::AsyncWorkerThread(AsyncEngine* jobdispatcher,
									unsigned int numthreadnumber) :
	m_JobDispatcher(jobdispatcher),
	m_luaerrorhandler(-1),
	m_threadnum(numthreadnumber)
{
	// create luastack
	m_LuaStack = luaL_newstate();

	// load basic lua modules
	luaL_openlibs(m_LuaStack);

	// load serialization functions
	luaopen_marshal(m_LuaStack);
}
예제 #3
0
파일: base.cpp 프로젝트: denanden/xray-16
extern "C" __declspec(dllexport) int luaopen_lua_extensions(lua_State *L){
    //luaopen_debug(L);

    open_additional_libs(L);

    luaopen_lfs(L);
    //open_string(L);
    //open_math(L);
    //open_table(L);
    luaopen_marshal(L);
    //open_kb(L);
    //open_log(L); 

    return 0;
}
예제 #4
0
 lua_State *lua_core_init() {
     lua_State *L = lua_open();
     luaL_openlibs(L);
     luaopen_marshal(L);
     luaopen_graphics(L);
     luaopen_font(L);
     luaopen_sound(L);
     luaopen_system(L);
     luaopen_image(L);
     luaopen_window(L);
     luaopen_directory(L);
     luaopen_matrix4x4(L);
     
     return L;
 }
예제 #5
0
int main(int argc, char ** argv)
{
  setExecutablePath(argv[0]);

  lua_State *L = lua_open();

  luaL_openlibs(L);

#if USE_IUP
  iuplua_open(L);
  cdlua_open(L);
  cdluaiup_open(L);

  iupkey_open(L);
  iupimlua_open(L);
  IupImageLibOpen ();
  iupcontrolslua_open(L);
  imlua_open(L);
  imlua_open_process(L);
#endif

  luaopen_pack(L);
  luaopen_lfs(L);
  luaopen_marshal(L);
  luaopen_mime_core(L);
  luaopen_socket_core(L);

  pdfdoc_register(L);
  pdfpage_register(L);
  clipboard_register(L);
  luaopen_system(L);
  luaopen_compare(L);

#if _DEBUG 
  lua_pushboolean(L, true);
  lua_setfield(L, LUA_GLOBALSINDEX, "_DEBUG");
#endif
  
  char luaFile[512] = "";
  char playlistFile[512] = "";
  int beginIndex = 1;
  if (argc > 1)
  {
    int strl = strlen(argv[1]);
    bool isLuaFile = strcmp(&argv[1][strl-4], ".lua") == 0;
    if (isLuaFile)
    {
      beginIndex = 2;
      strcpy_s(luaFile, sizeof(luaFile), argv[1]);
    }
    else if (strcmp(&argv[1][strl-5], ".sing") == 0
      || strcmp(&argv[1][strl-4], ".m3u") == 0
      || strcmp(&argv[1][strl-4], ".txt") == 0)
    {
    }
  }
  if (!luaFile[0])
  {
    lua_pushboolean(L, true);
    lua_setfield(L, LUA_GLOBALSINDEX, "APPLOADED");
	const char* execPath = getExecutablePath();
	sprintf_s(luaFile, sizeof(luaFile), "%s\\%s", execPath, "main.lua");
  }
    
  int temp_int = luaL_loadfile(L,luaFile);
  
  int returnval = 0;
  if (temp_int)
  {
    const char *error = lua_tostring(L, -1);
    printf("Error in file: \"%s\"\n", luaFile);
    printf("%s\n", error);
    returnval = 1;
  }
  else
  {
    const char *error;

    for (int i = beginIndex; i < argc; i++)
      lua_pushstring(L, argv[i]);

    if (docall(L,argc-beginIndex,0))
    {
      error = lua_tostring(L, -1);
      if (error)
        std::cout << error;
      returnval = 1;
    }
  }
  close(L);

  return returnval;
}