diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 00000000..972446b0 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,28 @@ +{ + "configurations": [ + { + "name": "Mac", + "includePath": ["/usr/include"], + "browse" : { + "limitSymbolsToIncludedHeaders" : true, + "databaseFilename" : "" + } + }, + { + "name": "Linux", + "includePath": ["/usr/include"], + "browse" : { + "limitSymbolsToIncludedHeaders" : true, + "databaseFilename" : "" + } + }, + { + "name": "Win32", + "includePath": ["c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include", "src"], + "browse" : { + "limitSymbolsToIncludedHeaders" : true, + "databaseFilename" : "" + } + } + ] +} diff --git a/build/Lol (vs2015).sln b/build/Lol (vs2015).sln index 22c0ffe0..d24d0a1d 100644 --- a/build/Lol (vs2015).sln +++ b/build/Lol (vs2015).sln @@ -66,6 +66,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{B629 EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "15_lolimgui", "..\doc\tutorial\15_lolimgui.vcxproj", "{81C83B42-D00A-4FA3-9A3D-80F9D46524BF}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "14_lol_lua", "..\doc\tutorial\14_lol_lua.vcxproj", "{31B96262-1C41-43B9-BA38-27AA385B05DB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ORBIS = Debug|ORBIS @@ -308,6 +310,18 @@ Global {81C83B42-D00A-4FA3-9A3D-80F9D46524BF}.Release|Win32.Build.0 = Release|Win32 {81C83B42-D00A-4FA3-9A3D-80F9D46524BF}.Release|x64.ActiveCfg = Release|x64 {81C83B42-D00A-4FA3-9A3D-80F9D46524BF}.Release|x64.Build.0 = Release|x64 + {31B96262-1C41-43B9-BA38-27AA385B05DB}.Debug|ORBIS.ActiveCfg = Debug|ORBIS + {31B96262-1C41-43B9-BA38-27AA385B05DB}.Debug|ORBIS.Build.0 = Debug|ORBIS + {31B96262-1C41-43B9-BA38-27AA385B05DB}.Debug|Win32.ActiveCfg = Debug|Win32 + {31B96262-1C41-43B9-BA38-27AA385B05DB}.Debug|Win32.Build.0 = Debug|Win32 + {31B96262-1C41-43B9-BA38-27AA385B05DB}.Debug|x64.ActiveCfg = Debug|x64 + {31B96262-1C41-43B9-BA38-27AA385B05DB}.Debug|x64.Build.0 = Debug|x64 + {31B96262-1C41-43B9-BA38-27AA385B05DB}.Release|ORBIS.ActiveCfg = Release|ORBIS + {31B96262-1C41-43B9-BA38-27AA385B05DB}.Release|ORBIS.Build.0 = Release|ORBIS + {31B96262-1C41-43B9-BA38-27AA385B05DB}.Release|Win32.ActiveCfg = Release|Win32 + {31B96262-1C41-43B9-BA38-27AA385B05DB}.Release|Win32.Build.0 = Release|Win32 + {31B96262-1C41-43B9-BA38-27AA385B05DB}.Release|x64.ActiveCfg = Release|x64 + {31B96262-1C41-43B9-BA38-27AA385B05DB}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -341,5 +355,6 @@ Global {73F1A804-1116-46C3-922A-9C0ADEB33F52} = {4C4BD478-3767-4C27-BD91-DAAFE7CD03A2} {B6297FF2-63D0-41EE-BE13-EFF720C9B0FA} = {1AFD580B-98B8-4689-B661-38C41132C60E} {81C83B42-D00A-4FA3-9A3D-80F9D46524BF} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} + {31B96262-1C41-43B9-BA38-27AA385B05DB} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} EndGlobalSection EndGlobal diff --git a/doc/tutorial/14_lol_lua.cpp b/doc/tutorial/14_lol_lua.cpp index 653354c6..e9311ac3 100644 --- a/doc/tutorial/14_lol_lua.cpp +++ b/doc/tutorial/14_lol_lua.cpp @@ -37,18 +37,26 @@ public: //------------------------------------------------------------------------- static int AddFive(lua_State* l) { - LuaInt32 i; i.Get(l, 1); + LuaStack stack(l); + int32_t i = stack.GetVar(); + //LuaInt32 i; i.Get(l, 1); i += 5; - return i.Return(l); - } + //return i.Return(l); + return stack.SetVar(i).Return(); + } static int AddTenInstance(lua_State* l) { LuaStack stack(l); - LuaDemoObjectPtr obj; - LuaFloat f; - stack >> obj >> f; + DemoObject* obj = nullptr; // stack.GetPtr(); + float f = stack.GetVar(); + + //LuaDemoObjectPtr obj; + //LuaFloat f; + //stack >> obj >> f; f = obj->AddTenMethod(f); - return f.Return(l); + + //return f.Return(l); + return 0;// stack.SetVar(f).SetPtr().Return(); } float AddTenMethod(float f) { diff --git a/doc/tutorial/imgui.ini b/doc/tutorial/imgui.ini index c39d8823..f11877b3 100644 --- a/doc/tutorial/imgui.ini +++ b/doc/tutorial/imgui.ini @@ -4,12 +4,12 @@ Size=400,400 Collapsed=0 [testature] -Pos=266,15 +Pos=187,98 Size=494,359 Collapsed=0 [SO FUN !!] -Pos=30,24 +Pos=16,24 Size=113,99 Collapsed=0 diff --git a/src/lolua/baselua.h b/src/lolua/baselua.h index 54cc511b..aaf6cb84 100644 --- a/src/lolua/baselua.h +++ b/src/lolua/baselua.h @@ -883,6 +883,24 @@ public: return lua_gettop(m_state); } + //------------------------------------------------------------------------- + template + T GetVar(T defaultValue = 0, bool isOptional = false) + { + return Var(defaultValue, m_state, m_index, isOptional).GetValue(); + } + + //------------------------------------------------------------------------- + template + Stack& SetVar(T& value) + { + m_result += Var(value, m_state, m_index).Return(m_state); + return *this; + } + + //------------------------------------------------------------------------- + int32_t Return() { return m_result; } + //------------------------------------------------------------------------- template Stack& operator>>(T& var) @@ -891,42 +909,6 @@ public: return *this; } - /* - template - Stack& operator>>(Var& var) - { - var = Var(var.GetValue(), m_state, m_index, var.IsOptional()); - return *this; - } - template - Stack& operator>>(Var& var) - { - var = Var(var.GetValue(), m_state, m_index, var.IsOptional()); - return *this; - } - template - Stack& operator>>(VarPtr& var) - { - var = VarPtr(m_state, m_index); - return *this; - } - */ - /* - template - Stack& operator>>(T& var) - { - Var ret(m_state, m_index); - var = ret.GetValue(); - return *this; - } - template - Stack& operator>>(VarPtrLight& var) - { - var = VarPtrLight(m_state, m_index); - return *this; - } - */ - //------------------------------------------------------------------------- template Stack& operator<<(T& var) @@ -934,27 +916,6 @@ public: m_result += var.Return(m_state); return *this; } - /* - template - Stack& operator<<(T& var) - { - Var ret(var, false); - m_result += ret.Return(m_state); - return *this; - } - template - Stack& operator<<(VarPtr& var) - { - m_result += var.Return(m_state); - return *this; - } - template - Stack& operator<<(VarPtrLight& var) - { - m_result += var.Return(m_state); - return *this; - } - */ private: lua_State* m_state = nullptr;