internal static void ReleaseIfNonNull(cef_base_ref_counted_t *instance) { if (instance != null) { instance->Release(); } }
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)); } }
/// <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); }
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); }
/// <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); }
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)); }
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); }
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); }
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; }
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); }
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)); }
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(); }
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()); }
public unsafe extern int SetUserData(cef_base_ref_counted_t *user_data);
public UnknownRefCounted(cef_base_ref_counted_t *instance) : base(instance) { }
/// <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) { }
internal unsafe CefBaseRefCountedImpl(cef_base_ref_counted_t *instance) : base(instance) { }