Exemple #1
0
 internal JsContext(int id,
                    JsEngine engine,
                    Action <int> notifyDispose,
                    JsTypeDefinitionBuilder jsTypeDefBuilder)
     : this(id, engine, notifyDispose, jscontext_new(id, engine.UnmanagedEngineHandler), jsTypeDefBuilder)
 {
 }
Exemple #2
0
        public JsEngine(IntPtr nativeJsEnginePtr,
            JsTypeDefinitionBuilder defaultTypeBuilder)
        {
            //native js engine is created from native side
            //for this managed object
            //so we add more managed function to handle
            _keepalive_remove = new KeepaliveRemoveDelegate(KeepAliveRemove);
            _keepalive_get_property_value = new KeepAliveGetPropertyValueDelegate(KeepAliveGetPropertyValue);
            _keepalive_set_property_value = new KeepAliveSetPropertyValueDelegate(KeepAliveSetPropertyValue);
            _keepalive_valueof = new KeepAliveValueOfDelegate(KeepAliveValueOf);
            _keepalive_invoke = new KeepAliveInvokeDelegate(KeepAliveInvoke);
            _keepalive_delete_property = new KeepAliveDeletePropertyDelegate(KeepAliveDeleteProperty);
            _keepalive_enumerate_properties = new KeepAliveEnumeratePropertiesDelegate(KeepAliveEnumerateProperties);

            jsengine_registerManagedDels(
                nativeJsEnginePtr,
                _keepalive_remove,
                _keepalive_get_property_value,
                _keepalive_set_property_value,
                _keepalive_valueof,
                _keepalive_invoke,
                _keepalive_delete_property,
                _keepalive_enumerate_properties
                );
            _engine = new HandleRef(this, nativeJsEnginePtr);
            this.defaultTypeBuilder = defaultTypeBuilder;
        }
Exemple #3
0
        public JsEngine(IntPtr nativeJsEnginePtr,
                        JsTypeDefinitionBuilder defaultTypeBuilder)
        {
            //native js engine is created from native side
            //for this managed object
            //so we add more managed function to handle
            _keepalive_remove               = new KeepaliveRemoveDelegate(KeepAliveRemove);
            _keepalive_get_property_value   = new KeepAliveGetPropertyValueDelegate(KeepAliveGetPropertyValue);
            _keepalive_set_property_value   = new KeepAliveSetPropertyValueDelegate(KeepAliveSetPropertyValue);
            _keepalive_valueof              = new KeepAliveValueOfDelegate(KeepAliveValueOf);
            _keepalive_invoke               = new KeepAliveInvokeDelegate(KeepAliveInvoke);
            _keepalive_delete_property      = new KeepAliveDeletePropertyDelegate(KeepAliveDeleteProperty);
            _keepalive_enumerate_properties = new KeepAliveEnumeratePropertiesDelegate(KeepAliveEnumerateProperties);

            jsengine_registerManagedDels(
                nativeJsEnginePtr,
                _keepalive_remove,
                _keepalive_get_property_value,
                _keepalive_set_property_value,
                _keepalive_valueof,
                _keepalive_invoke,
                _keepalive_delete_property,
                _keepalive_enumerate_properties
                );
            _engine = new HandleRef(this, nativeJsEnginePtr);
            this.defaultTypeBuilder = defaultTypeBuilder;
        }
Exemple #4
0
        public JsContext CreateContext(JsTypeDefinitionBuilder customTypeDefBuilder)
        {
            CheckDisposed();
            //
            int       id  = Interlocked.Increment(ref _currentContextId);
            JsContext ctx = new JsContext(id, this, ContextDisposed, customTypeDefBuilder);

            _aliveContexts.Add(id, ctx);
            return(ctx);
        }
Exemple #5
0
        public JsContext CreateContext(IntPtr nativeJsContext, JsTypeDefinitionBuilder typedefBuilder = null)
        {
            CheckDisposed();
            //
            int       id  = Interlocked.Increment(ref _currentContextId);
            JsContext ctx = new JsContext(id, this, ContextDisposed, nativeJsContext, typedefBuilder ?? _defaultTypeBuilder);

            ctx.IsFromNativeContext = true;
            _aliveContexts.Add(id, ctx);
            return(ctx);
        }
Exemple #6
0
        public JsEngine(JsTypeDefinitionBuilder defaultTypeBuilder, int maxYoungSpace, int maxOldSpace)
        {
            _keepalive_remove               = new KeepaliveRemoveDelegate(KeepAliveRemove);
            _keepalive_get_property_value   = new KeepAliveGetPropertyValueDelegate(KeepAliveGetPropertyValue);
            _keepalive_set_property_value   = new KeepAliveSetPropertyValueDelegate(KeepAliveSetPropertyValue);
            _keepalive_valueof              = new KeepAliveValueOfDelegate(KeepAliveValueOf);
            _keepalive_invoke               = new KeepAliveInvokeDelegate(KeepAliveInvoke);
            _keepalive_delete_property      = new KeepAliveDeletePropertyDelegate(KeepAliveDeleteProperty);
            _keepalive_enumerate_properties = new KeepAliveEnumeratePropertiesDelegate(KeepAliveEnumerateProperties);

            _engine = new HandleRef(this, jsengine_new(
                                        _keepalive_remove,
                                        _keepalive_get_property_value,
                                        _keepalive_set_property_value,
                                        _keepalive_valueof,
                                        _keepalive_invoke,
                                        _keepalive_delete_property,
                                        _keepalive_enumerate_properties,
                                        maxYoungSpace,
                                        maxOldSpace));
            this.defaultTypeBuilder = defaultTypeBuilder;
        }
Exemple #7
0
        public JsEngine(JsTypeDefinitionBuilder defaultTypeBuilder, int maxYoungSpace, int maxOldSpace)
        {
            _keepalive_remove = new KeepaliveRemoveDelegate(KeepAliveRemove);
            _keepalive_get_property_value = new KeepAliveGetPropertyValueDelegate(KeepAliveGetPropertyValue);
            _keepalive_set_property_value = new KeepAliveSetPropertyValueDelegate(KeepAliveSetPropertyValue);
            _keepalive_valueof = new KeepAliveValueOfDelegate(KeepAliveValueOf);
            _keepalive_invoke = new KeepAliveInvokeDelegate(KeepAliveInvoke);
            _keepalive_delete_property = new KeepAliveDeletePropertyDelegate(KeepAliveDeleteProperty);
            _keepalive_enumerate_properties = new KeepAliveEnumeratePropertiesDelegate(KeepAliveEnumerateProperties);

            _engine = new HandleRef(this, jsengine_new(
                _keepalive_remove,
                _keepalive_get_property_value,
                _keepalive_set_property_value,
                _keepalive_valueof,
                _keepalive_invoke,
                _keepalive_delete_property,
                _keepalive_enumerate_properties,
                maxYoungSpace,
                maxOldSpace));
            this.defaultTypeBuilder = defaultTypeBuilder;
        }
Exemple #8
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);
        }
Exemple #9
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);
        }
Exemple #10
0
 public static void SetDefaultJsTypeDefinitionBuilder(JsTypeDefinitionBuilder jstypedefBuilder)
 {
     s_jsTypeDefBuilder = jstypedefBuilder;
 }
Exemple #11
0
        public JsContext CreateContext(JsTypeDefinitionBuilder customTypeDefBuilder)
        {
            CheckDisposed();
            int id = Interlocked.Increment(ref _currentContextId);

            JsContext ctx = new JsContext(id, this, ContextDisposed, customTypeDefBuilder);

            _aliveContexts.Add(id, ctx);
            return ctx;
        }