public static extern void RegisterNamedPropertyHandlers32(NativeObjectTemplateProxy *proxy,

                                                                  ManagedNamedPropertyGetter getter,
                                                                  ManagedNamedPropertySetter setter,
                                                                  ManagedNamedPropertyQuery query,
                                                                  ManagedNamedPropertyDeleter deleter,
                                                                  ManagedNamedPropertyEnumerator enumerator);
Beispiel #2
0
        public override void Dispose() // (note: This can cause issues if removed while the native object exists [because of the callbacks].)
        {
            if (_NativeObjectTemplateProxy != null && CanDispose)
            {
                _Engine._ClearAccessors(_NativeObjectTemplateProxy->ObjectID);

                V8NetProxy.DeleteObjectTemplateProxy(_NativeObjectTemplateProxy); // (delete the corresponding native object as well; WARNING: This is done on the GC thread!)

                _NativeObjectTemplateProxy = null;
            }
        }
Beispiel #3
0
        public void Dispose() // TODO: !!! This will cause issues if removed while the native object exists. !!!
        {
            if (_NativeObjectTemplateProxy != null)
            {
                _Engine._ClearAccessors(_NativeObjectTemplateProxy->ObjectID);

                V8NetProxy.DeleteObjectTemplateProxy(_NativeObjectTemplateProxy); // (delete the corresponding native object as well; WARNING: This is done on the GC thread!)
                _NativeObjectTemplateProxy = null;
            }

            ((IFinalizable)this).CanFinalize = true;
        }
Beispiel #4
0
 protected override bool _Finalize(bool finalizer) // (note: This can cause issues if removed while the native object exists [because of the callbacks].)
 {
     if (_NativeObjectTemplateProxy != null)
     {
         if (V8NetProxy.DeleteObjectTemplateProxy(_NativeObjectTemplateProxy)) // (delete the corresponding native object as well; WARNING: This may be done on the GC thread!)
         {
             _NativeObjectTemplateProxy = null;
         }
         else
         {
             return(false); // (bounced, a script might be in progress; try again later)
         }
     }
     return(true);
 }
Beispiel #5
0
        internal void _Initialize(V8Engine v8EngineProxy, NativeObjectTemplateProxy *nativeObjectTemplateProxy, bool registerPropertyInterceptors = true)
        {
            if (v8EngineProxy == null)
            {
                throw new ArgumentNullException("v8EngineProxy");
            }

            if (nativeObjectTemplateProxy == null)
            {
                throw new ArgumentNullException("nativeObjectTemplateProxy");
            }

            _Engine = v8EngineProxy;

            _NativeObjectTemplateProxy = nativeObjectTemplateProxy;

            if (registerPropertyInterceptors)
            {
                RegisterNamedPropertyInterceptors();
                RegisterIndexedPropertyInterceptors();
            }

            OnInitialized();
        }
Beispiel #6
0
 public static unsafe extern HandleProxy *CreateObjectFromTemplate(NativeObjectTemplateProxy *objectTemplateProxy, Int32 objID);
Beispiel #7
0
 public static extern void RegisterInvokeHandler(NativeObjectTemplateProxy *proxy, ManagedJSFunctionCallback callback);
Beispiel #8
0
 public static extern void UnregisterIndexedPropertyHandlers(NativeObjectTemplateProxy *proxy);
Beispiel #9
0
 public static unsafe extern HandleProxy *SetGlobalObjectTemplate(NativeV8EngineProxy *engine, NativeObjectTemplateProxy *proxy);
Beispiel #10
0
 public static extern unsafe void DeleteObjectTemplateProxy(NativeObjectTemplateProxy *objectTemplateProxy);
        /// <summary>
        /// If there's any marshalling incompatibility, this will throw an exception.
        /// </summary>
        public void RunMarshallingTests()
        {
            HandleProxy *                hp    = V8NetProxy.CreateHandleProxyTest();
            NativeV8EngineProxy *        nv8ep = V8NetProxy.CreateV8EngineProxyTest();
            NativeObjectTemplateProxy *  notp  = V8NetProxy.CreateObjectTemplateProxyTest();
            NativeFunctionTemplateProxy *nftp  = V8NetProxy.CreateFunctionTemplateProxyTest();

            byte[] data;
            byte   ofs = 0; // (skip type)

            try
            {
                ofs = (byte)((int)&hp->NativeClassType - (int)hp);
                if (hp->NativeClassType != ProxyObjectType.HandleProxyClass)
                {
                    _ThrowMarshalTestError("HandleProxy", "NativeClassType", ofs, null, (byte *)&hp->NativeClassType, 4);
                }
                ofs = (byte)((int)&hp->ID - (int)hp);
                if ((Int32)hp->ID != _GetMarshalTestInt32Value(ofs, out data))
                {
                    _ThrowMarshalTestError("HandleProxy", "ID", ofs, data, (byte *)&hp->ID);
                }
                ofs = (byte)((int)&hp->_ObjectID - (int)hp);
                if ((Int32)hp->_ObjectID != _GetMarshalTestInt32Value(ofs, out data))
                {
                    _ThrowMarshalTestError("HandleProxy", "_ObjectID", ofs, data, (byte *)&hp->_ObjectID);
                }
                ofs = (byte)((int)&hp->_CLRTypeID - (int)hp);
                if ((Int32)hp->_CLRTypeID != _GetMarshalTestInt32Value(ofs, out data))
                {
                    _ThrowMarshalTestError("HandleProxy", "_CLRTypeID", ofs, data, (byte *)&hp->_CLRTypeID);
                }
                ofs = (byte)((int)&hp->_Type - (int)hp);
                if ((Int32)hp->_Type != _GetMarshalTestInt32Value(ofs, out data))
                {
                    _ThrowMarshalTestError("HandleProxy", "_ValueType", ofs, data, (byte *)&hp->_Type);
                }
                // region ### HANDLE VALUE ### - Note: This is only valid upon calling 'UpdateValue()'.
                ofs = (byte)((int)&hp->V8Boolean - (int)hp);
                if ((byte)hp->V8Boolean != _GetMarshalTestByteValue(ofs, out data))
                {
                    _ThrowMarshalTestError("HandleProxy", "V8Boolean", ofs, data, (byte *)&hp->V8Boolean);
                }
                if ((Int64)hp->V8Integer != _GetMarshalTestInt64Value(ofs, out data))
                {
                    _ThrowMarshalTestError("HandleProxy", "V8Integer", ofs, data, (byte *)&hp->V8Integer);
                }
                if ((double)hp->V8Number != _GetMarshalTestDoubleValue(ofs, out data))
                {
                    _ThrowMarshalTestError("HandleProxy", "V8Number", ofs, data, (byte *)&hp->V8Number);
                }
                ofs = (byte)((int)&hp->V8String - (int)hp);
                if ((Int64)hp->V8String != _GetMarshalTestPTRValue(ofs, out data))
                {
                    _ThrowMarshalTestError("HandleProxy", "V8String", ofs, data, (byte *)&hp->V8String);
                }
                // endregion
                ofs = (byte)((int)&hp->ManagedReference - (int)hp);
                if ((Int64)hp->ManagedReference != _GetMarshalTestInt32Value(ofs, out data))
                {
                    _ThrowMarshalTestError("HandleProxy", "ManagedReference", ofs, data, (byte *)&hp->ManagedReference);                                                                         // The number of references on the managed side.
                }
                ofs = (byte)((int)&hp->Disposed - (int)hp);
                if ((Int32)hp->Disposed != _GetMarshalTestInt32Value(ofs, out data))
                {
                    _ThrowMarshalTestError("HandleProxy", "Disposed", ofs, data, (byte *)&hp->Disposed);                                                                 // (0 = in use, 1 = managed side ready to dispose, 2 = object is weak (if applicable), 3 = disposed/cached)
                }
                ofs = (byte)((int)&hp->EngineID - (int)hp);
                if ((Int32)hp->EngineID != _GetMarshalTestInt32Value(ofs, out data))
                {
                    _ThrowMarshalTestError("HandleProxy", "EngineID", ofs, data, (byte *)&hp->EngineID);
                }
                ofs = (byte)((int)&hp->NativeEngineProxy - (int)hp);
                if ((Int64)hp->NativeEngineProxy != _GetMarshalTestPTRValue(ofs, out data))
                {
                    _ThrowMarshalTestError("HandleProxy", "NativeEngineProxy", ofs, data, (byte *)&hp->NativeEngineProxy);                                                                        // Pointer to the native V8 engine proxy object associated with this proxy handle instance (used native side to free the handle upon destruction).
                }
                ofs = (byte)((int)&hp->NativeV8Handle - (int)hp);
                if ((Int64)hp->NativeV8Handle != _GetMarshalTestPTRValue(ofs, out data))
                {
                    _ThrowMarshalTestError("HandleProxy", "NativeV8Handle", ofs, data, (byte *)&hp->NativeV8Handle);                                                                     // The native V8 persistent object handle (not used on the managed side).
                }
                ofs = (byte)((int)&nv8ep->NativeClassType - (int)nv8ep);
                if (nv8ep->NativeClassType != ProxyObjectType.V8EngineProxyClass)
                {
                    _ThrowMarshalTestError("NativeV8EngineProxy", "NativeClassType", ofs, null, (byte *)&nv8ep->NativeClassType, 4);
                }
                ofs = (byte)((int)&nv8ep->ID - (int)nv8ep);
                if ((Int32)nv8ep->ID != _GetMarshalTestInt32Value(ofs, out data))
                {
                    _ThrowMarshalTestError("NativeV8EngineProxy", "ID", ofs, data, (byte *)&nv8ep->ID);
                }
                ofs += (byte)data.Length;

                ofs = (byte)((int)&notp->NativeClassType - (int)notp);
                if (notp->NativeClassType != ProxyObjectType.ObjectTemplateProxyClass)
                {
                    _ThrowMarshalTestError("NativeObjectTemplateProxy", "NativeClassType", ofs, null, (byte *)&notp->NativeClassType, 4);
                }
                ofs = (byte)((int)&notp->NativeEngineProxy - (int)notp);
                if ((Int64)notp->NativeEngineProxy != _GetMarshalTestPTRValue(ofs, out data))
                {
                    _ThrowMarshalTestError("NativeObjectTemplateProxy", "NativeEngineProxy", ofs, data, (byte *)&notp->NativeEngineProxy);
                }
                ofs = (byte)((int)&notp->EngineID - (int)notp);
                if ((Int32)notp->EngineID != _GetMarshalTestInt32Value(ofs, out data))
                {
                    _ThrowMarshalTestError("NativeObjectTemplateProxy", "EngineID", ofs, data, (byte *)&notp->EngineID);
                }
                ofs = (byte)((int)&notp->ObjectID - (int)notp);
                if ((Int32)notp->ObjectID != _GetMarshalTestInt32Value(ofs, out data))
                {
                    _ThrowMarshalTestError("NativeObjectTemplateProxy", "ObjectID", ofs, data, (byte *)&notp->ObjectID);
                }
                ofs = (byte)((int)&notp->NativeObjectTemplate - (int)notp);
                if ((Int64)notp->NativeObjectTemplate != _GetMarshalTestPTRValue(ofs, out data))
                {
                    _ThrowMarshalTestError("NativeObjectTemplateProxy", "NativeObjectTemplate", ofs, data, (byte *)&notp->NativeObjectTemplate);
                }

                ofs = (byte)((int)&nftp->NativeClassType - (int)nftp);
                if (nftp->NativeClassType != ProxyObjectType.FunctionTemplateProxyClass)
                {
                    _ThrowMarshalTestError("NativeFunctionTemplateProxy", "NativeClassType", ofs, null, (byte *)&nftp->NativeClassType, 4);
                }
                ofs = (byte)((int)&nftp->NativeEngineProxy - (int)nftp);
                if ((Int64)nftp->NativeEngineProxy != _GetMarshalTestPTRValue(ofs, out data))
                {
                    _ThrowMarshalTestError("NativeFunctionTemplateProxy", "NativeEngineProxy", ofs, data, (byte *)&nftp->NativeEngineProxy);
                }
                ofs = (byte)((int)&nftp->EngineID - (int)nftp);
                if ((Int32)nftp->EngineID != _GetMarshalTestInt32Value(ofs, out data))
                {
                    _ThrowMarshalTestError("NativeFunctionTemplateProxy", "EngineID", ofs, data, (byte *)&nftp->EngineID);
                }
                ofs = (byte)((int)&nftp->NativeFucntionTemplate - (int)nftp);
                if ((Int64)nftp->NativeFucntionTemplate != _GetMarshalTestPTRValue(ofs, out data))
                {
                    _ThrowMarshalTestError("NativeFunctionTemplateProxy", "NativeFucntionTemplate", ofs, data, (byte *)&nftp->NativeFucntionTemplate);
                }
            }
            finally
            {
                V8NetProxy.DeleteTestData(hp);
                V8NetProxy.DeleteTestData(nv8ep);
                V8NetProxy.DeleteTestData(notp);
                V8NetProxy.DeleteTestData(nftp);
            }
        }
Beispiel #12
0
 public static extern unsafe bool DeleteObjectTemplateProxy64(NativeObjectTemplateProxy *objectTemplateProxy);
Beispiel #13
0
 public extern static NativeContext *CreateContext64(NativeV8EngineProxy *engine, NativeObjectTemplateProxy *templatePoxy);
Beispiel #14
0
 public static extern void SetCallAsFunctionHandler64(NativeObjectTemplateProxy *proxy, NativeFunctionCallback callback);
Beispiel #15
0
 public static unsafe extern void SetObjectTemplateAccessor(NativeObjectTemplateProxy *proxy, Int32 managedObjectID, string name,
                                                            ManagedAccessorGetter getter, ManagedAccessorSetter setter,
                                                            V8AccessControl access, V8PropertyAttributes attributes);
Beispiel #16
0
 public static unsafe extern void SetObjectTemplateProperty(NativeObjectTemplateProxy *proxy, string name, HandleProxy *value, V8PropertyAttributes attributes = V8PropertyAttributes.None);
Beispiel #17
0
 public static extern void SetCallAsFunctionHandler(NativeObjectTemplateProxy *proxy, ManagedJSFunctionCallback callback);