Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This module contains
VariantInternalType
,VariantInternal
,VariantGetInternalPtr
,VariantInternalAccessor
andVariantDefaultInitializer
, facilitating access and manipulation of a Variant's internal value in various ways.The reference godot variant_internal.hpp is here. I chose a different, less boilerplate-y approach to implementation. It should work the same though. Doing it this way should decrease maintenance (and implementation) effort, since most of these are just copy-pasted code without any type specific logic (with the exception of
Object *
).There are a few small differences:
VariantInternalType
does not exist in godot's implementation. I added it because it makes implementation of the other functions easier.get_object
returnsObject * const *
in my implementation, butconst Object **
in godot's. Technically speaking, godot's implementation is wrong, because it allows manipulation of the containedObject *
, even though aconst Variant
was supplied. Godot uses a C-style cast that acts as a const_cast to avoid cast issues.VariantInternalAccessor
is not implemented forObject *
, even though it is in Godot. I believe it is not possible to replicate the intended behavior without access toVariant::object_assign
(or internalObjData
). I made it fail statically using SFINAE.I think the rest should be the same.
PR contains a unit test for one of the internal accessors.
Depends on #1654.