From 2fb6b09dcf2ceb09cf021adb4a89f4c1255d5558 Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 13 Jan 2019 09:36:13 +0800 Subject: +luax --- Source/3rdParty/Luax/lua.hpp | 11 +++++++ Source/3rdParty/Luax/luax.cpp | 0 Source/3rdParty/Luax/luax.h | 21 ++++++++++++++ Source/3rdParty/Luax/luax_class.cpp | 0 Source/3rdParty/Luax/luax_class.h | 52 ++++++++++++++++++++++++++++++++++ Source/3rdParty/Luax/luax_function.cpp | 0 Source/3rdParty/Luax/luax_function.h | 0 Source/3rdParty/Luax/luax_module.cpp | 8 ++++++ Source/3rdParty/Luax/luax_module.h | 12 ++++++++ Source/3rdParty/Luax/luax_ref.cpp | 0 Source/3rdParty/Luax/luax_ref.h | 0 Source/3rdParty/Luax/luax_runtime.cpp | 0 Source/3rdParty/Luax/luax_runtime.h | 11 +++++++ Source/3rdParty/Luax/luax_state.cpp | 8 ++++++ Source/3rdParty/Luax/luax_state.h | 27 ++++++++++++++++++ Source/3rdParty/Luax/luax_variable.cpp | 0 Source/3rdParty/Luax/luax_variable.h | 0 17 files changed, 150 insertions(+) create mode 100644 Source/3rdParty/Luax/lua.hpp create mode 100644 Source/3rdParty/Luax/luax.cpp create mode 100644 Source/3rdParty/Luax/luax.h create mode 100644 Source/3rdParty/Luax/luax_class.cpp create mode 100644 Source/3rdParty/Luax/luax_class.h create mode 100644 Source/3rdParty/Luax/luax_function.cpp create mode 100644 Source/3rdParty/Luax/luax_function.h create mode 100644 Source/3rdParty/Luax/luax_module.cpp create mode 100644 Source/3rdParty/Luax/luax_module.h create mode 100644 Source/3rdParty/Luax/luax_ref.cpp create mode 100644 Source/3rdParty/Luax/luax_ref.h create mode 100644 Source/3rdParty/Luax/luax_runtime.cpp create mode 100644 Source/3rdParty/Luax/luax_runtime.h create mode 100644 Source/3rdParty/Luax/luax_state.cpp create mode 100644 Source/3rdParty/Luax/luax_state.h create mode 100644 Source/3rdParty/Luax/luax_variable.cpp create mode 100644 Source/3rdParty/Luax/luax_variable.h (limited to 'Source/3rdParty/Luax') diff --git a/Source/3rdParty/Luax/lua.hpp b/Source/3rdParty/Luax/lua.hpp new file mode 100644 index 0000000..2ad2293 --- /dev/null +++ b/Source/3rdParty/Luax/lua.hpp @@ -0,0 +1,11 @@ +#ifndef __LUAX_LUA_HPP__ +#define __LUAX_LUA_HPP__ + +// Include lua first + +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} +#endif \ No newline at end of file diff --git a/Source/3rdParty/Luax/luax.cpp b/Source/3rdParty/Luax/luax.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/3rdParty/Luax/luax.h b/Source/3rdParty/Luax/luax.h new file mode 100644 index 0000000..68ff9f2 --- /dev/null +++ b/Source/3rdParty/Luax/luax.h @@ -0,0 +1,21 @@ +#ifndef __LUAX_H__ +#define __LUAX_H__ + +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} +// include lua.hpp before this +#include "luax_runtime.h" +#include "luax_state.h" +#include "luax_ref.h" +#include "luax_class.h" +#include "luax_module.h" + +// luax 扩展的lua主要概念有 +// * modules +// * class +// * + +#endif \ No newline at end of file diff --git a/Source/3rdParty/Luax/luax_class.cpp b/Source/3rdParty/Luax/luax_class.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/3rdParty/Luax/luax_class.h b/Source/3rdParty/Luax/luax_class.h new file mode 100644 index 0000000..46918af --- /dev/null +++ b/Source/3rdParty/Luax/luax_class.h @@ -0,0 +1,52 @@ +#ifndef __LUAX_CLASS_H__ +#define __LUAX_CLASS_H__ + +#include + +namespace Luax +{ + + /// + /// 需要暴露给lua的class需要继承此类。 + /// + class LuaxClass + { + public: + +#define LUAX_DECL_METHOD(MTD) static int MTD(lua_State*) +#define LUAX_DECL_FACTORY(CLS) +#define LUAX_DECL_SINGLETON(CLS) + +#define LUAX_REGISTER_CLASS(CLS) CLS::RegisterLuaType() + + static void RegisterLuaType(); + + static void RegisterLuaFuncs(); + + private: + + }; + + /// + /// 需要作为工厂创建userdata的类继承此类。成为工厂的类,通过LUAX_DECL_FACTORY(CLS)宏指定类名。 + /// + class LuaxFactory : public LuaxClass + { + + + }; + + /// + /// 注入给lua的单例类继承此类。 + /// + class LuaxSingleton : public LuaxClass + { + public: + + private: + + }; + +} + +#endif \ No newline at end of file diff --git a/Source/3rdParty/Luax/luax_function.cpp b/Source/3rdParty/Luax/luax_function.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/3rdParty/Luax/luax_function.h b/Source/3rdParty/Luax/luax_function.h new file mode 100644 index 0000000..e69de29 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_ref.cpp b/Source/3rdParty/Luax/luax_ref.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/3rdParty/Luax/luax_ref.h b/Source/3rdParty/Luax/luax_ref.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/3rdParty/Luax/luax_runtime.cpp b/Source/3rdParty/Luax/luax_runtime.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/3rdParty/Luax/luax_runtime.h b/Source/3rdParty/Luax/luax_runtime.h new file mode 100644 index 0000000..a0dbea3 --- /dev/null +++ b/Source/3rdParty/Luax/luax_runtime.h @@ -0,0 +1,11 @@ +#ifndef __LUAX_RUNTIME_H__ +#define __LUAX_RUNTIME_H__ + +namespace Luax +{ + + + +} + +#endif \ No newline at end of file diff --git a/Source/3rdParty/Luax/luax_state.cpp b/Source/3rdParty/Luax/luax_state.cpp new file mode 100644 index 0000000..3fc1645 --- /dev/null +++ b/Source/3rdParty/Luax/luax_state.cpp @@ -0,0 +1,8 @@ +//#include "luax_state.h" + +namespace Luax +{ + + + +} \ No newline at end of file diff --git a/Source/3rdParty/Luax/luax_state.h b/Source/3rdParty/Luax/luax_state.h new file mode 100644 index 0000000..7b6338f --- /dev/null +++ b/Source/3rdParty/Luax/luax_state.h @@ -0,0 +1,27 @@ +#ifndef __LUAX_STATE_H__ +#define __LUAX_STATE_H__ + +namespace Luax +{ + + class LuaxState + { + public: + LuaxState(lua_State* state) : mState(state){}; + ~LuaxState() {}; + + inline operator lua_State*() { return mState; }; + operator bool(); + inline lua_State* operator ->() { return mState; }; + inline lua_State& operator *() { return *mState; }; + + private: + void* operator new(size_t size); + + lua_State* mState; + + }; + +} + +#endif \ No newline at end of file diff --git a/Source/3rdParty/Luax/luax_variable.cpp b/Source/3rdParty/Luax/luax_variable.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/3rdParty/Luax/luax_variable.h b/Source/3rdParty/Luax/luax_variable.h new file mode 100644 index 0000000..e69de29 -- cgit v1.1-26-g67d0