summaryrefslogtreecommitdiff
path: root/Source/3rdParty
diff options
context:
space:
mode:
Diffstat (limited to 'Source/3rdParty')
-rw-r--r--Source/3rdParty/Luax/luax.h1
-rw-r--r--Source/3rdParty/Luax/luax_class.cpp6
-rw-r--r--Source/3rdParty/Luax/luax_class.hpp12
-rw-r--r--Source/3rdParty/Luax/luax_class.inl8
-rw-r--r--Source/3rdParty/Luax/luax_context.cpp36
-rw-r--r--Source/3rdParty/Luax/luax_context.h36
-rw-r--r--Source/3rdParty/Luax/luax_enum.cpp37
-rw-r--r--Source/3rdParty/Luax/luax_enum.h24
-rw-r--r--Source/3rdParty/Luax/luax_function.h11
-rw-r--r--Source/3rdParty/Luax/luax_module.cpp8
-rw-r--r--Source/3rdParty/Luax/luax_module.h12
-rw-r--r--Source/3rdParty/Luax/luax_reftable.h2
-rw-r--r--Source/3rdParty/Luax/luax_runtime.cpp16
-rw-r--r--Source/3rdParty/Luax/luax_runtime.h19
-rw-r--r--Source/3rdParty/Luax/luax_state.cpp215
-rw-r--r--Source/3rdParty/Luax/luax_state.h36
-rw-r--r--Source/3rdParty/Luax/luax_state.inl9
-rw-r--r--Source/3rdParty/Luax/luax_variable.cpp0
-rw-r--r--Source/3rdParty/Luax/luax_variable.h0
19 files changed, 323 insertions, 165 deletions
diff --git a/Source/3rdParty/Luax/luax.h b/Source/3rdParty/Luax/luax.h
index 58ea2c8..ed67bdc 100644
--- a/Source/3rdParty/Luax/luax.h
+++ b/Source/3rdParty/Luax/luax.h
@@ -6,6 +6,7 @@
#include "luax_namespace.h"
#include "luax_ref.h"
#include "luax_reftable.h"
+#include "luax_enum.h"
#include "luax_class.hpp"
#include "luax_class.inl"
#include "luax_state.inl"
diff --git a/Source/3rdParty/Luax/luax_class.cpp b/Source/3rdParty/Luax/luax_class.cpp
deleted file mode 100644
index 3cb1f8a..0000000
--- a/Source/3rdParty/Luax/luax_class.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-namespace Luax
-{
-
-} \ No newline at end of file
diff --git a/Source/3rdParty/Luax/luax_class.hpp b/Source/3rdParty/Luax/luax_class.hpp
index 6ce8d19..96124f0 100644
--- a/Source/3rdParty/Luax/luax_class.hpp
+++ b/Source/3rdParty/Luax/luax_class.hpp
@@ -19,6 +19,7 @@ namespace Luax
#define LUAX_DECL_FACTORY(type) \
static void RegisterLuaxClass(LuaxState&);\
static void RegisterLuaxInterface(LuaxState&);\
+ static void RegisterLuaxPostprocess(LuaxState&); \
static const char* GetLuaxFactoryName() { return #type; };\
static const char* GetLuaxClassName() { return #type; };\
static bool IsLuaxClassSingleton() { return false; };
@@ -134,17 +135,6 @@ namespace Luax
};
- ///
- /// ڳԱﴴLuaxStateԲм顣
- ///
-#define LUAX_SETUP(L, params) \
- LuaxRuntime& runtime = LuaxRuntime::Get(); \
- LuaxState& state = runtime[L].state; \
- if(!state.CheckParams(1, params)) return 0
-
-#define LUAX_STATE(L) \
- LuaxState& state = LuaxRuntime::Get().GetLuaxState(L)
-
}
#endif \ No newline at end of file
diff --git a/Source/3rdParty/Luax/luax_class.inl b/Source/3rdParty/Luax/luax_class.inl
index 895152e..2d28d68 100644
--- a/Source/3rdParty/Luax/luax_class.inl
+++ b/Source/3rdParty/Luax/luax_class.inl
@@ -30,7 +30,7 @@ namespace Luax
{ NULL, NULL }
};
- state.Register(regTable);
+ state.RegisterMethods(regTable);
}
@@ -45,7 +45,7 @@ namespace Luax
{ NULL, NULL }
};
- state.Register(regTable);
+ state.RegisterMethods(regTable);
}
@@ -60,7 +60,7 @@ namespace Luax
{ NULL, NULL }
};
- state.Register(regTable);
+ state.RegisterMethods(regTable);
}
@@ -74,7 +74,7 @@ namespace Luax
{ NULL, NULL }
};
- state.Register(regTable);
+ state.RegisterMethods(regTable);
}
template<typename T>
diff --git a/Source/3rdParty/Luax/luax_context.cpp b/Source/3rdParty/Luax/luax_context.cpp
new file mode 100644
index 0000000..c0fb2f5
--- /dev/null
+++ b/Source/3rdParty/Luax/luax_context.cpp
@@ -0,0 +1,36 @@
+#include "luax_context.h"
+
+namespace Luax
+{
+
+ // ˴˺
+ int l_Errfunc(lua_State* L)
+ {
+ cc8* err = lua_tostring(L, lua_upvalueindex(1));
+ return luaL_error(L, err);
+ }
+
+ Context::Context(lua_State* L)
+ : state(L)
+ {
+ assert(state);
+ }
+
+ Context::~Context()
+ {
+ }
+
+ // ʼcontext
+ void Context::Setup()
+ {
+ SetupRefTables();
+ }
+
+ void Context::SetupRefTables()
+ {
+ // strong ref weak ref
+ strongRefTable.Init(state, "LUAX_STRONGREF_TABLE");
+ weakRefTable.Init(state, "LUAX_WEAKREF_TABLE", "v");
+ }
+
+} \ No newline at end of file
diff --git a/Source/3rdParty/Luax/luax_context.h b/Source/3rdParty/Luax/luax_context.h
new file mode 100644
index 0000000..5746cf1
--- /dev/null
+++ b/Source/3rdParty/Luax/luax_context.h
@@ -0,0 +1,36 @@
+#ifndef __LUAX_CONTEXT_H__
+#define __LUAX_CONTEXT_H__
+
+#include "luax_ref.h"
+#include "luax_config.h"
+#include "luax_state.h"
+
+namespace Luax
+{
+
+ ///
+ /// lua_stateصcontextһϵдļϣҲûϵҪΪ˽Լڴ档
+ ///
+ class Context
+ {
+ public:
+ Context(lua_State* L);
+ ~Context();
+
+ void Setup();
+
+ LuaxState state; // lua state
+ LuaxRefTable strongRefTable; // strong ref table
+ LuaxRefTable weakRefTable; // weak ref table
+
+ size_t objectCount; // ͳڴstateдʵ
+
+ private:
+
+ void SetupRefTables();
+
+ };
+
+}
+
+#endif \ No newline at end of file
diff --git a/Source/3rdParty/Luax/luax_enum.cpp b/Source/3rdParty/Luax/luax_enum.cpp
new file mode 100644
index 0000000..1ccc900
--- /dev/null
+++ b/Source/3rdParty/Luax/luax_enum.cpp
@@ -0,0 +1,37 @@
+#include "luax_enum.h"
+#include "luax_state.h"
+#include "luax_runtime.h"
+
+namespace Luax
+{
+
+ ///
+ /// ֻmetatable__index
+ ///
+ int l_rmt__index(lua_State* L)
+ {
+ // params:
+ // 1. enum table
+ // 2. key
+
+ // upvalues:
+ // 1. metatable
+
+ int mt = lua_upvalueindex(1);
+ lua_pushvalue(L, 2);
+ lua_rawget(L, mt);
+
+ return 1;
+ }
+
+ int l_rmt__newindex(lua_State* L)
+ {
+ // upvalue:
+ // 1. enum table name
+
+ cc8* name = lua_tostring(L, lua_upvalueindex(1));
+
+ return luaL_error(L, "Enum called \"%s\" is readonly.", name);
+ }
+
+} \ No newline at end of file
diff --git a/Source/3rdParty/Luax/luax_enum.h b/Source/3rdParty/Luax/luax_enum.h
new file mode 100644
index 0000000..bb96102
--- /dev/null
+++ b/Source/3rdParty/Luax/luax_enum.h
@@ -0,0 +1,24 @@
+#ifndef __LUAX_ENUM_H__
+#define __LUAX_ENUM_H__
+
+#include "luax_config.h"
+
+namespace Luax
+{
+
+ ///
+ /// ö٣öһ಻޸ͼϣöٵֵ
+ ///
+ struct LuaxEnum
+ {
+ cc8* name;
+ int value;
+ };
+
+ extern int l_rmt__index(lua_State* L);
+
+ extern int l_rmt__newindex(lua_State* L);
+
+}
+
+#endif \ No newline at end of file
diff --git a/Source/3rdParty/Luax/luax_function.h b/Source/3rdParty/Luax/luax_function.h
index e69de29..f4cc98b 100644
--- a/Source/3rdParty/Luax/luax_function.h
+++ b/Source/3rdParty/Luax/luax_function.h
@@ -0,0 +1,11 @@
+#ifndef __LUAX_FUNCTION_H__
+#define __LUAX_FUNCTION_H__
+
+namespace Luax
+{
+
+
+
+}
+
+#endif \ No newline at end of file
diff --git a/Source/3rdParty/Luax/luax_module.cpp b/Source/3rdParty/Luax/luax_module.cpp
new file mode 100644
index 0000000..94de1a6
--- /dev/null
+++ b/Source/3rdParty/Luax/luax_module.cpp
@@ -0,0 +1,8 @@
+#include "luax_module.h"
+
+namespace Luax
+{
+
+
+
+} \ No newline at end of file
diff --git a/Source/3rdParty/Luax/luax_module.h b/Source/3rdParty/Luax/luax_module.h
new file mode 100644
index 0000000..96d954c
--- /dev/null
+++ b/Source/3rdParty/Luax/luax_module.h
@@ -0,0 +1,12 @@
+#ifndef __LUAX_MODULE_H__
+#define __LUAX_MODULE_H__
+
+namespace Luax
+{
+
+#define LUAX_BEGIN_MODULE(MDL)
+#define LUAX_END_MODULE(MDL)
+
+}
+
+#endif \ No newline at end of file
diff --git a/Source/3rdParty/Luax/luax_reftable.h b/Source/3rdParty/Luax/luax_reftable.h
index 0ba42f7..58e4b9c 100644
--- a/Source/3rdParty/Luax/luax_reftable.h
+++ b/Source/3rdParty/Luax/luax_reftable.h
@@ -24,6 +24,8 @@ namespace Luax
LuaxRefTable();
~LuaxRefTable();
+ inline operator bool() { return mState; };
+
void Init(LuaxState& state, cc8* name, cc8* mode = nullptr);
bool IsKeyWeak();
diff --git a/Source/3rdParty/Luax/luax_runtime.cpp b/Source/3rdParty/Luax/luax_runtime.cpp
index 1c5becb..3903d9c 100644
--- a/Source/3rdParty/Luax/luax_runtime.cpp
+++ b/Source/3rdParty/Luax/luax_runtime.cpp
@@ -8,19 +8,6 @@ using namespace std;
namespace Luax
{
- Context::Context(lua_State* L)
- : state(L)
- {
- strongRefTable.Init(state, "LUAX_STRONGREF_TABLE");
- weakRefTable.Init(state, "LUAX_WEAKREF_TABLE", "v");
- }
-
- Context::~Context()
- {
- }
-
- //--------------------------------------------------------------------------------------------------------------
-
LuaxRuntime* LuaxRuntime::mRuntime = nullptr;
LuaxRuntime::LuaxRuntime() {};
@@ -38,7 +25,10 @@ namespace Luax
{
lua_State* L = lua_open();
assert(L);
+ //
mContexts.insert(pair<lua_State*, Context>(L, Context(L)));
+ // ʼcontext
+ (*this)[L].Setup();
return L;
}
diff --git a/Source/3rdParty/Luax/luax_runtime.h b/Source/3rdParty/Luax/luax_runtime.h
index fe70580..cb8b66b 100644
--- a/Source/3rdParty/Luax/luax_runtime.h
+++ b/Source/3rdParty/Luax/luax_runtime.h
@@ -3,30 +3,15 @@
#include <map>
+#include "luax_ref.h"
#include "luax_config.h"
#include "luax_state.h"
+#include "luax_context.h"
namespace Luax
{
///
- /// lua_stateصcontextһϵдļϣҲûϵҪΪ˽Լڴ档
- ///
- class Context
- {
- public:
- Context(lua_State* L);
- ~Context();
-
- LuaxState state; // lua state
- LuaxRefTable strongRefTable; // strong ref table
- LuaxRefTable weakRefTable; // weak ref table
-
- size_t objectCount; // ͳڴstateдʵ
-
- };
-
- ///
/// ͳһеlua states
///
class LuaxRuntime
diff --git a/Source/3rdParty/Luax/luax_state.cpp b/Source/3rdParty/Luax/luax_state.cpp
index 87c3bcd..5253a2c 100644
--- a/Source/3rdParty/Luax/luax_state.cpp
+++ b/Source/3rdParty/Luax/luax_state.cpp
@@ -1,18 +1,19 @@
+//#include "luax_class.h"
+#include "luax_enum.h"
#include "luax_state.h"
+#include "luax_runtime.h"
namespace Luax
{
-#define L mState
-
LuaxState::LuaxState(lua_State* state)
- : L(state)
+ : mState(state)
{
assert(state);
}
LuaxState::LuaxState(const LuaxState& state)
- : L(state.mState)
+ : mState(state.mState)
{
assert(state.mState);
}
@@ -21,49 +22,24 @@ namespace Luax
{
}
- LuaxState::operator lua_State*()
- {
- return L;
- };
-
- LuaxState::operator bool()
- {
- return L != nullptr;
- }
-
- lua_State* LuaxState::operator ->()
- {
- return L;
- }
-
- lua_State& LuaxState::operator*()
- {
- return *L;
- }
-
- lua_State* LuaxState::GetHandle()
- {
- return L;
- }
-
void LuaxState::OpenLibs()
{
- luaL_openlibs(L);
+ luaL_openlibs(mState);
}
void LuaxState::PushNamespace(cc8* name)
{
- bool isG = !lua_istable(L, -1);
+ bool isG = !lua_istable(mState, -1);
int idx = isG ? LUA_GLOBALSINDEX : -1;
- lua_getfield(L, idx, name);
- if (lua_isnil(L, -1))
+ lua_getfield(mState, idx, name);
+ if (lua_isnil(mState, -1))
{
- lua_pop(L, 1);
- lua_newtable(L);
- assert(lua_istable(L, -1));
- lua_pushvalue(L, -1);
+ lua_pop(mState, 1);
+ lua_newtable(mState);
+ assert(lua_istable(mState, -1));
+ lua_pushvalue(mState, -1);
int t = isG ? LUA_GLOBALSINDEX : -3;
- lua_setfield(L, t, name);
+ lua_setfield(mState, t, name);
}
// stack:
@@ -72,25 +48,25 @@ namespace Luax
void LuaxState::PopNamespace()
{
- assert(lua_istable(L, -1));
- lua_pop(L, 1);
+ assert(lua_istable(mState, -1));
+ lua_pop(mState, 1);
}
void LuaxState::DoString(const std::string& code)
{
- luaL_dostring(L, code.c_str());
+ luaL_dostring(mState, code.c_str());
}
int LuaxState::AbsIndex(int idx)
{
/*
-#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \
- lua_gettop(L) + (i) + 1)
+#define abs_index(mState, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \
+ lua_gettop(mState) + (i) + 1)
*/
if (idx < 0) {
- //return lua_gettop(L) + idx + 1;
+ //return lua_gettop(mState) + idx + 1;
return ((idx) > 0 || (idx) <= LUA_REGISTRYINDEX ? (idx) : \
- lua_gettop(L) + (idx)+1);
+ lua_gettop(mState) + (idx)+1);
}
return idx;
}
@@ -102,107 +78,107 @@ namespace Luax
void LuaxState::PushNil()
{
- lua_pushnil(L);
+ lua_pushnil(mState);
}
void LuaxState::Push(bool value)
{
- lua_pushboolean(L, value ? 1 : 0);
+ lua_pushboolean(mState, value ? 1 : 0);
}
void LuaxState::Push(cc8* value)
{
- lua_pushstring(L, value);
+ lua_pushstring(mState, value);
}
void LuaxState::Push(double value)
{
- lua_pushnumber(L, value);
+ lua_pushnumber(mState, value);
}
void LuaxState::Push(float value)
{
- lua_pushnumber(L, value);
+ lua_pushnumber(mState, value);
}
void LuaxState::Push(int value)
{
- lua_pushnumber(L, value);
+ lua_pushnumber(mState, value);
}
void LuaxState::Push(u16 value)
{
- lua_pushnumber(L, value);
+ lua_pushnumber(mState, value);
}
void LuaxState::Push(u32 value)
{
- lua_pushnumber(L, value);
+ lua_pushnumber(mState, value);
}
void LuaxState::Push(u64 value)
{
- lua_pushnumber(L, (double)value);
+ lua_pushnumber(mState, (double)value);
}
void LuaxState::Push(uintptr value)
{
- lua_pushlightuserdata(L, (void*)value);
+ lua_pushlightuserdata(mState, (void*)value);
}
void LuaxState::Push(lua_CFunction value)
{
- lua_pushcfunction(L, value);
+ lua_pushcfunction(mState, value);
}
void LuaxState::Push(void* data, size_t size)
{
- lua_pushlstring(L, (cc8*)data, size);
+ lua_pushlstring(mState, (cc8*)data, size);
}
void LuaxState::Push(const void* value)
{
- lua_pushlightuserdata(L, (void*)value);
+ lua_pushlightuserdata(mState, (void*)value);
}
void LuaxState::Pop(int n /* = 1 */)
{
- lua_pop(L, n);
+ lua_pop(mState, n);
}
void LuaxState::Settop(int idx)
{
- lua_settop(L, idx);
+ lua_settop(mState, idx);
}
bool LuaxState::IsNil(int idx)
{
- return lua_isnil(L, idx);
+ return lua_isnil(mState, idx);
}
bool LuaxState::IsNilOrNone(int idx)
{
- int t = lua_type(L, idx);
+ int t = lua_type(mState, idx);
return ((t == LUA_TNONE) || (t == LUA_TNIL));
}
bool LuaxState::IsTableOrUserdata(int idx)
{
- int check = lua_type(L, idx);
+ int check = lua_type(mState, idx);
return ((check == LUA_TTABLE) || (check == LUA_TUSERDATA));
}
bool LuaxState::IsTrueOrNotNil(int idx)
{
- if (lua_isboolean(L, idx)) {
- return lua_toboolean(L, idx) ? true : false;
+ if (lua_isboolean(mState, idx)) {
+ return lua_toboolean(mState, idx) ? true : false;
}
- return !lua_isnil(L, idx);
+ return !lua_isnil(mState, idx);
}
bool LuaxState::IsType(int idx, int type)
{
- return (lua_type(L, idx) == type);
+ return (lua_type(mState, idx) == type);
}
bool LuaxState::IsType(int idx, cc8* name, int type)
@@ -212,7 +188,7 @@ namespace Luax
bool LuaxState::IsValid()
{
- return (L != 0);
+ return (mState != 0);
}
int LuaxState::GetTop()
@@ -222,9 +198,9 @@ namespace Luax
bool LuaxState::HasField(int idx, cc8* name) {
- lua_getfield(L, idx, name);
- bool hasField = (lua_isnil(L, -1) == false);
- lua_pop(L, 1);
+ lua_getfield(mState, idx, name);
+ bool hasField = (lua_isnil(mState, -1) == false);
+ lua_pop(mState, 1);
return hasField;
}
@@ -232,17 +208,17 @@ namespace Luax
bool LuaxState::HasField(int idx, int key) {
this->GetField(idx, key);
- bool hasField = (lua_isnil(L, -1) == false);
- lua_pop(L, 1);
+ bool hasField = (lua_isnil(mState, -1) == false);
+ lua_pop(mState, 1);
return hasField;
}
bool LuaxState::HasField(int idx, cc8* name, int type) {
- lua_getfield(L, idx, name);
- bool hasField = (lua_type(L, -1) == type);
- lua_pop(L, 1);
+ lua_getfield(mState, idx, name);
+ bool hasField = (lua_type(mState, -1) == type);
+ lua_pop(mState, 1);
return hasField;
}
@@ -250,8 +226,8 @@ namespace Luax
bool LuaxState::HasField(int idx, int key, int type) {
this->GetField(idx, key);
- bool hasField = (lua_type(L, -1) == type);
- lua_pop(L, 1);
+ bool hasField = (lua_type(mState, -1) == type);
+ lua_pop(mState, 1);
return hasField;
}
@@ -260,38 +236,38 @@ namespace Luax
idx = this->AbsIndex(idx);
- lua_pushnil(L); /* first key */
- if (lua_next(L, idx) != 0) {
- lua_pop(L, 2);
+ lua_pushnil(mState); /* first key */
+ if (lua_next(mState, idx) != 0) {
+ lua_pop(mState, 2);
return true;
}
return false;
}
- void LuaxState::Register(const luaL_Reg *l)
+ void LuaxState::RegisterMethods(const luaL_Reg *l)
{
- luaL_register(L, 0, l);
+ luaL_register(mState, 0, l);
}
void LuaxState::GetField(int idx, cc8* name)
{
- lua_getfield(L, idx, name);
+ lua_getfield(mState, idx, name);
}
void LuaxState::GetField(int idx, int key)
{
idx = this->AbsIndex(idx);
- lua_pushinteger(L, key);
- lua_gettable(L, idx);
+ lua_pushinteger(mState, key);
+ lua_gettable(mState, idx);
}
std::string LuaxState::GetField(int idx, cc8* key, cc8* value)
{
std::string str;
if (this->GetFieldWithType(idx, key, LUA_TSTRING)) {
- str = lua_tostring(L, -1);
- lua_pop(L, 1);
+ str = lua_tostring(mState, -1);
+ lua_pop(mState, 1);
}
else {
str = value;
@@ -303,8 +279,8 @@ namespace Luax
{
std::string str;
if (this->GetFieldWithType(idx, key, LUA_TSTRING)) {
- str = lua_tostring(L, -1);
- lua_pop(L, 1);
+ str = lua_tostring(mState, -1);
+ lua_pop(mState, 1);
}
else {
str = value;
@@ -316,8 +292,8 @@ namespace Luax
{
std::string str;
if (this->GetFieldWithType(idx, key, LUA_TSTRING)) {
- str = lua_tostring(L, -1);
- lua_pop(L, 1);
+ str = lua_tostring(mState, -1);
+ lua_pop(mState, 1);
}
else {
str = value;
@@ -329,8 +305,8 @@ namespace Luax
{
std::string str;
if (this->GetFieldWithType(idx, key, LUA_TSTRING)) {
- str = lua_tostring(L, -1);
- lua_pop(L, 1);
+ str = lua_tostring(mState, -1);
+ lua_pop(mState, 1);
}
else {
str = value;
@@ -340,9 +316,9 @@ namespace Luax
bool LuaxState::GetFieldWithType(int idx, cc8* name, int type)
{
- lua_getfield(L, idx, name);
- if (lua_type(L, -1) != type) {
- lua_pop(L, 1);
+ lua_getfield(mState, idx, name);
+ if (lua_type(mState, -1) != type) {
+ lua_pop(mState, 1);
return false;
}
return true;
@@ -351,8 +327,8 @@ namespace Luax
bool LuaxState::GetFieldWithType(int idx, int key, int type)
{
this->GetField(idx, key);
- if (lua_type(L, -1) != type) {
- lua_pop(L, 1);
+ if (lua_type(mState, -1) != type) {
+ lua_pop(mState, 1);
return false;
}
return true;
@@ -363,7 +339,7 @@ namespace Luax
if (IsTableOrUserdata(idx))
{
idx = AbsIndex(idx);
- lua_setfield(L, idx, key);
+ lua_setfield(mState, idx, key);
}
}
@@ -631,4 +607,43 @@ namespace Luax
(*handle) = ptr;
}
+ void LuaxState::RegisterEnum(cc8* name, LuaxEnum* en)
+ {
+ assert(name);
+ assert(en);
+
+ // short name
+ lua_State* L = mState;
+
+ int top = GetTop();
+
+ lua_newtable(L); // enum table
+
+ int et = GetTop();
+
+ lua_newtable(L); // matatable
+
+ // öٶmetatable£޸ʱ__newindex
+ for (; en->name; ++en)
+ {
+ lua_pushinteger(L, en->value);
+ lua_setfield(L, -2, en->name);
+ }
+
+ // __index
+ //lua_pushvalue(L, -1); // metatable
+ //lua_pushcclosure(L, l_rmt__index, 1);
+ lua_pushvalue(L, -1);
+ lua_setfield(L, -2, "__index");
+
+ // __newinedx
+ lua_pushstring(L, name); // enum name
+ lua_pushcclosure(L, l_rmt__newindex, 1);
+ lua_setfield(L, -2, "__newindex");
+
+ lua_setmetatable(L, et);
+
+ lua_setfield(L, top, name);
+ }
+
} \ No newline at end of file
diff --git a/Source/3rdParty/Luax/luax_state.h b/Source/3rdParty/Luax/luax_state.h
index 2b143f8..166ac26 100644
--- a/Source/3rdParty/Luax/luax_state.h
+++ b/Source/3rdParty/Luax/luax_state.h
@@ -10,6 +10,9 @@ namespace Luax
{
class Context;
+ class LuaxEnum;
+ class LuaxStrongRef;
+ class LuaxWeakRef;
///
/// lua_StateĴ˱һlua_Stateòݡһʵmetatable£
@@ -23,15 +26,15 @@ namespace Luax
{
public:
- operator lua_State*();
- operator bool();
- lua_State* operator ->();
- lua_State& operator *();
+ inline lua_State* operator ->() { return mState; };
+ inline lua_State& operator *() { return *mState; };
+ inline operator lua_State*() { return mState; }
+ inline operator bool() { return mState != nullptr; };
///
/// ȡ󶨵lua_State
///
- lua_State* GetHandle();
+ inline lua_State* GetHandle() { return mState; };
//------------------------------------------------------------------------------------------------------------
@@ -55,7 +58,7 @@ namespace Luax
///
/// עCעһ{0 0}
///
- void Register(const luaL_Reg *l);
+ void RegisterMethods(const luaL_Reg *l);
void GetField(int idx, cc8* name);
void GetField(int idx, int key);
@@ -110,11 +113,6 @@ namespace Luax
template<typename T> T* GetLuaUserdata(int idx);
//------------------------------------------------------------------------------------------------------------
- // õĹregister[LUAX_STRONG_REFTABLE]register[LUAX_WEAK_REFTABLE]
-
- void Ref();
-
- //------------------------------------------------------------------------------------------------------------
template<typename T> T GetValue(int idx, T default_value);
template<typename T> T GetField(int idx, int key, T value);
@@ -139,6 +137,11 @@ namespace Luax
///
template<typename T> void RegisterSingleton();
+ ///
+ /// עö
+ ///
+ void RegisterEnum(cc8* name, LuaxEnum* enums);
+
private:
friend class Context;
@@ -175,6 +178,17 @@ namespace Luax
template <> std::string LuaxState::GetValue < std::string >(int idx, const std::string value);
template <> const void* LuaxState::GetValue < const void* >(int idx, const void* value);
+ ///
+ /// ڳԱﴴLuaxStateԲм顣
+ ///
+#define LUAX_SETUP(L, params) \
+ LuaxRuntime& runtime = LuaxRuntime::Get(); \
+ LuaxState& state = runtime[L].state; \
+ if(!state.CheckParams(1, params)) return 0
+
+#define LUAX_STATE(L) \
+ LuaxState& state = LuaxRuntime::Get().GetLuaxState(L)
+
}
#endif \ No newline at end of file
diff --git a/Source/3rdParty/Luax/luax_state.inl b/Source/3rdParty/Luax/luax_state.inl
index 2c9f7a8..b5ee5aa 100644
--- a/Source/3rdParty/Luax/luax_state.inl
+++ b/Source/3rdParty/Luax/luax_state.inl
@@ -44,12 +44,12 @@ namespace Luax
assert(IsType(-1, LUA_TFUNCTION)); \
Pop();
- // NewûУûеĻʾһ
- //_assertmethod(-1, "New");
+ // NewûУûеĻʾһ
+ //_assertmethod(-1, "New");
#undef _assertmethod
- // .Extend()
+ // .Extend()
lua_pushvalue(state, -1); // class table
LuaxClass<T>::PushInterfaceTable(state); // interface table
lua_pushcclosure(state, LuaxClass<T>::l_ExtendFactory, 2);
@@ -66,6 +66,9 @@ namespace Luax
// reset top
lua_settop(L, top);
+
+ //
+ T::RegisterLuaxPostprocess(state);
}
// עᵥ
diff --git a/Source/3rdParty/Luax/luax_variable.cpp b/Source/3rdParty/Luax/luax_variable.cpp
deleted file mode 100644
index e69de29..0000000
--- a/Source/3rdParty/Luax/luax_variable.cpp
+++ /dev/null
diff --git a/Source/3rdParty/Luax/luax_variable.h b/Source/3rdParty/Luax/luax_variable.h
deleted file mode 100644
index e69de29..0000000
--- a/Source/3rdParty/Luax/luax_variable.h
+++ /dev/null