2023-01-05 13:25:55 +01:00
|
|
|
/**************************************************************************/
|
|
|
|
/* method_bind.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. */
|
|
|
|
/**************************************************************************/
|
2018-01-05 00:50:27 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
#ifndef METHOD_BIND_H
|
|
|
|
#define METHOD_BIND_H
|
|
|
|
|
2020-11-07 23:33:38 +01:00
|
|
|
#include "core/variant/binder_common.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2023-01-08 00:55:54 +01:00
|
|
|
VARIANT_BITFIELD_CAST(MethodFlags)
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
// some helpers
|
|
|
|
|
|
|
|
class MethodBind {
|
|
|
|
int method_id;
|
2020-05-12 17:01:17 +02:00
|
|
|
uint32_t hint_flags = METHOD_FLAGS_DEFAULT;
|
2014-02-10 02:10:30 +01:00
|
|
|
StringName name;
|
2020-10-15 17:29:59 +02:00
|
|
|
StringName instance_class;
|
2014-02-10 02:10:30 +01:00
|
|
|
Vector<Variant> default_arguments;
|
2020-05-12 17:01:17 +02:00
|
|
|
int default_argument_count = 0;
|
|
|
|
int argument_count = 0;
|
2017-08-24 00:10:32 +02:00
|
|
|
|
2022-03-19 13:18:52 +01:00
|
|
|
bool _static = false;
|
2020-05-12 17:01:17 +02:00
|
|
|
bool _const = false;
|
|
|
|
bool _returns = false;
|
2023-02-03 11:42:51 +01:00
|
|
|
bool _returns_raw_obj_ptr = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
protected:
|
2020-05-12 17:01:17 +02:00
|
|
|
Variant::Type *argument_types = nullptr;
|
2021-10-07 20:18:52 +02:00
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
2017-08-24 00:10:32 +02:00
|
|
|
Vector<StringName> arg_names;
|
|
|
|
#endif
|
2014-02-10 02:10:30 +01:00
|
|
|
void _set_const(bool p_const);
|
2022-03-19 13:18:52 +01:00
|
|
|
void _set_static(bool p_static);
|
2016-08-03 00:11:05 +02:00
|
|
|
void _set_returns(bool p_returns);
|
2014-02-10 02:10:30 +01:00
|
|
|
virtual Variant::Type _gen_argument_type(int p_arg) const = 0;
|
2017-08-24 00:10:32 +02:00
|
|
|
virtual PropertyInfo _gen_argument_type_info(int p_arg) const = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
void _generate_argument_types(int p_count);
|
2017-08-24 00:10:32 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_argument_count(int p_count) { argument_count = p_count; }
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2020-10-15 17:29:59 +02:00
|
|
|
_FORCE_INLINE_ const Vector<Variant> &get_default_arguments() const { return default_arguments; }
|
2014-02-10 02:10:30 +01:00
|
|
|
_FORCE_INLINE_ int get_default_argument_count() const { return default_argument_count; }
|
|
|
|
|
|
|
|
_FORCE_INLINE_ Variant has_default_argument(int p_arg) const {
|
2020-10-15 17:29:59 +02:00
|
|
|
int idx = p_arg - (argument_count - default_arguments.size());
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-05-14 16:41:43 +02:00
|
|
|
if (idx < 0 || idx >= default_arguments.size()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
return false;
|
2020-05-14 16:41:43 +02:00
|
|
|
} else {
|
2014-02-10 02:10:30 +01:00
|
|
|
return true;
|
2020-05-14 16:41:43 +02:00
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_FORCE_INLINE_ Variant get_default_argument(int p_arg) const {
|
2020-10-15 17:29:59 +02:00
|
|
|
int idx = p_arg - (argument_count - default_arguments.size());
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-05-14 16:41:43 +02:00
|
|
|
if (idx < 0 || idx >= default_arguments.size()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
return Variant();
|
2020-05-14 16:41:43 +02:00
|
|
|
} else {
|
2014-02-10 02:10:30 +01:00
|
|
|
return default_arguments[idx];
|
2020-05-14 16:41:43 +02:00
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_FORCE_INLINE_ Variant::Type get_argument_type(int p_argument) const {
|
|
|
|
ERR_FAIL_COND_V(p_argument < -1 || p_argument > argument_count, Variant::NIL);
|
|
|
|
return argument_types[p_argument + 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyInfo get_argument_info(int p_argument) const;
|
2017-08-24 00:10:32 +02:00
|
|
|
PropertyInfo get_return_info() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-10-07 20:18:52 +02:00
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
2020-10-15 17:29:59 +02:00
|
|
|
void set_argument_names(const Vector<StringName> &p_names); // Set by ClassDB, can't be inferred otherwise.
|
2014-02-10 02:10:30 +01:00
|
|
|
Vector<StringName> get_argument_names() const;
|
2017-08-09 11:54:27 +02:00
|
|
|
|
2019-04-25 20:24:48 +02:00
|
|
|
virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
#endif
|
2020-10-15 17:29:59 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_hint_flags(uint32_t p_hint) { hint_flags = p_hint; }
|
2022-03-19 13:18:52 +01:00
|
|
|
uint32_t get_hint_flags() const { return hint_flags | (is_const() ? METHOD_FLAG_CONST : 0) | (is_vararg() ? METHOD_FLAG_VARARG : 0) | (is_static() ? METHOD_FLAG_STATIC : 0); }
|
2020-10-15 17:29:59 +02:00
|
|
|
_FORCE_INLINE_ StringName get_instance_class() const { return instance_class; }
|
|
|
|
_FORCE_INLINE_ void set_instance_class(const StringName &p_class) { instance_class = p_class; }
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
_FORCE_INLINE_ int get_argument_count() const { return argument_count; };
|
|
|
|
|
2022-10-22 15:18:33 +02:00
|
|
|
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const = 0;
|
2023-04-25 00:21:32 +02:00
|
|
|
virtual void validated_call(Object *p_object, const Variant **p_args, Variant *r_ret) const = 0;
|
|
|
|
|
2022-10-22 15:18:33 +02:00
|
|
|
virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) const = 0;
|
2016-06-23 04:12:20 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
StringName get_name() const;
|
|
|
|
void set_name(const StringName &p_name);
|
|
|
|
_FORCE_INLINE_ int get_method_id() const { return method_id; }
|
|
|
|
_FORCE_INLINE_ bool is_const() const { return _const; }
|
2022-03-19 13:18:52 +01:00
|
|
|
_FORCE_INLINE_ bool is_static() const { return _static; }
|
2016-08-03 00:11:05 +02:00
|
|
|
_FORCE_INLINE_ bool has_return() const { return _returns; }
|
2016-09-08 00:39:02 +02:00
|
|
|
virtual bool is_vararg() const { return false; }
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2023-02-03 11:42:51 +01:00
|
|
|
_FORCE_INLINE_ bool is_return_type_raw_object_ptr() { return _returns_raw_obj_ptr; }
|
|
|
|
_FORCE_INLINE_ void set_return_type_is_raw_object_ptr(bool p_returns_raw_obj) { _returns_raw_obj_ptr = p_returns_raw_obj; }
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_default_arguments(const Vector<Variant> &p_defargs);
|
|
|
|
|
2021-06-19 17:58:49 +02:00
|
|
|
uint32_t get_hash() const;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
MethodBind();
|
|
|
|
virtual ~MethodBind();
|
|
|
|
};
|
|
|
|
|
2022-02-22 12:15:43 +01:00
|
|
|
// MethodBindVarArg base CRTP
|
|
|
|
template <class Derived, class T, class R, bool should_returns>
|
|
|
|
class MethodBindVarArgBase : public MethodBind {
|
2014-02-10 02:10:30 +01:00
|
|
|
protected:
|
2022-02-22 12:15:43 +01:00
|
|
|
R(T::*method)
|
|
|
|
(const Variant **, int, Callable::CallError &);
|
|
|
|
MethodInfo method_info;
|
2020-05-12 17:01:17 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
|
2017-08-24 00:10:32 +02:00
|
|
|
if (p_arg < 0) {
|
2022-02-22 12:15:43 +01:00
|
|
|
return _gen_return_type_info();
|
|
|
|
} else if (p_arg < method_info.arguments.size()) {
|
|
|
|
return method_info.arguments[p_arg];
|
2017-08-24 00:10:32 +02:00
|
|
|
} else {
|
|
|
|
return PropertyInfo(Variant::NIL, "arg_" + itos(p_arg), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT);
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual Variant::Type _gen_argument_type(int p_arg) const override {
|
2017-08-24 00:10:32 +02:00
|
|
|
return _gen_argument_type_info(p_arg).type;
|
|
|
|
}
|
|
|
|
|
2021-10-07 20:18:52 +02:00
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual GodotTypeInfo::Metadata get_argument_meta(int) const override {
|
2019-04-25 20:24:48 +02:00
|
|
|
return GodotTypeInfo::METADATA_NONE;
|
|
|
|
}
|
2017-08-24 00:10:32 +02:00
|
|
|
#endif
|
2020-10-15 17:29:59 +02:00
|
|
|
|
2023-04-25 00:21:32 +02:00
|
|
|
virtual void validated_call(Object *p_object, const Variant **p_args, Variant *r_ret) const override {
|
|
|
|
ERR_FAIL_MSG("Validated call can't be used with vararg methods. This is a bug.");
|
|
|
|
}
|
|
|
|
|
2022-10-22 15:18:33 +02:00
|
|
|
virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) const override {
|
2023-04-25 00:21:32 +02:00
|
|
|
ERR_FAIL_MSG("ptrcall can't be used with vararg methods. This is a bug.");
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2017-08-09 11:54:27 +02:00
|
|
|
|
2022-02-22 12:15:43 +01:00
|
|
|
virtual bool is_const() const { return false; }
|
|
|
|
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual bool is_vararg() const override { return true; }
|
2022-02-22 12:15:43 +01:00
|
|
|
|
|
|
|
MethodBindVarArgBase(
|
|
|
|
R (T::*p_method)(const Variant **, int, Callable::CallError &),
|
|
|
|
const MethodInfo &p_method_info,
|
|
|
|
bool p_return_nil_is_variant) :
|
|
|
|
method(p_method), method_info(p_method_info) {
|
|
|
|
set_argument_count(method_info.arguments.size());
|
|
|
|
Variant::Type *at = memnew_arr(Variant::Type, method_info.arguments.size() + 1);
|
|
|
|
at[0] = _gen_return_type_info().type;
|
|
|
|
if (method_info.arguments.size()) {
|
2021-10-07 20:18:52 +02:00
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
2014-02-10 02:10:30 +01:00
|
|
|
Vector<StringName> names;
|
2022-02-22 12:15:43 +01:00
|
|
|
names.resize(method_info.arguments.size());
|
2021-10-07 20:18:52 +02:00
|
|
|
#endif
|
2022-02-22 12:15:43 +01:00
|
|
|
for (int i = 0; i < method_info.arguments.size(); i++) {
|
|
|
|
at[i + 1] = method_info.arguments[i].type;
|
2021-10-07 20:18:52 +02:00
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
2022-02-22 12:15:43 +01:00
|
|
|
names.write[i] = method_info.arguments[i].name;
|
2021-10-07 20:18:52 +02:00
|
|
|
#endif
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2021-10-07 20:18:52 +02:00
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
2014-02-10 02:10:30 +01:00
|
|
|
set_argument_names(names);
|
2021-10-07 20:18:52 +02:00
|
|
|
#endif
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2017-08-24 00:10:32 +02:00
|
|
|
argument_types = at;
|
2020-01-02 09:31:43 +01:00
|
|
|
if (p_return_nil_is_variant) {
|
2022-02-22 12:15:43 +01:00
|
|
|
method_info.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
|
2020-01-02 09:31:43 +01:00
|
|
|
}
|
2022-02-22 12:15:43 +01:00
|
|
|
|
|
|
|
_set_returns(should_returns);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2022-02-22 12:15:43 +01:00
|
|
|
private:
|
|
|
|
PropertyInfo _gen_return_type_info() const {
|
2022-03-31 17:35:56 +02:00
|
|
|
return Derived::_gen_return_type_info_impl();
|
2020-11-25 14:08:17 +01:00
|
|
|
}
|
2022-02-22 12:15:43 +01:00
|
|
|
};
|
2016-06-23 04:12:20 +02:00
|
|
|
|
2022-02-22 12:15:43 +01:00
|
|
|
// variadic, no return
|
|
|
|
template <class T>
|
|
|
|
class MethodBindVarArgT : public MethodBindVarArgBase<MethodBindVarArgT<T>, T, void, false> {
|
|
|
|
friend class MethodBindVarArgBase<MethodBindVarArgT<T>, T, void, false>;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-02-22 12:15:43 +01:00
|
|
|
public:
|
2022-10-22 15:18:33 +02:00
|
|
|
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override {
|
2022-02-22 12:15:43 +01:00
|
|
|
(static_cast<T *>(p_object)->*MethodBindVarArgBase<MethodBindVarArgT<T>, T, void, false>::method)(p_args, p_arg_count, r_error);
|
|
|
|
return {};
|
|
|
|
}
|
2016-09-08 00:39:02 +02:00
|
|
|
|
2022-02-22 12:15:43 +01:00
|
|
|
MethodBindVarArgT(
|
|
|
|
void (T::*p_method)(const Variant **, int, Callable::CallError &),
|
|
|
|
const MethodInfo &p_method_info,
|
|
|
|
bool p_return_nil_is_variant) :
|
|
|
|
MethodBindVarArgBase<MethodBindVarArgT<T>, T, void, false>(p_method, p_method_info, p_return_nil_is_variant) {
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2022-03-31 17:35:56 +02:00
|
|
|
static PropertyInfo _gen_return_type_info_impl() {
|
2022-02-22 12:15:43 +01:00
|
|
|
return {};
|
2016-09-08 00:39:02 +02:00
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class T>
|
2022-02-22 12:15:43 +01:00
|
|
|
MethodBind *create_vararg_method_bind(void (T::*p_method)(const Variant **, int, Callable::CallError &), const MethodInfo &p_info, bool p_return_nil_is_variant) {
|
|
|
|
MethodBind *a = memnew((MethodBindVarArgT<T>)(p_method, p_info, p_return_nil_is_variant));
|
|
|
|
a->set_instance_class(T::get_class_static());
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
// variadic, return
|
|
|
|
template <class T, class R>
|
|
|
|
class MethodBindVarArgTR : public MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true> {
|
|
|
|
friend class MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true>;
|
|
|
|
|
|
|
|
public:
|
2022-09-26 16:05:31 +02:00
|
|
|
#if defined(SANITIZERS_ENABLED) && defined(__GNUC__) && !defined(__clang__)
|
|
|
|
// Workaround GH-66343 raised only with UBSAN, seems to be a false positive.
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
|
|
|
#endif
|
2022-10-22 15:18:33 +02:00
|
|
|
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override {
|
2022-02-22 12:15:43 +01:00
|
|
|
return (static_cast<T *>(p_object)->*MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true>::method)(p_args, p_arg_count, r_error);
|
|
|
|
}
|
2023-04-25 00:21:32 +02:00
|
|
|
|
2022-09-26 16:05:31 +02:00
|
|
|
#if defined(SANITIZERS_ENABLED) && defined(__GNUC__) && !defined(__clang__)
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
#endif
|
2022-02-22 12:15:43 +01:00
|
|
|
|
|
|
|
MethodBindVarArgTR(
|
|
|
|
R (T::*p_method)(const Variant **, int, Callable::CallError &),
|
|
|
|
const MethodInfo &p_info,
|
|
|
|
bool p_return_nil_is_variant) :
|
|
|
|
MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true>(p_method, p_info, p_return_nil_is_variant) {
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2022-03-31 17:35:56 +02:00
|
|
|
static PropertyInfo _gen_return_type_info_impl() {
|
2022-02-22 12:15:43 +01:00
|
|
|
return GetTypeInfo<R>::get_class_info();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class T, class R>
|
|
|
|
MethodBind *create_vararg_method_bind(R (T::*p_method)(const Variant **, int, Callable::CallError &), const MethodInfo &p_info, bool p_return_nil_is_variant) {
|
|
|
|
MethodBind *a = memnew((MethodBindVarArgTR<T, R>)(p_method, p_info, p_return_nil_is_variant));
|
2020-10-15 17:29:59 +02:00
|
|
|
a->set_instance_class(T::get_class_static());
|
2014-02-10 02:10:30 +01:00
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2020-10-15 17:29:59 +02:00
|
|
|
/**** VARIADIC TEMPLATES ****/
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-10-15 17:29:59 +02:00
|
|
|
#ifndef TYPED_METHOD_BIND
|
2014-02-10 02:10:30 +01:00
|
|
|
class __UnexistingClass;
|
2020-10-15 17:29:59 +02:00
|
|
|
#define MB_T __UnexistingClass
|
|
|
|
#else
|
|
|
|
#define MB_T T
|
|
|
|
#endif
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-10-15 17:29:59 +02:00
|
|
|
// no return, not const
|
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
template <class T, class... P>
|
|
|
|
#else
|
|
|
|
template <class... P>
|
|
|
|
#endif
|
|
|
|
class MethodBindT : public MethodBind {
|
|
|
|
void (MB_T::*method)(P...);
|
|
|
|
|
|
|
|
protected:
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual Variant::Type _gen_argument_type(int p_arg) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
|
|
|
|
return call_get_argument_type<P...>(p_arg);
|
|
|
|
} else {
|
|
|
|
return Variant::NIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
PropertyInfo pi;
|
|
|
|
call_get_argument_type_info<P...>(p_arg, pi);
|
|
|
|
return pi;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
return call_get_argument_metadata<P...>(p_arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2022-10-22 15:18:33 +02:00
|
|
|
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
call_with_variant_args_dv(static_cast<T *>(p_object), method, p_args, p_arg_count, r_error, get_default_arguments());
|
|
|
|
#else
|
2022-04-07 12:23:40 +02:00
|
|
|
call_with_variant_args_dv(reinterpret_cast<MB_T *>(p_object), method, p_args, p_arg_count, r_error, get_default_arguments());
|
2020-10-15 17:29:59 +02:00
|
|
|
#endif
|
|
|
|
return Variant();
|
|
|
|
}
|
|
|
|
|
2023-04-25 00:21:32 +02:00
|
|
|
virtual void validated_call(Object *p_object, const Variant **p_args, Variant *r_ret) const override {
|
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
call_with_validated_object_instance_args(static_cast<T *>(p_object), method, p_args);
|
|
|
|
#else
|
|
|
|
call_with_validated_object_instance_args(reinterpret_cast<MB_T *>(p_object), method, p_args);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-10-22 15:18:33 +02:00
|
|
|
virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
call_with_ptr_args<T, P...>(static_cast<T *>(p_object), method, p_args);
|
|
|
|
#else
|
2022-04-07 12:23:40 +02:00
|
|
|
call_with_ptr_args<MB_T, P...>(reinterpret_cast<MB_T *>(p_object), method, p_args);
|
2020-10-15 17:29:59 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
MethodBindT(void (MB_T::*p_method)(P...)) {
|
|
|
|
method = p_method;
|
|
|
|
_generate_argument_types(sizeof...(P));
|
|
|
|
set_argument_count(sizeof...(P));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class T, class... P>
|
|
|
|
MethodBind *create_method_bind(void (T::*p_method)(P...)) {
|
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
MethodBind *a = memnew((MethodBindT<T, P...>)(p_method));
|
|
|
|
#else
|
|
|
|
MethodBind *a = memnew((MethodBindT<P...>)(reinterpret_cast<void (MB_T::*)(P...)>(p_method)));
|
|
|
|
#endif
|
|
|
|
a->set_instance_class(T::get_class_static());
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2022-03-19 13:18:52 +01:00
|
|
|
// no return, const
|
2020-10-15 17:29:59 +02:00
|
|
|
|
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
template <class T, class... P>
|
|
|
|
#else
|
|
|
|
template <class... P>
|
|
|
|
#endif
|
|
|
|
class MethodBindTC : public MethodBind {
|
|
|
|
void (MB_T::*method)(P...) const;
|
|
|
|
|
|
|
|
protected:
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual Variant::Type _gen_argument_type(int p_arg) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
|
|
|
|
return call_get_argument_type<P...>(p_arg);
|
|
|
|
} else {
|
|
|
|
return Variant::NIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
PropertyInfo pi;
|
|
|
|
call_get_argument_type_info<P...>(p_arg, pi);
|
|
|
|
return pi;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
return call_get_argument_metadata<P...>(p_arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2022-10-22 15:18:33 +02:00
|
|
|
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
call_with_variant_argsc_dv(static_cast<T *>(p_object), method, p_args, p_arg_count, r_error, get_default_arguments());
|
|
|
|
#else
|
2022-04-07 12:23:40 +02:00
|
|
|
call_with_variant_argsc_dv(reinterpret_cast<MB_T *>(p_object), method, p_args, p_arg_count, r_error, get_default_arguments());
|
2020-10-15 17:29:59 +02:00
|
|
|
#endif
|
|
|
|
return Variant();
|
|
|
|
}
|
|
|
|
|
2023-04-25 00:21:32 +02:00
|
|
|
virtual void validated_call(Object *p_object, const Variant **p_args, Variant *r_ret) const override {
|
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
call_with_validated_object_instance_argsc(static_cast<T *>(p_object), method, p_args);
|
|
|
|
#else
|
|
|
|
call_with_validated_object_instance_argsc(reinterpret_cast<MB_T *>(p_object), method, p_args);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-10-22 15:18:33 +02:00
|
|
|
virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
call_with_ptr_argsc<T, P...>(static_cast<T *>(p_object), method, p_args);
|
|
|
|
#else
|
2022-04-07 12:23:40 +02:00
|
|
|
call_with_ptr_argsc<MB_T, P...>(reinterpret_cast<MB_T *>(p_object), method, p_args);
|
2020-10-15 17:29:59 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
MethodBindTC(void (MB_T::*p_method)(P...) const) {
|
|
|
|
method = p_method;
|
|
|
|
_set_const(true);
|
|
|
|
_generate_argument_types(sizeof...(P));
|
|
|
|
set_argument_count(sizeof...(P));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class T, class... P>
|
|
|
|
MethodBind *create_method_bind(void (T::*p_method)(P...) const) {
|
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
MethodBind *a = memnew((MethodBindTC<T, P...>)(p_method));
|
|
|
|
#else
|
|
|
|
MethodBind *a = memnew((MethodBindTC<P...>)(reinterpret_cast<void (MB_T::*)(P...) const>(p_method)));
|
|
|
|
#endif
|
|
|
|
a->set_instance_class(T::get_class_static());
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return, not const
|
|
|
|
|
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
template <class T, class R, class... P>
|
|
|
|
#else
|
|
|
|
template <class R, class... P>
|
|
|
|
#endif
|
|
|
|
class MethodBindTR : public MethodBind {
|
|
|
|
R(MB_T::*method)
|
|
|
|
(P...);
|
|
|
|
|
|
|
|
protected:
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual Variant::Type _gen_argument_type(int p_arg) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
|
|
|
|
return call_get_argument_type<P...>(p_arg);
|
|
|
|
} else {
|
|
|
|
return GetTypeInfo<R>::VARIANT_TYPE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
|
|
|
|
PropertyInfo pi;
|
|
|
|
call_get_argument_type_info<P...>(p_arg, pi);
|
|
|
|
return pi;
|
|
|
|
} else {
|
|
|
|
return GetTypeInfo<R>::get_class_info();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
if (p_arg >= 0) {
|
|
|
|
return call_get_argument_metadata<P...>(p_arg);
|
|
|
|
} else {
|
|
|
|
return GetTypeInfo<R>::METADATA;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-10-22 15:18:33 +02:00
|
|
|
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
Variant ret;
|
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
call_with_variant_args_ret_dv(static_cast<T *>(p_object), method, p_args, p_arg_count, ret, r_error, get_default_arguments());
|
|
|
|
#else
|
2022-04-07 12:23:40 +02:00
|
|
|
call_with_variant_args_ret_dv(reinterpret_cast<MB_T *>(p_object), method, p_args, p_arg_count, ret, r_error, get_default_arguments());
|
2020-10-15 17:29:59 +02:00
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-04-25 00:21:32 +02:00
|
|
|
virtual void validated_call(Object *p_object, const Variant **p_args, Variant *r_ret) const override {
|
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
call_with_validated_object_instance_args_ret(static_cast<T *>(p_object), method, p_args, r_ret);
|
|
|
|
#else
|
|
|
|
call_with_validated_object_instance_args_ret(reinterpret_cast<MB_T *>(p_object), method, p_args, r_ret);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-10-22 15:18:33 +02:00
|
|
|
virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
call_with_ptr_args_ret<T, R, P...>(static_cast<T *>(p_object), method, p_args, r_ret);
|
|
|
|
#else
|
2022-04-07 12:23:40 +02:00
|
|
|
call_with_ptr_args_ret<MB_T, R, P...>(reinterpret_cast<MB_T *>(p_object), method, p_args, r_ret);
|
2020-10-15 17:29:59 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
MethodBindTR(R (MB_T::*p_method)(P...)) {
|
|
|
|
method = p_method;
|
|
|
|
_set_returns(true);
|
|
|
|
_generate_argument_types(sizeof...(P));
|
|
|
|
set_argument_count(sizeof...(P));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class T, class R, class... P>
|
|
|
|
MethodBind *create_method_bind(R (T::*p_method)(P...)) {
|
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
MethodBind *a = memnew((MethodBindTR<T, R, P...>)(p_method));
|
|
|
|
#else
|
|
|
|
MethodBind *a = memnew((MethodBindTR<R, P...>)(reinterpret_cast<R (MB_T::*)(P...)>(p_method)));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
a->set_instance_class(T::get_class_static());
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return, const
|
|
|
|
|
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
template <class T, class R, class... P>
|
|
|
|
#else
|
|
|
|
template <class R, class... P>
|
|
|
|
#endif
|
|
|
|
class MethodBindTRC : public MethodBind {
|
|
|
|
R(MB_T::*method)
|
|
|
|
(P...) const;
|
|
|
|
|
|
|
|
protected:
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual Variant::Type _gen_argument_type(int p_arg) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
|
|
|
|
return call_get_argument_type<P...>(p_arg);
|
|
|
|
} else {
|
|
|
|
return GetTypeInfo<R>::VARIANT_TYPE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
|
|
|
|
PropertyInfo pi;
|
|
|
|
call_get_argument_type_info<P...>(p_arg, pi);
|
|
|
|
return pi;
|
|
|
|
} else {
|
|
|
|
return GetTypeInfo<R>::get_class_info();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
if (p_arg >= 0) {
|
|
|
|
return call_get_argument_metadata<P...>(p_arg);
|
|
|
|
} else {
|
|
|
|
return GetTypeInfo<R>::METADATA;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-10-22 15:18:33 +02:00
|
|
|
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
Variant ret;
|
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
call_with_variant_args_retc_dv(static_cast<T *>(p_object), method, p_args, p_arg_count, ret, r_error, get_default_arguments());
|
|
|
|
#else
|
2022-04-07 12:23:40 +02:00
|
|
|
call_with_variant_args_retc_dv(reinterpret_cast<MB_T *>(p_object), method, p_args, p_arg_count, ret, r_error, get_default_arguments());
|
2020-10-15 17:29:59 +02:00
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-04-25 00:21:32 +02:00
|
|
|
virtual void validated_call(Object *p_object, const Variant **p_args, Variant *r_ret) const override {
|
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
call_with_validated_object_instance_args_retc(static_cast<T *>(p_object), method, p_args, r_ret);
|
|
|
|
#else
|
|
|
|
call_with_validated_object_instance_args_retc(reinterpret_cast<MB_T *>(p_object), method, p_args, r_ret);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-10-22 15:18:33 +02:00
|
|
|
virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) const override {
|
2020-10-15 17:29:59 +02:00
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
call_with_ptr_args_retc<T, R, P...>(static_cast<T *>(p_object), method, p_args, r_ret);
|
|
|
|
#else
|
2022-04-07 12:23:40 +02:00
|
|
|
call_with_ptr_args_retc<MB_T, R, P...>(reinterpret_cast<MB_T *>(p_object), method, p_args, r_ret);
|
2020-10-15 17:29:59 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
MethodBindTRC(R (MB_T::*p_method)(P...) const) {
|
|
|
|
method = p_method;
|
|
|
|
_set_returns(true);
|
|
|
|
_set_const(true);
|
|
|
|
_generate_argument_types(sizeof...(P));
|
|
|
|
set_argument_count(sizeof...(P));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class T, class R, class... P>
|
|
|
|
MethodBind *create_method_bind(R (T::*p_method)(P...) const) {
|
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
MethodBind *a = memnew((MethodBindTRC<T, R, P...>)(p_method));
|
|
|
|
#else
|
|
|
|
MethodBind *a = memnew((MethodBindTRC<R, P...>)(reinterpret_cast<R (MB_T::*)(P...) const>(p_method)));
|
|
|
|
#endif
|
|
|
|
a->set_instance_class(T::get_class_static());
|
|
|
|
return a;
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-03-19 13:18:52 +01:00
|
|
|
/* STATIC BINDS */
|
|
|
|
|
|
|
|
// no return
|
|
|
|
|
|
|
|
template <class... P>
|
|
|
|
class MethodBindTS : public MethodBind {
|
|
|
|
void (*function)(P...);
|
|
|
|
|
|
|
|
protected:
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual Variant::Type _gen_argument_type(int p_arg) const override {
|
2022-03-19 13:18:52 +01:00
|
|
|
if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
|
|
|
|
return call_get_argument_type<P...>(p_arg);
|
|
|
|
} else {
|
|
|
|
return Variant::NIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
|
2022-03-19 13:18:52 +01:00
|
|
|
PropertyInfo pi;
|
|
|
|
call_get_argument_type_info<P...>(p_arg, pi);
|
|
|
|
return pi;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override {
|
2022-03-19 13:18:52 +01:00
|
|
|
return call_get_argument_metadata<P...>(p_arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2022-10-22 15:18:33 +02:00
|
|
|
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override {
|
2022-03-19 13:18:52 +01:00
|
|
|
(void)p_object; // unused
|
|
|
|
call_with_variant_args_static_dv(function, p_args, p_arg_count, r_error, get_default_arguments());
|
|
|
|
return Variant();
|
|
|
|
}
|
|
|
|
|
2023-04-25 00:21:32 +02:00
|
|
|
virtual void validated_call(Object *p_object, const Variant **p_args, Variant *r_ret) const override {
|
|
|
|
call_with_validated_variant_args_static_method(function, p_args);
|
|
|
|
}
|
|
|
|
|
2022-10-22 15:18:33 +02:00
|
|
|
virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) const override {
|
2022-03-19 13:18:52 +01:00
|
|
|
(void)p_object;
|
|
|
|
(void)r_ret;
|
|
|
|
call_with_ptr_args_static_method(function, p_args);
|
|
|
|
}
|
|
|
|
|
|
|
|
MethodBindTS(void (*p_function)(P...)) {
|
|
|
|
function = p_function;
|
|
|
|
_generate_argument_types(sizeof...(P));
|
|
|
|
set_argument_count(sizeof...(P));
|
|
|
|
_set_static(true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class... P>
|
|
|
|
MethodBind *create_static_method_bind(void (*p_method)(P...)) {
|
|
|
|
MethodBind *a = memnew((MethodBindTS<P...>)(p_method));
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return
|
|
|
|
|
|
|
|
template <class R, class... P>
|
|
|
|
class MethodBindTRS : public MethodBind {
|
|
|
|
R(*function)
|
|
|
|
(P...);
|
|
|
|
|
|
|
|
protected:
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual Variant::Type _gen_argument_type(int p_arg) const override {
|
2022-03-19 13:18:52 +01:00
|
|
|
if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
|
|
|
|
return call_get_argument_type<P...>(p_arg);
|
|
|
|
} else {
|
|
|
|
return GetTypeInfo<R>::VARIANT_TYPE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
|
2022-03-19 13:18:52 +01:00
|
|
|
if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
|
|
|
|
PropertyInfo pi;
|
|
|
|
call_get_argument_type_info<P...>(p_arg, pi);
|
|
|
|
return pi;
|
|
|
|
} else {
|
|
|
|
return GetTypeInfo<R>::get_class_info();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
2022-04-07 12:23:40 +02:00
|
|
|
virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override {
|
2022-03-19 13:18:52 +01:00
|
|
|
if (p_arg >= 0) {
|
|
|
|
return call_get_argument_metadata<P...>(p_arg);
|
|
|
|
} else {
|
|
|
|
return GetTypeInfo<R>::METADATA;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2022-10-22 15:18:33 +02:00
|
|
|
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override {
|
2022-03-19 13:18:52 +01:00
|
|
|
Variant ret;
|
|
|
|
call_with_variant_args_static_ret_dv(function, p_args, p_arg_count, ret, r_error, get_default_arguments());
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-04-25 00:21:32 +02:00
|
|
|
virtual void validated_call(Object *p_object, const Variant **p_args, Variant *r_ret) const override {
|
|
|
|
call_with_validated_variant_args_static_method_ret(function, p_args, r_ret);
|
|
|
|
}
|
|
|
|
|
2022-10-22 15:18:33 +02:00
|
|
|
virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) const override {
|
2022-03-19 13:18:52 +01:00
|
|
|
(void)p_object;
|
|
|
|
call_with_ptr_args_static_method_ret(function, p_args, r_ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
MethodBindTRS(R (*p_function)(P...)) {
|
|
|
|
function = p_function;
|
|
|
|
_generate_argument_types(sizeof...(P));
|
|
|
|
set_argument_count(sizeof...(P));
|
|
|
|
_set_static(true);
|
|
|
|
_set_returns(true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class R, class... P>
|
|
|
|
MethodBind *create_static_method_bind(R (*p_method)(P...)) {
|
|
|
|
MethodBind *a = memnew((MethodBindTRS<R, P...>)(p_method));
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2020-03-25 11:10:34 +01:00
|
|
|
#endif // METHOD_BIND_H
|