From 4dafefe46a72ba47468b13d011f8299055081b0f Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 22 Oct 2021 23:59:54 +0800 Subject: *LuaBind --- Editor/EditorApplication.cpp | 3 ++- Editor/EditorApplication.h | 2 +- Editor/GUI/ContainerWindow.cpp | 3 ++- Editor/GUI/EditorWindows.h | 4 +++- Editor/GUI/GUIWindow.cpp | 7 ++++++- Editor/Scripting/Editor/EditorApplication.bind.cpp | 2 +- Editor/Scripting/EditorGUI/ContainerWindow.bind.cpp | 2 +- Editor/Scripting/EditorGUI/GUIWindow.bind.cpp | 14 +++----------- 8 files changed, 19 insertions(+), 18 deletions(-) (limited to 'Editor') diff --git a/Editor/EditorApplication.cpp b/Editor/EditorApplication.cpp index 2f2d1e3..f9a6fa0 100644 --- a/Editor/EditorApplication.cpp +++ b/Editor/EditorApplication.cpp @@ -4,7 +4,8 @@ static bool s_Created; -EditorApplication::EditorApplication() +EditorApplication::EditorApplication(LuaBind::VM* vm) + : LuaBind::NativeClass(vm) { Assert(!s_Created); } diff --git a/Editor/EditorApplication.h b/Editor/EditorApplication.h index 9109a1f..25661a1 100644 --- a/Editor/EditorApplication.h +++ b/Editor/EditorApplication.h @@ -10,7 +10,7 @@ class EditorApplication : public LuaBind::NativeClass { public: - EditorApplication(); + EditorApplication(LuaBind::VM* vm); ~EditorApplication(); void PullMessage(); diff --git a/Editor/GUI/ContainerWindow.cpp b/Editor/GUI/ContainerWindow.cpp index ee42635..2aca239 100644 --- a/Editor/GUI/ContainerWindow.cpp +++ b/Editor/GUI/ContainerWindow.cpp @@ -177,7 +177,8 @@ LRESULT CALLBACK ContainerWindow::ContainerWndProc(HWND hWnd, UINT message, WPAR return flag; } -ContainerWindow::ContainerWindow() +ContainerWindow::ContainerWindow(LuaBind::VM* vm) + : LuaBind::NativeClass(vm) { } diff --git a/Editor/GUI/EditorWindows.h b/Editor/GUI/EditorWindows.h index 58a37fb..d9805a0 100644 --- a/Editor/GUI/EditorWindows.h +++ b/Editor/GUI/EditorWindows.h @@ -53,7 +53,7 @@ public: kShowAuxWindow = 5, // Popup windows like the color picker, gradient editor, etc. Drawn with black background on Mac }; - ContainerWindow(); + ContainerWindow(LuaBind::VM* vm); ~ContainerWindow(); void Init(Rectf size, int showMode, const Vector2f& minSize, const Vector2f& maxSize, std::string name = ""); @@ -134,6 +134,8 @@ public: static LRESULT CALLBACK GUIViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); static void RepaintAll(); + GUIWindow(LuaBind::VM* vm); + void Init(std::string name = ""); void DoPaint(); void SetContainerWindow(ContainerWindow* wnd); diff --git a/Editor/GUI/GUIWindow.cpp b/Editor/GUI/GUIWindow.cpp index 0502b21..8918ad3 100644 --- a/Editor/GUI/GUIWindow.cpp +++ b/Editor/GUI/GUIWindow.cpp @@ -174,6 +174,12 @@ void GUIWindow::RepaintAll() //////////////////////////////////////////////////////////// +GUIWindow::GUIWindow(LuaBind::VM* vm) + : LuaBind::NativeClass(vm) + , m_Instance(vm, Ref::STRONG_REF) +{ +} + void GUIWindow::ProcessEventMessages(UINT message, WPARAM wParam, LPARAM lParam) { @@ -226,7 +232,6 @@ void GUIWindow::Init(std::string name) log_error("Failed to setup rendering context"); log_info("Created GUIWindow " /*+ (long)this*/); - } bool GUIWindow::SetRenderContext() diff --git a/Editor/Scripting/Editor/EditorApplication.bind.cpp b/Editor/Scripting/Editor/EditorApplication.bind.cpp index 672bdcd..c6ea9f7 100644 --- a/Editor/Scripting/Editor/EditorApplication.bind.cpp +++ b/Editor/Scripting/Editor/EditorApplication.bind.cpp @@ -16,7 +16,7 @@ LUA_BIND_POSTPROCESS(EditorApplication) LUA_BIND_IMPL_METHOD(EditorApplication, EditorApplication::_New) { LUA_BIND_PREPARE(L, EditorApplication); - EditorApplication* app = new EditorApplication(); + EditorApplication* app = new EditorApplication(state.GetVM()); app->PushUserdata(state); return 1; } diff --git a/Editor/Scripting/EditorGUI/ContainerWindow.bind.cpp b/Editor/Scripting/EditorGUI/ContainerWindow.bind.cpp index 75d28aa..ce0efc8 100644 --- a/Editor/Scripting/EditorGUI/ContainerWindow.bind.cpp +++ b/Editor/Scripting/EditorGUI/ContainerWindow.bind.cpp @@ -54,7 +54,7 @@ LUA_BIND_IMPL_METHOD(ContainerWindow, ContainerWindow::_New) LUA_BIND_STATE(L, ContainerWindow); LUA_BIND_CHECK(L, "TNTT"); - ContainerWindow* wnd = new ContainerWindow(); + ContainerWindow* wnd = new ContainerWindow(state.GetVM()); Rectf rect = state.GetValue(state, Rectf()); int showMode = state.GetValue(2, 0); diff --git a/Editor/Scripting/EditorGUI/GUIWindow.bind.cpp b/Editor/Scripting/EditorGUI/GUIWindow.bind.cpp index 78ea635..075bce5 100644 --- a/Editor/Scripting/EditorGUI/GUIWindow.bind.cpp +++ b/Editor/Scripting/EditorGUI/GUIWindow.bind.cpp @@ -7,8 +7,7 @@ LUA_BIND_REGISTRY(GUIWindow) { "Focus", _Focus }, { "SetContainerWindow", _SetContainerWindow }, { "SetPosition", _SetPosition }, - { "New", _New }, - { "__gc", _GC } + { "New", _New } ); } @@ -16,13 +15,6 @@ LUA_BIND_POSTPROCESS(GUIWindow) { } -LUA_BIND_IMPL_METHOD(GUIWindow, _GC) -{ - LUA_BIND_PREPARE(L, GUIWindow); - - return 0; -} - LUA_BIND_IMPL_METHOD(GUIWindow, _DoPaint) { LUA_BIND_PREPARE(L, GUIWindow); @@ -64,8 +56,8 @@ LUA_BIND_IMPL_METHOD(GUIWindow, _SetPosition) LUA_BIND_IMPL_METHOD(GUIWindow, _New) { LUA_BIND_PREPARE(L, GUIWindow); - GUIWindow* wnd = new GUIWindow(); - wnd->PushUserdata(state); + GUIWindow* wnd = new GUIWindow(state.GetVM()); wnd->Init(); + wnd->PushUserdata(state); return 1; } \ No newline at end of file -- cgit v1.1-26-g67d0