public static byte AndAllMembers([DNNE.C99Type("struct bool_struct*")] BoolStructNative_V1* pArray, int length) { bool result = true; for (int i = 0; i < length; i++) { BoolStruct_V1 managed = pArray[i].ToManaged(); result &= managed.b1 && managed.b2 && managed.b3; } return (byte)(result ? 1 : 0); }
public void NonBlittableStructIn(bool b1, bool b2, bool b3) { var container = new BoolStruct_V1 { b1 = b1, b2 = b2, b3 = b3 }; Assert.Equal(b1 && b2 && b3, NativeExportsNE.V1.AndBoolsRef(container)); }
public void NonBlittableStructWithoutAllocation() { var boolStruct = new BoolStruct_V1 { b1 = true, b2 = false, b3 = true }; NativeExportsNE.V1.NegateBools(boolStruct, out BoolStruct_V1 boolStructNegated); Assert.Equal(!boolStruct.b1, boolStructNegated.b1); Assert.Equal(!boolStruct.b2, boolStructNegated.b2); Assert.Equal(!boolStruct.b3, boolStructNegated.b3); }
public static partial void NegateBools( BoolStruct_V1 boolStruct, out BoolStruct_V1 pBoolStructOut);