summaryrefslogtreecommitdiffstats
path: root/src/Bindings
diff options
context:
space:
mode:
Diffstat (limited to 'src/Bindings')
-rw-r--r--src/Bindings/LuaState.cpp14
-rw-r--r--src/Bindings/LuaState.h7
-rw-r--r--src/Bindings/PluginLua.cpp1
3 files changed, 16 insertions, 6 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index aa6ee05b3..dfc428bbc 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -94,12 +94,20 @@ void cLuaState::Create(void)
}
m_LuaState = lua_open();
luaL_openlibs(m_LuaState);
+ m_IsOwned = true;
+}
+
+
+
+
+
+void cLuaState::RegisterAPILibs(void)
+{
tolua_AllToLua_open(m_LuaState);
ManualBindings::Bind(m_LuaState);
DeprecatedBindings::Bind(m_LuaState);
luaopen_lsqlite3(m_LuaState);
luaopen_lxp(m_LuaState);
- m_IsOwned = true;
}
@@ -734,10 +742,6 @@ void cLuaState::GetStackValue(int a_StackPos, AString & a_Value)
{
a_Value.assign(data, len);
}
- else
- {
- a_Value.clear();
- }
}
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h
index 1156f5363..73f9629cb 100644
--- a/src/Bindings/LuaState.h
+++ b/src/Bindings/LuaState.h
@@ -140,9 +140,14 @@ public:
/** Allows this object to be used in the same way as a lua_State *, for example in the LuaLib functions */
operator lua_State * (void) { return m_LuaState; }
- /** Creates the m_LuaState, if not closed already. This state will be automatically closed in the destructor */
+ /** Creates the m_LuaState, if not closed already. This state will be automatically closed in the destructor.
+ The regular Lua libs are registered, but the MCS API is not registered (so that Lua can be used as
+ lite-config as well), use RegisterAPILibs() to do that. */
void Create(void);
+ /** Registers all the API libraries that MCS provides into m_LuaState. */
+ void RegisterAPILibs(void);
+
/** Closes the m_LuaState, if not closed already */
void Close(void);
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 45c8216be..cccbc3c93 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -75,6 +75,7 @@ bool cPluginLua::Initialize(void)
if (!m_LuaState.IsValid())
{
m_LuaState.Create();
+ m_LuaState.RegisterAPILibs();
// Inject the identification global variables into the state:
lua_pushlightuserdata(m_LuaState, this);