From 8aa58b3804239514cab4f44be4dec0ed0bc189cc Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Wed, 29 Jun 2022 15:17:04 -0700 Subject: [PATCH] Fixed fully qualified generic lookup --- BeefTools/TestDLL/TestDLL.cpp | 41 +++++++++++++++++++++++++------ BeefTools/TestDLL/TestDLL.vcxproj | 16 ++++++------ IDE/mintest/src/main.bf | 24 ++++++++++++++++++ 3 files changed, 67 insertions(+), 14 deletions(-) diff --git a/BeefTools/TestDLL/TestDLL.cpp b/BeefTools/TestDLL/TestDLL.cpp index d889c73b..377d4eb2 100644 --- a/BeefTools/TestDLL/TestDLL.cpp +++ b/BeefTools/TestDLL/TestDLL.cpp @@ -138,9 +138,7 @@ void TestMem() char* mem = (char*)::VirtualAlloc(0, 4096 * 2, MEM_RESERVE, PAGE_READWRITE); ::VirtualAlloc(mem, 4096, MEM_COMMIT, PAGE_READWRITE); - char* str = "Hey"; - char* cPtr = mem + 4096 - 3; - memcpy(cPtr, str, 3); + } void Test6() @@ -163,10 +161,41 @@ void Test3(int a) Test4(100, 200, 300); } + +#pragma pack(1) +class TestStruct +{ +public: + int mA; + int mB; + int mC; + int mD; +}; + +enum EnumVal +{ + EnumVal_A, + EnumVal_B, + EnumVal_C +}; + +struct Color +{ + float r, g, b, a; +}; + // THIS IS VERSION 6. extern "C" -__declspec(dllexport) void Test2(int aa, int bb, int cc, int dd) +__declspec(dllexport) void Test2(int aa, int bb, int cc, int dd, Color func(int a, int b)) { + Color clr = func(100, 200); + + EnumVal ev = EnumVal_A; + + TestStruct ts; + ts.mA = 123; + ts.mB = 234; + int a = 1234; for (int i = 0; i < 100; i++) @@ -174,9 +203,7 @@ __declspec(dllexport) void Test2(int aa, int bb, int cc, int dd) a++; } - Test3(10); - - char* strP = "Hey yo"; + Test3(10); TestMem(); diff --git a/BeefTools/TestDLL/TestDLL.vcxproj b/BeefTools/TestDLL/TestDLL.vcxproj index c4b1c718..4d5c6e14 100644 --- a/BeefTools/TestDLL/TestDLL.vcxproj +++ b/BeefTools/TestDLL/TestDLL.vcxproj @@ -22,32 +22,32 @@ {14700A80-0FC4-4A3D-99EF-8B78D4B070F1} Win32Proj TestDLL - 10.0.17763.0 + 10.0.16299.0 DynamicLibrary true - v141 + v142 Unicode Application false - v141 + v142 true Unicode DynamicLibrary true - v141 + v142 Unicode DynamicLibrary false - v141 + v142 true Unicode @@ -104,7 +104,7 @@ Level3 Disabled _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - \Beef\BeefySysLib;\Beef\BeefySysLib\third_party + \Beef\BeefySysLib;\Beef\BeefySysLib\third_party;C:\temp\Chipmunk-7.0.3\include stdcpplatest @@ -112,7 +112,8 @@ DebugFull - copy C:\Beef\BeefTools\TestDLL\x64\Debug\TestDLL.dll c:\beef\ide\mintest\build\release_win64\mintest + + @@ -152,6 +153,7 @@ + diff --git a/IDE/mintest/src/main.bf b/IDE/mintest/src/main.bf index 24d0505d..7156c5e5 100644 --- a/IDE/mintest/src/main.bf +++ b/IDE/mintest/src/main.bf @@ -21,6 +21,11 @@ namespace Hey.Dude.Bro } } + struct Color + { + public float r, g, b, a; + } + class TestClass { /*static void TestFunc() @@ -37,8 +42,27 @@ namespace Hey.Dude.Bro }*/ + //private const uint16[] DebugIndexes = scope uint16[](0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7); + + + + [Import(@"C:\Beef\BeefTools\TestDLL\x64\Debug\TestDLL.dll"), LinkName("Test2")] + public static extern void Test2(int32 a, int32 b, int32 c, int32 d, function Color(int32 a, int32 b) func); + + public static Color GetColor(int32 a, int32 b) + { + Color c; + c.r = 1.2f; + c.g = 2.3f; + c.b = 3.4f; + c.a = 4.5f; + return c; + } + public static int Main(String[] args) { + Test2(1, 2, 3, 4, => GetColor); + //Blurg.Hey(); return 1; }