summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-03-20 22:43:25 +0800
committerchai <chaifix@163.com>2019-03-20 22:43:25 +0800
commit82956beb1fe17e1226327638c8ab22b5f5adfc1d (patch)
treeb47464697174d5f9db4c8c9ab4a25cc384927d97 /source
parent1497dccd63a84b7ee2b229b1ad9c5c02718f2a78 (diff)
*misc
Diffstat (limited to 'source')
-rw-r--r--source/3rd-party/Luax/luax_class.hpp25
-rw-r--r--source/3rd-party/Luax/luax_class.inl8
-rw-r--r--source/3rd-party/Luax/luax_config.h2
-rw-r--r--source/3rd-party/Luax/luax_enum.cpp2
-rw-r--r--source/3rd-party/Luax/luax_enum.h2
-rw-r--r--source/3rd-party/Luax/luax_state.cpp122
-rw-r--r--source/3rd-party/Luax/luax_state.h33
-rw-r--r--source/3rd-party/Luax/luax_state.inl31
-rw-r--r--source/Asura.Editor/dui_module.cpp (renamed from source/Asura.Editor/widgets/rbutton.cpp)0
-rw-r--r--source/Asura.Editor/dui_module.h6
-rw-r--r--source/Asura.Editor/editor.cpp1
-rw-r--r--source/Asura.Editor/editor.h17
-rw-r--r--source/Asura.Editor/layout/horizontal_layout.cpp (renamed from source/Asura.Editor/widgets/rbutton.h)0
-rw-r--r--source/Asura.Editor/layout/horizontal_layout.h (renamed from source/libs/asura-lib-utils/scripting/portable.inl)0
-rw-r--r--source/Asura.Editor/layout/vertical_layout.cpp0
-rw-r--r--source/Asura.Editor/layout/vertical_layout.h0
-rw-r--r--source/Asura.Editor/main.cpp10
-rw-r--r--source/Asura.Editor/widgets/progress.cpp0
-rw-r--r--source/Asura.Editor/widgets/progress.h0
-rw-r--r--source/Asura.Editor/widgets/radio_button.cpp0
-rw-r--r--source/Asura.Editor/widgets/radio_button.h0
-rw-r--r--source/Asura.Editor/widgets/widget.h4
-rw-r--r--source/libs/asura-lib-core/application.cpp33
-rw-r--r--source/libs/asura-lib-core/application.h14
-rw-r--r--source/libs/asura-lib-core/asura.h15
-rw-r--r--source/libs/asura-lib-core/client/client.h15
-rw-r--r--source/libs/asura-lib-core/client/sdl/sdl_thread.cpp0
-rw-r--r--source/libs/asura-lib-core/client/sdl/sdl_thread.h0
-rw-r--r--source/libs/asura-lib-core/client/sdl/sdl_window.h17
-rw-r--r--source/libs/asura-lib-core/config.h4
-rw-r--r--source/libs/asura-lib-core/core_config.h8
-rw-r--r--source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp56
-rw-r--r--source/libs/asura-lib-core/graphics/canvas.h14
-rw-r--r--source/libs/asura-lib-core/graphics/color.h5
-rw-r--r--source/libs/asura-lib-core/graphics/gl.cpp2
-rw-r--r--source/libs/asura-lib-core/graphics/image_data.cpp3
-rw-r--r--source/libs/asura-lib-core/graphics/image_data.h24
-rw-r--r--source/libs/asura-lib-core/graphics/image_decoder.h4
-rw-r--r--source/libs/asura-lib-utils/filesystem/binding/data_buffer.binding.cpp100
-rw-r--r--source/libs/asura-lib-utils/filesystem/data_buffer.cpp54
-rw-r--r--source/libs/asura-lib-utils/filesystem/data_buffer.h30
-rw-r--r--source/libs/asura-lib-utils/filesystem/resource_manager.h4
-rw-r--r--source/libs/asura-lib-utils/scripting/luax.hpp13
-rw-r--r--source/libs/asura-lib-utils/scripting/portable.hpp7
-rw-r--r--source/libs/asura-lib-utils/type.h3
-rw-r--r--source/libs/asura-lib-utils/utils_module.cpp2
-rw-r--r--source/libs/asura-lib-utils/utils_module.h2
-rw-r--r--source/tests/02-luax/main.cpp65
48 files changed, 519 insertions, 238 deletions
diff --git a/source/3rd-party/Luax/luax_class.hpp b/source/3rd-party/Luax/luax_class.hpp
index ea1fab9..539ff1a 100644
--- a/source/3rd-party/Luax/luax_class.hpp
+++ b/source/3rd-party/Luax/luax_class.hpp
@@ -35,15 +35,32 @@ namespace Luax
static const char* GetLuaxClassName() { return #type; }; \
static bool IsLuaxClassSingleton() { return true; };
+ ///
+ /// ʵֵĺꡣһL
+ ///
#define LUAX_IMPL_METHOD(type, f) int type::f(lua_State* L)
+ ///
+ /// Ӧóʵֵӿڡһstate
+ ///
#define LUAX_REGISTRY(type) void type::RegisterLuaxClass(Luax::LuaxState& state)
-
#define LUAX_POSTPROCESS(type) void type::RegisterLuaxPostprocess(Luax::LuaxState& state)
-#define LUAX_REGISTER_FACTORY(stt, type) stt.RegisterFactory<type>()
-
-#define LUAX_REGISTER_SINGLETON(stt, type) stt.RegisterSingleton<type>()
+ ///
+ /// עĺꡣ
+ ///
+#define LUAX_REGISTER_FACTORY(state, type) state.RegisterFactory<type>()
+#define LUAX_REGISTER_SINGLETON(state, type) state.RegisterSingleton<type>()
+#define LUAX_REGISTER_METHODS(state, ...) \
+ do{ \
+ luaL_Reg __m[] = {__VA_ARGS__,{0, 0}}; \
+ state.RegisterMethods(__m); \
+ }while(0)
+#define LUAX_REGISTER_ENUM(state, name, ...) \
+ do{ \
+ Luax::LuaxEnum __e[] = {__VA_ARGS__,{0, 0}}; \
+ state.RegisterEnum(name, __e); \
+ }while(0)
///
/// Ҫ¶luanative classҪ̳дࡣͨluaʵҪȷüȷԣڶ߳Ҫȷͷš
diff --git a/source/3rd-party/Luax/luax_class.inl b/source/3rd-party/Luax/luax_class.inl
index 028d4f9..7a24896 100644
--- a/source/3rd-party/Luax/luax_class.inl
+++ b/source/3rd-party/Luax/luax_class.inl
@@ -206,7 +206,7 @@ namespace Luax
assert(!mUserdata);
// userdataջ
- state.PushPtrUserData(this);
+ state.PushPtrUserdata(this);
lua_newtable(state); // ref table޷luaʣC
lua_newtable(state); // member tableluaдĶԱ
@@ -308,7 +308,7 @@ namespace Luax
int LuaxNativeClass<T>::l___gc(lua_State* L)
{
LUAX_SETUP(L, "U");
- T* self = state.GetLuaUserdata<T>(1);
+ T* self = state.GetUserdata<T>(1);
delete self;
return 0;
}
@@ -324,7 +324,7 @@ namespace Luax
// 1: userdata
LUAX_STATE(L);
- T* self = state.GetLuaUserdata<T>(1);
+ T* self = state.GetUserdata<T>(1);
if (self)
{
cc8* classname = "";
@@ -464,7 +464,7 @@ namespace Luax
int LuaxNativeClass<T>::l_GetRefTable(lua_State* L)
{
LUAX_STATE(L);
- T* self = state.GetLuaUserdata<T>(1);
+ T* self = state.GetUserdata<T>(1);
bool success = self->PushLuaxRefTable(state);
if (!success)
lua_pushnil(L);
diff --git a/source/3rd-party/Luax/luax_config.h b/source/3rd-party/Luax/luax_config.h
index c6562cc..d95ae8b 100644
--- a/source/3rd-party/Luax/luax_config.h
+++ b/source/3rd-party/Luax/luax_config.h
@@ -53,7 +53,7 @@ namespace Luax
#define LUAX_ENABLE_NATIVE_EXTEND 0
#define LUAX_ENABLE_PLAIN_CLASS 1
-#define LUAX_ENABLE_PLAIN_ENABLE 1
+#define LUAX_ENABLE_PLAIN_ENUM 1
}
diff --git a/source/3rd-party/Luax/luax_enum.cpp b/source/3rd-party/Luax/luax_enum.cpp
index 88bbab4..b054d98 100644
--- a/source/3rd-party/Luax/luax_enum.cpp
+++ b/source/3rd-party/Luax/luax_enum.cpp
@@ -35,7 +35,7 @@ namespace Luax
}
//--------------------------------------------------------------------------------------------------------------
-#if LUAX_ENABLE_PLAIN_ENABLE
+#if LUAX_ENABLE_PLAIN_ENUM
int LuaxPlainEnum::registry(lua_State* L)
{
// params:
diff --git a/source/3rd-party/Luax/luax_enum.h b/source/3rd-party/Luax/luax_enum.h
index 36f6bab..c385dc5 100644
--- a/source/3rd-party/Luax/luax_enum.h
+++ b/source/3rd-party/Luax/luax_enum.h
@@ -20,7 +20,7 @@ namespace Luax
extern int l_rmt__newindex(lua_State* L);
//--------------------------------------------------------------------------------------------------------------
-#if LUAX_ENABLE_PLAIN_ENABLE
+#if LUAX_ENABLE_PLAIN_ENUM
///
/// luaö٣޸ĵtable
///
diff --git a/source/3rd-party/Luax/luax_state.cpp b/source/3rd-party/Luax/luax_state.cpp
index 881aaea..622f352 100644
--- a/source/3rd-party/Luax/luax_state.cpp
+++ b/source/3rd-party/Luax/luax_state.cpp
@@ -596,15 +596,6 @@ namespace Luax
return value;
}
- template<>
- int LuaxState::GetValue<int>(int idx, int value)
- {
- if (this->IsType(idx, LUA_TNUMBER)) {
- return (int)lua_tointeger(this->mState, idx);
- }
- return value;
- }
-
template <>
u16 LuaxState::GetValue < u16 >(int idx, const u16 value)
{
@@ -641,7 +632,7 @@ namespace Luax
return value;
}
- void LuaxState::PushPtrUserData(void* ptr) {
+ void LuaxState::PushPtrUserdata(void* ptr) {
void** handle = (void**)lua_newuserdata(this->mState, sizeof(void*));
assert(handle);
@@ -725,7 +716,7 @@ namespace Luax
}
#endif
-#if LUAX_ENABLE_PLAIN_ENABLE
+#if LUAX_ENABLE_PLAIN_ENUM
void LuaxState::RegisterPlainEnumRegistry(cc8* name)
{
assert(lua_istable(mState, -1));
@@ -734,4 +725,113 @@ namespace Luax
}
#endif
+ int LuaxState::ErrorType(int idx, cc8* hint)
+ {
+ return luaL_typerror(mState, idx, hint);
+ }
+
+ template <>
+ bool LuaxState::CheckParam < bool >(int idx)
+ {
+ bool b = false;
+ if (lua_type(mState, idx) == LUA_TBOOLEAN)
+ {
+ b = lua_toboolean(mState, idx);
+ }
+ else
+ {
+ luaL_typerror(mState, idx, lua_typename(mState, LUA_TBOOLEAN));
+ }
+ return b;
+ }
+
+ template <>
+ cc8* LuaxState::CheckParam < cc8* >(int idx)
+ {
+ return luaL_checkstring(mState, idx);
+ }
+
+ template <>
+ double LuaxState::CheckParam < double >(int idx)
+ {
+ return luaL_checknumber(mState, idx);
+ }
+
+ template <>
+ float LuaxState::CheckParam < float >(int idx)
+ {
+ return luaL_checknumber(mState, idx);
+ }
+
+ template <>
+ s8 LuaxState::CheckParam < s8 >(int idx)
+ {
+ return luaL_checkinteger(mState, idx);
+ }
+
+ template <>
+ s16 LuaxState::CheckParam < s16 >(int idx)
+ {
+ return luaL_checkinteger(mState, idx);
+ }
+
+ template <>
+ s32 LuaxState::CheckParam < s32 >(int idx)
+ {
+ return luaL_checkinteger(mState, idx);
+ }
+
+ template <>
+ s64 LuaxState::CheckParam < s64 >(int idx)
+ {
+ return luaL_checkinteger(mState, idx);
+ }
+
+ template <>
+ u8 LuaxState::CheckParam < u8 >(int idx)
+ {
+ return luaL_checkinteger(mState, idx);
+ }
+
+ template <>
+ u16 LuaxState::CheckParam < u16 >(int idx)
+ {
+ return luaL_checkinteger(mState, idx);
+ }
+
+ template <>
+ u32 LuaxState::CheckParam < u32 >(int idx)
+ {
+ return luaL_checkinteger(mState, idx);
+ }
+
+ template <>
+ u64 LuaxState::CheckParam < u64 >(int idx)
+ {
+ return luaL_checkinteger(mState, idx);
+ }
+
+ template <>
+ std::string LuaxState::CheckParam < std::string >(int idx)
+ {
+ return luaL_checkstring(mState, idx);
+ }
+
+ ///
+ /// check light userdata
+ ///
+ template <>
+ const void* LuaxState::CheckParam < const void* >(int idx)
+ {
+ if (IsType(idx, LUA_TLIGHTUSERDATA))
+ {
+ return GetValue<const void*>(idx, nullptr);
+ }
+ else
+ {
+ luaL_typerror(mState, idx, "light userdata");
+ return nullptr;
+ }
+ }
+
} \ No newline at end of file
diff --git a/source/3rd-party/Luax/luax_state.h b/source/3rd-party/Luax/luax_state.h
index fbe424b..564eba3 100644
--- a/source/3rd-party/Luax/luax_state.h
+++ b/source/3rd-party/Luax/luax_state.h
@@ -107,13 +107,17 @@ namespace Luax
///
/// void** ʽuserdataֵΪptr
///
- void PushPtrUserData(void* ptr);
+ void PushPtrUserdata(void* ptr);
void Pop(int n = 1);
void Settop(int idx);
- template<typename T> T* GetLuaUserdata(int idx = 1);
+ template<typename T> T* GetUserdata(int idx = 1);
+
+ //------------------------------------------------------------------------------------------------------------
+
+ int ErrorType(int idx, cc8* hint);
//------------------------------------------------------------------------------------------------------------
@@ -123,6 +127,9 @@ namespace Luax
template<typename T> void SetField(int idx, cc8* key, T value);
template<typename T> void SetFieldByIndex(int idx, int key, T value);
+ template<typename T> T* CheckUserdata(int idx);
+ template<typename T> T CheckParam(int idx);
+
//------------------------------------------------------------------------------------------------------------
void DoString(const std::string& code);
@@ -175,7 +182,7 @@ namespace Luax
void RegisterPlainClassRegistry(cc8* name);
#endif
-#if LUAX_ENABLE_PLAIN_ENABLE
+#if LUAX_ENABLE_PLAIN_ENUM
///
/// עᴿluaö٣Էֹ޸öֵ
///
@@ -203,7 +210,7 @@ namespace Luax
};
//--------------------------------------------------------------------------------------------------------------
- // GetValue()ģػ
+ // GetValue()ģʵ
template <> bool LuaxState::GetValue < bool >(int idx, const bool value);
template <> cc8* LuaxState::GetValue < cc8* >(int idx, const cc8* value);
@@ -219,8 +226,24 @@ namespace Luax
template <> u64 LuaxState::GetValue < u64 >(int idx, const u64 value);
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);
- template <> int LuaxState::GetValue < int >(int idx, int value);
+ //--------------------------------------------------------------------------------------------------------------
+ // CheckParamģʵ
+
+ template <> bool LuaxState::CheckParam < bool >(int idx);
+ template <> cc8* LuaxState::CheckParam < cc8* >(int idx);
+ template <> double LuaxState::CheckParam < double >(int idx);
+ template <> float LuaxState::CheckParam < float >(int idx);
+ template <> s8 LuaxState::CheckParam < s8 >(int idx);
+ template <> s16 LuaxState::CheckParam < s16 >(int idx);
+ template <> s32 LuaxState::CheckParam < s32 >(int idx);
+ template <> s64 LuaxState::CheckParam < s64 >(int idx);
+ template <> u8 LuaxState::CheckParam < u8 >(int idx);
+ template <> u16 LuaxState::CheckParam < u16 >(int idx);
+ template <> u32 LuaxState::CheckParam < u32 >(int idx);
+ template <> u64 LuaxState::CheckParam < u64 >(int idx);
+ template <> std::string LuaxState::CheckParam < std::string >(int idx);
+ template <> const void* LuaxState::CheckParam < const void* >(int idx);
///
/// ڳԱﴴLuaxStateԲм顣
diff --git a/source/3rd-party/Luax/luax_state.inl b/source/3rd-party/Luax/luax_state.inl
index 06d9350..4af45a2 100644
--- a/source/3rd-party/Luax/luax_state.inl
+++ b/source/3rd-party/Luax/luax_state.inl
@@ -125,7 +125,7 @@ namespace Luax
}
template<typename T>
- T* LuaxState::GetLuaUserdata(int idx)
+ T* LuaxState::GetUserdata(int idx)
{
void* p = nullptr;
@@ -137,4 +137,33 @@ namespace Luax
return static_cast<T*>(p);
}
+ template<typename T>
+ T* LuaxState::CheckUserdata(int idx)
+ {
+ if (IsType(idx, LUA_TUSERDATA))
+ {
+ if (lua_getmetatable(mState, idx)) // ref table
+ {
+ if (lua_getmetatable(mState, -1)) // member table
+ {
+ if (lua_getmetatable(mState, -1)) // class table
+ {
+ T::PushLuaxClassTable(*this); // target class table
+ if (lua_rawequal(mState, -1, -2))
+ {
+ Pop(4); // ref\member\class\target class
+ T* udata = GetUserdata<T>(idx);
+ return udata; // userdata
+ }
+ Pop(2); // target class table\class table
+ }
+ Pop(1); // member table
+ }
+ Pop(1); // ref table
+ }
+ }
+ luaL_typerror(mState, idx, T::GetLuaxClassName());
+ return nullptr;
+ }
+
} \ No newline at end of file
diff --git a/source/Asura.Editor/widgets/rbutton.cpp b/source/Asura.Editor/dui_module.cpp
index e69de29..e69de29 100644
--- a/source/Asura.Editor/widgets/rbutton.cpp
+++ b/source/Asura.Editor/dui_module.cpp
diff --git a/source/Asura.Editor/dui_module.h b/source/Asura.Editor/dui_module.h
new file mode 100644
index 0000000..abcaca5
--- /dev/null
+++ b/source/Asura.Editor/dui_module.h
@@ -0,0 +1,6 @@
+#ifndef __ASRUA_EDITOR_DIRECTUI_MODULE_H__
+#define __ASRUA_EDITOR_DIRECTUI_MODULE_H__
+
+
+
+#endif \ No newline at end of file
diff --git a/source/Asura.Editor/editor.cpp b/source/Asura.Editor/editor.cpp
index 29fb76d..38e7c26 100644
--- a/source/Asura.Editor/editor.cpp
+++ b/source/Asura.Editor/editor.cpp
@@ -1,5 +1,4 @@
-
int main(int argc, char *argv[])
{
diff --git a/source/Asura.Editor/editor.h b/source/Asura.Editor/editor.h
new file mode 100644
index 0000000..6555c81
--- /dev/null
+++ b/source/Asura.Editor/editor.h
@@ -0,0 +1,17 @@
+#ifndef __ASURA_EDITOR_H__
+#define __ASURA_EDITOR_H__
+
+namespace AsuraEditor
+{
+
+ ///
+ ///
+ ///
+ class Editor
+ {
+
+ };
+
+}
+
+#endif \ No newline at end of file
diff --git a/source/Asura.Editor/widgets/rbutton.h b/source/Asura.Editor/layout/horizontal_layout.cpp
index e69de29..e69de29 100644
--- a/source/Asura.Editor/widgets/rbutton.h
+++ b/source/Asura.Editor/layout/horizontal_layout.cpp
diff --git a/source/libs/asura-lib-utils/scripting/portable.inl b/source/Asura.Editor/layout/horizontal_layout.h
index e69de29..e69de29 100644
--- a/source/libs/asura-lib-utils/scripting/portable.inl
+++ b/source/Asura.Editor/layout/horizontal_layout.h
diff --git a/source/Asura.Editor/layout/vertical_layout.cpp b/source/Asura.Editor/layout/vertical_layout.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/Asura.Editor/layout/vertical_layout.cpp
diff --git a/source/Asura.Editor/layout/vertical_layout.h b/source/Asura.Editor/layout/vertical_layout.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/Asura.Editor/layout/vertical_layout.h
diff --git a/source/Asura.Editor/main.cpp b/source/Asura.Editor/main.cpp
index e69de29..cfe59ac 100644
--- a/source/Asura.Editor/main.cpp
+++ b/source/Asura.Editor/main.cpp
@@ -0,0 +1,10 @@
+///
+/// ༭ĽͨdirectUIʵ֣Ⱦasura-libϣ¼Ӧͨwin32APIʵ֡
+///
+
+int main(int argn, char* args[])
+{
+
+
+
+} \ No newline at end of file
diff --git a/source/Asura.Editor/widgets/progress.cpp b/source/Asura.Editor/widgets/progress.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/Asura.Editor/widgets/progress.cpp
diff --git a/source/Asura.Editor/widgets/progress.h b/source/Asura.Editor/widgets/progress.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/Asura.Editor/widgets/progress.h
diff --git a/source/Asura.Editor/widgets/radio_button.cpp b/source/Asura.Editor/widgets/radio_button.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/Asura.Editor/widgets/radio_button.cpp
diff --git a/source/Asura.Editor/widgets/radio_button.h b/source/Asura.Editor/widgets/radio_button.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/Asura.Editor/widgets/radio_button.h
diff --git a/source/Asura.Editor/widgets/widget.h b/source/Asura.Editor/widgets/widget.h
index 437e2bf..5fb18f1 100644
--- a/source/Asura.Editor/widgets/widget.h
+++ b/source/Asura.Editor/widgets/widget.h
@@ -1,7 +1,7 @@
#ifndef __ASURA_EDITOR_WIDGET_H__
#define __ASURA_EDITOR_WIDGET_H__
-#include <Object.h>
+#include <asura-lib-utils/type.h>
namespace AusraEditor
{
@@ -9,7 +9,7 @@ namespace AusraEditor
///
/// Asura EditorĿؼ߼Ⱦں¼ѯֻ¼Ӧ߼ӿڡ
///
- class Widget : virtual public Object
+ ASURA_ABSTRACT class Widget
{
public:
diff --git a/source/libs/asura-lib-core/application.cpp b/source/libs/asura-lib-core/application.cpp
index 598bca8..0a1c1ef 100644
--- a/source/libs/asura-lib-core/application.cpp
+++ b/source/libs/asura-lib-core/application.cpp
@@ -20,40 +20,7 @@ namespace AsuraEngine
bool Application::InitSubModules(uint flag)
{
- // ʼģ
- #define TryInitSubModule(module_name, func_name) \
- if((flag&ASURA_MODULE_##module_name) && !Application::Init##func_name()) \
- throw Exception("Asura init submodule %s failed.", #module_name);
-
- TryInitSubModule(GRAPHICS, Graphics);
- TryInitSubModule(AUDIO, Audio);
- TryInitSubModule(FONT, Font);
- TryInitSubModule(INPUT, Input);
- TryInitSubModule(MATH, Math);
- TryInitSubModule(PHYSICS, Physics);
- TryInitSubModule(TIME, Time);
- TryInitSubModule(WINDOW, Window);
}
- void Application::PortToLua()
- {
- LuaxState state(mLuaState);
-
-#define RegisterLuaFactory(T) state.RegisterFactory<T>();
-
- state.SetToGlobalNamespace();
- state.PushNamespace("AsuraEngine");
-
- RegisterLuaFactory(AEGraphics::Image>);
-
-#ifdef ASURA_AUTHOR
- state.PushNamespace("Version");
-
- state.PopNamespace(); // AsuraEngine.Version
-#endif
-
- state.PopNamespace(); // AsuraEngine
- }
-
} \ No newline at end of file
diff --git a/source/libs/asura-lib-core/application.h b/source/libs/asura-lib-core/application.h
index 6ae3218..983dbce 100644
--- a/source/libs/asura-lib-core/application.h
+++ b/source/libs/asura-lib-core/application.h
@@ -5,7 +5,7 @@
#include <asura-lib-utils/module.h>
#include <queue>
-#include "config.h"
+#include "core_config.h"
namespace AsuraEngine
{
@@ -65,18 +65,6 @@ namespace AsuraEngine
private:
///
- /// ģʼڸģļʵ֡
- ///
- bool InitGraphics();
- bool InitAudio();
- bool InitFont();
- bool InitInput();
- bool InitMath();
- bool InitPhysics();
- bool InitTime();
- bool InitWindow();
-
- ///
/// Lua state.
///
lua_State* mLuaState;
diff --git a/source/libs/asura-lib-core/asura.h b/source/libs/asura-lib-core/asura.h
deleted file mode 100644
index 5ca56f3..0000000
--- a/source/libs/asura-lib-core/asura.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef __ASURA_ENGINE_H__
-#define __ASURA_ENGINE_H__
-
-#include "Application.h"
-
-#include "Graphics/Shader.h"
-
-//namespace AEGraphics = AsuraEngine::Graphics;
-//namespace AEMath = AsuraEngine::Math;
-//namespace AETime = AsuraEngine::Time;
-//namespace AEInput = AsuraEngine::Input;
-//namespace AEProfiler = AsuraEngine::Profiler;
-//namespace AEFont = AsuraEngine::Font;
-
-#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-core/client/client.h b/source/libs/asura-lib-core/client/client.h
index f2464a5..8df30fe 100644
--- a/source/libs/asura-lib-core/client/client.h
+++ b/source/libs/asura-lib-core/client/client.h
@@ -1,16 +1,23 @@
#ifndef __ASURA_ENGINE_HOST_H__
#define __ASURA_ENGINE_HOST_H__
-/**
-* ʹڿйص
-*/
+#include <asura-lib-utils/type.h>
+///
+/// ʹйصʵ֣ǵϷĿƽ̨ʹüֱʵ֡༭벻ڿƽ̨ڿ⣬Ŀǰʹwin32APIʵϢѭ
+///
namespace AsuraEngine
{
- namespace Host
+ namespace Client
{
+ ///
+ /// ࡣ
+ ///
+ ASURA_ABSTRACT class Client
+ {
+ };
}
}
diff --git a/source/libs/asura-lib-core/client/sdl/sdl_thread.cpp b/source/libs/asura-lib-core/client/sdl/sdl_thread.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-core/client/sdl/sdl_thread.cpp
diff --git a/source/libs/asura-lib-core/client/sdl/sdl_thread.h b/source/libs/asura-lib-core/client/sdl/sdl_thread.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-core/client/sdl/sdl_thread.h
diff --git a/source/libs/asura-lib-core/client/sdl/sdl_window.h b/source/libs/asura-lib-core/client/sdl/sdl_window.h
index 1fdef1e..040c23e 100644
--- a/source/libs/asura-lib-core/client/sdl/sdl_window.h
+++ b/source/libs/asura-lib-core/client/sdl/sdl_window.h
@@ -1,14 +1,29 @@
#ifndef __ASURA_SDL_WINDOW_H__
#define __ASURA_SDL_WINDOW_H__
+#include "../../core_config.h"
+#if ASURA_CORE_SDL
+
+#include <asura-lib-utils/scripting/portable.hpp>
+#include "../../graphics/window.h"
+
namespace AsuraEngine
{
namespace SDL
{
+ class SDLWindow ASURA_FINAL
+ : public Graphics::Window
+ , public Scripting::Portable<SDLWindow>
+ {
+ public:
+
+ };
}
}
-#endif \ No newline at end of file
+#endif // ASURA_CORE_SDL
+
+#endif // __ASURA_SDL_WINDOW_H__ \ No newline at end of file
diff --git a/source/libs/asura-lib-core/config.h b/source/libs/asura-lib-core/config.h
deleted file mode 100644
index df7ad99..0000000
--- a/source/libs/asura-lib-core/config.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef __ASURA_CORE_CONFIG_H__
-#define __ASURA_CORE_CONFIG_H__
-
-#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-core/core_config.h b/source/libs/asura-lib-core/core_config.h
new file mode 100644
index 0000000..06eecc7
--- /dev/null
+++ b/source/libs/asura-lib-core/core_config.h
@@ -0,0 +1,8 @@
+#ifndef __ASURA_CORE_CONFIG_H__
+#define __ASURA_CORE_CONFIG_H__
+
+#define ASURA_CORE_SDL 1
+#define ASURA_CORE_GLUT 0
+#define ASURA_CORE_GLFW 0
+
+#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp b/source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp
index 0d68c11..72e33da 100644
--- a/source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp
@@ -1,4 +1,4 @@
-#include "../image.h"
+#include "../image_data.h"
using namespace Luax;
@@ -7,23 +7,55 @@ namespace AsuraEngine
namespace Graphics
{
- void Image::RegisterLuaxClass(LuaxState& state)
+ LUAX_REGISTRY(ImageData)
{
}
- void Image::RegisterLuaxPostprocess(LuaxState& state)
+ LUAX_POSTPROCESS(ImageData)
+ {
+ LUAX_REGISTER_ENUM(state, "EBlendMode",
+ { "Additive", 1 }
+ );
+ LUAX_REGISTER_ENUM(state, "EPixelFormat",
+ { "RGBA32", 1 }
+ );
+ }
+
+ // imagedata = ImageData.New(databuffer)
+ LUAX_IMPL_METHOD(ImageData, _New)
+ {
+ LUAX_STATE(L);
+
+ Filesystem::DataBuffer* db = state.CheckUserdata<Filesystem::DataBuffer>(1);
+ ImageData* image = new ImageData(*db);
+ image->PushLuaxUserdata(state);
+ return 1;
+ }
+
+ LUAX_IMPL_METHOD(ImageData, _GetPixel)
+ {
+
+ }
+
+ LUAX_IMPL_METHOD(ImageData, _GetSize)
+ {
+
+ }
+
+ LUAX_IMPL_METHOD(ImageData, _GetWidth)
+ {
+
+ }
+
+ LUAX_IMPL_METHOD(ImageData, _GetHeight)
+ {
+
+ }
+
+ LUAX_IMPL_METHOD(ImageData, _GetPixelFormat)
{
- // blendö٣AsuraEngine.EBlendMode
- LuaxEnum EBlendMode[] = {
- { "Additive", 1 },
- { "PreBlend", 2 },
- { "Substruction", 3 },
- { "Multiplied", 4 },
- {0, 0}
- };
- state.RegisterEnum("EBlendMode", EBlendMode);
}
}
diff --git a/source/libs/asura-lib-core/graphics/canvas.h b/source/libs/asura-lib-core/graphics/canvas.h
index c4e0f65..6b8b630 100644
--- a/source/libs/asura-lib-core/graphics/canvas.h
+++ b/source/libs/asura-lib-core/graphics/canvas.h
@@ -1,12 +1,14 @@
#ifndef __ASURA_ENGINE_CANVAS_H__
#define __ASURA_ENGINE_CANVAS_H__
-#include <Scripting/Luax.hpp>
+#include <asura-lib-utils/scripting/portable.hpp>
+#include <asura-lib-utils/math/rect.hpp>
+#include <asura-lib-utils/math/vector2.hpp>
-#include "Math/Rect.hpp"
-#include "GL.h"
-#include "Texture.h"
-#include "RenderTarget.h"
+#include "gl.h"
+#include "texture.h"
+#include "render_target.h"
+#include "render_state.h"
namespace AsuraEngine
{
@@ -19,7 +21,7 @@ namespace AsuraEngine
class Canvas ASURA_FINAL
: public Drawable
, public RenderTarget
- , public Scripting::Portable
+ , public Scripting::Portable<Canvas>
{
public:
diff --git a/source/libs/asura-lib-core/graphics/color.h b/source/libs/asura-lib-core/graphics/color.h
index a18c682..74cf8f3 100644
--- a/source/libs/asura-lib-core/graphics/color.h
+++ b/source/libs/asura-lib-core/graphics/color.h
@@ -1,8 +1,9 @@
#ifndef __ASURA_ENGINE_COLOR_H__
#define __ASURA_ENGINE_COLOR_H__
-#include "config.h"
-#include "scripting/portable.hpp"
+#include <asura-lib-utils/scripting/portable.hpp>
+
+#include "../core_config.h"
namespace AsuraEngine
{
diff --git a/source/libs/asura-lib-core/graphics/gl.cpp b/source/libs/asura-lib-core/graphics/gl.cpp
index 01c90de..7c68c8f 100644
--- a/source/libs/asura-lib-core/graphics/gl.cpp
+++ b/source/libs/asura-lib-core/graphics/gl.cpp
@@ -1,4 +1,4 @@
-#include "config.h"
+#include "../core_config.h"
#include "gl.h"
namespace AsuraEngine
diff --git a/source/libs/asura-lib-core/graphics/image_data.cpp b/source/libs/asura-lib-core/graphics/image_data.cpp
index 821bfd6..28c706a 100644
--- a/source/libs/asura-lib-core/graphics/image_data.cpp
+++ b/source/libs/asura-lib-core/graphics/image_data.cpp
@@ -1,6 +1,7 @@
#include "image_data.h"
#include "png_decoder.h"
#include "stb_decoder.h"
+#include "image_decoder.h"
namespace AsuraEngine
{
@@ -35,7 +36,7 @@ namespace AsuraEngine
{
if (decoder->CanDecode(buffer))
{
- decoder->Decode(buffer, this);
+ decoder->Decode(buffer, *this);
return;
}
}
diff --git a/source/libs/asura-lib-core/graphics/image_data.h b/source/libs/asura-lib-core/graphics/image_data.h
index 1e711a8..53a9e85 100644
--- a/source/libs/asura-lib-core/graphics/image_data.h
+++ b/source/libs/asura-lib-core/graphics/image_data.h
@@ -3,9 +3,10 @@
#include <list>
-#include "scripting/luax.hpp"
-#include "filesystem/decoded_data.h"
-#include "image_decoder.h"
+#include <asura-lib-utils/scripting/portable.hpp>
+#include <asura-lib-utils/filesystem/decoded_data.h>
+#include <asura-lib-utils/filesystem/data_buffer.h>
+
#include "pixel_format.h"
#include "color.h"
@@ -14,9 +15,11 @@ namespace AsuraEngine
namespace Graphics
{
+ class ImageDecoder;
+
class ImageData ASURA_FINAL
: public Filesystem::DecodedData
- , public Scripting::Portable
+ , public Scripting::Portable<ImageData>
{
public:
@@ -24,7 +27,6 @@ namespace AsuraEngine
/// ͼƬļϢʧܣ׳쳣
///
ImageData(const Filesystem::DataBuffer& buffer);
-
~ImageData();
Color GetPixel(uint x, uint y);
@@ -45,14 +47,14 @@ namespace AsuraEngine
public:
- //----------------------------------------------------------------------------------------------------------
-
LUAX_DECL_FACTORY(ImageData);
- LUAX_DECL_METHOD(l_GetPixel);
- LUAX_DECL_METHOD(l_GetSize);
-
- //----------------------------------------------------------------------------------------------------------
+ LUAX_DECL_METHOD(_New);
+ LUAX_DECL_METHOD(_GetPixel);
+ LUAX_DECL_METHOD(_GetSize);
+ LUAX_DECL_METHOD(_GetWidth);
+ LUAX_DECL_METHOD(_GetHeight);
+ LUAX_DECL_METHOD(_GetPixelFormat);
};
diff --git a/source/libs/asura-lib-core/graphics/image_decoder.h b/source/libs/asura-lib-core/graphics/image_decoder.h
index 2c73fd1..921d129 100644
--- a/source/libs/asura-lib-core/graphics/image_decoder.h
+++ b/source/libs/asura-lib-core/graphics/image_decoder.h
@@ -1,9 +1,9 @@
#ifndef __ASURA_ENGINE_IMAGE_DECODER_H__
#define __ASURA_ENGINE_IMAGE_DECODER_H__
-#include "FileSystem/DataBuffer.h"
+#include <asura-lib-utils/filesystem/data_buffer.h>
-#include "ImageData.h"
+#include "image_data.h"
namespace AsuraEngine
{
diff --git a/source/libs/asura-lib-utils/filesystem/binding/data_buffer.binding.cpp b/source/libs/asura-lib-utils/filesystem/binding/data_buffer.binding.cpp
index a9113a7..8e92eee 100644
--- a/source/libs/asura-lib-utils/filesystem/binding/data_buffer.binding.cpp
+++ b/source/libs/asura-lib-utils/filesystem/binding/data_buffer.binding.cpp
@@ -9,59 +9,101 @@ namespace AsuraEngine
LUAX_REGISTRY(DataBuffer)
{
- luaL_Reg f[] = {
+ LUAX_REGISTER_METHODS(state,
{ "New", _New },
- { "SetContent", _SetContent },
- { "GetContent", _GetContent },
- { "GetContentLength", _GetContentLength },
- {0, 0}
- };
-
- state.RegisterMethods(f);
+ { "GetBuffer", _GetBuffer },
+ { "GetSize", _GetSize },
+ { "Load", _Load },
+ { "Clear", _Clear }
+ );
}
LUAX_POSTPROCESS(DataBuffer)
{
-
}
+ // databuffer = DataBuffer.New(lstring)
+ // databuffer = DataBuffer.New(size)
LUAX_IMPL_METHOD(DataBuffer, _New)
{
+ LUAX_STATE(L);
+ if (state.IsType(1, LUA_TSTRING))
+ {
+ byte* bytes;
+ size_t size;
+ lua_tolstring(L, 1, &size);
+ DataBuffer* buffer = new DataBuffer(bytes, size);
+ buffer->PushLuaxUserdata(state);
+ return 1;
+ }
+ else if (state.IsType(1, LUA_TNUMBER))
+ {
+ size_t size = lua_tonumber(L, 1);
+ DataBuffer* buffer = new DataBuffer(size);
+ buffer->PushLuaxUserdata(state);
+ }
+ else
+ {
+ return state.ErrorType(1, "number or string");
+ }
}
- // SetContent(dataBuffer, lString)
- LUAX_IMPL_METHOD(DataBuffer, _SetContent)
+ // lsting, len = databuffer:GetBuffer()
+ LUAX_IMPL_METHOD(DataBuffer, _GetBuffer)
{
- LUAX_SETUP(L, "US");
- // params:
- // 1: data buffer
- // 2: lstring
+ LUAX_SETUP(L, "U");
- DataBuffer* self = state.GetLuaUserdata<DataBuffer>(1);
- size_t size = 0;
- const char* str = lua_tolstring(L, 2, &size);
- void* data = new char[size];
- memcpy(data, str, size);
- self->SetContent(data, size);
- return 0;
+ DataBuffer* self = state.GetUserdata<DataBuffer>(1);
+ lua_pushlstring(L, self->GetBuffer(), self->GetSize());
+ return 2;
}
- LUAX_IMPL_METHOD(DataBuffer, _GetContent)
+ // length = databuffer:GetSize()
+ LUAX_IMPL_METHOD(DataBuffer, _GetSize)
{
LUAX_SETUP(L, "U");
- DataBuffer* self = state.GetLuaUserdata<DataBuffer>(1);
- lua_pushlstring(L, (const char*)self->data, self->size);
+ DataBuffer* self = state.GetUserdata<DataBuffer>(1);
+ lua_pushinteger(L, self->GetSize());
return 1;
}
- LUAX_IMPL_METHOD(DataBuffer, _GetContentLength)
+ // databuffer:Load(lstring)
+ // databuffer:Load(src)
+ LUAX_IMPL_METHOD(DataBuffer, _Load)
+ {
+ LUAX_STATE(L);
+
+ DataBuffer* buffer = state.GetUserdata<DataBuffer>(1);
+ const byte* data;
+ size_t size;
+ if (state.IsType(2, LUA_TSTRING))
+ {
+ data = lua_tolstring(L, 2, &size);
+ buffer->Load(data, size);
+ return 0;
+ }
+ else if(state.IsType(2, LUA_TUSERDATA))
+ {
+ DataBuffer* src = state.CheckUserdata<DataBuffer>(2);
+ buffer->Load(*src);
+ return 0;
+ }
+ else
+ {
+ return state.ErrorType(1, "lstring or DataBuffer");
+ }
+ }
+
+ // databuffer:Clear()
+ LUAX_IMPL_METHOD(DataBuffer, _Clear)
{
LUAX_SETUP(L, "U");
- DataBuffer* self = state.GetLuaUserdata<DataBuffer>(1);
- lua_pushinteger(L, self->size);
- return 1;
+
+ DataBuffer* self = state.GetUserdata<DataBuffer>(1);
+ self->Clear();
+ return 0;
}
}
diff --git a/source/libs/asura-lib-utils/filesystem/data_buffer.cpp b/source/libs/asura-lib-utils/filesystem/data_buffer.cpp
index 629dc92..32a123f 100644
--- a/source/libs/asura-lib-utils/filesystem/data_buffer.cpp
+++ b/source/libs/asura-lib-utils/filesystem/data_buffer.cpp
@@ -1,3 +1,5 @@
+#include <cstdlib>
+#include <cstring>
#include "data_buffer.h"
namespace AsuraEngine
@@ -5,24 +7,60 @@ namespace AsuraEngine
namespace Filesystem
{
+ DataBuffer::DataBuffer(DataBuffer& src)
+ {
+ Load(src);
+ }
+
+ DataBuffer::DataBuffer(std::size_t size)
+ : mSize(size)
+ , mBytes(nullptr)
+ {
+ mBytes = new byte[size];
+ memset(mBytes, 0, size);
+ }
+
DataBuffer::DataBuffer(const void* data, std::size_t size)
+ : mSize(size)
+ , mBytes(nullptr)
{
- this->data = (const byte*)data;
- this->size = size;
+ Load(data, size);
}
DataBuffer::~DataBuffer()
{
- delete[] data;
+ delete[] mBytes;
}
- void DataBuffer::SetContent(const void* data, std::size_t siez)
+ void DataBuffer::Load(DataBuffer& db)
{
- if (this->data != nullptr)
- delete[] this->data;
+ Load(db.GetBuffer(), db.GetSize());
+ }
- this->data = (const byte*)data;
- this->size = size;
+ void DataBuffer::Load(const void* data, std::size_t size)
+ {
+ if (!mBytes || mSize != size)
+ {
+ delete[] mBytes;
+ mBytes = new byte[size];
+ }
+ memcpy(mBytes, data, size);
+ }
+
+ byte* DataBuffer::GetBuffer()
+ {
+ return mBytes;
+ }
+
+ void DataBuffer::Clear()
+ {
+ if (mBytes)
+ memset(mBytes, 0, mSize);
+ }
+
+ std::size_t DataBuffer::GetSize()
+ {
+ return mSize;
}
}
diff --git a/source/libs/asura-lib-utils/filesystem/data_buffer.h b/source/libs/asura-lib-utils/filesystem/data_buffer.h
index 4b013ed..5c80efb 100644
--- a/source/libs/asura-lib-utils/filesystem/data_buffer.h
+++ b/source/libs/asura-lib-utils/filesystem/data_buffer.h
@@ -3,7 +3,6 @@
#include <cstdlib>
-#include "../scripting/Luax.hpp"
#include "../scripting/portable.hpp"
namespace AsuraEngine
@@ -19,23 +18,34 @@ namespace AsuraEngine
{
public:
- DataBuffer(const void* data, std::size_t size);
-
+ DataBuffer(DataBuffer& src);
+ DataBuffer(std::size_t size);
+ DataBuffer(const void* bytes, std::size_t size);
~DataBuffer();
- void SetContent(const void* data, std::size_t siez);
+ byte* GetBuffer();
+ size_t GetSize();
+
+ void Load(DataBuffer& db);
+ void Load(const void* bytes, std::size_t size);
+ void Clear();
- const byte* data;
- size_t size;
+ private:
- //----------------------------------------------------------------------------------------------------------
+ byte* mBytes;
+ size_t mSize;
+
+ //------------------------------------------------------------------------------------------------------------
+
+ public:
LUAX_DECL_FACTORY(DataBuffer);
LUAX_DECL_METHOD(_New);
- LUAX_DECL_METHOD(_SetContent);
- LUAX_DECL_METHOD(_GetContent);
- LUAX_DECL_METHOD(_GetContentLength);
+ LUAX_DECL_METHOD(_GetBuffer);
+ LUAX_DECL_METHOD(_GetSize);
+ LUAX_DECL_METHOD(_Load);
+ LUAX_DECL_METHOD(_Clear);
};
diff --git a/source/libs/asura-lib-utils/filesystem/resource_manager.h b/source/libs/asura-lib-utils/filesystem/resource_manager.h
index c5d8f06..36d46cf 100644
--- a/source/libs/asura-lib-utils/filesystem/resource_manager.h
+++ b/source/libs/asura-lib-utils/filesystem/resource_manager.h
@@ -36,6 +36,10 @@ namespace AsuraEngine
///
void SaveFile(const std::string& path, const DataBuffer* buffer);
+ //----------------------------------------------------------------------------------------------------------
+
+ LUAX_DECL_SINGLETON(ResourceManager);
+
};
}
diff --git a/source/libs/asura-lib-utils/scripting/luax.hpp b/source/libs/asura-lib-utils/scripting/luax.hpp
deleted file mode 100644
index cca26e2..0000000
--- a/source/libs/asura-lib-utils/scripting/luax.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef __ASURA_ENGINE_LUAX_H__
-#define __ASURA_ENGINE_LUAX_H__
-
-///
-/// Scripting with Lua.
-///
-extern "C" {
-#include <Lua51/lua.h>
-#include <Lua51/lauxlib.h>
-}
-#include <Luax/luax.h>
-
-#endif \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/scripting/portable.hpp b/source/libs/asura-lib-utils/scripting/portable.hpp
index 7f780d1..00ede90 100644
--- a/source/libs/asura-lib-utils/scripting/portable.hpp
+++ b/source/libs/asura-lib-utils/scripting/portable.hpp
@@ -3,7 +3,12 @@
#include "../type.h"
-#include "Luax.hpp"
+extern "C"
+{
+ #include <Lua51/lua.h>
+ #include <Lua51/lauxlib.h>
+}
+#include <Luax/luax.h>
namespace AsuraEngine
{
diff --git a/source/libs/asura-lib-utils/type.h b/source/libs/asura-lib-utils/type.h
index 25b52fe..72ed8cc 100644
--- a/source/libs/asura-lib-utils/type.h
+++ b/source/libs/asura-lib-utils/type.h
@@ -11,7 +11,8 @@ namespace AsuraEngine
typedef int8_t int8;
typedef uint8_t uint8;
- typedef uint8 byte;
+ //typedef uint8 byte;
+ typedef char byte;
typedef int16_t int16;
typedef uint16_t uint16;
typedef int32_t int32;
diff --git a/source/libs/asura-lib-utils/utils_module.cpp b/source/libs/asura-lib-utils/utils_module.cpp
index 7fe3612..f025cac 100644
--- a/source/libs/asura-lib-utils/utils_module.cpp
+++ b/source/libs/asura-lib-utils/utils_module.cpp
@@ -9,12 +9,10 @@ namespace AsuraEngine
void UtilsModule::Initialize(Luax::LuaxState& state)
{
LUAX_REGISTER_FACTORY(state, DataBuffer);
-
}
void UtilsModule::Finalize(Luax::LuaxState& state)
{
-
}
} \ No newline at end of file
diff --git a/source/libs/asura-lib-utils/utils_module.h b/source/libs/asura-lib-utils/utils_module.h
index 0b5d076..c4b046b 100644
--- a/source/libs/asura-lib-utils/utils_module.h
+++ b/source/libs/asura-lib-utils/utils_module.h
@@ -9,7 +9,7 @@ namespace AsuraEngine
///
/// Asuraģ
///
- class UtilsModule : public Module
+ class UtilsModule ASURA_FINAL : public Module
{
public:
diff --git a/source/tests/02-luax/main.cpp b/source/tests/02-luax/main.cpp
index f87226e..cd718ac 100644
--- a/source/tests/02-luax/main.cpp
+++ b/source/tests/02-luax/main.cpp
@@ -2,10 +2,11 @@
/// Scripting with Lua.
///
extern "C"{
-#include "Lua51/lua.h"
-#include "Lua51/lauxlib.h"
+#include <Lua51/lua.h>
+#include <Lua51/lauxlib.h>
}
-#include "Luax/luax.h"
+#include <Luax/luax.h>
+
#include "header.h"
#include <iostream>
@@ -114,7 +115,7 @@ int Boy::l_New(lua_State* L)
int Boy::l_GetAge(lua_State* L)
{
LUAX_SETUP(L, "U");
- Boy* self = state.GetLuaUserdata<Boy>(1);
+ Boy* self = state.CheckUserdata<Boy>(1);
state.Push(self->mAge);
return 1;
}
@@ -122,7 +123,7 @@ int Boy::l_GetAge(lua_State* L)
int Boy::l_GetName(lua_State* L)
{
LUAX_SETUP(L, "U");
- Boy* self = state.GetLuaUserdata<Boy>(1);
+ Boy* self = state.CheckUserdata<Boy>(1);
state.Push(self->mName);
return 1;
}
@@ -138,7 +139,7 @@ int Boy::l_Speak(lua_State* L)
{
LUAX_STATE(L);
- Boy* self = state.GetLuaUserdata<Boy>(1);
+ Boy* self = state.CheckUserdata<Boy>(1);
self->PushMemberRef(state, self->mCallbak);
state.Call(0, 1);
return 1;
@@ -148,51 +149,41 @@ int Boy::l_Write(lua_State* L)
{
LUAX_STATE(L);
// self, func
- Boy* self = state.GetLuaUserdata<Boy>(1);
+ Boy* self = state.CheckUserdata<Boy>(1);
self->SetMemberRef(state, self->mCallbak, 2);
return 0;
}
void Boy::RegisterLuaxClass(LuaxState& state)
{
- luaL_Reg regTable[] = {
- // class functions
- { "New", l_New },
- { "GetGender", l_GetGender },
- // members
- { "GetAge", l_GetAge },
- { "GetName", l_GetName },
- { "Write", l_Write },
- { "Speak", l_Speak },
- { 0, 0}
- };
- state.RegisterMethods(regTable);
+ LUAX_REGISTER_METHODS(state,
+ { "New", l_New },/**/
+ { "GetGender", l_GetGender },
+ { "GetAge", l_GetAge },
+ { "GetName", l_GetName },
+ { "Write", l_Write },
+ { "Speak", l_Speak }
+ );
// boyİ
- LuaxEnum EHabits[] = {
- { "Computer", 1},
- { "Buscketball", 2},
- { "Baseball", 3},
- { "Girls", 4},
- {0, 0}
- };
-
- state.RegisterEnum("EHabits", EHabits);
+ LUAX_REGISTER_ENUM(state, "EHabits",
+ { "Computer", 1 },
+ { "Buscketball", 2 },
+ { "Baseball", 3 },
+ { "Girls", 4 }
+ );
}
void Boy::RegisterLuaxPostprocess(LuaxState& state)
{
// boyİ
- LuaxEnum EHabits[] = {
- { "Computer", 1},
- { "Buscketball", 2},
- { "Baseball", 3},
- { "Girls", 4},
- {0, 0}
- };
-
- state.RegisterEnum("EHabits", EHabits);
+ LUAX_REGISTER_ENUM(state, "EHabits",
+ { "Computer", 1 },
+ { "Buscketball", 2 },
+ { "Baseball", 3 },
+ { "Girls", 4 }
+ );
}
//----------------------------------------------------------------------------------------------------------------