A few fixes in the extension C API
- Add MethodBind call (besides ptrcall), since vararg methods don't work with ptrcall. - Fix argument name in register constant function to the way it actually is used in the engine. - Change the integer constant type to GDNativeInt to keep it consistent.
This commit is contained in:
parent
ecc5921143
commit
fcfea84d5e
3 changed files with 22 additions and 4 deletions
|
@ -663,7 +663,23 @@ static const char32_t *gdnative_string_operator_index_const(const GDNativeString
|
|||
|
||||
/* OBJECT API */
|
||||
|
||||
static void gdnative_object_method_bind_ptrcall(GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr p_ret) {
|
||||
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) {
|
||||
MethodBind *mb = (MethodBind *)p_method_bind;
|
||||
Object *o = (Object *)p_instance;
|
||||
const Variant **args = (const Variant **)p_args;
|
||||
Callable::CallError error;
|
||||
|
||||
Variant ret = mb->call(o, args, p_arg_count, error);
|
||||
memnew_placement(r_return, Variant(ret));
|
||||
|
||||
if (r_error) {
|
||||
r_error->error = (GDNativeCallErrorType)(error.error);
|
||||
r_error->argument = error.argument;
|
||||
r_error->expected = error.expected;
|
||||
}
|
||||
}
|
||||
|
||||
static void gdnative_object_method_bind_ptrcall(const GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr p_ret) {
|
||||
MethodBind *mb = (MethodBind *)p_method_bind;
|
||||
Object *o = (Object *)p_instance;
|
||||
mb->ptrcall(o, (const void **)p_args, p_ret);
|
||||
|
@ -829,6 +845,7 @@ void gdnative_setup_interface(GDNativeInterface *p_interface) {
|
|||
|
||||
/* OBJECT */
|
||||
|
||||
gdni.object_method_bind_call = gdnative_object_method_bind_call;
|
||||
gdni.object_method_bind_ptrcall = gdnative_object_method_bind_ptrcall;
|
||||
gdni.object_destroy = gdnative_object_destroy;
|
||||
gdni.global_get_singleton = gdnative_global_get_singleton;
|
||||
|
|
|
@ -389,7 +389,8 @@ typedef struct {
|
|||
|
||||
/* OBJECT */
|
||||
|
||||
void (*object_method_bind_ptrcall)(GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret);
|
||||
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_ptrcall)(const GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret);
|
||||
void (*object_destroy)(GDNativeObjectPtr p_o);
|
||||
GDNativeObjectPtr (*global_get_singleton)(const char *p_name);
|
||||
void *(*object_get_instance_binding)(GDNativeObjectPtr p_o, void *p_token, const GDNativeInstanceBindingCallbacks *p_callbacks);
|
||||
|
@ -409,7 +410,7 @@ typedef struct {
|
|||
|
||||
void (*classdb_register_extension_class)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_parent_class_name, const GDNativeExtensionClassCreationInfo *p_extension_funcs);
|
||||
void (*classdb_register_extension_class_method)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativeExtensionClassMethodInfo *p_method_info);
|
||||
void (*classdb_register_extension_class_integer_constant)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_enum_name, const char *p_class_name, const char *p_constant_name, uint32_t p_constant_value);
|
||||
void (*classdb_register_extension_class_integer_constant)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_enum_name, const char *p_constant_name, GDNativeInt p_constant_value);
|
||||
void (*classdb_register_extension_class_property)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativePropertyInfo *p_info, const char *p_setter, const char *p_getter);
|
||||
void (*classdb_register_extension_class_signal)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_signal_name, const GDNativePropertyInfo *p_argument_info, GDNativeInt p_argument_count);
|
||||
void (*classdb_unregister_extension_class)(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name); /* Unregistering a parent class before a class that inherits it will result in failure. Inheritors must be unregistered first. */
|
||||
|
|
|
@ -48,7 +48,7 @@ class NativeExtension : public Resource {
|
|||
|
||||
static void _register_extension_class(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_parent_class_name, const GDNativeExtensionClassCreationInfo *p_extension_funcs);
|
||||
static void _register_extension_class_method(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativeExtensionClassMethodInfo *p_method_info);
|
||||
static void _register_extension_class_integer_constant(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_enum_name, const char *p_constant_name, uint32_t p_constant_value);
|
||||
static void _register_extension_class_integer_constant(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_enum_name, const char *p_constant_name, GDNativeInt p_constant_value);
|
||||
static void _register_extension_class_property(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativePropertyInfo *p_info, const char *p_setter, const char *p_getter);
|
||||
static void _register_extension_class_signal(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_signal_name, const GDNativePropertyInfo *p_argument_info, GDNativeInt p_argument_count);
|
||||
static void _unregister_extension_class(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name);
|
||||
|
|
Loading…
Reference in a new issue