Ejemplo n.º 1
0
 internal static void ReleaseIfNonNull(cef_base_ref_counted_t *instance)
 {
     if (instance != null)
     {
         instance->Release();
     }
 }
Ejemplo n.º 2
0
 public unsafe int SetUserData(cef_base_ref_counted_t *user_data)
 {
     fixed(cef_v8value_t *self = &this)
     {
         return(((delegate * unmanaged[Stdcall] < cef_v8value_t *, cef_base_ref_counted_t *, int >)set_user_data)(self, user_data));
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of <see cref="CefBaseRefCounted"/> using
 /// the pointer to ref-counted CEF struct.
 /// </summary>
 /// <param name="instance">The pointer to a ref-counted CEF struct.</param>
 /// <exception cref="NullReferenceException"><paramref name="instance"/> is null.</exception>
 public CefBaseRefCounted(cef_base_ref_counted_t *instance)
 {
     if (instance == null)
     {
         throw new ArgumentNullException(nameof(instance));
     }
     _instance = new IntPtr(instance);
 }
Ejemplo n.º 4
0
        private unsafe static cef_base_ref_counted_t *Allocate(int size)
        {
            cef_base_ref_counted_t *instance = (cef_base_ref_counted_t *)CefStructure.Allocate(size);

            instance->add_ref              = (void *)Marshal.GetFunctionPointerForDelegate(fnAddRef);
            instance->release              = (void *)Marshal.GetFunctionPointerForDelegate(fnRelease);
            instance->has_one_ref          = (void *)Marshal.GetFunctionPointerForDelegate(fnHasOneRef);
            instance->has_at_least_one_ref = (void *)Marshal.GetFunctionPointerForDelegate(fnHasAtLeastOneRef);
            return(instance);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns a pointer to a ref-counted struct and increments the reference count.
        /// </summary>
        /// <returns>A pointer to a ref-counted struct.</returns>
        public unsafe cef_base_ref_counted_t *GetNativeInstance()
        {
            cef_base_ref_counted_t *instance = (cef_base_ref_counted_t *)Volatile.Read(ref _instance);

            if (instance == null)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }
            instance->AddRef();
            return(instance);
        }
Ejemplo n.º 6
0
        public int Release()
        {
            cef_base_ref_counted_t *pbrc = (cef_base_ref_counted_t *)Ptr;

#if CACHEPTR
            if (_typed_release == null)
            {
                _typed_release = Marshal.GetDelegateForFunctionPointer <GetInt32Handler>(pbrc->release);
            }
#else
            var _typed_release = Marshal.GetDelegateForFunctionPointer <GetInt32Handler>(pbrc->release);
#endif
            return(_typed_release(Ptr));
        }
Ejemplo n.º 7
0
        public void AddRef()
        {
            cef_base_ref_counted_t *pbrc = (cef_base_ref_counted_t *)Ptr;

#if CACHEPTR
            if (_typed_add_ref == null)
            {
                _typed_add_ref = Marshal.GetDelegateForFunctionPointer <EventCallbackHandler>(pbrc->add_ref);
            }
#else
            var _typed_add_ref = Marshal.GetDelegateForFunctionPointer <EventCallbackHandler>(pbrc->add_ref);
#endif
            _typed_add_ref(Ptr);
        }
Ejemplo n.º 8
0
        private unsafe static int HasAtLeastOneRefImpl(cef_base_ref_counted_t *self)
        {
            RefCountedReference reference;

            GlobalSyncRoot.EnterReadLock();
            try
            {
                RefCounted.TryGetValue(new IntPtr(self), out reference);
            }
            finally
            {
                GlobalSyncRoot.ExitReadLock();
            }
            return((reference != null && reference.IsRooted) ? 1 : 0);
        }
Ejemplo n.º 9
0
        public ObjectFromNet()
        {
            Ptr = Marshal.AllocHGlobal(T_SIZE);
            WindowsInterop.RtlZeroMemory(Ptr, (UIntPtr)T_SIZE);

            WriteDebugMsg("ObjectFromNet New: 0x" + Ptr.ToString("X"));
            s_map[Ptr] = new WeakReference <ObjectFromNet <TS, TC> >(this, true);

            cef_base_ref_counted_t *pbrc = (cef_base_ref_counted_t *)Ptr;

            pbrc->size                 = T_SIZE;
            pbrc->add_ref              = holder_add_ref;
            pbrc->release              = holder_release;
            pbrc->has_one_ref          = holder_has_one_ref;
            pbrc->has_at_least_one_ref = holder_has_at_least_one_ref;
        }
Ejemplo n.º 10
0
        private protected unsafe static cef_base_ref_counted_t *Allocate(int size)
        {
            cef_base_ref_counted_t *instance = (cef_base_ref_counted_t *)CefStructure.Allocate(size);

#if NET_LESS_5_0
            instance->add_ref              = (void *)Marshal.GetFunctionPointerForDelegate(fnAddRef);
            instance->release              = (void *)Marshal.GetFunctionPointerForDelegate(fnRelease);
            instance->has_one_ref          = (void *)Marshal.GetFunctionPointerForDelegate(fnHasOneRef);
            instance->has_at_least_one_ref = (void *)Marshal.GetFunctionPointerForDelegate(fnHasAtLeastOneRef);
#else
            instance->add_ref              = (delegate * unmanaged[Stdcall] < cef_base_ref_counted_t *, void >) & AddRefImpl;
            instance->release              = (delegate * unmanaged[Stdcall] < cef_base_ref_counted_t *, int >) & ReleaseImpl;
            instance->has_one_ref          = (delegate * unmanaged[Stdcall] < cef_base_ref_counted_t *, int >) & HasOneRefImpl;
            instance->has_at_least_one_ref = (delegate * unmanaged[Stdcall] < cef_base_ref_counted_t *, int >) & HasAtLeastOneRefImpl;
#endif
            return(instance);
        }
Ejemplo n.º 11
0
        public static int set_user_data(cef_v8value_t *self, cef_base_ref_counted_t *user_data)
        {
            set_user_data_delegate d;
            var p = self->_set_user_data;

            if (p == _p26)
            {
                d = _d26;
            }
            else
            {
                d = (set_user_data_delegate)Marshal.GetDelegateForFunctionPointer(p, typeof(set_user_data_delegate));
                if (_p26 == IntPtr.Zero)
                {
                    _d26 = d; _p26 = p;
                }
            }
            return(d(self, user_data));
        }
Ejemplo n.º 12
0
        private unsafe static void AddRefImpl(cef_base_ref_counted_t *self)
        {
            RefCountedReference reference;

            GlobalSyncRoot.EnterReadLock();
            try
            {
                RefCounted.TryGetValue(new IntPtr(self), out reference);
            }
            finally
            {
                GlobalSyncRoot.ExitReadLock();
            }
            if (reference == null)
            {
                throw new InvalidOperationException();
            }
            reference.AddRef();
        }
Ejemplo n.º 13
0
        private unsafe static int ReleaseImpl(cef_base_ref_counted_t *self)
        {
            RefCountedReference reference;

            GlobalSyncRoot.EnterReadLock();
            try
            {
                RefCounted.TryGetValue(new IntPtr(self), out reference);
            }
            finally
            {
                GlobalSyncRoot.ExitReadLock();
            }
            if (reference == null)
            {
                if (Environment.HasShutdownStarted)
                {
                    return(0);
                }
                throw new InvalidOperationException();
            }
            return(reference.Release());
        }
Ejemplo n.º 14
0
 public unsafe extern int SetUserData(cef_base_ref_counted_t *user_data);
Ejemplo n.º 15
0
 public UnknownRefCounted(cef_base_ref_counted_t *instance)
     : base(instance)
 {
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of <see cref="CefBaseRefCounted{T}"/> using
 /// the specified pointer to a specified CEF struct.
 /// </summary>
 /// <param name="instance">The pointer to a specified CEF struct.</param>
 public unsafe CefBaseRefCounted(cef_base_ref_counted_t *instance)
     : base(instance)
 {
 }
Ejemplo n.º 17
0
 internal unsafe CefBaseRefCountedImpl(cef_base_ref_counted_t *instance)
     : base(instance)
 {
 }