// Case 1) User created structure: // allocate native on creation, free native on dispose. internal CfxStructure(CfxApi.cfx_ctor_delegate cfx_ctor, CfxApi.cfx_dtor_delegate cfx_dtor) { this.m_cfx_dtor = cfx_dtor; //this might happen if the application tries to instanciate a platform specific struct //on the wrong platform. if(cfx_ctor == null) return; CreateNative(cfx_ctor); }
internal CfxTime(IntPtr nativePtr, CfxApi.cfx_dtor_delegate cfx_dtor) : base(nativePtr, cfx_dtor) { }
internal void CreateNative(CfxApi.cfx_ctor_delegate cfx_ctor) { m_nativePtr = cfx_ctor(); if(m_nativePtr == IntPtr.Zero) throw new OutOfMemoryException(); }
internal void CreateNative(CfxApi.cfx_ctor_with_gc_handle_delegate cfx_ctor) { // must be a weak handle // otherwise transient callback structs never go out of scope if // they are not explicitly disposed System.Runtime.InteropServices.GCHandle handle = System.Runtime.InteropServices.GCHandle.Alloc(this, System.Runtime.InteropServices.GCHandleType.Weak); m_nativePtr = cfx_ctor(System.Runtime.InteropServices.GCHandle.ToIntPtr(handle)); if(m_nativePtr == IntPtr.Zero) throw new OutOfMemoryException(); }
internal CfxBrowserSettings(IntPtr nativePtr, CfxApi.cfx_dtor_delegate cfx_dtor) : base(nativePtr, cfx_dtor) { }
/// <summary> /// Sets the value at the specified index as type int. Returns true (1) if the /// value was set successfully. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>. /// </remarks> public bool SetInt(int index, int value) { return(0 != CfxApi.cfx_list_value_set_int(NativePtr, index, value)); }
/// <summary> /// Sets the value at the specified index as type bool. Returns true (1) if the /// value was set successfully. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>. /// </remarks> public bool SetBool(int index, bool value) { return(0 != CfxApi.cfx_list_value_set_bool(NativePtr, index, value ? 1 : 0)); }
/// <summary> /// Sets the value at the specified index as type null. Returns true (1) if the /// value was set successfully. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>. /// </remarks> public bool SetNull(int index) { return(0 != CfxApi.cfx_list_value_set_null(NativePtr, index)); }
/// <summary> /// Returns the value at the specified index as type list. The returned value /// will reference existing data and modifications to the value will modify /// this object. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>. /// </remarks> public CfxListValue GetList(int index) { return(CfxListValue.Wrap(CfxApi.cfx_list_value_get_list(NativePtr, index))); }
internal CfxScreenInfo(IntPtr nativePtr, CfxApi.cfx_dtor_delegate cfx_dtor) : base(nativePtr, cfx_dtor) { }
internal CfxWindowInfoWindows(IntPtr nativePtr, CfxApi.cfx_dtor_delegate cfx_dtor) : base(nativePtr, cfx_dtor) { }
internal CfxBase(CfxApi.cfx_ctor_with_gc_handle_delegate cfx_ctor) { CreateNative(cfx_ctor); }
// Case 3) struct passed in from framework as a return value // native layer makes a copy -> free native pointer on dispose internal CfxStructure(IntPtr nativePtr, CfxApi.cfx_dtor_delegate cfx_dtor) { this.m_cfx_dtor = cfx_dtor; SetNative(nativePtr); }
internal CfxDraggableRegion(IntPtr nativePtr, CfxApi.cfx_dtor_delegate cfx_dtor) : base(nativePtr, cfx_dtor) { }