From b09012b9a3cd04ace637eb1b6c761db5ce72a354 Mon Sep 17 00:00:00 2001 From: Aidan Lee Date: Sat, 31 Oct 2026 13:19:00 +0000 Subject: [PATCH 1/2] Fix Dynamic to PointerType conversion using the wrong type parameter --- include/cpp/marshal/PointerType.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/cpp/marshal/PointerType.hpp b/include/cpp/marshal/PointerType.hpp index e2bd26af2..7d75c1cf1 100644 --- a/include/cpp/marshal/PointerType.hpp +++ b/include/cpp/marshal/PointerType.hpp @@ -5,7 +5,7 @@ template inline T* cpp::marshal::PointerType::FromDynamic(const Dynamic& inRHS) { - return FromBoxed(inRHS.StaticCast>()); + return FromBoxed(inRHS.StaticCast>()); } template From 9547eacafe7793b28b1da4d8a5575ac8f0c32bb4 Mon Sep 17 00:00:00 2001 From: Aidan Lee Date: Sat, 31 Oct 2026 13:39:25 +0000 Subject: [PATCH 2/2] Add test case --- test/native/tests/marshalling/Build.xml | 4 +++ .../tests/marshalling/native/Opaque.cpp | 8 ++++++ .../tests/marshalling/native/Opaque.hpp | 5 ++++ .../marshalling/pointers/TestPointerFields.hx | 25 +++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 test/native/tests/marshalling/native/Opaque.cpp create mode 100644 test/native/tests/marshalling/native/Opaque.hpp diff --git a/test/native/tests/marshalling/Build.xml b/test/native/tests/marshalling/Build.xml index 29f8ef243..fb3fab9f4 100644 --- a/test/native/tests/marshalling/Build.xml +++ b/test/native/tests/marshalling/Build.xml @@ -29,6 +29,10 @@ + + + + diff --git a/test/native/tests/marshalling/native/Opaque.cpp b/test/native/tests/marshalling/native/Opaque.cpp new file mode 100644 index 000000000..78b6936be --- /dev/null +++ b/test/native/tests/marshalling/native/Opaque.cpp @@ -0,0 +1,8 @@ +#include + +struct Opaque {}; + +Opaque* opaque_create() +{ + return new Opaque(); +} \ No newline at end of file diff --git a/test/native/tests/marshalling/native/Opaque.hpp b/test/native/tests/marshalling/native/Opaque.hpp new file mode 100644 index 000000000..535313fb2 --- /dev/null +++ b/test/native/tests/marshalling/native/Opaque.hpp @@ -0,0 +1,5 @@ +#pragma once + +struct Opaque; + +Opaque* opaque_create(); \ No newline at end of file diff --git a/test/native/tests/marshalling/pointers/TestPointerFields.hx b/test/native/tests/marshalling/pointers/TestPointerFields.hx index 3b0fde545..1c38d189b 100644 --- a/test/native/tests/marshalling/pointers/TestPointerFields.hx +++ b/test/native/tests/marshalling/pointers/TestPointerFields.hx @@ -18,6 +18,25 @@ private extern class Holder { var pPtr : Point; } +@:semantics(value) +@:include("Opaque.hpp") +@:cpp.PointerType +extern class Opaque {} + +@:include("Opaque.hpp") +extern class OpaqueApi { + @:native("opaque_create") + static function create():Opaque; +} + +private class OpaqueHolder { + public var opaque:Opaque; + + public function new(opaque) { + this.opaque = opaque; + } +} + class TestPointerFields extends Test { function test_field_access() { @@ -73,6 +92,12 @@ class TestPointerFields extends Test { Assert.equals(200f64, h.pPtr.y); } + function test_holding_opaque_pointer() { + final h = new OpaqueHolder(OpaqueApi.create()); + + Assert.notNull(h.opaque); + } + function create_holder() : Holder { return untyped __cpp__('::holder(::hx::maths::point(), ::hx::maths::point())'); }