Beispiel #1
0
    private static void TestEnumReverse()
    {
        ThisCallNative.C c      = CreateCWithManagedVTable(2.0f, 3.0f);
        ThisCallNative.E result = ThisCallNative.GetEFromManaged(&c);

        Assert.AreEqual(c.dummy, result);
    }
Beispiel #2
0
    private static void Test4ByteHFAReverse()
    {
        ThisCallNative.C     c      = CreateCWithManagedVTable(2.0f, 3.0f);
        ThisCallNative.Width result = ThisCallNative.GetWidthFromManaged(&c);

        Assert.AreEqual(c.width, result.width);
    }
Beispiel #3
0
    private static void Test4ByteNonHFAReverse()
    {
        ThisCallNative.C          c      = CreateCWithManagedVTable(2.0f, 3.0f);
        ThisCallNative.IntWrapper result = ThisCallNative.GetHeightAsIntFromManaged(&c);

        Assert.AreEqual((int)c.height, result.i);
    }
Beispiel #4
0
 public static int Main(string[] args)
 {
     try
     {
         float             width    = 1.0f;
         float             height   = 2.0f;
         ThisCallNative.C *instance = ThisCallNative.CreateInstanceOfC(width, height);
         Test8ByteHFA(instance);
         Test4ByteHFA(instance);
         Test4ByteNonHFA(instance);
         TestEnum(instance);
         TestCLong(instance);
         Test8ByteHFAReverse();
         Test4ByteHFAReverse();
         Test4ByteNonHFAReverse();
         TestEnumReverse();
         TestCLongReverse();
         Test8ByteHFAUnmanagedCallersOnly();
         Test4ByteHFAUnmanagedCallersOnly();
         Test4ByteNonHFAUnmanagedCallersOnly();
         TestEnumUnmanagedCallersOnly();
         TestCLongUnmanagedCallersOnly();
     }
     catch (System.Exception ex)
     {
         Console.WriteLine(ex);
         return(101);
     }
     return(100);
 }
Beispiel #5
0
    private static void TestCLongUnmanagedCallersOnly()
    {
        ThisCallNative.C c      = CreateCWithUnmanagedCallersOnlyVTable(2.0f, 3.0f);
        CLong            result = ThisCallNative.GetWidthAsLongFromManaged(&c);

        Assert.Equal((nint)c.width, result.Value);
    }
Beispiel #6
0
    private static void TestEnumUnmanagedCallersOnly()
    {
        ThisCallNative.C c      = CreateCWithUnmanagedCallersOnlyVTable(2.0f, 3.0f);
        ThisCallNative.E result = ThisCallNative.GetEFromManaged(&c);

        Assert.Equal(c.dummy, result);
    }
Beispiel #7
0
    private static void Test4ByteHFAUnmanagedCallersOnly()
    {
        ThisCallNative.C     c      = CreateCWithUnmanagedCallersOnlyVTable(2.0f, 3.0f);
        ThisCallNative.Width result = ThisCallNative.GetWidthFromManaged(&c);

        Assert.Equal(c.width, result.width);
    }
Beispiel #8
0
    private static void TestCLongReverse()
    {
        ThisCallNative.C c = CreateCWithManagedVTable(2.0f, 3.0f);
        CLong result = ThisCallNative.GetWidthAsLongFromManaged(&c);

        Assert.AreEqual((nint)c.width, result.Value);
    }
Beispiel #9
0
    private static void Test8ByteHFAReverse()
    {
        ThisCallNative.C     c      = CreateCWithManagedVTable(2.0f, 3.0f);
        ThisCallNative.SizeF result = ThisCallNative.GetSizeFromManaged(&c);

        Assert.AreEqual(c.width, result.width);
        Assert.AreEqual(c.height, result.height);
    }
 public unsafe static int Main(string[] args)
 {
     try
     {
         float             width    = 1.0f;
         float             height   = 2.0f;
         ThisCallNative.C *instance = ThisCallNative.CreateInstanceOfC(width, height);
         Test8ByteHFA(instance);
         Test4ByteHFA(instance);
         Test4ByteNonHFA(instance);
     }
     catch (System.Exception ex)
     {
         Console.WriteLine(ex);
         return(101);
     }
     return(100);
 }
Beispiel #11
0
    public unsafe static int Main(string[] args)
    {
        try
        {
            float                    width    = 1.0f;
            float                    height   = 2.0f;
            ThisCallNative.C *       instance = ThisCallNative.CreateInstanceOfC(width, height);
            ThisCallNative.GetSizeFn callback = Marshal.GetDelegateForFunctionPointer <ThisCallNative.GetSizeFn>(instance->vtable->getSize);

            ThisCallNative.SizeF result = callback(instance);

            Assert.AreEqual(width, result.width);
            Assert.AreEqual(height, result.height);
        }
        catch (System.Exception ex)
        {
            Console.WriteLine(ex);
            return(101);
        }
        return(100);
    }