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 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())'); }