mirror of
https://github.com/godotengine/godot.git
synced 2025-01-22 18:43:29 -05:00
Merge pull request #101016 from kiroxas/AddVariantStaticAssert
Add static assert checks in `Variant` constructors
This commit is contained in:
commit
b857c2f3e6
1 changed files with 21 additions and 0 deletions
|
@ -2378,66 +2378,79 @@ Variant::Variant(const ObjectID &p_id) :
|
|||
Variant::Variant(const StringName &p_string) :
|
||||
type(STRING_NAME) {
|
||||
memnew_placement(_data._mem, StringName(p_string));
|
||||
static_assert(sizeof(StringName) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const String &p_string) :
|
||||
type(STRING) {
|
||||
memnew_placement(_data._mem, String(p_string));
|
||||
static_assert(sizeof(String) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const char *const p_cstring) :
|
||||
type(STRING) {
|
||||
memnew_placement(_data._mem, String((const char *)p_cstring));
|
||||
static_assert(sizeof(String) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const char32_t *p_wstring) :
|
||||
type(STRING) {
|
||||
memnew_placement(_data._mem, String(p_wstring));
|
||||
static_assert(sizeof(String) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const Vector3 &p_vector3) :
|
||||
type(VECTOR3) {
|
||||
memnew_placement(_data._mem, Vector3(p_vector3));
|
||||
static_assert(sizeof(Vector3) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const Vector3i &p_vector3i) :
|
||||
type(VECTOR3I) {
|
||||
memnew_placement(_data._mem, Vector3i(p_vector3i));
|
||||
static_assert(sizeof(Vector3i) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const Vector4 &p_vector4) :
|
||||
type(VECTOR4) {
|
||||
memnew_placement(_data._mem, Vector4(p_vector4));
|
||||
static_assert(sizeof(Vector4) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const Vector4i &p_vector4i) :
|
||||
type(VECTOR4I) {
|
||||
memnew_placement(_data._mem, Vector4i(p_vector4i));
|
||||
static_assert(sizeof(Vector4i) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const Vector2 &p_vector2) :
|
||||
type(VECTOR2) {
|
||||
memnew_placement(_data._mem, Vector2(p_vector2));
|
||||
static_assert(sizeof(Vector2) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const Vector2i &p_vector2i) :
|
||||
type(VECTOR2I) {
|
||||
memnew_placement(_data._mem, Vector2i(p_vector2i));
|
||||
static_assert(sizeof(Vector2i) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const Rect2 &p_rect2) :
|
||||
type(RECT2) {
|
||||
memnew_placement(_data._mem, Rect2(p_rect2));
|
||||
static_assert(sizeof(Rect2) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const Rect2i &p_rect2i) :
|
||||
type(RECT2I) {
|
||||
memnew_placement(_data._mem, Rect2i(p_rect2i));
|
||||
static_assert(sizeof(Rect2i) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const Plane &p_plane) :
|
||||
type(PLANE) {
|
||||
memnew_placement(_data._mem, Plane(p_plane));
|
||||
static_assert(sizeof(Plane) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const ::AABB &p_aabb) :
|
||||
|
@ -2455,6 +2468,7 @@ Variant::Variant(const Basis &p_matrix) :
|
|||
Variant::Variant(const Quaternion &p_quaternion) :
|
||||
type(QUATERNION) {
|
||||
memnew_placement(_data._mem, Quaternion(p_quaternion));
|
||||
static_assert(sizeof(Quaternion) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const Transform3D &p_transform) :
|
||||
|
@ -2478,16 +2492,19 @@ Variant::Variant(const Transform2D &p_transform) :
|
|||
Variant::Variant(const Color &p_color) :
|
||||
type(COLOR) {
|
||||
memnew_placement(_data._mem, Color(p_color));
|
||||
static_assert(sizeof(Color) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const NodePath &p_node_path) :
|
||||
type(NODE_PATH) {
|
||||
memnew_placement(_data._mem, NodePath(p_node_path));
|
||||
static_assert(sizeof(NodePath) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const ::RID &p_rid) :
|
||||
type(RID) {
|
||||
memnew_placement(_data._mem, ::RID(p_rid));
|
||||
static_assert(sizeof(::RID) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const Object *p_object) :
|
||||
|
@ -2499,21 +2516,25 @@ Variant::Variant(const Object *p_object) :
|
|||
Variant::Variant(const Callable &p_callable) :
|
||||
type(CALLABLE) {
|
||||
memnew_placement(_data._mem, Callable(p_callable));
|
||||
static_assert(sizeof(Callable) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const Signal &p_callable) :
|
||||
type(SIGNAL) {
|
||||
memnew_placement(_data._mem, Signal(p_callable));
|
||||
static_assert(sizeof(Signal) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const Dictionary &p_dictionary) :
|
||||
type(DICTIONARY) {
|
||||
memnew_placement(_data._mem, Dictionary(p_dictionary));
|
||||
static_assert(sizeof(Dictionary) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const Array &p_array) :
|
||||
type(ARRAY) {
|
||||
memnew_placement(_data._mem, Array(p_array));
|
||||
static_assert(sizeof(Array) <= sizeof(_data._mem));
|
||||
}
|
||||
|
||||
Variant::Variant(const PackedByteArray &p_byte_array) :
|
||||
|
|
Loading…
Reference in a new issue