예제 #1
0
        public object GetArgAsObject(int index)
        {
            JsValue output = new JsValue();

            NativeV8JsInterOp.ArgGetObject(this.metArgsPtr, index, ref output);
            return(this.context.Converter.FromJsValue(ref output));
        }
예제 #2
0
        public void SetResultObj(object result)
        {
            JsValue output = new JsValue();

            this.context.Converter.AnyToJsValue(result, ref output);
            NativeV8JsInterOp.ResultSetValue(metArgsPtr, ref output);
        }
예제 #3
0
        public object GetThisArg()
        {
            JsValue output = new JsValue();

            NativeV8JsInterOp.ArgGetThis(this.metArgsPtr, ref output);
            return(this.context.Converter.FromJsValue(ref output));
        }
예제 #4
0
 public static void RegisterCallBacks()
 {
     //------------------
     //built in listener
     //------------------
     NativeV8JsInterOp.RegisterManagedListener(engineListenerDel);
 }
예제 #5
0
        public void SetResultAutoWrap <T>(T result)
            where T : class, new()
        {
            Type actualType = result.GetType();
            var  jsTypeDef  = this.context.GetJsTypeDefinition(actualType);
            var  proxy      = this.context.CreateWrapper(result, jsTypeDef);

            NativeV8JsInterOp.ResultSetJsValue(metArgsPtr,
                                               this.context.Converter.ToJsValue(proxy));
        }
예제 #6
0
        public void Dispose()
        {
            int j = nativeRefList.Count;

            for (int i = nativeRefList.Count - 1; i > -1; --i)
            {
                NativeV8JsInterOp.UnRegisterNativePart(nativeRefList[i]);
            }
            nativeRefList.Clear();
        }
예제 #7
0
        public void SetResultAutoWrap <T>(T result)
            where T : class, new()
        {
            Type              actualType = result.GetType();
            JsTypeDefinition  jsTypeDef  = this.context.GetJsTypeDefinition(actualType);
            INativeScriptable proxy      = this.context.CreateWrapper(result, jsTypeDef);
            JsValue           output     = new JsValue();

            this.context.Converter.ToJsValue(proxy, ref output);
            NativeV8JsInterOp.ResultSetValue(metArgsPtr, ref output);
        }
예제 #8
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));
        }
예제 #9
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);
        }
예제 #10
0
        public void SetResultObj(object result, JsTypeDefinition jsTypeDef)
        {
            if (!jsTypeDef.IsRegisterd)
            {
                this.context.RegisterTypeDefinition(jsTypeDef);
            }

            INativeScriptable proxy  = this.context.CreateWrapper(result, jsTypeDef);
            JsValue           output = new JsValue();

            this.context.Converter.ToJsValue(proxy, ref output);
            NativeV8JsInterOp.ResultSetValue(metArgsPtr, ref output);
        }
예제 #11
0
        public static void LoadV8(string dllfile, bool doV8Init = true)
        {
            hModuleV8 = LoadLibrary(dllfile);
            if (hModuleV8 == IntPtr.Zero)
            {
                return;
            }

            //-------------------
            if (doV8Init)
            {
                //sometime we set to false , and  let underlying lib init the v8 engine.
                NativeV8JsInterOp.V8Init();
            }
        }
예제 #12
0
        public NativeJsInstanceProxy CreateProxyForObject(object o, JsTypeDefinition jsTypeDefinition)
        {
            if (_createdWrappers.TryGetValue(o, out NativeJsInstanceProxy found))
            {
                return(found);
            }

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

            _nativeRefList.Add(proxyObject);
            _createdWrappers.Add(o, proxyObject);

            //register
            NativeV8JsInterOp.CreateNativePart(_ownerContext, proxyObject);
            return(proxyObject);
        }
예제 #13
0
        internal JsContext(int id,
                           JsEngine engine,
                           Action <int> notifyDispose,
                           JsTypeDefinitionBuilder jsTypeDefBuilder)
        {
            _id            = id;
            _notifyDispose = notifyDispose;
            _engine        = engine;
            _keepalives    = new KeepAliveDictionaryStore();
            //create native js context
            _context = new HandleRef(this, jscontext_new(id, engine.UnmanagedEngineHandler));
            _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);
        }
예제 #14
0
        internal JsContext(int id,
                           JsEngine engine,
                           Action <int> notifyDispose,
                           IntPtr nativeJsContext,
                           JsTypeDefinitionBuilder jsTypeDefBuilder)
        {
            //constructor setup
            _id            = id;
            _notifyDispose = notifyDispose;
            _engine        = engine;
            _keepalives    = new KeepAliveDictionaryStore();
            //create native js context
            _context = new HandleRef(this, nativeJsContext);
            _convert = new JsConvert(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);
        }
예제 #15
0
 public void SetResult(int value)
 {
     NativeV8JsInterOp.ResultSetInt32(metArgsPtr, value);
 }
예제 #16
0
 public void SetResultNull()
 {
     NativeV8JsInterOp.ResultSetJsValue(metArgsPtr, JsValue.Null);
 }
예제 #17
0
 public void SetResultUndefined()
 {
     NativeV8JsInterOp.ResultSetJsValue(metArgsPtr, JsValue.Empty);
 }
예제 #18
0
 public void SetResultUndefined()
 {
     //TODO: review here again
     NativeV8JsInterOp.ResultSetJsVoid(metArgsPtr);
 }
예제 #19
0
 public void SetResultNull()
 {
     NativeV8JsInterOp.ResultSetJsNull(metArgsPtr);
 }
예제 #20
0
 public void SetResult(float value)
 {
     NativeV8JsInterOp.ResultSetFloat(metArgsPtr, value);
 }
예제 #21
0
        public object GetArgAsObject(int index)
        {
            var value = NativeV8JsInterOp.ArgGetObject(this.metArgsPtr, index);

            return(this.context.Converter.FromJsValue(value));
        }
예제 #22
0
 public static void V8Init()
 {
     NativeV8JsInterOp.V8Init();
 }
예제 #23
0
 public void SetResultObj(object result)
 {
     NativeV8JsInterOp.ResultSetJsValue(metArgsPtr,
                                        this.context.Converter.AnyToJsValue(result));
 }
예제 #24
0
 //--------------------------------------------------------------------
 public void SetResult(bool value)
 {
     NativeV8JsInterOp.ResultSetBool(metArgsPtr, value);
 }
예제 #25
0
 public void SetResult(string value)
 {
     NativeV8JsInterOp.ResultSetString(metArgsPtr, value);
 }
예제 #26
0
 public void SetResult(double value)
 {
     NativeV8JsInterOp.ResultSetDouble(metArgsPtr, value);
 }
예제 #27
0
 public static void dbugTestCallbacks()
 {
     NativeV8JsInterOp.RegisterCallBacks();
     NativeV8JsInterOp.TestCallBack();
 }
예제 #28
0
        public object GetThisArg()
        {
            var value = NativeV8JsInterOp.ArgGetThis(this.metArgsPtr);

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