Add GD extensions operator functions for arrays

This commit is contained in:
Bastiaan Olij 2021-09-16 17:20:09 +10:00
parent 73ec378c64
commit 25d0e4bb5b
2 changed files with 18 additions and 0 deletions

View File

@ -771,6 +771,18 @@ static GDNativeTypePtr gdnative_packed_vector3_array_operator_index_const(const
return (GDNativeTypePtr)&self->ptr()[p_index]; return (GDNativeTypePtr)&self->ptr()[p_index];
} }
static GDNativeVariantPtr gdnative_array_operator_index(GDNativeTypePtr p_self, GDNativeInt p_index) {
Array *self = (Array *)p_self;
ERR_FAIL_INDEX_V(p_index, self->size(), nullptr);
return (GDNativeTypePtr)&self[p_index];
}
static GDNativeVariantPtr gdnative_array_operator_index_const(const GDNativeTypePtr p_self, GDNativeInt p_index) {
const Array *self = (const Array *)p_self;
ERR_FAIL_INDEX_V(p_index, self->size(), nullptr);
return (GDNativeTypePtr)&self[p_index];
}
/* OBJECT API */ /* OBJECT API */
static void gdnative_object_method_bind_call(const GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeVariantPtr *p_args, GDNativeInt p_arg_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error) { static void gdnative_object_method_bind_call(const GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeVariantPtr *p_args, GDNativeInt p_arg_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error) {
@ -979,6 +991,9 @@ void gdnative_setup_interface(GDNativeInterface *p_interface) {
gdni.packed_vector3_array_operator_index = gdnative_packed_vector3_array_operator_index; gdni.packed_vector3_array_operator_index = gdnative_packed_vector3_array_operator_index;
gdni.packed_vector3_array_operator_index_const = gdnative_packed_vector3_array_operator_index_const; gdni.packed_vector3_array_operator_index_const = gdnative_packed_vector3_array_operator_index_const;
gdni.array_operator_index = gdnative_array_operator_index;
gdni.array_operator_index_const = gdnative_array_operator_index_const;
/* OBJECT */ /* OBJECT */
gdni.object_method_bind_call = gdnative_object_method_bind_call; gdni.object_method_bind_call = gdnative_object_method_bind_call;

View File

@ -413,6 +413,9 @@ typedef struct {
GDNativeTypePtr (*packed_vector3_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedVector3Array, returns Vector3 ptr GDNativeTypePtr (*packed_vector3_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedVector3Array, returns Vector3 ptr
GDNativeTypePtr (*packed_vector3_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedVector3Array, returns Vector3 ptr GDNativeTypePtr (*packed_vector3_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedVector3Array, returns Vector3 ptr
GDNativeVariantPtr (*array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be an Array ptr
GDNativeVariantPtr (*array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be an Array ptr
/* OBJECT */ /* OBJECT */
void (*object_method_bind_call)(const GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeVariantPtr *p_args, GDNativeInt p_arg_count, GDNativeVariantPtr r_ret, GDNativeCallError *r_error); void (*object_method_bind_call)(const GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeVariantPtr *p_args, GDNativeInt p_arg_count, GDNativeVariantPtr r_ret, GDNativeCallError *r_error);