utopia-rise / godot-kotlin-native

Kotlin bindings for Godot Engine
MIT License
290 stars 16 forks source link

Variant, Array and Dictionary #154

Closed CedNaru closed 4 years ago

CedNaru commented 4 years ago

Variant Class is implemented. I tried to use the inline class feature of Kotlin. This would save us a lot of allocations as Variant is used to send/receive data to/from Godot. Not many drawbacks to this method. The Kotlin Variant class only needs to keep a reference to the C++ pointer. But for now, inline classes don't allow secondary constructor so I had to create fake ones as normal functions. I'm not sure if it will work. The compiler is complaining about constructor ambiguity for now.

I am also not sure about all the wrap/unwrap functions. Unwrap, as it is now, seems really unsafe. I tried to change the signature of the function but if I do that, I break another part of the library outside the cores. So I'm open to suggestions.