From 704cb4c0f121dc6e54ee1cfaa5f5bdf67fba0366 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sun, 1 Nov 2026 15:06:02 +0000 Subject: [PATCH 1/3] [tests] Add test to cover issue 1321 --- test/cppia/Client.hx | 1 + test/cppia/Common.hx | 3 +++ test/cppia/cases/TestCommon.hx | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/test/cppia/Client.hx b/test/cppia/Client.hx index af77a301f..ade66ef95 100644 --- a/test/cppia/Client.hx +++ b/test/cppia/Client.hx @@ -23,6 +23,7 @@ class Client { Common.clientImplementation = new ClientOne(); Common.callback = () -> Common.callbackSet = 2; + Common.instance.dynamicMethod = () -> Common.callbackSet = 3; } public static function useHostImplementation() { diff --git a/test/cppia/Common.hx b/test/cppia/Common.hx index 5ea2d63c7..8a147b2db 100644 --- a/test/cppia/Common.hx +++ b/test/cppia/Common.hx @@ -21,4 +21,7 @@ class Common public function instanceIncrementCount(_) { count++; } + + public static var instance = new Common(); + public dynamic function dynamicMethod() {} } diff --git a/test/cppia/cases/TestCommon.hx b/test/cppia/cases/TestCommon.hx index cbbb3a20a..207ac9d34 100644 --- a/test/cppia/cases/TestCommon.hx +++ b/test/cppia/cases/TestCommon.hx @@ -55,6 +55,12 @@ class TestCommon extends Test { Assert.equals(2, Common.callbackSet, 'Bad cppia closure'); } + function testDynamicMethod() { + Common.instance.dynamicMethod(); + + Assert.equals(3, Common.callbackSet, 'Bad cppia closure'); + } + function testInterfaceCalling() { final obj : IFoo = Type.createInstance(Type.resolveClass('ClientFoo'), []); From d51fe1a946c1f3ae05dd9b1f6575bd06714e7e2f Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sun, 1 Nov 2026 12:28:55 +0000 Subject: [PATCH 2/3] [cppia] Restore memref object access for haxe 4 Removing this had a serious impact on performance. It only has to be removed for haxe 5, where functions are now a typed callable object and accessing a function field using MemReference caused a crash. --- src/hx/cppia/Cppia.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/hx/cppia/Cppia.cpp b/src/hx/cppia/Cppia.cpp index f9c6cefc0..03980394d 100644 --- a/src/hx/cppia/Cppia.cpp +++ b/src/hx/cppia/Cppia.cpp @@ -4654,6 +4654,12 @@ struct GetFieldByLinkage : public CppiaExpr (CppiaExpr*)new MemReference(this,offset); break; case fsObject: +#if (HXCPP_API_LEVEL<500) + replace = object ? + (CppiaExpr*)new MemReference(this,offset,object): + (CppiaExpr*)new MemReference(this,offset); + break; +#endif case fsByte: case fsUnknown: forceNamedAccess = true; From 71ffa0437a6cf274285008f4794344f82875d254 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sun, 1 Nov 2026 15:07:37 +0000 Subject: [PATCH 3/3] [tests] Remove unneeded line from cppia hxml This type is included from Client, so doesn't need to be included here explicitly. --- test/cppia/compile-client.hxml | 1 - 1 file changed, 1 deletion(-) diff --git a/test/cppia/compile-client.hxml b/test/cppia/compile-client.hxml index 686135e2c..224792a31 100644 --- a/test/cppia/compile-client.hxml +++ b/test/cppia/compile-client.hxml @@ -1,5 +1,4 @@ -m Client -cases.client.TestClient -D dll_import=host_classes.info -L utest --cppia bin/client.cppia