1/**************************************************************************/
2/* variant_destruct.h */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#ifndef VARIANT_DESTRUCT_H
32#define VARIANT_DESTRUCT_H
33
34#include "core/variant/variant.h"
35
36#include "core/object/class_db.h"
37
38template <class T>
39struct VariantDestruct {};
40
41#define MAKE_PTRDESTRUCT(m_type) \
42 template <> \
43 struct VariantDestruct<m_type> { \
44 _FORCE_INLINE_ static void ptr_destruct(void *p_ptr) { \
45 reinterpret_cast<m_type *>(p_ptr)->~m_type(); \
46 } \
47 _FORCE_INLINE_ static Variant::Type get_base_type() { \
48 return GetTypeInfo<m_type>::VARIANT_TYPE; \
49 } \
50 }
51
52MAKE_PTRDESTRUCT(String);
53MAKE_PTRDESTRUCT(StringName);
54MAKE_PTRDESTRUCT(NodePath);
55MAKE_PTRDESTRUCT(Callable);
56MAKE_PTRDESTRUCT(Signal);
57MAKE_PTRDESTRUCT(Dictionary);
58MAKE_PTRDESTRUCT(Array);
59MAKE_PTRDESTRUCT(PackedByteArray);
60MAKE_PTRDESTRUCT(PackedInt32Array);
61MAKE_PTRDESTRUCT(PackedInt64Array);
62MAKE_PTRDESTRUCT(PackedFloat32Array);
63MAKE_PTRDESTRUCT(PackedFloat64Array);
64MAKE_PTRDESTRUCT(PackedStringArray);
65MAKE_PTRDESTRUCT(PackedVector2Array);
66MAKE_PTRDESTRUCT(PackedVector3Array);
67MAKE_PTRDESTRUCT(PackedColorArray);
68
69#undef MAKE_PTRDESTRUCT
70
71#endif // VARIANT_DESTRUCT_H
72