Răsfoiți Sursa

Add lua_getmainthread function to return main thread.

aster2013 11 ani în urmă
părinte
comite
4a50e3d78d

+ 10 - 2
Source/ThirdParty/Lua/src/lapi.c

@@ -149,6 +149,14 @@ LUA_API lua_State *lua_newthread (lua_State *L) {
   return L1;
   return L1;
 }
 }
 
 
+/* Modified by Aster Jian for Urho3D */
+LUA_API lua_State *lua_getmainthread (lua_State* L) {
+    lua_State* L1;
+    lua_lock(L);
+    L1 = G(L)->mainthread;
+    lua_unlock(L);
+    return L1;
+}
 
 
 
 
 /*
 /*
@@ -211,7 +219,7 @@ LUA_API void lua_replace (lua_State *L, int idx) {
   api_checkvalidindex(L, o);
   api_checkvalidindex(L, o);
   if (idx == LUA_ENVIRONINDEX) {
   if (idx == LUA_ENVIRONINDEX) {
     Closure *func = curr_func(L);
     Closure *func = curr_func(L);
-    api_check(L, ttistable(L->top - 1)); 
+    api_check(L, ttistable(L->top - 1));
     func->c.env = hvalue(L->top - 1);
     func->c.env = hvalue(L->top - 1);
     luaC_barrier(L, func, L->top - 1);
     luaC_barrier(L, func, L->top - 1);
   }
   }
@@ -771,7 +779,7 @@ LUA_API int lua_setfenv (lua_State *L, int idx) {
 
 
 #define checkresults(L,na,nr) \
 #define checkresults(L,na,nr) \
      api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)))
      api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)))
-	
+
 
 
 LUA_API void lua_call (lua_State *L, int nargs, int nresults) {
 LUA_API void lua_call (lua_State *L, int nargs, int nresults) {
   StkId func;
   StkId func;

+ 3 - 1
Source/ThirdParty/Lua/src/lua.h

@@ -110,6 +110,8 @@ typedef LUA_INTEGER lua_Integer;
 LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
 LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
 LUA_API void       (lua_close) (lua_State *L);
 LUA_API void       (lua_close) (lua_State *L);
 LUA_API lua_State *(lua_newthread) (lua_State *L);
 LUA_API lua_State *(lua_newthread) (lua_State *L);
+/* Modified by Aster Jian for Urho3D */
+LUA_API lua_State *(lua_getmainthread) (lua_State *L);
 
 
 LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
 LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
 
 
@@ -245,7 +247,7 @@ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
 
 
 
 
 
 
-/* 
+/*
 ** ===============================================================
 ** ===============================================================
 ** some useful macros
 ** some useful macros
 ** ===============================================================
 ** ===============================================================

+ 8 - 0
Source/ThirdParty/LuaJIT/src/lj_api.c

@@ -689,6 +689,14 @@ LUA_API lua_State *lua_newthread(lua_State *L)
   return L1;
   return L1;
 }
 }
 
 
+/* Modified by Aster Jian for Urho3D */
+LUA_API lua_State *lua_getmainthread(lua_State *L)
+{
+    lua_State *L1;
+    L1 = mainthread(G(L));
+    return L1;
+}
+
 LUA_API void *lua_newuserdata(lua_State *L, size_t size)
 LUA_API void *lua_newuserdata(lua_State *L, size_t size)
 {
 {
   GCudata *ud;
   GCudata *ud;

+ 2 - 0
Source/ThirdParty/LuaJIT/src/lua.h

@@ -110,6 +110,8 @@ typedef LUA_INTEGER lua_Integer;
 LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
 LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
 LUA_API void       (lua_close) (lua_State *L);
 LUA_API void       (lua_close) (lua_State *L);
 LUA_API lua_State *(lua_newthread) (lua_State *L);
 LUA_API lua_State *(lua_newthread) (lua_State *L);
+/* Modified by Aster Jian for Urho3D */
+LUA_API lua_State *(lua_getmainthread) (lua_State *L);
 
 
 LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
 LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);