예제 #1
0
 public ScriptValue(ScriptContext context, JSValue jsValue)
 {
     _context = context;
     _jsValue = jsValue;
     JSApi.JS_DupValue(context, jsValue);
     _context.GetObjectCache().AddScriptValue(_jsValue, this);
 }
예제 #2
0
 public ScriptPromise(ScriptContext context)
 {
     _context         = context;
     _resolving_funcs = new[] { JSApi.JS_UNDEFINED, JSApi.JS_UNDEFINED };
     _promise         = JSApi.JS_NewPromiseCapability(_context, _resolving_funcs);
     _context.GetObjectCache().AddScriptPromise(_promise, this);
 }
예제 #3
0
 public ScriptDelegate(ScriptContext context, JSValue jsValue)
 {
     _context = context;
     _jsValue = jsValue;
     JSApi.JS_DupValue(context, jsValue);
     // ScriptDelegate 拥有 js 对象的强引用, 此 js 对象无法释放 cache 中的 object, 所以这里用弱引用注册
     // 会出现的问题是, 如果 c# 没有对 ScriptDelegate 的强引用, 那么反复 get_delegate 会重复创建 ScriptDelegate
     _context.GetObjectCache().AddDelegate(_jsValue, this);
 }