godot/core/variant/type_info.h

/**************************************************************************/
/*  type_info.h                                                           */
/**************************************************************************/
/*                         This file is part of:                          */
/*                             GODOT ENGINE                               */
/*                        https://godotengine.org                         */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */
/*                                                                        */
/* Permission is hereby granted, free of charge, to any person obtaining  */
/* a copy of this software and associated documentation files (the        */
/* "Software"), to deal in the Software without restriction, including    */
/* without limitation the rights to use, copy, modify, merge, publish,    */
/* distribute, sublicense, and/or sell copies of the Software, and to     */
/* permit persons to whom the Software is furnished to do so, subject to  */
/* the following conditions:                                              */
/*                                                                        */
/* The above copyright notice and this permission notice shall be         */
/* included in all copies or substantial portions of the Software.        */
/*                                                                        */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */
/**************************************************************************/

#ifndef TYPE_INFO_H
#define TYPE_INFO_H

#include "core/typedefs.h"

#include <type_traits>

namespace GodotTypeInfo {
enum Metadata {};
}

// If the compiler fails because it's trying to instantiate the primary 'GetTypeInfo' template
// instead of one of the specializations, it's most likely because the type 'T' is not supported.
// If 'T' is a class that inherits 'Object', make sure it can see the actual class declaration
// instead of a forward declaration. You can always forward declare 'T' in a header file, and then
// include the actual declaration of 'T' in the source file where 'GetTypeInfo<T>' is instantiated.
template <typename T, typename = void>
struct GetTypeInfo;

#define MAKE_TYPE_INFO(m_type, m_var_type)

#define MAKE_TYPE_INFO_WITH_META(m_type, m_var_type, m_metadata)

MAKE_TYPE_INFO(bool, Variant::BOOL)
MAKE_TYPE_INFO_WITH_META()
MAKE_TYPE_INFO_WITH_META()
MAKE_TYPE_INFO_WITH_META()
MAKE_TYPE_INFO_WITH_META()
MAKE_TYPE_INFO_WITH_META()
MAKE_TYPE_INFO_WITH_META()
MAKE_TYPE_INFO_WITH_META()
MAKE_TYPE_INFO_WITH_META()
MAKE_TYPE_INFO_WITH_META(char16_t, Variant::INT, GodotTypeInfo::METADATA_INT_IS_CHAR16)
MAKE_TYPE_INFO_WITH_META(char32_t, Variant::INT, GodotTypeInfo::METADATA_INT_IS_CHAR32)
MAKE_TYPE_INFO_WITH_META(float, Variant::FLOAT, GodotTypeInfo::METADATA_REAL_IS_FLOAT)
MAKE_TYPE_INFO_WITH_META(double, Variant::FLOAT, GodotTypeInfo::METADATA_REAL_IS_DOUBLE)

MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()
MAKE_TYPE_INFO()

MAKE_TYPE_INFO()

//objectID
template <>
struct GetTypeInfo<ObjectID> {};

//for variant
template <>
struct GetTypeInfo<Variant> {};

template <>
struct GetTypeInfo<const Variant &> {};

#define MAKE_TEMPLATE_TYPE_INFO(m_template, m_type, m_var_type)

MAKE_TEMPLATE_TYPE_INFO()
MAKE_TEMPLATE_TYPE_INFO()
MAKE_TEMPLATE_TYPE_INFO()
MAKE_TEMPLATE_TYPE_INFO()
MAKE_TEMPLATE_TYPE_INFO()

GetTypeInfo<T *, std::enable_if_t<std::is_base_of_v<Object, T>>>;

namespace godot {
namespace details {
inline String enum_qualified_name_to_class_info_name(const String &p_qualified_name) {}
} // namespace details
} // namespace godot

#define TEMPL_MAKE_ENUM_TYPE_INFO(m_enum, m_impl)

#define MAKE_ENUM_TYPE_INFO(m_enum)

template <typename T>
inline StringName __constant_get_enum_name(T param, const String &p_constant) {}

template <typename T>
class BitField {};

#define TEMPL_MAKE_BITFIELD_TYPE_INFO(m_enum, m_impl)

#define MAKE_BITFIELD_TYPE_INFO(m_enum)

template <typename T>
inline StringName __constant_get_bitfield_name(T param, const String &p_constant) {}
#define CLASS_INFO(m_type)

template <typename T>
struct ZeroInitializer {};

template <>
struct ZeroInitializer<bool> {};

ZeroInitializer<T *>;

#define ZERO_INITIALIZER_NUMBER(m_type)

ZERO_INITIALIZER_NUMBER(uint8_t)
ZERO_INITIALIZER_NUMBER(int8_t)
ZERO_INITIALIZER_NUMBER(uint16_t)
ZERO_INITIALIZER_NUMBER(int16_t)
ZERO_INITIALIZER_NUMBER(uint32_t)
ZERO_INITIALIZER_NUMBER(int32_t)
ZERO_INITIALIZER_NUMBER(uint64_t)
ZERO_INITIALIZER_NUMBER(int64_t)
ZERO_INITIALIZER_NUMBER(char16_t)
ZERO_INITIALIZER_NUMBER(char32_t)
ZERO_INITIALIZER_NUMBER(float)
ZERO_INITIALIZER_NUMBER(double)

#endif // TYPE_INFO_H