feat: modules moved and engine moved to submodule

This commit is contained in:
Jan van der Weide 2025-04-12 18:40:44 +02:00
parent dfb5e645cd
commit c33d2130cc
5136 changed files with 225275 additions and 64485 deletions

View file

@ -28,15 +28,18 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef METHOD_PTRCALL_H
#define METHOD_PTRCALL_H
#pragma once
#include "core/object/object_id.h"
#include "core/templates/simple_type.h"
#include "core/typedefs.h"
#include "core/variant/variant.h"
template <typename T, typename = void>
struct PtrToArg;
template <typename T>
struct PtrToArg {};
struct PtrToArg<T, std::enable_if_t<!std::is_same_v<T, GetSimpleTypeT<T>>>> : PtrToArg<GetSimpleTypeT<T>> {};
#define MAKE_PTRARG(m_type) \
template <> \
@ -48,17 +51,7 @@ struct PtrToArg {};
_FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
*((m_type *)p_ptr) = p_val; \
} \
}; \
template <> \
struct PtrToArg<const m_type &> { \
_FORCE_INLINE_ static const m_type &convert(const void *p_ptr) { \
return *reinterpret_cast<const m_type *>(p_ptr); \
} \
typedef m_type EncodeT; \
_FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
*((m_type *)p_ptr) = p_val; \
} \
}
};
#define MAKE_PTRARGCONV(m_type, m_conv) \
template <> \
@ -70,17 +63,7 @@ struct PtrToArg {};
_FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
*((m_conv *)p_ptr) = static_cast<m_conv>(p_val); \
} \
}; \
template <> \
struct PtrToArg<const m_type &> { \
_FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
return static_cast<m_type>(*reinterpret_cast<const m_conv *>(p_ptr)); \
} \
typedef m_conv EncodeT; \
_FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
*((m_conv *)p_ptr) = static_cast<m_conv>(p_val); \
} \
}
};
#define MAKE_PTRARG_BY_REFERENCE(m_type) \
template <> \
@ -92,17 +75,19 @@ struct PtrToArg {};
_FORCE_INLINE_ static void encode(const m_type &p_val, void *p_ptr) { \
*((m_type *)p_ptr) = p_val; \
} \
}; \
template <> \
struct PtrToArg<const m_type &> { \
_FORCE_INLINE_ static const m_type &convert(const void *p_ptr) { \
return *reinterpret_cast<const m_type *>(p_ptr); \
} \
typedef m_type EncodeT; \
_FORCE_INLINE_ static void encode(const m_type &p_val, void *p_ptr) { \
*((m_type *)p_ptr) = p_val; \
} \
}
};
#define MAKE_PTRARGCONV_CONDITIONAL(m_type, m_conv, m_conditional) \
template <typename T> \
struct PtrToArg<m_type, std::enable_if_t<m_conditional>> { \
_FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
return static_cast<m_type>(*reinterpret_cast<const m_conv *>(p_ptr)); \
} \
typedef m_conv EncodeT; \
_FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
*((m_conv *)p_ptr) = static_cast<m_conv>(p_val); \
} \
};
MAKE_PTRARGCONV(bool, uint8_t);
// Integer types.
@ -155,6 +140,9 @@ MAKE_PTRARG(PackedColorArray);
MAKE_PTRARG(PackedVector4Array);
MAKE_PTRARG_BY_REFERENCE(Variant);
MAKE_PTRARGCONV_CONDITIONAL(T, int64_t, std::is_enum_v<T>);
MAKE_PTRARGCONV_CONDITIONAL(BitField<T>, int64_t, std::is_enum_v<T>);
// This is for Object.
template <typename T>
@ -222,23 +210,7 @@ struct PtrToArg<ObjectID> {
} \
} \
} \
}; \
template <> \
struct PtrToArg<const Vector<m_type> &> { \
_FORCE_INLINE_ static Vector<m_type> convert(const void *p_ptr) { \
const Vector<m_type> *dvs = reinterpret_cast<const Vector<m_type> *>(p_ptr); \
Vector<m_type> ret; \
int len = dvs->size(); \
ret.resize(len); \
{ \
const m_type *r = dvs->ptr(); \
for (int i = 0; i < len; i++) { \
ret.write[i] = r[i]; \
} \
} \
return ret; \
} \
}
};
// No EncodeT because direct pointer conversion not possible.
#define MAKE_VECARG_ALT(m_type, m_type_alt) \
@ -268,23 +240,7 @@ struct PtrToArg<ObjectID> {
} \
} \
} \
}; \
template <> \
struct PtrToArg<const Vector<m_type_alt> &> { \
_FORCE_INLINE_ static Vector<m_type_alt> convert(const void *p_ptr) { \
const Vector<m_type> *dvs = reinterpret_cast<const Vector<m_type> *>(p_ptr); \
Vector<m_type_alt> ret; \
int len = dvs->size(); \
ret.resize(len); \
{ \
const m_type *r = dvs->ptr(); \
for (int i = 0; i < len; i++) { \
ret.write[i] = r[i]; \
} \
} \
return ret; \
} \
}
};
MAKE_VECARG_ALT(String, StringName);
@ -312,20 +268,7 @@ MAKE_VECARG_ALT(String, StringName);
(*arr)[i] = p_vec[i]; \
} \
} \
}; \
template <> \
struct PtrToArg<const Vector<m_type> &> { \
_FORCE_INLINE_ static Vector<m_type> convert(const void *p_ptr) { \
const Array *arr = reinterpret_cast<const Array *>(p_ptr); \
Vector<m_type> ret; \
int len = arr->size(); \
ret.resize(len); \
for (int i = 0; i < len; i++) { \
ret.write[i] = (*arr)[i]; \
} \
return ret; \
} \
}
};
MAKE_VECARR(Variant);
MAKE_VECARR(RID);
@ -359,23 +302,7 @@ MAKE_VECARR(Plane);
} \
} \
} \
}; \
template <> \
struct PtrToArg<const Vector<m_type> &> { \
_FORCE_INLINE_ static Vector<m_type> convert(const void *p_ptr) { \
const Array *arr = reinterpret_cast<const Array *>(p_ptr); \
Vector<m_type> ret; \
int len = arr->size(); \
ret.resize(len); \
{ \
m_type *w = ret.ptrw(); \
for (int i = 0; i < len; i++) { \
w[i] = (*arr)[i]; \
} \
} \
return ret; \
} \
}
};
// Special case for IPAddress.
@ -391,15 +318,7 @@ MAKE_VECARR(Plane);
String *arr = reinterpret_cast<String *>(p_ptr); \
*arr = p_vec; \
} \
}; \
\
template <> \
struct PtrToArg<const m_type &> { \
_FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
m_type s = *reinterpret_cast<const String *>(p_ptr); \
return s; \
} \
}
};
MAKE_STRINGCONV_BY_REFERENCE(IPAddress);
@ -437,26 +356,3 @@ struct PtrToArg<Vector<Face3>> {
}
}
};
// No EncodeT because direct pointer conversion not possible.
template <>
struct PtrToArg<const Vector<Face3> &> {
_FORCE_INLINE_ static Vector<Face3> convert(const void *p_ptr) {
const Vector<Vector3> *dvs = reinterpret_cast<const Vector<Vector3> *>(p_ptr);
Vector<Face3> ret;
int len = dvs->size() / 3;
ret.resize(len);
{
const Vector3 *r = dvs->ptr();
Face3 *w = ret.ptrw();
for (int i = 0; i < len; i++) {
w[i].vertex[0] = r[i * 3 + 0];
w[i].vertex[1] = r[i * 3 + 1];
w[i].vertex[2] = r[i * 3 + 2];
}
}
return ret;
}
};
#endif // METHOD_PTRCALL_H