mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Updated interop tests
This commit is contained in:
parent
1338eec75d
commit
da0bff04a4
2 changed files with 62 additions and 0 deletions
|
@ -180,6 +180,25 @@ namespace Tests
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct StructJ
|
||||||
|
{
|
||||||
|
char* mPtr;
|
||||||
|
intptr_t mLength;
|
||||||
|
|
||||||
|
int MethodJ0(int arg0)
|
||||||
|
{
|
||||||
|
return arg0 + (int)mLength * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
StructJ MethodJ1(StructJ other, int arg0)
|
||||||
|
{
|
||||||
|
StructJ ret;
|
||||||
|
ret.mPtr = other.mPtr;
|
||||||
|
ret.mLength = other.mLength + arg0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,6 +358,16 @@ extern "C" int Func3G(Interop::StructG* ptr)
|
||||||
return ptr[0].mA + ptr[1].mA * 100;
|
return ptr[0].mA + ptr[1].mA * 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
extern "C" Interop::StructJ Func4J(Interop::StructJ arg0, Interop::StructJ arg1, Interop::StructJ arg2, Interop::StructJ arg3)
|
||||||
|
{
|
||||||
|
Interop::StructJ ret;
|
||||||
|
ret.mPtr = arg0.mPtr;
|
||||||
|
ret.mLength = arg0.mLength + arg1.mLength * 100 + arg2.mLength * 10000 + arg3.mLength * 1000000;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void UseIt()
|
void UseIt()
|
||||||
{
|
{
|
||||||
Interop::StructA sa;
|
Interop::StructA sa;
|
||||||
|
@ -368,4 +397,7 @@ void UseIt()
|
||||||
Interop::StructI si;
|
Interop::StructI si;
|
||||||
si.MethodI0(0);
|
si.MethodI0(0);
|
||||||
si.MethodI1(si, 1);
|
si.MethodI1(si, 1);
|
||||||
|
Interop::StructJ sj;
|
||||||
|
sj.MethodJ0(0);
|
||||||
|
sj.MethodJ1(sj, 1);
|
||||||
}
|
}
|
|
@ -119,6 +119,18 @@ namespace Tests
|
||||||
public extern StructI MethodI1(StructI sa, int32 arg0) mut;
|
public extern StructI MethodI1(StructI sa, int32 arg0) mut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CRepr]
|
||||||
|
public struct StructJ
|
||||||
|
{
|
||||||
|
public char8* mPtr;
|
||||||
|
public int mLength;
|
||||||
|
|
||||||
|
[LinkName(.CPP)]
|
||||||
|
public extern int32 MethodJ0(int32 arg0) mut;
|
||||||
|
[LinkName(.CPP)]
|
||||||
|
public extern StructJ MethodJ1(StructJ sa, int32 arg0) mut;
|
||||||
|
}
|
||||||
|
|
||||||
[LinkName(.C)]
|
[LinkName(.C)]
|
||||||
public static extern int32 Func0(int32 a, int32 b);
|
public static extern int32 Func0(int32 a, int32 b);
|
||||||
|
|
||||||
|
@ -160,6 +172,9 @@ namespace Tests
|
||||||
[LinkName(.C)]
|
[LinkName(.C)]
|
||||||
public static extern StructI Func2I(StructI arg0, int32 arg2);
|
public static extern StructI Func2I(StructI arg0, int32 arg2);
|
||||||
|
|
||||||
|
[LinkName(.C)]
|
||||||
|
public static extern StructJ Func4J(StructJ arg0, StructJ arg1, StructJ arg2, StructJ arg3);
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public static void TestBasics()
|
public static void TestBasics()
|
||||||
{
|
{
|
||||||
|
@ -256,6 +271,21 @@ namespace Tests
|
||||||
Test.Assert(si0.MethodI0(12) == 9012);
|
Test.Assert(si0.MethodI0(12) == 9012);
|
||||||
Test.Assert(si0.MethodI1(si1, 12).mA == (int8)193);
|
Test.Assert(si0.MethodI1(si1, 12).mA == (int8)193);
|
||||||
Test.Assert(Func2I(si0, 12).mA == 102);
|
Test.Assert(Func2I(si0, 12).mA == 102);
|
||||||
|
|
||||||
|
StructJ sj0;
|
||||||
|
sj0.mPtr = "ABC";
|
||||||
|
sj0.mLength = 3;
|
||||||
|
StructJ sj1;
|
||||||
|
sj1.mPtr = "DEFG";
|
||||||
|
sj1.mLength = 4;
|
||||||
|
StructJ sj2;
|
||||||
|
sj2.mPtr = "HIJKL";
|
||||||
|
sj2.mLength = 5;
|
||||||
|
StructJ sj3;
|
||||||
|
sj3.mPtr = "MNOPQR";
|
||||||
|
sj3.mLength = 6;
|
||||||
|
var sjRet = Func4J(sj0, sj1, sj2, sj3);
|
||||||
|
Test.Assert(sjRet.mLength == 6050403);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue