Compare commits

..

3 Commits

Author SHA1 Message Date
A Thousand Ships f7674a16b6
[Temporary] Redirected artifact checkout to allow testing 2024-01-29 13:08:41 +01:00
A Thousand Ships 0c861587ba
New compatibility update 2024-01-29 13:07:48 +01:00
A Thousand Ships 575e8270ac
Add support for getting argument count from `Callable`s 2024-01-28 19:51:08 +01:00
7 changed files with 17 additions and 29 deletions

View File

@ -215564,13 +215564,14 @@
]
},
{
"name": "_get_script_method_argument_count",
"name": "_get_method_argument_count",
"is_const": true,
"is_static": false,
"is_vararg": false,
"is_virtual": true,
"return_value": {
"type": "Variant"
"type": "int",
"meta": "int32"
},
"arguments": [
{

View File

@ -391,7 +391,7 @@ typedef GDExtensionBool (*GDExtensionCallableCustomLessThan)(void *callable_user
typedef void (*GDExtensionCallableCustomToString)(void *callable_userdata, GDExtensionBool *r_is_valid, GDExtensionStringPtr r_out);
typedef GDExtensionInt (*GDExtensionCallableCustomGetArgumentCount)(void *callable_userdata, GDExtensionBool *r_is_valid);
typedef GDExtensionInt (*GDExtensionCallableCustomGetArgumentCount)(void *callable_userdata);
typedef struct {
/* Only `call_func` and `token` are strictly required, however, `object_id` should be passed if its not a static method.
@ -482,7 +482,7 @@ typedef void (*GDExtensionScriptInstanceFreeMethodList)(GDExtensionScriptInstanc
typedef GDExtensionBool (*GDExtensionScriptInstanceHasMethod)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name);
typedef GDExtensionInt (*GDExtensionScriptInstanceGetMethodArgumentCount)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionBool *r_is_valid);
typedef GDExtensionInt (*GDExtensionScriptInstanceGetMethodArgumentCount)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name);
typedef void (*GDExtensionScriptInstanceCall)(GDExtensionScriptInstanceDataPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
typedef void (*GDExtensionScriptInstanceNotification)(GDExtensionScriptInstanceDataPtr p_instance, int32_t p_what); // Deprecated. Use GDExtensionScriptInstanceNotification2 instead.

View File

@ -41,7 +41,7 @@ class Object;
class CallableCustomBase {
public:
virtual ObjectID get_object() const = 0;
virtual int get_argument_count(bool &r_is_valid) const;
virtual int get_argument_count() const;
virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, GDExtensionCallError &r_call_error) const = 0;
virtual ~CallableCustomBase() {}
};

View File

@ -73,8 +73,7 @@ public:
return ObjectID(data.instance->get_instance_id());
}
virtual int get_argument_count(bool &r_is_valid) const override {
r_is_valid = true;
virtual int get_argument_count() const override {
return sizeof...(P);
}
@ -115,8 +114,7 @@ public:
return ObjectID(data.instance->get_instance_id());
}
virtual int get_argument_count(bool &r_is_valid) const override {
r_is_valid = true;
virtual int get_argument_count() const override {
return sizeof...(P);
}
@ -157,8 +155,7 @@ public:
return ObjectID(data.instance->get_instance_id());
}
virtual int get_argument_count(bool &r_is_valid) const override {
r_is_valid = true;
virtual int get_argument_count() const override {
return sizeof...(P);
}
@ -197,8 +194,7 @@ public:
return ObjectID();
}
virtual int get_argument_count(bool &r_is_valid) const override {
r_is_valid = true;
virtual int get_argument_count() const override {
return sizeof...(P);
}
@ -238,8 +234,7 @@ public:
return ObjectID();
}
virtual int get_argument_count(bool &r_is_valid) const override {
r_is_valid = true;
virtual int get_argument_count() const override {
return sizeof...(P);
}

View File

@ -35,8 +35,7 @@
namespace godot {
int CallableCustomBase::get_argument_count(bool &r_is_valid) const {
r_is_valid = false;
int CallableCustomBase::get_argument_count() const {
return 0;
}
@ -89,12 +88,9 @@ static GDExtensionBool callable_custom_less_than_func(void *p_a, void *p_b) {
return func_a(a, b);
}
static GDExtensionInt custom_callable_get_argument_count_func(void *p_userdata, GDExtensionBool *r_is_valid) {
static GDExtensionInt custom_callable_get_argument_count_func(void *p_userdata) {
CallableCustom *callable_custom = (CallableCustom *)p_userdata;
bool valid = false;
int ret = callable_custom->get_argument_count(valid);
*r_is_valid = valid;
return ret;
return callable_custom->get_argument_count();
}
bool CallableCustom::is_valid() const {

View File

@ -77,12 +77,9 @@ static GDExtensionBool custom_callable_mp_less_than_func(void *p_a, void *p_b) {
return memcmp(a->get_comp_ptr(), b->get_comp_ptr(), a->get_comp_size() * 4) < 0;
}
static GDExtensionInt custom_callable_mp_get_argument_count_func(void *p_userdata, GDExtensionBool *r_is_valid) {
static GDExtensionInt custom_callable_mp_get_argument_count_func(void *p_userdata) {
CallableCustomMethodPointerBase *callable_method_pointer = (CallableCustomMethodPointerBase *)p_userdata;
bool valid = false;
int ret = callable_method_pointer->get_argument_count(valid);
*r_is_valid = valid;
return ret;
return callable_method_pointer->get_argument_count();
}
void CallableCustomMethodPointerBase::_setup(uint32_t *p_base_ptr, uint32_t p_ptr_size) {

View File

@ -49,8 +49,7 @@ public:
return ObjectID();
}
virtual int get_argument_count(bool &r_is_valid) const {
r_is_valid = true;
virtual int get_argument_count() const {
return 2;
}