Fix issues with method calls
parent
e4ed48976a
commit
8bcf32a619
|
@ -58,6 +58,8 @@ endif()
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||||
add_definitions(-D_DEBUG)
|
add_definitions(-D_DEBUG)
|
||||||
|
add_definitions(-DDEBUG_ENABLED)
|
||||||
|
add_definitions(-DDEBUG_METHODS_ENABLED)
|
||||||
else()
|
else()
|
||||||
add_definitions(-DNDEBUG)
|
add_definitions(-DNDEBUG)
|
||||||
endif(CMAKE_BUILD_TYPE MATCHES Debug)
|
endif(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||||
|
|
14
SConstruct
14
SConstruct
|
@ -158,11 +158,14 @@ if host_platform == "windows" and env["platform"] != "android":
|
||||||
|
|
||||||
opts.Update(env)
|
opts.Update(env)
|
||||||
|
|
||||||
|
if env["target"] == "debug":
|
||||||
|
env.Append(CPPDEFINES=["DEBUG_ENABLED", "DEBUG_METHODS_ENABLED"])
|
||||||
|
|
||||||
if env["platform"] == "linux" or env["platform"] == "freebsd":
|
if env["platform"] == "linux" or env["platform"] == "freebsd":
|
||||||
if env["use_llvm"]:
|
if env["use_llvm"]:
|
||||||
env["CXX"] = "clang++"
|
env["CXX"] = "clang++"
|
||||||
|
|
||||||
env.Append(CCFLAGS=["-fPIC", "-std=c++14", "-Wwrite-strings"])
|
env.Append(CCFLAGS=["-fPIC", "-std=c++17", "-Wwrite-strings"])
|
||||||
env.Append(LINKFLAGS=["-Wl,-R,'$$ORIGIN'"])
|
env.Append(LINKFLAGS=["-Wl,-R,'$$ORIGIN'"])
|
||||||
|
|
||||||
if env["target"] == "debug":
|
if env["target"] == "debug":
|
||||||
|
@ -184,7 +187,7 @@ elif env["platform"] == "osx":
|
||||||
if env["bits"] == "32":
|
if env["bits"] == "32":
|
||||||
raise ValueError("Only 64-bit builds are supported for the macOS target.")
|
raise ValueError("Only 64-bit builds are supported for the macOS target.")
|
||||||
|
|
||||||
env.Append(CCFLAGS=["-std=c++14", "-arch", env["macos_arch"]])
|
env.Append(CCFLAGS=["-std=c++17", "-arch", env["macos_arch"]])
|
||||||
|
|
||||||
if env["macos_deployment_target"] != "default":
|
if env["macos_deployment_target"] != "default":
|
||||||
env.Append(CCFLAGS=["-mmacosx-version-min=" + env["macos_deployment_target"]])
|
env.Append(CCFLAGS=["-mmacosx-version-min=" + env["macos_deployment_target"]])
|
||||||
|
@ -231,7 +234,7 @@ elif env["platform"] == "ios":
|
||||||
env["AR"] = compiler_path + "ar"
|
env["AR"] = compiler_path + "ar"
|
||||||
env["RANLIB"] = compiler_path + "ranlib"
|
env["RANLIB"] = compiler_path + "ranlib"
|
||||||
|
|
||||||
env.Append(CCFLAGS=["-std=c++14", "-arch", env["ios_arch"], "-isysroot", sdk_path])
|
env.Append(CCFLAGS=["-std=c++17", "-arch", env["ios_arch"], "-isysroot", sdk_path])
|
||||||
env.Append(
|
env.Append(
|
||||||
LINKFLAGS=[
|
LINKFLAGS=[
|
||||||
"-arch",
|
"-arch",
|
||||||
|
@ -283,7 +286,7 @@ elif env["platform"] == "windows":
|
||||||
# Native or cross-compilation using MinGW
|
# Native or cross-compilation using MinGW
|
||||||
if host_platform == "linux" or host_platform == "freebsd" or host_platform == "osx" or env["use_mingw"]:
|
if host_platform == "linux" or host_platform == "freebsd" or host_platform == "osx" or env["use_mingw"]:
|
||||||
# These options are for a release build even using target=debug
|
# These options are for a release build even using target=debug
|
||||||
env.Append(CCFLAGS=["-O3", "-std=c++14", "-Wwrite-strings"])
|
env.Append(CCFLAGS=["-O3", "-std=c++17", "-Wwrite-strings"])
|
||||||
env.Append(
|
env.Append(
|
||||||
LINKFLAGS=[
|
LINKFLAGS=[
|
||||||
"--static",
|
"--static",
|
||||||
|
@ -429,7 +432,7 @@ else:
|
||||||
|
|
||||||
if env["generate_bindings"] == "auto":
|
if env["generate_bindings"] == "auto":
|
||||||
# Check if generated files exist
|
# Check if generated files exist
|
||||||
should_generate_bindings = not os.path.isfile(os.path.join(os.getcwd(), "src", "gen", "object.cpp"))
|
should_generate_bindings = not os.path.isfile(os.path.join(os.getcwd(), "gen", "src", "classes", "object.cpp"))
|
||||||
else:
|
else:
|
||||||
should_generate_bindings = env["generate_bindings"] in ["yes", "true"]
|
should_generate_bindings = env["generate_bindings"] in ["yes", "true"]
|
||||||
|
|
||||||
|
@ -441,6 +444,7 @@ if should_generate_bindings:
|
||||||
|
|
||||||
# Sources to compile
|
# Sources to compile
|
||||||
sources = []
|
sources = []
|
||||||
|
add_sources(sources, "src", "cpp")
|
||||||
add_sources(sources, "src/core", "cpp")
|
add_sources(sources, "src/core", "cpp")
|
||||||
add_sources(sources, "src/variant", "cpp")
|
add_sources(sources, "src/variant", "cpp")
|
||||||
add_sources(sources, "gen/src/variant", "cpp")
|
add_sources(sources, "gen/src/variant", "cpp")
|
||||||
|
|
|
@ -179,7 +179,7 @@ def generate_builtin_bindings(api, output_dir, build_config):
|
||||||
builtin_header.append("")
|
builtin_header.append("")
|
||||||
|
|
||||||
for builtin in builtin_classes:
|
for builtin in builtin_classes:
|
||||||
builtin_header.append(f'#include <godot_cpp/variant/{camel_to_snake(builtin)}.hpp>')
|
builtin_header.append(f"#include <godot_cpp/variant/{camel_to_snake(builtin)}.hpp>")
|
||||||
|
|
||||||
builtin_header.append("")
|
builtin_header.append("")
|
||||||
|
|
||||||
|
@ -229,7 +229,9 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
|
||||||
result.append(f"class {class_name} {{")
|
result.append(f"class {class_name} {{")
|
||||||
result.append(f"\tstatic constexpr size_t {snake_class_name}_SIZE = {size};")
|
result.append(f"\tstatic constexpr size_t {snake_class_name}_SIZE = {size};")
|
||||||
result.append(f"\tuint8_t opaque[{snake_class_name}_SIZE] {{ 0 }};")
|
result.append(f"\tuint8_t opaque[{snake_class_name}_SIZE] {{ 0 }};")
|
||||||
result.append(f"\tGDNativeTypePtr ptr = const_cast<uint8_t (*)[{snake_class_name}_SIZE]>(&opaque);")
|
result.append(
|
||||||
|
f"\t_FORCE_INLINE_ GDNativeTypePtr ptr() const {{ return const_cast<uint8_t (*)[{snake_class_name}_SIZE]>(&opaque); }}"
|
||||||
|
)
|
||||||
|
|
||||||
result.append("")
|
result.append("")
|
||||||
result.append("\tfriend class Variant;")
|
result.append("\tfriend class Variant;")
|
||||||
|
@ -1007,10 +1009,10 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
|
||||||
if is_pod_type(return_type) or is_variant(return_type) or is_enum(return_type):
|
if is_pod_type(return_type) or is_variant(return_type) or is_enum(return_type):
|
||||||
method_call += f"return internal::_call_native_mb_ret<{correct_type(return_type, meta_type)}>(___method_bind, _owner"
|
method_call += f"return internal::_call_native_mb_ret<{correct_type(return_type, meta_type)}>(___method_bind, _owner"
|
||||||
elif is_refcounted(return_type):
|
elif is_refcounted(return_type):
|
||||||
method_call += f"return Ref<{return_type}>::___internal_constructor(internal::_call_native_mb_ret_obj<{class_name}>(___method_bind, _owner"
|
method_call += f"return Ref<{return_type}>::___internal_constructor(internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, _owner"
|
||||||
is_ref = True
|
is_ref = True
|
||||||
else:
|
else:
|
||||||
method_call += f"return ({correct_type(return_type)})internal::_call_native_mb_ret_obj<{class_name}>(___method_bind, _owner"
|
method_call += f"return ({correct_type(return_type)})internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, _owner"
|
||||||
else:
|
else:
|
||||||
method_call += f"internal::_call_native_mb_no_ret(___method_bind, _owner"
|
method_call += f"internal::_call_native_mb_no_ret(___method_bind, _owner"
|
||||||
|
|
||||||
|
@ -1029,7 +1031,7 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
|
||||||
else: # vararg.
|
else: # vararg.
|
||||||
result.append("\tGDNativeCallError error;")
|
result.append("\tGDNativeCallError error;")
|
||||||
result.append("\tVariant ret;")
|
result.append("\tVariant ret;")
|
||||||
method_call += "internal::interface->object_method_bind_call(___method_bind, _owner, (const GDNativeVariantPtr *)args, arg_count, ret, &error"
|
method_call += "internal::interface->object_method_bind_call(___method_bind, _owner, (const GDNativeVariantPtr *)args, arg_count, &ret, &error"
|
||||||
|
|
||||||
if is_ref:
|
if is_ref:
|
||||||
method_call += ")" # Close Ref<> constructor.
|
method_call += ")" # Close Ref<> constructor.
|
||||||
|
|
|
@ -259,7 +259,7 @@ void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), const G
|
||||||
std::array<const Variant *, sizeof...(P)> argsp;
|
std::array<const Variant *, sizeof...(P)> argsp;
|
||||||
for (int32_t i = 0; i < (int32_t)sizeof...(P); i++) {
|
for (int32_t i = 0; i < (int32_t)sizeof...(P); i++) {
|
||||||
if (i < p_argcount) {
|
if (i < p_argcount) {
|
||||||
args[i] = p_args[i];
|
args[i] = Variant(p_args[i]);
|
||||||
} else {
|
} else {
|
||||||
args[i] = default_values[i - p_argcount + (dvs - missing)];
|
args[i] = default_values[i - p_argcount + (dvs - missing)];
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,7 @@ void call_with_variant_argsc_dv(T *p_instance, void (T::*p_method)(P...) const,
|
||||||
std::array<const Variant *, sizeof...(P)> argsp;
|
std::array<const Variant *, sizeof...(P)> argsp;
|
||||||
for (int32_t i = 0; i < (int32_t)sizeof...(P); i++) {
|
for (int32_t i = 0; i < (int32_t)sizeof...(P); i++) {
|
||||||
if (i < p_argcount) {
|
if (i < p_argcount) {
|
||||||
args[i] = p_args[i];
|
args[i] = Variant(p_args[i]);
|
||||||
} else {
|
} else {
|
||||||
args[i] = default_values[i - p_argcount + (dvs - missing)];
|
args[i] = default_values[i - p_argcount + (dvs - missing)];
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,7 @@ void call_with_variant_args_ret_dv(T *p_instance, R (T::*p_method)(P...), const
|
||||||
std::array<const Variant *, sizeof...(P)> argsp;
|
std::array<const Variant *, sizeof...(P)> argsp;
|
||||||
for (int32_t i = 0; i < (int32_t)sizeof...(P); i++) {
|
for (int32_t i = 0; i < (int32_t)sizeof...(P); i++) {
|
||||||
if (i < p_argcount) {
|
if (i < p_argcount) {
|
||||||
args[i] = p_args[i];
|
args[i] = Variant(p_args[i]);
|
||||||
} else {
|
} else {
|
||||||
args[i] = default_values[i - p_argcount + (dvs - missing)];
|
args[i] = default_values[i - p_argcount + (dvs - missing)];
|
||||||
}
|
}
|
||||||
|
@ -364,7 +364,7 @@ void call_with_variant_args_retc_dv(T *p_instance, R (T::*p_method)(P...) const,
|
||||||
std::array<const Variant *, sizeof...(P)> argsp;
|
std::array<const Variant *, sizeof...(P)> argsp;
|
||||||
for (int32_t i = 0; i < (int32_t)sizeof...(P); i++) {
|
for (int32_t i = 0; i < (int32_t)sizeof...(P); i++) {
|
||||||
if (i < p_argcount) {
|
if (i < p_argcount) {
|
||||||
args[i] = p_args[i];
|
args[i] = Variant(p_args[i]);
|
||||||
} else {
|
} else {
|
||||||
args[i] = default_values[i - p_argcount + (dvs - missing)];
|
args[i] = default_values[i - p_argcount + (dvs - missing)];
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,36 @@
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
|
template <bool C, typename T = void>
|
||||||
|
struct EnableIf {
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct EnableIf<false, T> {
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename, typename>
|
||||||
|
struct TypesAreSame {
|
||||||
|
static bool const value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename A>
|
||||||
|
struct TypesAreSame<A, A> {
|
||||||
|
static bool const value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename B, typename D>
|
||||||
|
struct TypeInherits {
|
||||||
|
static D *get_d();
|
||||||
|
|
||||||
|
static char (&test(B *))[1];
|
||||||
|
static char (&test(...))[2];
|
||||||
|
|
||||||
|
static bool const value = sizeof(test(get_d())) == sizeof(char) &&
|
||||||
|
!TypesAreSame<B volatile const, void volatile const>::value;
|
||||||
|
};
|
||||||
|
|
||||||
// If the compiler fails because it's trying to instantiate the primary 'GetTypeInfo' template
|
// 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.
|
// 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
|
// If 'T' is a class that inherits 'Object', make sure it can see the actual class declaration
|
||||||
|
@ -147,6 +177,24 @@ struct GetTypeInfo<const Variant &> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct GetTypeInfo<T *, typename EnableIf<TypeInherits<Object, T>::value>::type> {
|
||||||
|
static const GDNativeVariantType VARIANT_TYPE = GDNATIVE_VARIANT_TYPE_OBJECT;
|
||||||
|
static const GDNativeExtensionClassMethodArgumentMetadata METADATA = GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_NONE;
|
||||||
|
static inline PropertyInfo get_class_info() {
|
||||||
|
return PropertyInfo(GDNATIVE_VARIANT_TYPE_OBJECT, T::get_class_static());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct GetTypeInfo<const T *, typename EnableIf<TypeInherits<Object, T>::value>::type> {
|
||||||
|
static const GDNativeVariantType VARIANT_TYPE = GDNATIVE_VARIANT_TYPE_OBJECT;
|
||||||
|
static const GDNativeExtensionClassMethodArgumentMetadata METADATA = GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_NONE;
|
||||||
|
static inline PropertyInfo get_class_info() {
|
||||||
|
return PropertyInfo(GDNATIVE_VARIANT_TYPE_OBJECT, T::get_class_static());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
#define TEMPL_MAKE_ENUM_TYPE_INFO(m_class, m_enum, m_impl) \
|
#define TEMPL_MAKE_ENUM_TYPE_INFO(m_class, m_enum, m_impl) \
|
||||||
template <> \
|
template <> \
|
||||||
struct GetTypeInfo<m_impl> { \
|
struct GetTypeInfo<m_impl> { \
|
||||||
|
|
|
@ -44,7 +44,8 @@ namespace godot {
|
||||||
|
|
||||||
class Variant {
|
class Variant {
|
||||||
uint8_t opaque[GODOT_CPP_VARIANT_SIZE]{ 0 };
|
uint8_t opaque[GODOT_CPP_VARIANT_SIZE]{ 0 };
|
||||||
GDNativeVariantPtr ptr = const_cast<uint8_t (*)[GODOT_CPP_VARIANT_SIZE]>(&opaque);
|
|
||||||
|
_FORCE_INLINE_ GDNativeVariantPtr ptr() const { return const_cast<uint8_t(*)[GODOT_CPP_VARIANT_SIZE]>(&opaque); }
|
||||||
|
|
||||||
friend class GDExtensionBinding;
|
friend class GDExtensionBinding;
|
||||||
friend class MethodBind;
|
friend class MethodBind;
|
||||||
|
@ -141,7 +142,7 @@ public:
|
||||||
Variant();
|
Variant();
|
||||||
Variant(std::nullptr_t n) :
|
Variant(std::nullptr_t n) :
|
||||||
Variant() {}
|
Variant() {}
|
||||||
Variant(const GDNativeVariantPtr native_ptr);
|
explicit Variant(const GDNativeVariantPtr native_ptr);
|
||||||
Variant(const Variant &other);
|
Variant(const Variant &other);
|
||||||
Variant(Variant &&other);
|
Variant(Variant &&other);
|
||||||
Variant(bool v);
|
Variant(bool v);
|
||||||
|
@ -235,17 +236,12 @@ public:
|
||||||
operator PackedVector3Array() const;
|
operator PackedVector3Array() const;
|
||||||
operator PackedColorArray() const;
|
operator PackedColorArray() const;
|
||||||
|
|
||||||
operator const GDNativeVariantPtr() const;
|
|
||||||
operator GDNativeVariantPtr();
|
|
||||||
|
|
||||||
Variant &operator=(const Variant &other);
|
Variant &operator=(const Variant &other);
|
||||||
Variant &operator=(Variant &&other);
|
Variant &operator=(Variant &&other);
|
||||||
bool operator==(const Variant &other) const;
|
bool operator==(const Variant &other) const;
|
||||||
bool operator!=(const Variant &other) const;
|
bool operator!=(const Variant &other) const;
|
||||||
bool operator<(const Variant &other) const;
|
bool operator<(const Variant &other) const;
|
||||||
|
|
||||||
void operator=(const GDNativeVariantPtr other_ptr);
|
|
||||||
|
|
||||||
void call(const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDNativeCallError &r_error);
|
void call(const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDNativeCallError &r_error);
|
||||||
|
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
|
|
|
@ -103,7 +103,7 @@ void MethodBind::bind_call(void *p_method_userdata, GDExtensionClassInstancePtr
|
||||||
Variant ret = bind->call(p_instance, p_args, p_argument_count, *r_error);
|
Variant ret = bind->call(p_instance, p_args, p_argument_count, *r_error);
|
||||||
// This assumes the return value is an empty Variant, so it doesn't need to call the destructor first.
|
// This assumes the return value is an empty Variant, so it doesn't need to call the destructor first.
|
||||||
// Since only NativeExtensionMethodBind calls this from the Godot side, it should always be the case.
|
// Since only NativeExtensionMethodBind calls this from the Godot side, it should always be the case.
|
||||||
internal::interface->variant_new_copy(r_return, ret.ptr);
|
internal::interface->variant_new_copy(r_return, ret.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MethodBind::bind_ptrcall(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_return) {
|
void MethodBind::bind_ptrcall(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_return) {
|
||||||
|
|
|
@ -75,25 +75,25 @@ CharWideString::~CharWideString() {
|
||||||
// It's easier to have them written in C++ directly than in a Python script that generates them.
|
// It's easier to have them written in C++ directly than in a Python script that generates them.
|
||||||
|
|
||||||
String::String(const char *from) {
|
String::String(const char *from) {
|
||||||
internal::interface->string_new_with_utf8_chars(ptr, from);
|
internal::interface->string_new_with_utf8_chars(ptr(), from);
|
||||||
}
|
}
|
||||||
|
|
||||||
String::String(const wchar_t *from) {
|
String::String(const wchar_t *from) {
|
||||||
internal::interface->string_new_with_wide_chars(ptr, from);
|
internal::interface->string_new_with_wide_chars(ptr(), from);
|
||||||
}
|
}
|
||||||
|
|
||||||
String::String(const char16_t *from) {
|
String::String(const char16_t *from) {
|
||||||
internal::interface->string_new_with_utf16_chars(ptr, from);
|
internal::interface->string_new_with_utf16_chars(ptr(), from);
|
||||||
}
|
}
|
||||||
|
|
||||||
String::String(const char32_t *from) {
|
String::String(const char32_t *from) {
|
||||||
internal::interface->string_new_with_utf32_chars(ptr, from);
|
internal::interface->string_new_with_utf32_chars(ptr(), from);
|
||||||
}
|
}
|
||||||
|
|
||||||
CharString String::utf8() const {
|
CharString String::utf8() const {
|
||||||
int size = internal::interface->string_to_utf8_chars(ptr, nullptr, 0);
|
int size = internal::interface->string_to_utf8_chars(ptr(), nullptr, 0);
|
||||||
char *cstr = memnew_arr(char, size + 1);
|
char *cstr = memnew_arr(char, size + 1);
|
||||||
internal::interface->string_to_utf8_chars(ptr, cstr, size + 1);
|
internal::interface->string_to_utf8_chars(ptr(), cstr, size + 1);
|
||||||
|
|
||||||
cstr[size] = '\0';
|
cstr[size] = '\0';
|
||||||
|
|
||||||
|
@ -101,9 +101,9 @@ CharString String::utf8() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
CharString String::ascii() const {
|
CharString String::ascii() const {
|
||||||
int size = internal::interface->string_to_latin1_chars(ptr, nullptr, 0);
|
int size = internal::interface->string_to_latin1_chars(ptr(), nullptr, 0);
|
||||||
char *cstr = memnew_arr(char, size + 1);
|
char *cstr = memnew_arr(char, size + 1);
|
||||||
internal::interface->string_to_latin1_chars(ptr, cstr, size + 1);
|
internal::interface->string_to_latin1_chars(ptr(), cstr, size + 1);
|
||||||
|
|
||||||
cstr[size] = '\0';
|
cstr[size] = '\0';
|
||||||
|
|
||||||
|
@ -111,9 +111,9 @@ CharString String::ascii() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
Char16String String::utf16() const {
|
Char16String String::utf16() const {
|
||||||
int size = internal::interface->string_to_utf16_chars(ptr, nullptr, 0);
|
int size = internal::interface->string_to_utf16_chars(ptr(), nullptr, 0);
|
||||||
char16_t *cstr = memnew_arr(char16_t, size + 1);
|
char16_t *cstr = memnew_arr(char16_t, size + 1);
|
||||||
internal::interface->string_to_utf16_chars(ptr, cstr, size + 1);
|
internal::interface->string_to_utf16_chars(ptr(), cstr, size + 1);
|
||||||
|
|
||||||
cstr[size] = '\0';
|
cstr[size] = '\0';
|
||||||
|
|
||||||
|
@ -121,9 +121,9 @@ Char16String String::utf16() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
Char32String String::utf32() const {
|
Char32String String::utf32() const {
|
||||||
int size = internal::interface->string_to_utf32_chars(ptr, nullptr, 0);
|
int size = internal::interface->string_to_utf32_chars(ptr(), nullptr, 0);
|
||||||
char32_t *cstr = memnew_arr(char32_t, size + 1);
|
char32_t *cstr = memnew_arr(char32_t, size + 1);
|
||||||
internal::interface->string_to_utf32_chars(ptr, cstr, size + 1);
|
internal::interface->string_to_utf32_chars(ptr(), cstr, size + 1);
|
||||||
|
|
||||||
cstr[size] = '\0';
|
cstr[size] = '\0';
|
||||||
|
|
||||||
|
@ -131,9 +131,9 @@ Char32String String::utf32() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
CharWideString String::wide_string() const {
|
CharWideString String::wide_string() const {
|
||||||
int size = internal::interface->string_to_wide_chars(ptr, nullptr, 0);
|
int size = internal::interface->string_to_wide_chars(ptr(), nullptr, 0);
|
||||||
wchar_t *cstr = memnew_arr(wchar_t, size + 1);
|
wchar_t *cstr = memnew_arr(wchar_t, size + 1);
|
||||||
internal::interface->string_to_wide_chars(ptr, cstr, size + 1);
|
internal::interface->string_to_wide_chars(ptr(), cstr, size + 1);
|
||||||
|
|
||||||
cstr[size] = '\0';
|
cstr[size] = '\0';
|
||||||
|
|
||||||
|
|
|
@ -82,15 +82,15 @@ void Variant::init_bindings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant() {
|
Variant::Variant() {
|
||||||
internal::interface->variant_new_nil(ptr);
|
internal::interface->variant_new_nil(ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const GDNativeVariantPtr native_ptr) {
|
Variant::Variant(const GDNativeVariantPtr native_ptr) {
|
||||||
internal::interface->variant_new_copy(ptr, native_ptr);
|
internal::interface->variant_new_copy(ptr(), native_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Variant &other) {
|
Variant::Variant(const Variant &other) {
|
||||||
internal::interface->variant_new_copy(ptr, other.ptr);
|
internal::interface->variant_new_copy(ptr(), other.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(Variant &&other) {
|
Variant::Variant(Variant &&other) {
|
||||||
|
@ -100,158 +100,158 @@ Variant::Variant(Variant &&other) {
|
||||||
Variant::Variant(bool v) {
|
Variant::Variant(bool v) {
|
||||||
GDNativeBool encoded;
|
GDNativeBool encoded;
|
||||||
PtrToArg<bool>::encode(v, &encoded);
|
PtrToArg<bool>::encode(v, &encoded);
|
||||||
from_type_constructor[BOOL](ptr, &encoded);
|
from_type_constructor[BOOL](ptr(), &encoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(int64_t v) {
|
Variant::Variant(int64_t v) {
|
||||||
GDNativeInt encoded;
|
GDNativeInt encoded;
|
||||||
PtrToArg<int64_t>::encode(v, &encoded);
|
PtrToArg<int64_t>::encode(v, &encoded);
|
||||||
from_type_constructor[INT](ptr, &encoded);
|
from_type_constructor[INT](ptr(), &encoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(double v) {
|
Variant::Variant(double v) {
|
||||||
double encoded;
|
double encoded;
|
||||||
PtrToArg<double>::encode(v, &encoded);
|
PtrToArg<double>::encode(v, &encoded);
|
||||||
from_type_constructor[FLOAT](ptr, &encoded);
|
from_type_constructor[FLOAT](ptr(), &encoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const String &v) {
|
Variant::Variant(const String &v) {
|
||||||
from_type_constructor[STRING](ptr, v.ptr);
|
from_type_constructor[STRING](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Vector2 &v) {
|
Variant::Variant(const Vector2 &v) {
|
||||||
from_type_constructor[VECTOR2](ptr, v.ptr);
|
from_type_constructor[VECTOR2](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Vector2i &v) {
|
Variant::Variant(const Vector2i &v) {
|
||||||
from_type_constructor[VECTOR2I](ptr, v.ptr);
|
from_type_constructor[VECTOR2I](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Rect2 &v) {
|
Variant::Variant(const Rect2 &v) {
|
||||||
from_type_constructor[RECT2](ptr, v.ptr);
|
from_type_constructor[RECT2](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Rect2i &v) {
|
Variant::Variant(const Rect2i &v) {
|
||||||
from_type_constructor[RECT2I](ptr, v.ptr);
|
from_type_constructor[RECT2I](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Vector3 &v) {
|
Variant::Variant(const Vector3 &v) {
|
||||||
from_type_constructor[VECTOR3](ptr, v.ptr);
|
from_type_constructor[VECTOR3](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Vector3i &v) {
|
Variant::Variant(const Vector3i &v) {
|
||||||
from_type_constructor[VECTOR3I](ptr, v.ptr);
|
from_type_constructor[VECTOR3I](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Transform2D &v) {
|
Variant::Variant(const Transform2D &v) {
|
||||||
from_type_constructor[TRANSFORM2D](ptr, v.ptr);
|
from_type_constructor[TRANSFORM2D](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Plane &v) {
|
Variant::Variant(const Plane &v) {
|
||||||
from_type_constructor[PLANE](ptr, v.ptr);
|
from_type_constructor[PLANE](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Quaternion &v) {
|
Variant::Variant(const Quaternion &v) {
|
||||||
from_type_constructor[QUATERNION](ptr, v.ptr);
|
from_type_constructor[QUATERNION](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const godot::AABB &v) {
|
Variant::Variant(const godot::AABB &v) {
|
||||||
from_type_constructor[AABB](ptr, v.ptr);
|
from_type_constructor[AABB](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Basis &v) {
|
Variant::Variant(const Basis &v) {
|
||||||
from_type_constructor[BASIS](ptr, v.ptr);
|
from_type_constructor[BASIS](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Transform3D &v) {
|
Variant::Variant(const Transform3D &v) {
|
||||||
from_type_constructor[TRANSFORM3D](ptr, v.ptr);
|
from_type_constructor[TRANSFORM3D](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Color &v) {
|
Variant::Variant(const Color &v) {
|
||||||
from_type_constructor[COLOR](ptr, v.ptr);
|
from_type_constructor[COLOR](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const StringName &v) {
|
Variant::Variant(const StringName &v) {
|
||||||
from_type_constructor[STRING_NAME](ptr, v.ptr);
|
from_type_constructor[STRING_NAME](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const NodePath &v) {
|
Variant::Variant(const NodePath &v) {
|
||||||
from_type_constructor[NODE_PATH](ptr, v.ptr);
|
from_type_constructor[NODE_PATH](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const godot::RID &v) {
|
Variant::Variant(const godot::RID &v) {
|
||||||
from_type_constructor[RID](ptr, v.ptr);
|
from_type_constructor[RID](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Object *v) {
|
Variant::Variant(const Object *v) {
|
||||||
from_type_constructor[OBJECT](ptr, v->_owner);
|
from_type_constructor[OBJECT](ptr(), const_cast<GodotObject **>(&v->_owner));
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Callable &v) {
|
Variant::Variant(const Callable &v) {
|
||||||
from_type_constructor[CALLABLE](ptr, v.ptr);
|
from_type_constructor[CALLABLE](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Signal &v) {
|
Variant::Variant(const Signal &v) {
|
||||||
from_type_constructor[SIGNAL](ptr, v.ptr);
|
from_type_constructor[SIGNAL](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Dictionary &v) {
|
Variant::Variant(const Dictionary &v) {
|
||||||
from_type_constructor[DICTIONARY](ptr, v.ptr);
|
from_type_constructor[DICTIONARY](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const Array &v) {
|
Variant::Variant(const Array &v) {
|
||||||
from_type_constructor[ARRAY](ptr, v.ptr);
|
from_type_constructor[ARRAY](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const PackedByteArray &v) {
|
Variant::Variant(const PackedByteArray &v) {
|
||||||
from_type_constructor[PACKED_BYTE_ARRAY](ptr, v.ptr);
|
from_type_constructor[PACKED_BYTE_ARRAY](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const PackedInt32Array &v) {
|
Variant::Variant(const PackedInt32Array &v) {
|
||||||
from_type_constructor[PACKED_INT32_ARRAY](ptr, v.ptr);
|
from_type_constructor[PACKED_INT32_ARRAY](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const PackedInt64Array &v) {
|
Variant::Variant(const PackedInt64Array &v) {
|
||||||
from_type_constructor[PACKED_INT64_ARRAY](ptr, v.ptr);
|
from_type_constructor[PACKED_INT64_ARRAY](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const PackedFloat32Array &v) {
|
Variant::Variant(const PackedFloat32Array &v) {
|
||||||
from_type_constructor[PACKED_FLOAT32_ARRAY](ptr, v.ptr);
|
from_type_constructor[PACKED_FLOAT32_ARRAY](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const PackedFloat64Array &v) {
|
Variant::Variant(const PackedFloat64Array &v) {
|
||||||
from_type_constructor[PACKED_FLOAT64_ARRAY](ptr, v.ptr);
|
from_type_constructor[PACKED_FLOAT64_ARRAY](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const PackedStringArray &v) {
|
Variant::Variant(const PackedStringArray &v) {
|
||||||
from_type_constructor[PACKED_STRING_ARRAY](ptr, v.ptr);
|
from_type_constructor[PACKED_STRING_ARRAY](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const PackedVector2Array &v) {
|
Variant::Variant(const PackedVector2Array &v) {
|
||||||
from_type_constructor[PACKED_VECTOR2_ARRAY](ptr, v.ptr);
|
from_type_constructor[PACKED_VECTOR2_ARRAY](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const PackedVector3Array &v) {
|
Variant::Variant(const PackedVector3Array &v) {
|
||||||
from_type_constructor[PACKED_VECTOR3_ARRAY](ptr, v.ptr);
|
from_type_constructor[PACKED_VECTOR3_ARRAY](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant(const PackedColorArray &v) {
|
Variant::Variant(const PackedColorArray &v) {
|
||||||
from_type_constructor[PACKED_COLOR_ARRAY](ptr, v.ptr);
|
from_type_constructor[PACKED_COLOR_ARRAY](ptr(), v.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::~Variant() {
|
Variant::~Variant() {
|
||||||
internal::interface->variant_destroy(ptr);
|
internal::interface->variant_destroy(ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator bool() const {
|
Variant::operator bool() const {
|
||||||
GDNativeBool result;
|
GDNativeBool result;
|
||||||
to_type_constructor[BOOL](&result, ptr);
|
to_type_constructor[BOOL](&result, ptr());
|
||||||
return PtrToArg<bool>::convert(&result);
|
return PtrToArg<bool>::convert(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator int64_t() const {
|
Variant::operator int64_t() const {
|
||||||
GDNativeInt result;
|
GDNativeInt result;
|
||||||
to_type_constructor[INT](&result, ptr);
|
to_type_constructor[INT](&result, ptr());
|
||||||
return PtrToArg<int64_t>::convert(&result);
|
return PtrToArg<int64_t>::convert(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ Variant::operator uint32_t() const {
|
||||||
|
|
||||||
Variant::operator double() const {
|
Variant::operator double() const {
|
||||||
double result;
|
double result;
|
||||||
to_type_constructor[FLOAT](&result, ptr);
|
to_type_constructor[FLOAT](&result, ptr());
|
||||||
return PtrToArg<double>::convert(&result);
|
return PtrToArg<double>::convert(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,201 +279,196 @@ Variant::operator float() const {
|
||||||
|
|
||||||
Variant::operator String() const {
|
Variant::operator String() const {
|
||||||
String result;
|
String result;
|
||||||
to_type_constructor[STRING](result.ptr, ptr);
|
to_type_constructor[STRING](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Vector2() const {
|
Variant::operator Vector2() const {
|
||||||
Vector2 result;
|
Vector2 result;
|
||||||
to_type_constructor[VECTOR2](result.ptr, ptr);
|
to_type_constructor[VECTOR2](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Vector2i() const {
|
Variant::operator Vector2i() const {
|
||||||
Vector2i result;
|
Vector2i result;
|
||||||
to_type_constructor[VECTOR2I](result.ptr, ptr);
|
to_type_constructor[VECTOR2I](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Rect2() const {
|
Variant::operator Rect2() const {
|
||||||
Rect2 result;
|
Rect2 result;
|
||||||
to_type_constructor[RECT2](result.ptr, ptr);
|
to_type_constructor[RECT2](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Rect2i() const {
|
Variant::operator Rect2i() const {
|
||||||
Rect2i result;
|
Rect2i result;
|
||||||
to_type_constructor[RECT2I](result.ptr, ptr);
|
to_type_constructor[RECT2I](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Vector3() const {
|
Variant::operator Vector3() const {
|
||||||
Vector3 result;
|
Vector3 result;
|
||||||
to_type_constructor[VECTOR3](result.ptr, ptr);
|
to_type_constructor[VECTOR3](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Vector3i() const {
|
Variant::operator Vector3i() const {
|
||||||
Vector3i result;
|
Vector3i result;
|
||||||
to_type_constructor[VECTOR3I](result.ptr, ptr);
|
to_type_constructor[VECTOR3I](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Transform2D() const {
|
Variant::operator Transform2D() const {
|
||||||
Transform2D result;
|
Transform2D result;
|
||||||
to_type_constructor[TRANSFORM2D](result.ptr, ptr);
|
to_type_constructor[TRANSFORM2D](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Plane() const {
|
Variant::operator Plane() const {
|
||||||
Plane result;
|
Plane result;
|
||||||
to_type_constructor[PLANE](result.ptr, ptr);
|
to_type_constructor[PLANE](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Quaternion() const {
|
Variant::operator Quaternion() const {
|
||||||
Quaternion result;
|
Quaternion result;
|
||||||
to_type_constructor[QUATERNION](result.ptr, ptr);
|
to_type_constructor[QUATERNION](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator godot::AABB() const {
|
Variant::operator godot::AABB() const {
|
||||||
godot::AABB result;
|
godot::AABB result;
|
||||||
to_type_constructor[AABB](result.ptr, ptr);
|
to_type_constructor[AABB](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Basis() const {
|
Variant::operator Basis() const {
|
||||||
Basis result;
|
Basis result;
|
||||||
to_type_constructor[BASIS](result.ptr, ptr);
|
to_type_constructor[BASIS](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Transform3D() const {
|
Variant::operator Transform3D() const {
|
||||||
Transform3D result;
|
Transform3D result;
|
||||||
to_type_constructor[TRANSFORM3D](result.ptr, ptr);
|
to_type_constructor[TRANSFORM3D](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Color() const {
|
Variant::operator Color() const {
|
||||||
Color result;
|
Color result;
|
||||||
to_type_constructor[COLOR](result.ptr, ptr);
|
to_type_constructor[COLOR](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator StringName() const {
|
Variant::operator StringName() const {
|
||||||
StringName result;
|
StringName result;
|
||||||
to_type_constructor[STRING_NAME](result.ptr, ptr);
|
to_type_constructor[STRING_NAME](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator NodePath() const {
|
Variant::operator NodePath() const {
|
||||||
NodePath result;
|
NodePath result;
|
||||||
to_type_constructor[NODE_PATH](result.ptr, ptr);
|
to_type_constructor[NODE_PATH](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator godot::RID() const {
|
Variant::operator godot::RID() const {
|
||||||
godot::RID result;
|
godot::RID result;
|
||||||
to_type_constructor[RID](result.ptr, ptr);
|
to_type_constructor[RID](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Object *() const {
|
Variant::operator Object *() const {
|
||||||
GodotObject *obj;
|
GodotObject *obj;
|
||||||
to_type_constructor[OBJECT](&obj, ptr);
|
to_type_constructor[OBJECT](&obj, ptr());
|
||||||
|
if (obj == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
return reinterpret_cast<Object *>(internal::interface->object_get_instance_binding(obj, internal::token, &Object::___binding_callbacks));
|
return reinterpret_cast<Object *>(internal::interface->object_get_instance_binding(obj, internal::token, &Object::___binding_callbacks));
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Callable() const {
|
Variant::operator Callable() const {
|
||||||
Callable result;
|
Callable result;
|
||||||
to_type_constructor[CALLABLE](result.ptr, ptr);
|
to_type_constructor[CALLABLE](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Signal() const {
|
Variant::operator Signal() const {
|
||||||
Signal result;
|
Signal result;
|
||||||
to_type_constructor[SIGNAL](result.ptr, ptr);
|
to_type_constructor[SIGNAL](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Dictionary() const {
|
Variant::operator Dictionary() const {
|
||||||
Dictionary result;
|
Dictionary result;
|
||||||
to_type_constructor[DICTIONARY](result.ptr, ptr);
|
to_type_constructor[DICTIONARY](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator Array() const {
|
Variant::operator Array() const {
|
||||||
Array result;
|
Array result;
|
||||||
to_type_constructor[ARRAY](result.ptr, ptr);
|
to_type_constructor[ARRAY](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator PackedByteArray() const {
|
Variant::operator PackedByteArray() const {
|
||||||
PackedByteArray result;
|
PackedByteArray result;
|
||||||
to_type_constructor[PACKED_BYTE_ARRAY](result.ptr, ptr);
|
to_type_constructor[PACKED_BYTE_ARRAY](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator PackedInt32Array() const {
|
Variant::operator PackedInt32Array() const {
|
||||||
PackedInt32Array result;
|
PackedInt32Array result;
|
||||||
to_type_constructor[PACKED_INT32_ARRAY](result.ptr, ptr);
|
to_type_constructor[PACKED_INT32_ARRAY](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator PackedInt64Array() const {
|
Variant::operator PackedInt64Array() const {
|
||||||
PackedInt64Array result;
|
PackedInt64Array result;
|
||||||
to_type_constructor[PACKED_INT64_ARRAY](result.ptr, ptr);
|
to_type_constructor[PACKED_INT64_ARRAY](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator PackedFloat32Array() const {
|
Variant::operator PackedFloat32Array() const {
|
||||||
PackedFloat32Array result;
|
PackedFloat32Array result;
|
||||||
to_type_constructor[PACKED_FLOAT32_ARRAY](result.ptr, ptr);
|
to_type_constructor[PACKED_FLOAT32_ARRAY](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator PackedFloat64Array() const {
|
Variant::operator PackedFloat64Array() const {
|
||||||
PackedFloat64Array result;
|
PackedFloat64Array result;
|
||||||
to_type_constructor[PACKED_FLOAT64_ARRAY](result.ptr, ptr);
|
to_type_constructor[PACKED_FLOAT64_ARRAY](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator PackedStringArray() const {
|
Variant::operator PackedStringArray() const {
|
||||||
PackedStringArray result;
|
PackedStringArray result;
|
||||||
to_type_constructor[PACKED_STRING_ARRAY](result.ptr, ptr);
|
to_type_constructor[PACKED_STRING_ARRAY](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator PackedVector2Array() const {
|
Variant::operator PackedVector2Array() const {
|
||||||
PackedVector2Array result;
|
PackedVector2Array result;
|
||||||
to_type_constructor[PACKED_VECTOR2_ARRAY](result.ptr, ptr);
|
to_type_constructor[PACKED_VECTOR2_ARRAY](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator PackedVector3Array() const {
|
Variant::operator PackedVector3Array() const {
|
||||||
PackedVector3Array result;
|
PackedVector3Array result;
|
||||||
to_type_constructor[PACKED_VECTOR3_ARRAY](result.ptr, ptr);
|
to_type_constructor[PACKED_VECTOR3_ARRAY](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator PackedColorArray() const {
|
Variant::operator PackedColorArray() const {
|
||||||
PackedColorArray result;
|
PackedColorArray result;
|
||||||
to_type_constructor[PACKED_COLOR_ARRAY](result.ptr, ptr);
|
to_type_constructor[PACKED_COLOR_ARRAY](result.ptr(), ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::operator const GDNativeVariantPtr() const {
|
|
||||||
return reinterpret_cast<const GDNativeVariantPtr>(const_cast<uint8_t(*)[GODOT_CPP_VARIANT_SIZE]>(&opaque));
|
|
||||||
}
|
|
||||||
|
|
||||||
Variant::operator GDNativeVariantPtr() {
|
|
||||||
return reinterpret_cast<const GDNativeVariantPtr>(&opaque);
|
|
||||||
}
|
|
||||||
|
|
||||||
Variant &Variant::operator=(const Variant &other) {
|
Variant &Variant::operator=(const Variant &other) {
|
||||||
clear();
|
clear();
|
||||||
internal::interface->variant_new_copy(ptr, other.ptr);
|
internal::interface->variant_new_copy(ptr(), other.ptr());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,28 +507,23 @@ bool Variant::operator<(const Variant &other) const {
|
||||||
return result.operator bool();
|
return result.operator bool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Variant::operator=(const GDNativeVariantPtr other_ptr) {
|
|
||||||
internal::interface->variant_destroy(ptr);
|
|
||||||
internal::interface->variant_new_copy(ptr, other_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Variant::call(const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDNativeCallError &r_error) {
|
void Variant::call(const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDNativeCallError &r_error) {
|
||||||
internal::interface->variant_call(ptr, method.ptr, reinterpret_cast<const GDNativeVariantPtr *>(const_cast<Variant **>(args)), argcount, r_ret.ptr, &r_error);
|
internal::interface->variant_call(ptr(), method.ptr(), reinterpret_cast<const GDNativeVariantPtr *>(const_cast<Variant **>(args)), argcount, r_ret.ptr(), &r_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Variant::call_static(Variant::Type type, const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDNativeCallError &r_error) {
|
void Variant::call_static(Variant::Type type, const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDNativeCallError &r_error) {
|
||||||
internal::interface->variant_call_static(static_cast<GDNativeVariantType>(type), method.ptr, reinterpret_cast<const GDNativeVariantPtr *>(const_cast<Variant **>(args)), argcount, r_ret.ptr, &r_error);
|
internal::interface->variant_call_static(static_cast<GDNativeVariantType>(type), method.ptr(), reinterpret_cast<const GDNativeVariantPtr *>(const_cast<Variant **>(args)), argcount, r_ret.ptr(), &r_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Variant::evaluate(const Operator &op, const Variant &a, const Variant &b, Variant &r_ret, bool &r_valid) {
|
void Variant::evaluate(const Operator &op, const Variant &a, const Variant &b, Variant &r_ret, bool &r_valid) {
|
||||||
GDNativeBool valid;
|
GDNativeBool valid;
|
||||||
internal::interface->variant_evaluate(static_cast<GDNativeVariantOperator>(op), a.ptr, b.ptr, r_ret.ptr, &valid);
|
internal::interface->variant_evaluate(static_cast<GDNativeVariantOperator>(op), a.ptr(), b.ptr(), r_ret.ptr(), &valid);
|
||||||
r_valid = PtrToArg<bool>::convert(&valid);
|
r_valid = PtrToArg<bool>::convert(&valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Variant::set(const Variant &key, const Variant &value, bool *r_valid) {
|
void Variant::set(const Variant &key, const Variant &value, bool *r_valid) {
|
||||||
GDNativeBool valid;
|
GDNativeBool valid;
|
||||||
internal::interface->variant_set(ptr, key.ptr, value.ptr, &valid);
|
internal::interface->variant_set(ptr(), key.ptr(), value.ptr(), &valid);
|
||||||
if (r_valid) {
|
if (r_valid) {
|
||||||
*r_valid = PtrToArg<bool>::convert(&valid);
|
*r_valid = PtrToArg<bool>::convert(&valid);
|
||||||
}
|
}
|
||||||
|
@ -541,27 +531,27 @@ void Variant::set(const Variant &key, const Variant &value, bool *r_valid) {
|
||||||
|
|
||||||
void Variant::set_named(const StringName &name, const Variant &value, bool &r_valid) {
|
void Variant::set_named(const StringName &name, const Variant &value, bool &r_valid) {
|
||||||
GDNativeBool valid;
|
GDNativeBool valid;
|
||||||
internal::interface->variant_set_named(ptr, name.ptr, value.ptr, &valid);
|
internal::interface->variant_set_named(ptr(), name.ptr(), value.ptr(), &valid);
|
||||||
r_valid = PtrToArg<bool>::convert(&valid);
|
r_valid = PtrToArg<bool>::convert(&valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Variant::set_indexed(int64_t index, const Variant &value, bool &r_valid, bool &r_oob) {
|
void Variant::set_indexed(int64_t index, const Variant &value, bool &r_valid, bool &r_oob) {
|
||||||
GDNativeBool valid, oob;
|
GDNativeBool valid, oob;
|
||||||
internal::interface->variant_set_indexed(ptr, index, value.ptr, &valid, &oob);
|
internal::interface->variant_set_indexed(ptr(), index, value.ptr(), &valid, &oob);
|
||||||
r_valid = PtrToArg<bool>::convert(&valid);
|
r_valid = PtrToArg<bool>::convert(&valid);
|
||||||
r_oob = PtrToArg<bool>::convert(&oob);
|
r_oob = PtrToArg<bool>::convert(&oob);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Variant::set_keyed(const Variant &key, const Variant &value, bool &r_valid) {
|
void Variant::set_keyed(const Variant &key, const Variant &value, bool &r_valid) {
|
||||||
GDNativeBool valid;
|
GDNativeBool valid;
|
||||||
internal::interface->variant_set_keyed(ptr, key.ptr, value.ptr, &valid);
|
internal::interface->variant_set_keyed(ptr(), key.ptr(), value.ptr(), &valid);
|
||||||
r_valid = PtrToArg<bool>::convert(&valid);
|
r_valid = PtrToArg<bool>::convert(&valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant Variant::get(const Variant &key, bool *r_valid) const {
|
Variant Variant::get(const Variant &key, bool *r_valid) const {
|
||||||
Variant result;
|
Variant result;
|
||||||
GDNativeBool valid;
|
GDNativeBool valid;
|
||||||
internal::interface->variant_get(ptr, key.ptr, result.ptr, &valid);
|
internal::interface->variant_get(ptr(), key.ptr(), result.ptr(), &valid);
|
||||||
if (r_valid) {
|
if (r_valid) {
|
||||||
*r_valid = PtrToArg<bool>::convert(&valid);
|
*r_valid = PtrToArg<bool>::convert(&valid);
|
||||||
}
|
}
|
||||||
|
@ -571,7 +561,7 @@ Variant Variant::get(const Variant &key, bool *r_valid) const {
|
||||||
Variant Variant::get_named(const StringName &name, bool &r_valid) const {
|
Variant Variant::get_named(const StringName &name, bool &r_valid) const {
|
||||||
Variant result;
|
Variant result;
|
||||||
GDNativeBool valid;
|
GDNativeBool valid;
|
||||||
internal::interface->variant_get_named(ptr, name.ptr, result.ptr, &valid);
|
internal::interface->variant_get_named(ptr(), name.ptr(), result.ptr(), &valid);
|
||||||
r_valid = PtrToArg<bool>::convert(&valid);
|
r_valid = PtrToArg<bool>::convert(&valid);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -580,7 +570,7 @@ Variant Variant::get_indexed(int64_t index, bool &r_valid, bool &r_oob) const {
|
||||||
Variant result;
|
Variant result;
|
||||||
GDNativeBool valid;
|
GDNativeBool valid;
|
||||||
GDNativeBool oob;
|
GDNativeBool oob;
|
||||||
internal::interface->variant_get_indexed(ptr, index, result.ptr, &valid, &oob);
|
internal::interface->variant_get_indexed(ptr(), index, result.ptr(), &valid, &oob);
|
||||||
r_valid = PtrToArg<bool>::convert(&valid);
|
r_valid = PtrToArg<bool>::convert(&valid);
|
||||||
r_oob = PtrToArg<bool>::convert(&oob);
|
r_oob = PtrToArg<bool>::convert(&oob);
|
||||||
return result;
|
return result;
|
||||||
|
@ -589,7 +579,7 @@ Variant Variant::get_indexed(int64_t index, bool &r_valid, bool &r_oob) const {
|
||||||
Variant Variant::get_keyed(const Variant &key, bool &r_valid) const {
|
Variant Variant::get_keyed(const Variant &key, bool &r_valid) const {
|
||||||
Variant result;
|
Variant result;
|
||||||
GDNativeBool valid;
|
GDNativeBool valid;
|
||||||
internal::interface->variant_get_keyed(ptr, key.ptr, result.ptr, &valid);
|
internal::interface->variant_get_keyed(ptr(), key.ptr(), result.ptr(), &valid);
|
||||||
r_valid = PtrToArg<bool>::convert(&valid);
|
r_valid = PtrToArg<bool>::convert(&valid);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -606,36 +596,36 @@ bool Variant::in(const Variant &index, bool *r_valid) const {
|
||||||
|
|
||||||
bool Variant::iter_init(Variant &r_iter, bool &r_valid) const {
|
bool Variant::iter_init(Variant &r_iter, bool &r_valid) const {
|
||||||
GDNativeBool valid;
|
GDNativeBool valid;
|
||||||
internal::interface->variant_iter_init(ptr, r_iter.ptr, &valid);
|
internal::interface->variant_iter_init(ptr(), r_iter.ptr(), &valid);
|
||||||
return PtrToArg<bool>::convert(&valid);
|
return PtrToArg<bool>::convert(&valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Variant::iter_next(Variant &r_iter, bool &r_valid) const {
|
bool Variant::iter_next(Variant &r_iter, bool &r_valid) const {
|
||||||
GDNativeBool valid;
|
GDNativeBool valid;
|
||||||
internal::interface->variant_iter_next(ptr, r_iter.ptr, &valid);
|
internal::interface->variant_iter_next(ptr(), r_iter.ptr(), &valid);
|
||||||
return PtrToArg<bool>::convert(&valid);
|
return PtrToArg<bool>::convert(&valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
|
Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
|
||||||
Variant result;
|
Variant result;
|
||||||
GDNativeBool valid;
|
GDNativeBool valid;
|
||||||
internal::interface->variant_iter_get(ptr, r_iter.ptr, result.ptr, &valid);
|
internal::interface->variant_iter_get(ptr(), r_iter.ptr(), result.ptr(), &valid);
|
||||||
r_valid = PtrToArg<bool>::convert(&valid);
|
r_valid = PtrToArg<bool>::convert(&valid);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Type Variant::get_type() const {
|
Variant::Type Variant::get_type() const {
|
||||||
return static_cast<Variant::Type>(internal::interface->variant_get_type(ptr));
|
return static_cast<Variant::Type>(internal::interface->variant_get_type(ptr()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Variant::has_method(const StringName &method) const {
|
bool Variant::has_method(const StringName &method) const {
|
||||||
GDNativeBool has = internal::interface->variant_has_method(ptr, method.ptr);
|
GDNativeBool has = internal::interface->variant_has_method(ptr(), method.ptr());
|
||||||
return PtrToArg<bool>::convert(&has);
|
return PtrToArg<bool>::convert(&has);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Variant::has_key(const Variant &key, bool *r_valid) const {
|
bool Variant::has_key(const Variant &key, bool *r_valid) const {
|
||||||
GDNativeBool valid;
|
GDNativeBool valid;
|
||||||
GDNativeBool has = internal::interface->variant_has_key(ptr, key.ptr, &valid);
|
GDNativeBool has = internal::interface->variant_has_key(ptr(), key.ptr(), &valid);
|
||||||
if (r_valid) {
|
if (r_valid) {
|
||||||
*r_valid = PtrToArg<bool>::convert(&valid);
|
*r_valid = PtrToArg<bool>::convert(&valid);
|
||||||
}
|
}
|
||||||
|
@ -643,23 +633,23 @@ bool Variant::has_key(const Variant &key, bool *r_valid) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Variant::has_member(Variant::Type type, const StringName &member) {
|
bool Variant::has_member(Variant::Type type, const StringName &member) {
|
||||||
GDNativeBool has = internal::interface->variant_has_member(static_cast<GDNativeVariantType>(type), member.ptr);
|
GDNativeBool has = internal::interface->variant_has_member(static_cast<GDNativeVariantType>(type), member.ptr());
|
||||||
return PtrToArg<bool>::convert(&has);
|
return PtrToArg<bool>::convert(&has);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Variant::hash_compare(const Variant &variant) const {
|
bool Variant::hash_compare(const Variant &variant) const {
|
||||||
GDNativeBool compare = internal::interface->variant_hash_compare(ptr, variant.ptr);
|
GDNativeBool compare = internal::interface->variant_hash_compare(ptr(), variant.ptr());
|
||||||
return PtrToArg<bool>::convert(&compare);
|
return PtrToArg<bool>::convert(&compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Variant::booleanize() const {
|
bool Variant::booleanize() const {
|
||||||
GDNativeBool booleanized = internal::interface->variant_booleanize(ptr);
|
GDNativeBool booleanized = internal::interface->variant_booleanize(ptr());
|
||||||
return PtrToArg<bool>::convert(&booleanized);
|
return PtrToArg<bool>::convert(&booleanized);
|
||||||
}
|
}
|
||||||
|
|
||||||
String Variant::stringify() const {
|
String Variant::stringify() const {
|
||||||
String result;
|
String result;
|
||||||
internal::interface->variant_stringify(ptr, result.ptr);
|
internal::interface->variant_stringify(ptr(), result.ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,21 +657,21 @@ Variant Variant::duplicate(bool deep) const {
|
||||||
Variant result;
|
Variant result;
|
||||||
GDNativeBool _deep;
|
GDNativeBool _deep;
|
||||||
PtrToArg<bool>::encode(deep, &_deep);
|
PtrToArg<bool>::encode(deep, &_deep);
|
||||||
internal::interface->variant_duplicate(ptr, result.ptr, _deep);
|
internal::interface->variant_duplicate(ptr(), result.ptr(), _deep);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Variant::blend(const Variant &a, const Variant &b, float c, Variant &r_dst) {
|
void Variant::blend(const Variant &a, const Variant &b, float c, Variant &r_dst) {
|
||||||
internal::interface->variant_blend(a.ptr, b.ptr, c, r_dst.ptr);
|
internal::interface->variant_blend(a.ptr(), b.ptr(), c, r_dst.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &r_dst) {
|
void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &r_dst) {
|
||||||
internal::interface->variant_interpolate(a.ptr, b.ptr, c, r_dst.ptr);
|
internal::interface->variant_interpolate(a.ptr(), b.ptr(), c, r_dst.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
String Variant::get_type_name(Variant::Type type) {
|
String Variant::get_type_name(Variant::Type type) {
|
||||||
String result;
|
String result;
|
||||||
internal::interface->variant_get_type_name(static_cast<GDNativeVariantType>(type), result.ptr);
|
internal::interface->variant_get_type_name(static_cast<GDNativeVariantType>(type), result.ptr());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -741,9 +731,9 @@ void Variant::clear() {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (unlikely(needs_deinit[get_type()])) { // Make it fast for types that don't need deinit.
|
if (unlikely(needs_deinit[get_type()])) { // Make it fast for types that don't need deinit.
|
||||||
internal::interface->variant_destroy(ptr);
|
internal::interface->variant_destroy(ptr());
|
||||||
}
|
}
|
||||||
internal::interface->variant_new_nil(ptr);
|
internal::interface->variant_new_nil(ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace godot
|
} // namespace godot
|
||||||
|
|
Loading…
Reference in New Issue