-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2、增加LuaManagedValue,用于管理Lua对象在原生层的生命周期。 Former-commit-id: 81f41c0f87bddfc576f23b267d2fbbe2247002e7
- Loading branch information
Showing
7 changed files
with
88 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
Source/Android/luascriptcore/src/main/java/cn/vimfung/luascriptcore/LuaManagedValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package cn.vimfung.luascriptcore; | ||
|
||
import android.util.Log; | ||
|
||
/** | ||
* 管理值对象,用于将LuaValue的值所指向的Lua对象生命周期维持在LuaManagedValue释放后进行。 | ||
* Created by vimfung on 2017/5/24. | ||
*/ | ||
public class LuaManagedValue extends LuaBaseObject | ||
{ | ||
private LuaValue _source; | ||
private LuaContext _context; | ||
|
||
/** | ||
* 初始化对象 | ||
* @param value 原始值对象 | ||
* @param context 上下文对象 | ||
*/ | ||
public LuaManagedValue(LuaValue value, LuaContext context) | ||
{ | ||
_source = value; | ||
_context = context; | ||
|
||
context.retainValue(_source); | ||
} | ||
|
||
/** | ||
* 获取源值 | ||
* @return 值对象 | ||
*/ | ||
public LuaValue getSource() | ||
{ | ||
return _source; | ||
} | ||
|
||
@Override | ||
protected void finalize() throws Throwable | ||
{ | ||
_context.releaseValue(_source); | ||
super.finalize(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters