diff --git a/Sample/Android/app/app.iml b/Sample/Android/app/app.iml
index a6c23401..0695fdfc 100644
--- a/Sample/Android/app/app.iml
+++ b/Sample/Android/app/app.iml
@@ -69,14 +69,6 @@
-
-
-
-
-
-
-
-
@@ -85,6 +77,14 @@
+
+
+
+
+
+
+
+
diff --git a/Source/lua-common/LuaDataExchanger.cpp b/Source/lua-common/LuaDataExchanger.cpp
index 69e8a431..ea0fbac7 100644
--- a/Source/lua-common/LuaDataExchanger.cpp
+++ b/Source/lua-common/LuaDataExchanger.cpp
@@ -317,6 +317,19 @@ void LuaDataExchanger::getLuaObject(LuaObject *object)
}
}
+void LuaDataExchanger::setLuaObject(int stackIndex, const std::string &linkId)
+{
+ lua_State *state = _context -> getLuaState();
+
+ beginGetVarsTable();
+
+ //放入对象到_vars_表中
+ lua_pushvalue(state, stackIndex);
+ lua_setfield(state, -2, linkId.c_str());
+
+ endGetVarsTable();
+}
+
void LuaDataExchanger::retainLuaObject(LuaObject *object)
{
if (object != NULL)
diff --git a/Source/lua-common/LuaDataExchanger.h b/Source/lua-common/LuaDataExchanger.h
index ac29cdd4..0e07edea 100644
--- a/Source/lua-common/LuaDataExchanger.h
+++ b/Source/lua-common/LuaDataExchanger.h
@@ -68,6 +68,14 @@ namespace cn {
*/
void getLuaObject(LuaObject *object);
+ /**
+ * 设置Lua对象
+ *
+ * @param stackIndex 栈索引
+ * @param linkId 连接标识
+ */
+ void setLuaObject(int stackIndex, const std::string &linkId);
+
/**
* 保留对象对应在Lua中的引用
*
diff --git a/Source/lua-common/LuaFunction.cpp b/Source/lua-common/LuaFunction.cpp
index 1f60ad02..b9d3f124 100644
--- a/Source/lua-common/LuaFunction.cpp
+++ b/Source/lua-common/LuaFunction.cpp
@@ -32,6 +32,8 @@ LuaFunction::LuaFunction(LuaContext *context, int index)
_context = context;
_linkId = StringUtils::format("%p", this);
+ _context -> getDataExchanger() -> setLuaObject(index, _linkId);
+
LuaValue *value = LuaValue::FunctionValue(this);
_context->retainValue(value);
value -> release();