Skip to content

Commit 4b7f6b7

Browse files
committed
Introduce VariantImplicitConvert<> template for types that can be implicitly converted to and from Variant.
De-duplicate a lot of `VariantGetInternalPtr`, `VariantInternalAccessor`, `VariantInitializer` and `VariantDefaultInitializer`.
1 parent c374ce2 commit 4b7f6b7

File tree

4 files changed

+143
-547
lines changed

4 files changed

+143
-547
lines changed

core/variant/variant.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ class Variant {
171171

172172
friend struct _VariantCall;
173173
friend class VariantInternal;
174+
template <typename>
175+
friend struct _VariantGetInternalPtrLocal;
176+
template <typename>
177+
friend struct _VariantGetInternalPtrElsewhere;
178+
template <typename>
179+
friend struct _VariantGetInternalPtrPackedArrayRef;
174180
// Variant takes 24 bytes when real_t is float, and 40 bytes if double.
175181
// It only allocates extra memory for AABB/Transform2D (24, 48 if double),
176182
// Basis/Transform3D (48, 96 if double), Projection (64, 128 if double),

core/variant/variant_construct.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ void Variant::_register_variant_constructors() {
125125

126126
add_constructor<VariantConstructNoArgs<Transform2D>>(sarray());
127127
add_constructor<VariantConstructor<Transform2D, Transform2D>>(sarray("from"));
128-
add_constructor<VariantConstructor<Transform2D, float, Vector2>>(sarray("rotation", "position"));
129-
add_constructor<VariantConstructor<Transform2D, float, Size2, float, Vector2>>(sarray("rotation", "scale", "skew", "position"));
128+
add_constructor<VariantConstructor<Transform2D, double, Vector2>>(sarray("rotation", "position"));
129+
add_constructor<VariantConstructor<Transform2D, double, Size2, double, Vector2>>(sarray("rotation", "scale", "skew", "position"));
130130
add_constructor<VariantConstructor<Transform2D, Vector2, Vector2, Vector2>>(sarray("x_axis", "y_axis", "origin"));
131131

132132
add_constructor<VariantConstructNoArgs<Plane>>(sarray());

0 commit comments

Comments
 (0)