Skip to content

Commit f81287d

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 4fcd855 commit f81287d

File tree

4 files changed

+143
-625
lines changed

4 files changed

+143
-625
lines changed

core/variant/variant.h

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

174174
friend struct _VariantCall;
175175
friend class VariantInternal;
176+
template <typename>
177+
friend struct _VariantGetInternalPtrLocal;
178+
template <typename>
179+
friend struct _VariantGetInternalPtrElsewhere;
180+
template <typename>
181+
friend struct _VariantGetInternalPtrPackedArrayRef;
176182
// Variant takes 24 bytes when real_t is float, and 40 bytes if double.
177183
// It only allocates extra memory for AABB/Transform2D (24, 48 if double),
178184
// 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)