Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
东方怂天
xLua
提交
994bea5a
X
xLua
项目概览
东方怂天
/
xLua
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
xLua
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
994bea5a
编写于
11月 28, 2017
作者:
J
johnche(车雄生)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加xlua.release,用于主动解除lua对c#某对象的引用
上级
38e26cad
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
2 deletion
+29
-2
Assets/XLua/Src/ObjectTranslator.cs
Assets/XLua/Src/ObjectTranslator.cs
+12
-0
Assets/XLua/Src/StaticLuaCallbacks.cs
Assets/XLua/Src/StaticLuaCallbacks.cs
+17
-2
未找到文件。
Assets/XLua/Src/ObjectTranslator.cs
浏览文件 @
994bea5a
...
...
@@ -569,6 +569,9 @@ namespace XLua
LuaAPI
.
xlua_pushasciistring
(
L
,
"tofunction"
);
LuaAPI
.
lua_pushstdcallcfunction
(
L
,
StaticLuaCallbacks
.
ToFunction
);
LuaAPI
.
lua_rawset
(
L
,
-
3
);
LuaAPI
.
xlua_pushasciistring
(
L
,
"release"
);
LuaAPI
.
lua_pushstdcallcfunction
(
L
,
StaticLuaCallbacks
.
ReleaseCsObject
);
LuaAPI
.
lua_rawset
(
L
,
-
3
);
LuaAPI
.
lua_pop
(
L
,
1
);
LuaAPI
.
lua_createtable
(
L
,
1
,
4
);
// 4 for __gc, __tostring, __index, __newindex
...
...
@@ -1217,6 +1220,15 @@ namespace XLua
return
getCsObj
(
L
,
index
,
LuaAPI
.
xlua_tocsobj_fast
(
L
,
index
));
}
internal
void
ReleaseCSObj
(
RealStatePtr
L
,
int
index
)
{
int
udata
=
LuaAPI
.
xlua_tocsobj_safe
(
L
,
index
);
if
(
udata
!=
-
1
)
{
objects
.
Replace
(
udata
,
null
);
}
}
List
<
LuaCSFunction
>
fix_cs_functions
=
new
List
<
LuaCSFunction
>();
internal
LuaCSFunction
GetFixCSFunction
(
int
index
)
...
...
Assets/XLua/Src/StaticLuaCallbacks.cs
浏览文件 @
994bea5a
...
...
@@ -29,7 +29,7 @@ namespace XLua
internal
LuaCSFunction
StaticCSFunctionWraper
,
FixCSFunctionWraper
;
internal
LuaCSFunction
DelegateCtor
;
public
StaticLuaCallbacks
()
{
GcMeta
=
new
LuaCSFunction
(
StaticLuaCallbacks
.
LuaGC
);
...
...
@@ -94,7 +94,7 @@ namespace XLua
LuaCSFunction
func
=
(
LuaCSFunction
)
translator
.
FastGetCSObj
(
L
,
LuaAPI
.
xlua_upvalueindex
(
1
));
return
func
(
L
);
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
return
LuaAPI
.
luaL_error
(
L
,
"c# exception in StaticCSFunction:"
+
e
);
}
...
...
@@ -1079,5 +1079,20 @@ namespace XLua
return
LuaAPI
.
luaL_error
(
L
,
"c# exception in ToFunction: "
+
e
);
}
}
[
MonoPInvokeCallback
(
typeof
(
LuaCSFunction
))]
public
static
int
ReleaseCsObject
(
RealStatePtr
L
)
{
try
{
ObjectTranslator
translator
=
ObjectTranslatorPool
.
Instance
.
Find
(
L
);
translator
.
ReleaseCSObj
(
L
,
1
);
return
0
;
}
catch
(
Exception
e
)
{
return
LuaAPI
.
luaL_error
(
L
,
"c# exception in ReleaseCsObject: "
+
e
);
}
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录