HaxeFoundation / HaxeFoundation/hxcpp
Cppia: Custom types are not cast to Dynamic anymore
- Dominant language
- C++
- Stars
- 330
- Forks
- 227
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 18
Description
In Unreal.hx, we have two special C++/Haxe types that help us make a seamless integration with C++ code:
`IntPtr / UIntPtr` - they are just typedefs over `uintptr_t` / `intptr_t` : https://github.com/proletariatgames/unreal.hx/blob/development/Haxe/Templates/Source/HaxeRuntime/Shared/IntPtr.h
On haxe side, they are represented as https://github.com/proletariatgames/unreal.hx/blob/development/Haxe/Static/unreal/UIntPtr.hx
These types help us share the same type between Unreal and Haxe (cpp.Pointer could not be included by Unreal because of some incompatible compilation flags). We used to use `cpp.RawPointer` before, but the non-reflectivity of these made them so hard to work with. Having a typedef over uintptr_t allows these types to be boxed as Int/Int64 easily and seamlessly.
`VariantPtr` - these are a little bit trickier. They are there so that we can have zero-cost external code pointers (without allocation), but still support haxe garbage collected types if it was created by us : https://github.com/proletariatgames/unreal.hx/blob/development/Haxe/Templates/Source/HaxeRuntime/Shared/VariantPtr.h
On haxe, they are represented as
https://github.com/proletariatgames/unreal.hx/blob/development/Haxe/Static/unreal/VariantPtr.hx
I'm trying out Haxe 4,0, and I've hit into a regression when using these types with cppia: Field accesses for for example UIntPtr types (e.g. `someType.anIntPtrField`) are now retrieved by offset, and cppia does not recognize UIntPtr as an integer type. So we end up with cppia thinking that the `UIntPtr` is actually a pointer to a haxe object, which makes it crash when e.g. trying to check for `==`. I imagine that the same would happen on VariantPtr.
I think a good solution would be to allow marking types as incompatible with offset access, falling back to the `__Field` access instead. What do you think? Would that be possible?
Thanks!! :)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.