Пример #1
0
 public static void RegisterCallBacks()
 {
     //------------------
     //built in listener
     //------------------
     NativeV8JsInterOp.RegisterManagedListener(engineListenerDel);
 }
Пример #2
0
        public void SetResultAutoWrap <T>(T result)
            where T : class, new()
        {
            var jsTypeDef = this.context.GetJsTypeDefinition <T>(result);
            var proxy     = this.context.CreateWrapper(result, jsTypeDef);

            NativeV8JsInterOp.ResultSetJsValue(metArgsPtr,
                                               this.context.Converter.ToJsValue(proxy));
        }
Пример #3
0
        public void Dispose()
        {
            int j = nativeRefList.Count;

            for (int i = nativeRefList.Count - 1; i > -1; --i)
            {
                NativeV8JsInterOp.UnRegisterNativePart(nativeRefList[i]);
            }
            nativeRefList.Clear();
        }
Пример #4
0
        public static void LoadV8(string v8bridgeDll)
        {
            IntPtr v8mod = UnsafeNativeMethods.LoadLibrary(v8bridgeDll);

            hModuleV8 = v8mod;
            if (v8mod == IntPtr.Zero)
            {
                return;
            }
            NativeV8JsInterOp.V8Init();
        }
Пример #5
0
        public INativeRef CreateProxyForTypeDefinition(JsTypeDefinition jsTypeDefinition)
        {
            var proxyObject = new NativeRef(nativeRefList.Count, jsTypeDefinition);

            //store data this side too
            jsTypeDefinition.nativeProxy = proxyObject;
            //store in exported list
            nativeRefList.Add(proxyObject);
            //register type definition
            NativeV8JsInterOp.RegisterTypeDef(ownerContext, jsTypeDefinition);
            return(proxyObject);
        }
Пример #6
0
        public void SetResultObj(object result, JsTypeDefinition jsTypeDef)
        {
            if (!jsTypeDef.IsRegisterd)
            {
                this.context.RegisterTypeDefinition(jsTypeDef);
            }

            var proxy = this.context.CreateWrapper(result, jsTypeDef);

            NativeV8JsInterOp.ResultSetJsValue(metArgsPtr,
                                               this.context.Converter.ToJsValue(proxy));
        }
Пример #7
0
        public NativeJsInstanceProxy CreateProxyForObject(object o, JsTypeDefinition jsTypeDefinition)
        {
            NativeJsInstanceProxy found;

            if (this.createdWrappers.TryGetValue(o, out found))
            {
                return(found);
            }

            var proxyObject = new NativeJsInstanceProxy(
                nativeRefList.Count,
                o,
                jsTypeDefinition);

            nativeRefList.Add(proxyObject);
            this.createdWrappers.Add(o, proxyObject);

            //register
            NativeV8JsInterOp.CreateNativePart(ownerContext, proxyObject);
            return(proxyObject);
        }
Пример #8
0
        internal JsContext(int id,
                           JsEngine engine,
                           HandleRef engineHandle,
                           Action <int> notifyDispose,
                           JsTypeDefinitionBuilder jsTypeDefBuilder)
        {
            _id            = id;
            _engine        = engine;
            _notifyDispose = notifyDispose;

            _keepalives = new KeepAliveDictionaryStore();
            _context    = new HandleRef(this, jscontext_new(id, engineHandle));
            _convert    = new JsConvert(this);

            this.jsTypeDefBuilder = jsTypeDefBuilder;

            engineMethodCallbackDel = new ManagedMethodCallDel(EngineListener_MethodCall);
            NativeV8JsInterOp.CtxRegisterManagedMethodCall(this, engineMethodCallbackDel);
            registerMethods.Add(null);    //first is null
            registerProperties.Add(null); //first is null


            proxyStore = new NativeObjectProxyStore(this);
        }
Пример #9
0
 //--------------------------------------------------------------------
 public void SetResult(bool value)
 {
     NativeV8JsInterOp.ResultSetBool(metArgsPtr, value);
 }
Пример #10
0
 public static void V8Init()
 {
     NativeV8JsInterOp.V8Init();
 }
Пример #11
0
 public void SetResultObj(object result)
 {
     NativeV8JsInterOp.ResultSetJsValue(metArgsPtr,
                                        this.context.Converter.AnyToJsValue(result));
 }
Пример #12
0
 public void SetResultUndefined()
 {
     NativeV8JsInterOp.ResultSetJsValue(metArgsPtr, JsValue.Empty);
 }
Пример #13
0
 public void SetResultNull()
 {
     NativeV8JsInterOp.ResultSetJsValue(metArgsPtr, JsValue.Null);
 }
Пример #14
0
 public void SetResult(float value)
 {
     NativeV8JsInterOp.ResultSetFloat(metArgsPtr, value);
 }
Пример #15
0
 public void SetResult(double value)
 {
     NativeV8JsInterOp.ResultSetDouble(metArgsPtr, value);
 }
Пример #16
0
 public void SetResult(string value)
 {
     NativeV8JsInterOp.ResultSetString(metArgsPtr, value);
 }
Пример #17
0
 public void SetResult(int value)
 {
     NativeV8JsInterOp.ResultSetInt32(metArgsPtr, value);
 }
Пример #18
0
        //---------------------------------------------
#if DEBUG
        public static void dbugTestCallbacks()
        {
            NativeV8JsInterOp.RegisterCallBacks();
            NativeV8JsInterOp.TestCallBack();
        }
Пример #19
0
        public object GetArgAsObject(int index)
        {
            var value = NativeV8JsInterOp.ArgGetObject(this.metArgsPtr, index);

            return(this.context.Converter.FromJsValue(value));
        }
Пример #20
0
        public object GetThisArg()
        {
            var value = NativeV8JsInterOp.ArgGetThis(this.metArgsPtr);

            return(this.context.Converter.FromJsValue(value));
        }