Exemplo n.º 1
0
        public DuktapeThread(DuktapeFunction fn)
        {
            var ctx = fn.ctx;
            var vm  = DuktapeVM.GetContext(ctx).vm;
            var idx = DuktapeDLL.duk_push_thread(ctx);

            DuktapeDLL.duk_dup(ctx, -1);
            var ptr = DuktapeDLL.duk_get_heapptr(ctx, -1);

            _thread        = new DuktapeValue(ctx, DuktapeDLL.duk_unity_ref(ctx), ptr);
            _threadContext = new DuktapeContext(vm, DuktapeDLL.duk_get_context(ctx, idx));
            if (fn.Push(_threadContext.rawValue))
            {
            }

            DuktapeDLL.duk_pop(ctx);
        }
Exemplo n.º 2
0
 // 记录栈状态
 public void BeginInvoke(IntPtr ctx)
 {
     // Debug.Log($"BeginInvoke: {_savedState}");
     if (_jsInvoker == null)
     {
         this.Push(ctx); // push this
         if (!DuktapeDLL.duk_is_function(ctx, -1))
         {
             // Debug.Log("DuktapeDelegate based on Dispatcher");
             DuktapeDLL.duk_get_prop_string(ctx, -1, "dispatch");
             DuktapeDLL.duk_remove(ctx, -2); // remove this
         }
         _jsInvoker = new DuktapeFunction(ctx, DuktapeDLL.duk_unity_ref(ctx));
     }
     _jsInvoker.Push(ctx); // push function
     this.Push(ctx);       // push this
     _savedState = DuktapeDLL.duk_get_top(ctx);
 }