public void GetCallbackPtrForClassWithMultipleInheritenceShouldReturnPointer() { using var callback = new Callback2Impl(); Assert.NotEqual(IntPtr.Zero, MarshallingHelpers.ToCallbackPtr <ICallback>(callback)); Assert.NotEqual(IntPtr.Zero, MarshallingHelpers.ToCallbackPtr <ICallback2>(callback)); }
unsafe IntPtr IStateSubObjectDescriptionMarshal.__MarshalAlloc(Dictionary <StateSubObject, IntPtr> subObjectLookup) { __Native *native = (__Native *)Marshal.AllocHGlobal(sizeof(__Native)); native->RootSignature = MarshallingHelpers.ToCallbackPtr <ID3D12RootSignature>(RootSignature); return((IntPtr)native); }
internal unsafe void __MarshalTo(ref __Native @ref) { @ref.RootSignature = MarshallingHelpers.ToCallbackPtr <ID3D12RootSignature>(RootSignature); ComputeShader?.__MarshalTo(ref @ref.CS); @ref.NodeMask = NodeMask; CachedPSO.__MarshalTo(ref @ref.CachedPSO); @ref.Flags = Flags; }
public unsafe Result FlushAllSurfacesWithDevice(IUnknown device) { IntPtr device_ = MarshallingHelpers.ToCallbackPtr <IUnknown>(device); Result result = ((delegate * unmanaged[Stdcall] < IntPtr, void *, int >) this[3])(NativePointer, (void *)device_); GC.KeepAlive(device); return(result); }
public void CanRoundTripCallThroughNativeVtblToManagedObject() { using var callback = new CallbackImpl(); var callbackPtr = MarshallingHelpers.ToCallbackPtr <ICallback>(callback); var methodPtr = Marshal.ReadIntPtr(Marshal.ReadIntPtr(callbackPtr)); var delegateObject = Marshal.GetDelegateForFunctionPointer <CallbackShadow.CallbackVbtl.IncrementDelegate>(methodPtr); Assert.Equal(3, delegateObject(callbackPtr, 2)); }
private static IDisposable SetupTests(bool supportExceptions, out CallbackInterfaceNative nativeView, out ManagedImplementation target) { target = supportExceptions ? new ExceptionEnabledManagedImplementation() : new ManagedImplementation(); nativeView = new CallbackInterfaceNative(MarshallingHelpers.ToCallbackPtr <CallbackInterface>(target)); return(new CompositeDisposable { target, nativeView }); }
unsafe IntPtr IStateSubObjectDescriptionMarshal.__MarshalAlloc(Dictionary <StateSubObject, IntPtr> subObjectLookup) { __Native *native = (__Native *)Marshal.AllocHGlobal(sizeof(__Native)); native->pExistingCollection = MarshallingHelpers.ToCallbackPtr <ID3D12StateObject>(ExistingCollection); native->NumExports = Exports?.Length ?? 0; if (native->NumExports > 0) { var nativeExports = (ExportDescription.__Native *)UnsafeUtilities.Alloc <ExportDescription.__Native>(native->NumExports); for (int i = 0; i < native->NumExports; i++) { Exports ![i].__MarshalTo(ref nativeExports[i]);
private int CreateCustomEffectImpl(out IntPtr nativeCustomEffectPtr) { nativeCustomEffectPtr = IntPtr.Zero; try { var customEffect = _createID2D1EffectImplFunc(); nativeCustomEffectPtr = MarshallingHelpers.ToCallbackPtr <ID2D1EffectImpl>(customEffect); } catch (SharpGenException ex) { return(ex.HResult); } return(Result.Ok.Code); }
internal unsafe void __MarshalTo(ref __Native @ref) { @ref.Enable9On12 = Enable9On12; @ref.pD3D12Device = MarshallingHelpers.ToCallbackPtr(D3D12Device); @ref.NumQueues = 0; if (D3D12Queue1 != null) { @ref.pD3D12Queue1 = MarshallingHelpers.ToCallbackPtr(D3D12Queue1); @ref.NumQueues++; } if (D3D12Queue2 != null) { @ref.pD3D12Queue2 = MarshallingHelpers.ToCallbackPtr(D3D12Queue2); @ref.NumQueues++; } @ref.NodeMask = NodeMask; }
public void GetCallbackPtrReturnsPointerToShadow() { using var callback = new CallbackImpl(); Assert.NotEqual(IntPtr.Zero, MarshallingHelpers.ToCallbackPtr <ICallback>(callback)); }