diff --git a/README.md b/README.md index 0b38853..38451e1 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ extern "C" { // Initialization. -GDNativeBool GDN_EXPORT example_library_init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) { +GDNativeBool GDN_EXPORT example_library_init(const GDNativeInterface *p_interface, GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) { godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization); init_obj.register_initializer(initialize_example_module); diff --git a/binding_generator.py b/binding_generator.py index fd994bf..aac51fa 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -861,7 +861,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl if f'get_{member["name"]}' not in method_list: result.append(f'{correct_type(member["type"])} {class_name}::get_{member["name"]}() const {{') result.append( - f'\treturn internal::_call_builtin_ptr_getter<{correct_type(member["type"])}>(_method_bindings.member_{member["name"]}_getter, (const GDNativeTypePtr)&opaque);' + f'\treturn internal::_call_builtin_ptr_getter<{correct_type(member["type"])}>(_method_bindings.member_{member["name"]}_getter, (GDNativeConstTypePtr)&opaque);' ) result.append("}") @@ -870,7 +870,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl (encode, arg_name) = get_encoded_arg("value", member["type"], None) result += encode result.append( - f'\t_method_bindings.member_{member["name"]}_setter((const GDNativeTypePtr)&opaque, (const GDNativeTypePtr){arg_name});' + f'\t_method_bindings.member_{member["name"]}_setter((GDNativeConstTypePtr)&opaque, (GDNativeConstTypePtr){arg_name});' ) result.append("}") @@ -886,7 +886,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl (encode, arg_name) = get_encoded_arg("other", operator["right_type"], None) result += encode result.append( - f'\treturn internal::_call_builtin_operator_ptr<{get_gdnative_type(correct_type(operator["return_type"]))}>(_method_bindings.operator_{get_operator_id_name(operator["name"])}_{operator["right_type"]}, (const GDNativeTypePtr)&opaque, (const GDNativeTypePtr){arg_name});' + f'\treturn internal::_call_builtin_operator_ptr<{get_gdnative_type(correct_type(operator["return_type"]))}>(_method_bindings.operator_{get_operator_id_name(operator["name"])}_{operator["right_type"]}, (GDNativeConstTypePtr)&opaque, (GDNativeConstTypePtr){arg_name});' ) result.append("}") else: @@ -894,7 +894,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl f'{correct_type(operator["return_type"])} {class_name}::operator{operator["name"].replace("unary", "")}() const {{' ) result.append( - f'\treturn internal::_call_builtin_operator_ptr<{get_gdnative_type(correct_type(operator["return_type"]))}>(_method_bindings.operator_{get_operator_id_name(operator["name"])}, (const GDNativeTypePtr)&opaque, (const GDNativeTypePtr)nullptr);' + f'\treturn internal::_call_builtin_operator_ptr<{get_gdnative_type(correct_type(operator["return_type"]))}>(_method_bindings.operator_{get_operator_id_name(operator["name"])}, (GDNativeConstTypePtr)&opaque, (GDNativeConstTypePtr)nullptr);' ) result.append("}") result.append("") @@ -1401,7 +1401,7 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us else: # vararg. result.append("\tGDNativeCallError error;") result.append("\tVariant ret;") - method_call += "internal::gdn_interface->object_method_bind_call(___method_bind, _owner, (const GDNativeVariantPtr *)args, arg_count, &ret, &error" + method_call += "internal::gdn_interface->object_method_bind_call(___method_bind, _owner, reinterpret_cast(args), arg_count, &ret, &error" if is_ref: method_call += ")" # Close Ref<> constructor. @@ -1627,7 +1627,7 @@ def generate_utility_functions(api, output_dir): function_call += ", ".join(arguments) else: source.append("\tVariant ret;") - function_call += "___function(&ret, (const GDNativeVariantPtr *)args, arg_count" + function_call += "___function(&ret, reinterpret_cast(args), arg_count" function_call += ");" source.append(function_call) diff --git a/godot-headers/godot/gdnative_interface.h b/godot-headers/godot/gdnative_interface.h index 50410c4..486f5be 100644 --- a/godot-headers/godot/gdnative_interface.h +++ b/godot-headers/godot/gdnative_interface.h @@ -141,12 +141,16 @@ typedef enum { } GDNativeVariantOperator; typedef void *GDNativeVariantPtr; +typedef const void *GDNativeConstVariantPtr; typedef void *GDNativeStringNamePtr; +typedef const void *GDNativeConstStringNamePtr; typedef void *GDNativeStringPtr; +typedef const void *GDNativeConstStringPtr; typedef void *GDNativeObjectPtr; +typedef const void *GDNativeConstObjectPtr; typedef void *GDNativeTypePtr; -typedef void *GDNativeExtensionPtr; -typedef void *GDNativeMethodBindPtr; +typedef const void *GDNativeConstTypePtr; +typedef const void *GDNativeMethodBindPtr; typedef int64_t GDNativeInt; typedef uint8_t GDNativeBool; typedef uint64_t GDObjectInstanceID; @@ -171,18 +175,18 @@ typedef struct { typedef void (*GDNativeVariantFromTypeConstructorFunc)(GDNativeVariantPtr, GDNativeTypePtr); typedef void (*GDNativeTypeFromVariantConstructorFunc)(GDNativeTypePtr, GDNativeVariantPtr); -typedef void (*GDNativePtrOperatorEvaluator)(const GDNativeTypePtr p_left, const GDNativeTypePtr p_right, GDNativeTypePtr r_result); -typedef void (*GDNativePtrBuiltInMethod)(GDNativeTypePtr p_base, const GDNativeTypePtr *p_args, GDNativeTypePtr r_return, int p_argument_count); -typedef void (*GDNativePtrConstructor)(GDNativeTypePtr p_base, const GDNativeTypePtr *p_args); +typedef void (*GDNativePtrOperatorEvaluator)(GDNativeConstTypePtr p_left, GDNativeConstTypePtr p_right, GDNativeTypePtr r_result); +typedef void (*GDNativePtrBuiltInMethod)(GDNativeTypePtr p_base, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_return, int p_argument_count); +typedef void (*GDNativePtrConstructor)(GDNativeTypePtr p_base, GDNativeConstTypePtr *p_args); typedef void (*GDNativePtrDestructor)(GDNativeTypePtr p_base); -typedef void (*GDNativePtrSetter)(GDNativeTypePtr p_base, const GDNativeTypePtr p_value); -typedef void (*GDNativePtrGetter)(const GDNativeTypePtr p_base, GDNativeTypePtr r_value); -typedef void (*GDNativePtrIndexedSetter)(GDNativeTypePtr p_base, GDNativeInt p_index, const GDNativeTypePtr p_value); -typedef void (*GDNativePtrIndexedGetter)(const GDNativeTypePtr p_base, GDNativeInt p_index, GDNativeTypePtr r_value); -typedef void (*GDNativePtrKeyedSetter)(GDNativeTypePtr p_base, const GDNativeTypePtr p_key, const GDNativeTypePtr p_value); -typedef void (*GDNativePtrKeyedGetter)(const GDNativeTypePtr p_base, const GDNativeTypePtr p_key, GDNativeTypePtr r_value); -typedef uint32_t (*GDNativePtrKeyedChecker)(const GDNativeVariantPtr p_base, const GDNativeVariantPtr p_key); -typedef void (*GDNativePtrUtilityFunction)(GDNativeTypePtr r_return, const GDNativeTypePtr *p_arguments, int p_argument_count); +typedef void (*GDNativePtrSetter)(GDNativeTypePtr p_base, GDNativeConstTypePtr p_value); +typedef void (*GDNativePtrGetter)(GDNativeConstTypePtr p_base, GDNativeTypePtr r_value); +typedef void (*GDNativePtrIndexedSetter)(GDNativeTypePtr p_base, GDNativeInt p_index, GDNativeConstTypePtr p_value); +typedef void (*GDNativePtrIndexedGetter)(GDNativeConstTypePtr p_base, GDNativeInt p_index, GDNativeTypePtr r_value); +typedef void (*GDNativePtrKeyedSetter)(GDNativeTypePtr p_base, GDNativeConstTypePtr p_key, GDNativeConstTypePtr p_value); +typedef void (*GDNativePtrKeyedGetter)(GDNativeConstTypePtr p_base, GDNativeConstTypePtr p_key, GDNativeTypePtr r_value); +typedef uint32_t (*GDNativePtrKeyedChecker)(GDNativeConstVariantPtr p_base, GDNativeConstVariantPtr p_key); +typedef void (*GDNativePtrUtilityFunction)(GDNativeTypePtr r_return, GDNativeConstTypePtr *p_arguments, int p_argument_count); typedef GDNativeObjectPtr (*GDNativeClassConstructor)(); @@ -200,8 +204,8 @@ typedef struct { typedef void *GDExtensionClassInstancePtr; -typedef GDNativeBool (*GDNativeExtensionClassSet)(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value); -typedef GDNativeBool (*GDNativeExtensionClassGet)(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret); +typedef GDNativeBool (*GDNativeExtensionClassSet)(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeConstVariantPtr p_value); +typedef GDNativeBool (*GDNativeExtensionClassGet)(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeVariantPtr r_ret); typedef uint64_t (*GDNativeExtensionClassGetRID)(GDExtensionClassInstancePtr p_instance); typedef struct { @@ -230,16 +234,16 @@ typedef struct { typedef const GDNativePropertyInfo *(*GDNativeExtensionClassGetPropertyList)(GDExtensionClassInstancePtr p_instance, uint32_t *r_count); typedef void (*GDNativeExtensionClassFreePropertyList)(GDExtensionClassInstancePtr p_instance, const GDNativePropertyInfo *p_list); -typedef GDNativeBool (*GDNativeExtensionClassPropertyCanRevert)(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name); -typedef GDNativeBool (*GDNativeExtensionClassPropertyGetRevert)(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret); +typedef GDNativeBool (*GDNativeExtensionClassPropertyCanRevert)(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name); +typedef GDNativeBool (*GDNativeExtensionClassPropertyGetRevert)(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeVariantPtr r_ret); typedef void (*GDNativeExtensionClassNotification)(GDExtensionClassInstancePtr p_instance, int32_t p_what); typedef void (*GDNativeExtensionClassToString)(GDExtensionClassInstancePtr p_instance, GDNativeBool *r_is_valid, GDNativeStringPtr p_out); typedef void (*GDNativeExtensionClassReference)(GDExtensionClassInstancePtr p_instance); typedef void (*GDNativeExtensionClassUnreference)(GDExtensionClassInstancePtr p_instance); -typedef void (*GDNativeExtensionClassCallVirtual)(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret); +typedef void (*GDNativeExtensionClassCallVirtual)(GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret); typedef GDNativeObjectPtr (*GDNativeExtensionClassCreateInstance)(void *p_userdata); typedef void (*GDNativeExtensionClassFreeInstance)(void *p_userdata, GDExtensionClassInstancePtr p_instance); -typedef GDNativeExtensionClassCallVirtual (*GDNativeExtensionClassGetVirtual)(void *p_userdata, const GDNativeStringNamePtr p_name); +typedef GDNativeExtensionClassCallVirtual (*GDNativeExtensionClassGetVirtual)(void *p_userdata, GDNativeConstStringNamePtr p_name); typedef struct { GDNativeBool is_virtual; @@ -289,8 +293,8 @@ typedef enum { GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_DOUBLE } GDNativeExtensionClassMethodArgumentMetadata; -typedef void (*GDNativeExtensionClassMethodCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error); -typedef void (*GDNativeExtensionClassMethodPtrCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret); +typedef void (*GDNativeExtensionClassMethodCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error); +typedef void (*GDNativeExtensionClassMethodPtrCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret); typedef struct { GDNativeStringNamePtr name; @@ -320,25 +324,25 @@ typedef struct { typedef void *GDNativeExtensionScriptInstanceDataPtr; // Pointer to custom ScriptInstance native implementation. -typedef GDNativeBool (*GDNativeExtensionScriptInstanceSet)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value); -typedef GDNativeBool (*GDNativeExtensionScriptInstanceGet)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret); +typedef GDNativeBool (*GDNativeExtensionScriptInstanceSet)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeConstVariantPtr p_value); +typedef GDNativeBool (*GDNativeExtensionScriptInstanceGet)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeVariantPtr r_ret); typedef const GDNativePropertyInfo *(*GDNativeExtensionScriptInstanceGetPropertyList)(GDNativeExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count); typedef void (*GDNativeExtensionScriptInstanceFreePropertyList)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativePropertyInfo *p_list); -typedef GDNativeVariantType (*GDNativeExtensionScriptInstanceGetPropertyType)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name, GDNativeBool *r_is_valid); +typedef GDNativeVariantType (*GDNativeExtensionScriptInstanceGetPropertyType)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeBool *r_is_valid); -typedef GDNativeBool (*GDNativeExtensionScriptInstancePropertyCanRevert)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name); -typedef GDNativeBool (*GDNativeExtensionScriptInstancePropertyGetRevert)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret); +typedef GDNativeBool (*GDNativeExtensionScriptInstancePropertyCanRevert)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeConstStringNamePtr p_name); +typedef GDNativeBool (*GDNativeExtensionScriptInstancePropertyGetRevert)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeVariantPtr r_ret); typedef GDNativeObjectPtr (*GDNativeExtensionScriptInstanceGetOwner)(GDNativeExtensionScriptInstanceDataPtr p_instance); -typedef void (*GDNativeExtensionScriptInstancePropertyStateAdd)(const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value, void *p_userdata); +typedef void (*GDNativeExtensionScriptInstancePropertyStateAdd)(GDNativeConstStringNamePtr p_name, GDNativeConstVariantPtr p_value, void *p_userdata); typedef void (*GDNativeExtensionScriptInstanceGetPropertyState)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeExtensionScriptInstancePropertyStateAdd p_add_func, void *p_userdata); typedef const GDNativeMethodInfo *(*GDNativeExtensionScriptInstanceGetMethodList)(GDNativeExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count); typedef void (*GDNativeExtensionScriptInstanceFreeMethodList)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeMethodInfo *p_list); -typedef GDNativeBool (*GDNativeExtensionScriptInstanceHasMethod)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name); +typedef GDNativeBool (*GDNativeExtensionScriptInstanceHasMethod)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeConstStringNamePtr p_name); -typedef void (*GDNativeExtensionScriptInstanceCall)(GDNativeExtensionScriptInstanceDataPtr p_self, const GDNativeStringNamePtr p_method, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error); +typedef void (*GDNativeExtensionScriptInstanceCall)(GDNativeExtensionScriptInstanceDataPtr p_self, GDNativeConstStringNamePtr p_method, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error); typedef void (*GDNativeExtensionScriptInstanceNotification)(GDNativeExtensionScriptInstanceDataPtr p_instance, int32_t p_what); typedef void (*GDNativeExtensionScriptInstanceToString)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeBool *r_is_valid, GDNativeStringPtr r_out); @@ -413,41 +417,41 @@ typedef struct { void (*print_warning)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line); void (*print_script_error)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line); - uint64_t (*get_native_struct_size)(const GDNativeStringNamePtr p_name); + uint64_t (*get_native_struct_size)(GDNativeConstStringNamePtr p_name); /* GODOT VARIANT */ /* variant general */ - void (*variant_new_copy)(GDNativeVariantPtr r_dest, const GDNativeVariantPtr p_src); + void (*variant_new_copy)(GDNativeVariantPtr r_dest, GDNativeConstVariantPtr p_src); void (*variant_new_nil)(GDNativeVariantPtr r_dest); void (*variant_destroy)(GDNativeVariantPtr p_self); /* variant type */ - void (*variant_call)(GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_method, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error); - void (*variant_call_static)(GDNativeVariantType p_type, const GDNativeStringNamePtr p_method, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error); - void (*variant_evaluate)(GDNativeVariantOperator p_op, const GDNativeVariantPtr p_a, const GDNativeVariantPtr p_b, GDNativeVariantPtr r_return, GDNativeBool *r_valid); - void (*variant_set)(GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, const GDNativeVariantPtr p_value, GDNativeBool *r_valid); - void (*variant_set_named)(GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_key, const GDNativeVariantPtr p_value, GDNativeBool *r_valid); - void (*variant_set_keyed)(GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, const GDNativeVariantPtr p_value, GDNativeBool *r_valid); - void (*variant_set_indexed)(GDNativeVariantPtr p_self, GDNativeInt p_index, const GDNativeVariantPtr p_value, GDNativeBool *r_valid, GDNativeBool *r_oob); - void (*variant_get)(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid); - void (*variant_get_named)(const GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid); - void (*variant_get_keyed)(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid); - void (*variant_get_indexed)(const GDNativeVariantPtr p_self, GDNativeInt p_index, GDNativeVariantPtr r_ret, GDNativeBool *r_valid, GDNativeBool *r_oob); - GDNativeBool (*variant_iter_init)(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeBool *r_valid); - GDNativeBool (*variant_iter_next)(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeBool *r_valid); - void (*variant_iter_get)(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeVariantPtr r_ret, GDNativeBool *r_valid); - GDNativeInt (*variant_hash)(const GDNativeVariantPtr p_self); - GDNativeInt (*variant_recursive_hash)(const GDNativeVariantPtr p_self, GDNativeInt p_recursion_count); - GDNativeBool (*variant_hash_compare)(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_other); - GDNativeBool (*variant_booleanize)(const GDNativeVariantPtr p_self); - void (*variant_duplicate)(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_ret, GDNativeBool p_deep); - void (*variant_stringify)(const GDNativeVariantPtr p_self, GDNativeStringPtr r_ret); + void (*variant_call)(GDNativeVariantPtr p_self, GDNativeConstStringNamePtr p_method, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error); + void (*variant_call_static)(GDNativeVariantType p_type, GDNativeConstStringNamePtr p_method, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error); + void (*variant_evaluate)(GDNativeVariantOperator p_op, GDNativeConstVariantPtr p_a, GDNativeConstVariantPtr p_b, GDNativeVariantPtr r_return, GDNativeBool *r_valid); + void (*variant_set)(GDNativeVariantPtr p_self, GDNativeConstVariantPtr p_key, GDNativeConstVariantPtr p_value, GDNativeBool *r_valid); + void (*variant_set_named)(GDNativeVariantPtr p_self, GDNativeConstStringNamePtr p_key, GDNativeConstVariantPtr p_value, GDNativeBool *r_valid); + void (*variant_set_keyed)(GDNativeVariantPtr p_self, GDNativeConstVariantPtr p_key, GDNativeConstVariantPtr p_value, GDNativeBool *r_valid); + void (*variant_set_indexed)(GDNativeVariantPtr p_self, GDNativeInt p_index, GDNativeConstVariantPtr p_value, GDNativeBool *r_valid, GDNativeBool *r_oob); + void (*variant_get)(GDNativeConstVariantPtr p_self, GDNativeConstVariantPtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid); + void (*variant_get_named)(GDNativeConstVariantPtr p_self, GDNativeConstStringNamePtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid); + void (*variant_get_keyed)(GDNativeConstVariantPtr p_self, GDNativeConstVariantPtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid); + void (*variant_get_indexed)(GDNativeConstVariantPtr p_self, GDNativeInt p_index, GDNativeVariantPtr r_ret, GDNativeBool *r_valid, GDNativeBool *r_oob); + GDNativeBool (*variant_iter_init)(GDNativeConstVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeBool *r_valid); + GDNativeBool (*variant_iter_next)(GDNativeConstVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeBool *r_valid); + void (*variant_iter_get)(GDNativeConstVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeVariantPtr r_ret, GDNativeBool *r_valid); + GDNativeInt (*variant_hash)(GDNativeConstVariantPtr p_self); + GDNativeInt (*variant_recursive_hash)(GDNativeConstVariantPtr p_self, GDNativeInt p_recursion_count); + GDNativeBool (*variant_hash_compare)(GDNativeConstVariantPtr p_self, GDNativeConstVariantPtr p_other); + GDNativeBool (*variant_booleanize)(GDNativeConstVariantPtr p_self); + void (*variant_duplicate)(GDNativeConstVariantPtr p_self, GDNativeVariantPtr r_ret, GDNativeBool p_deep); + void (*variant_stringify)(GDNativeConstVariantPtr p_self, GDNativeStringPtr r_ret); - GDNativeVariantType (*variant_get_type)(const GDNativeVariantPtr p_self); - GDNativeBool (*variant_has_method)(const GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_method); - GDNativeBool (*variant_has_member)(GDNativeVariantType p_type, const GDNativeStringNamePtr p_member); - GDNativeBool (*variant_has_key)(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, GDNativeBool *r_valid); + GDNativeVariantType (*variant_get_type)(GDNativeConstVariantPtr p_self); + GDNativeBool (*variant_has_method)(GDNativeConstVariantPtr p_self, GDNativeConstStringNamePtr p_method); + GDNativeBool (*variant_has_member)(GDNativeVariantType p_type, GDNativeConstStringNamePtr p_member); + GDNativeBool (*variant_has_key)(GDNativeConstVariantPtr p_self, GDNativeConstVariantPtr p_key, GDNativeBool *r_valid); void (*variant_get_type_name)(GDNativeVariantType p_type, GDNativeStringPtr r_name); GDNativeBool (*variant_can_convert)(GDNativeVariantType p_from, GDNativeVariantType p_to); GDNativeBool (*variant_can_convert_strict)(GDNativeVariantType p_from, GDNativeVariantType p_to); @@ -456,19 +460,19 @@ typedef struct { GDNativeVariantFromTypeConstructorFunc (*get_variant_from_type_constructor)(GDNativeVariantType p_type); GDNativeTypeFromVariantConstructorFunc (*get_variant_to_type_constructor)(GDNativeVariantType p_type); GDNativePtrOperatorEvaluator (*variant_get_ptr_operator_evaluator)(GDNativeVariantOperator p_operator, GDNativeVariantType p_type_a, GDNativeVariantType p_type_b); - GDNativePtrBuiltInMethod (*variant_get_ptr_builtin_method)(GDNativeVariantType p_type, const GDNativeStringNamePtr p_method, GDNativeInt p_hash); + GDNativePtrBuiltInMethod (*variant_get_ptr_builtin_method)(GDNativeVariantType p_type, GDNativeConstStringNamePtr p_method, GDNativeInt p_hash); GDNativePtrConstructor (*variant_get_ptr_constructor)(GDNativeVariantType p_type, int32_t p_constructor); GDNativePtrDestructor (*variant_get_ptr_destructor)(GDNativeVariantType p_type); - void (*variant_construct)(GDNativeVariantType p_type, GDNativeVariantPtr p_base, const GDNativeVariantPtr *p_args, int32_t p_argument_count, GDNativeCallError *r_error); - GDNativePtrSetter (*variant_get_ptr_setter)(GDNativeVariantType p_type, const GDNativeStringNamePtr p_member); - GDNativePtrGetter (*variant_get_ptr_getter)(GDNativeVariantType p_type, const GDNativeStringNamePtr p_member); + void (*variant_construct)(GDNativeVariantType p_type, GDNativeVariantPtr p_base, GDNativeConstVariantPtr *p_args, int32_t p_argument_count, GDNativeCallError *r_error); + GDNativePtrSetter (*variant_get_ptr_setter)(GDNativeVariantType p_type, GDNativeConstStringNamePtr p_member); + GDNativePtrGetter (*variant_get_ptr_getter)(GDNativeVariantType p_type, GDNativeConstStringNamePtr p_member); GDNativePtrIndexedSetter (*variant_get_ptr_indexed_setter)(GDNativeVariantType p_type); GDNativePtrIndexedGetter (*variant_get_ptr_indexed_getter)(GDNativeVariantType p_type); GDNativePtrKeyedSetter (*variant_get_ptr_keyed_setter)(GDNativeVariantType p_type); GDNativePtrKeyedGetter (*variant_get_ptr_keyed_getter)(GDNativeVariantType p_type); GDNativePtrKeyedChecker (*variant_get_ptr_keyed_checker)(GDNativeVariantType p_type); - void (*variant_get_constant_value)(GDNativeVariantType p_type, const GDNativeStringNamePtr p_constant, GDNativeVariantPtr r_ret); - GDNativePtrUtilityFunction (*variant_get_ptr_utility_function)(const GDNativeStringNamePtr p_function, GDNativeInt p_hash); + void (*variant_get_constant_value)(GDNativeVariantType p_type, GDNativeConstStringNamePtr p_constant, GDNativeVariantPtr r_ret); + GDNativePtrUtilityFunction (*variant_get_ptr_utility_function)(GDNativeConstStringNamePtr p_function, GDNativeInt p_hash); /* extra utilities */ void (*string_new_with_latin1_chars)(GDNativeStringPtr r_dest, const char *p_contents); @@ -476,12 +480,11 @@ typedef struct { void (*string_new_with_utf16_chars)(GDNativeStringPtr r_dest, const char16_t *p_contents); void (*string_new_with_utf32_chars)(GDNativeStringPtr r_dest, const char32_t *p_contents); void (*string_new_with_wide_chars)(GDNativeStringPtr r_dest, const wchar_t *p_contents); - void (*string_new_with_latin1_chars_and_len)(GDNativeStringPtr r_dest, const char *p_contents, const GDNativeInt p_size); - void (*string_new_with_utf8_chars_and_len)(GDNativeStringPtr r_dest, const char *p_contents, const GDNativeInt p_size); - void (*string_new_with_utf16_chars_and_len)(GDNativeStringPtr r_dest, const char16_t *p_contents, const GDNativeInt p_size); - void (*string_new_with_utf32_chars_and_len)(GDNativeStringPtr r_dest, const char32_t *p_contents, const GDNativeInt p_size); - void (*string_new_with_wide_chars_and_len)(GDNativeStringPtr r_dest, const wchar_t *p_contents, const GDNativeInt p_size); - + void (*string_new_with_latin1_chars_and_len)(GDNativeStringPtr r_dest, const char *p_contents, GDNativeInt p_size); + void (*string_new_with_utf8_chars_and_len)(GDNativeStringPtr r_dest, const char *p_contents, GDNativeInt p_size); + void (*string_new_with_utf16_chars_and_len)(GDNativeStringPtr r_dest, const char16_t *p_contents, GDNativeInt p_size); + void (*string_new_with_utf32_chars_and_len)(GDNativeStringPtr r_dest, const char32_t *p_contents, GDNativeInt p_size); + void (*string_new_with_wide_chars_and_len)(GDNativeStringPtr r_dest, const wchar_t *p_contents, GDNativeInt p_size); /* Information about the following functions: * - The return value is the resulting encoded string length. * - The length returned is in characters, not in bytes. It also does not include a trailing zero. @@ -490,63 +493,63 @@ typedef struct { * - p_max_write_length argument is in characters, not bytes. It will be ignored if r_text is NULL. * - p_max_write_length argument does not affect the return value, it's only to cap write length. */ - GDNativeInt (*string_to_latin1_chars)(const GDNativeStringPtr p_self, char *r_text, GDNativeInt p_max_write_length); - GDNativeInt (*string_to_utf8_chars)(const GDNativeStringPtr p_self, char *r_text, GDNativeInt p_max_write_length); - GDNativeInt (*string_to_utf16_chars)(const GDNativeStringPtr p_self, char16_t *r_text, GDNativeInt p_max_write_length); - GDNativeInt (*string_to_utf32_chars)(const GDNativeStringPtr p_self, char32_t *r_text, GDNativeInt p_max_write_length); - GDNativeInt (*string_to_wide_chars)(const GDNativeStringPtr p_self, wchar_t *r_text, GDNativeInt p_max_write_length); + GDNativeInt (*string_to_latin1_chars)(GDNativeConstStringPtr p_self, char *r_text, GDNativeInt p_max_write_length); + GDNativeInt (*string_to_utf8_chars)(GDNativeConstStringPtr p_self, char *r_text, GDNativeInt p_max_write_length); + GDNativeInt (*string_to_utf16_chars)(GDNativeConstStringPtr p_self, char16_t *r_text, GDNativeInt p_max_write_length); + GDNativeInt (*string_to_utf32_chars)(GDNativeConstStringPtr p_self, char32_t *r_text, GDNativeInt p_max_write_length); + GDNativeInt (*string_to_wide_chars)(GDNativeConstStringPtr p_self, wchar_t *r_text, GDNativeInt p_max_write_length); char32_t *(*string_operator_index)(GDNativeStringPtr p_self, GDNativeInt p_index); - const char32_t *(*string_operator_index_const)(const GDNativeStringPtr p_self, GDNativeInt p_index); + const char32_t *(*string_operator_index_const)(GDNativeConstStringPtr p_self, GDNativeInt p_index); /* Packed array functions */ uint8_t *(*packed_byte_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedByteArray - const uint8_t *(*packed_byte_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedByteArray + const uint8_t *(*packed_byte_array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedByteArray GDNativeTypePtr (*packed_color_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedColorArray, returns Color ptr - GDNativeTypePtr (*packed_color_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedColorArray, returns Color ptr + GDNativeTypePtr (*packed_color_array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedColorArray, returns Color ptr float *(*packed_float32_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedFloat32Array - const float *(*packed_float32_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedFloat32Array + const float *(*packed_float32_array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedFloat32Array double *(*packed_float64_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedFloat64Array - const double *(*packed_float64_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedFloat64Array + const double *(*packed_float64_array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedFloat64Array int32_t *(*packed_int32_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedInt32Array - const int32_t *(*packed_int32_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedInt32Array + const int32_t *(*packed_int32_array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedInt32Array int64_t *(*packed_int64_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedInt32Array - const int64_t *(*packed_int64_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedInt32Array + const int64_t *(*packed_int64_array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedInt32Array GDNativeStringPtr (*packed_string_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedStringArray - GDNativeStringPtr (*packed_string_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedStringArray + GDNativeStringPtr (*packed_string_array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedStringArray GDNativeTypePtr (*packed_vector2_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedVector2Array, returns Vector2 ptr - GDNativeTypePtr (*packed_vector2_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedVector2Array, returns Vector2 ptr + GDNativeTypePtr (*packed_vector2_array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedVector2Array, returns Vector2 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)(GDNativeConstTypePtr 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 + GDNativeVariantPtr (*array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be an Array ptr /* Dictionary functions */ - GDNativeVariantPtr (*dictionary_operator_index)(GDNativeTypePtr p_self, const GDNativeVariantPtr p_key); // p_self should be an Dictionary ptr - GDNativeVariantPtr (*dictionary_operator_index_const)(const GDNativeTypePtr p_self, const GDNativeVariantPtr p_key); // p_self should be an Dictionary ptr + GDNativeVariantPtr (*dictionary_operator_index)(GDNativeTypePtr p_self, GDNativeConstVariantPtr p_key); // p_self should be an Dictionary ptr + GDNativeVariantPtr (*dictionary_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeConstVariantPtr p_key); // p_self should be an Dictionary ptr /* 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_ptrcall)(const GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret); + void (*object_method_bind_call)(GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_arg_count, GDNativeVariantPtr r_ret, GDNativeCallError *r_error); + void (*object_method_bind_ptrcall)(GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret); void (*object_destroy)(GDNativeObjectPtr p_o); - GDNativeObjectPtr (*global_get_singleton)(const GDNativeStringNamePtr p_name); + GDNativeObjectPtr (*global_get_singleton)(GDNativeConstStringNamePtr p_name); void *(*object_get_instance_binding)(GDNativeObjectPtr p_o, void *p_token, const GDNativeInstanceBindingCallbacks *p_callbacks); void (*object_set_instance_binding)(GDNativeObjectPtr p_o, void *p_token, void *p_binding, const GDNativeInstanceBindingCallbacks *p_callbacks); - void (*object_set_instance)(GDNativeObjectPtr p_o, const GDNativeStringNamePtr p_classname, GDExtensionClassInstancePtr p_instance); /* p_classname should be a registered extension class and should extend the p_o object's class. */ + void (*object_set_instance)(GDNativeObjectPtr p_o, GDNativeConstStringNamePtr p_classname, GDExtensionClassInstancePtr p_instance); /* p_classname should be a registered extension class and should extend the p_o object's class. */ - GDNativeObjectPtr (*object_cast_to)(const GDNativeObjectPtr p_object, void *p_class_tag); + GDNativeObjectPtr (*object_cast_to)(GDNativeConstObjectPtr p_object, void *p_class_tag); GDNativeObjectPtr (*object_get_instance_from_id)(GDObjectInstanceID p_instance_id); - GDObjectInstanceID (*object_get_instance_id)(const GDNativeObjectPtr p_object); + GDObjectInstanceID (*object_get_instance_id)(GDNativeConstObjectPtr p_object); /* SCRIPT INSTANCE */ @@ -554,23 +557,23 @@ typedef struct { /* CLASSDB */ - GDNativeObjectPtr (*classdb_construct_object)(const GDNativeStringNamePtr p_classname); /* The passed class must be a built-in godot class, or an already-registered extension class. In both case, object_set_instance should be called to fully initialize the object. */ - GDNativeMethodBindPtr (*classdb_get_method_bind)(const GDNativeStringNamePtr p_classname, const GDNativeStringNamePtr p_methodname, GDNativeInt p_hash); - void *(*classdb_get_class_tag)(const GDNativeStringNamePtr p_classname); + GDNativeObjectPtr (*classdb_construct_object)(GDNativeConstStringNamePtr p_classname); /* The passed class must be a built-in godot class, or an already-registered extension class. In both case, object_set_instance should be called to fully initialize the object. */ + GDNativeMethodBindPtr (*classdb_get_method_bind)(GDNativeConstStringNamePtr p_classname, GDNativeConstStringNamePtr p_methodname, GDNativeInt p_hash); + void *(*classdb_get_class_tag)(GDNativeConstStringNamePtr p_classname); /* CLASSDB EXTENSION */ /* Provided parameters for `classdb_register_extension_*` can be safely freed once the function returns. */ - void (*classdb_register_extension_class)(const GDNativeExtensionClassLibraryPtr p_library, const GDNativeStringNamePtr p_class_name, const GDNativeStringNamePtr p_parent_class_name, const GDNativeExtensionClassCreationInfo *p_extension_funcs); - void (*classdb_register_extension_class_method)(const GDNativeExtensionClassLibraryPtr p_library, const GDNativeStringNamePtr p_class_name, const GDNativeExtensionClassMethodInfo *p_method_info); - void (*classdb_register_extension_class_integer_constant)(const GDNativeExtensionClassLibraryPtr p_library, const GDNativeStringNamePtr p_class_name, const GDNativeStringNamePtr p_enum_name, const GDNativeStringNamePtr p_constant_name, GDNativeInt p_constant_value, GDNativeBool p_is_bitfield); - void (*classdb_register_extension_class_property)(const GDNativeExtensionClassLibraryPtr p_library, const GDNativeStringNamePtr p_class_name, const GDNativePropertyInfo *p_info, const GDNativeStringNamePtr p_setter, const GDNativeStringNamePtr p_getter); - void (*classdb_register_extension_class_property_group)(const GDNativeExtensionClassLibraryPtr p_library, const GDNativeStringNamePtr p_class_name, const GDNativeStringPtr p_group_name, const GDNativeStringPtr p_prefix); - void (*classdb_register_extension_class_property_subgroup)(const GDNativeExtensionClassLibraryPtr p_library, const GDNativeStringNamePtr p_class_name, const GDNativeStringPtr p_subgroup_name, const GDNativeStringPtr p_prefix); - void (*classdb_register_extension_class_signal)(const GDNativeExtensionClassLibraryPtr p_library, const GDNativeStringNamePtr p_class_name, const GDNativeStringNamePtr p_signal_name, const GDNativePropertyInfo *p_argument_info, GDNativeInt p_argument_count); - void (*classdb_unregister_extension_class)(const GDNativeExtensionClassLibraryPtr p_library, const GDNativeStringNamePtr p_class_name); /* Unregistering a parent class before a class that inherits it will result in failure. Inheritors must be unregistered first. */ + void (*classdb_register_extension_class)(GDNativeExtensionClassLibraryPtr p_library, GDNativeConstStringNamePtr p_class_name, GDNativeConstStringNamePtr p_parent_class_name, const GDNativeExtensionClassCreationInfo *p_extension_funcs); + void (*classdb_register_extension_class_method)(GDNativeExtensionClassLibraryPtr p_library, GDNativeConstStringNamePtr p_class_name, const GDNativeExtensionClassMethodInfo *p_method_info); + void (*classdb_register_extension_class_integer_constant)(GDNativeExtensionClassLibraryPtr p_library, GDNativeConstStringNamePtr p_class_name, GDNativeConstStringNamePtr p_enum_name, GDNativeConstStringNamePtr p_constant_name, GDNativeInt p_constant_value, GDNativeBool p_is_bitfield); + void (*classdb_register_extension_class_property)(GDNativeExtensionClassLibraryPtr p_library, GDNativeConstStringNamePtr p_class_name, const GDNativePropertyInfo *p_info, GDNativeConstStringNamePtr p_setter, GDNativeConstStringNamePtr p_getter); + void (*classdb_register_extension_class_property_group)(GDNativeExtensionClassLibraryPtr p_library, GDNativeConstStringNamePtr p_class_name, GDNativeConstStringPtr p_group_name, GDNativeConstStringPtr p_prefix); + void (*classdb_register_extension_class_property_subgroup)(GDNativeExtensionClassLibraryPtr p_library, GDNativeConstStringNamePtr p_class_name, GDNativeConstStringPtr p_subgroup_name, GDNativeConstStringPtr p_prefix); + void (*classdb_register_extension_class_signal)(GDNativeExtensionClassLibraryPtr p_library, GDNativeConstStringNamePtr p_class_name, GDNativeConstStringNamePtr p_signal_name, const GDNativePropertyInfo *p_argument_info, GDNativeInt p_argument_count); + void (*classdb_unregister_extension_class)(GDNativeExtensionClassLibraryPtr p_library, GDNativeConstStringNamePtr p_class_name); /* Unregistering a parent class before a class that inherits it will result in failure. Inheritors must be unregistered first. */ - void (*get_library_path)(const GDNativeExtensionClassLibraryPtr p_library, GDNativeStringPtr r_path); + void (*get_library_path)(GDNativeExtensionClassLibraryPtr p_library, GDNativeStringPtr r_path); } GDNativeInterface; @@ -600,7 +603,7 @@ typedef struct { * It can be used to set up different init levels, which are called during various stages of initialization/shutdown. * The function name must be a unique one specified in the .gdextension config file. */ -typedef GDNativeBool (*GDNativeInitializationFunction)(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization); +typedef GDNativeBool (*GDNativeInitializationFunction)(const GDNativeInterface *p_interface, GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization); #ifdef __cplusplus } diff --git a/include/godot_cpp/classes/ref.hpp b/include/godot_cpp/classes/ref.hpp index 21171d7..cc7f2d6 100644 --- a/include/godot_cpp/classes/ref.hpp +++ b/include/godot_cpp/classes/ref.hpp @@ -240,13 +240,13 @@ public: template struct PtrToArg> { _FORCE_INLINE_ static Ref convert(const void *p_ptr) { - return Ref(reinterpret_cast(godot::internal::gdn_interface->object_get_instance_binding(*(const GDNativeObjectPtr *)p_ptr, godot::internal::token, &T::___binding_callbacks))); + return Ref(reinterpret_cast(godot::internal::gdn_interface->object_get_instance_binding(*reinterpret_cast(const_cast(p_ptr)), godot::internal::token, &T::___binding_callbacks))); } typedef Ref EncodeT; - _FORCE_INLINE_ static void encode(Ref p_val, const void *p_ptr) { - *(void **)p_ptr = p_val->_owner; + _FORCE_INLINE_ static void encode(Ref p_val, void *p_ptr) { + *reinterpret_cast(p_ptr) = p_val->_owner; } }; @@ -255,7 +255,7 @@ struct PtrToArg &> { typedef Ref EncodeT; _FORCE_INLINE_ static Ref convert(const void *p_ptr) { - return Ref(reinterpret_cast(godot::internal::gdn_interface->object_get_instance_binding(*(const GDNativeObjectPtr *)p_ptr, godot::internal::token, &T::___binding_callbacks))); + return Ref(reinterpret_cast(godot::internal::gdn_interface->object_get_instance_binding(*reinterpret_cast(const_cast(p_ptr)), godot::internal::token, &T::___binding_callbacks))); } }; diff --git a/include/godot_cpp/classes/wrapped.hpp b/include/godot_cpp/classes/wrapped.hpp index dfc2748..1d15f6d 100644 --- a/include/godot_cpp/classes/wrapped.hpp +++ b/include/godot_cpp/classes/wrapped.hpp @@ -61,12 +61,12 @@ protected: String _to_string() const { return "[" + String(get_class_static()) + ":" + itos(get_instance_id()) + "]"; } static void notification_bind(GDExtensionClassInstancePtr p_instance, int32_t p_what) {} - static GDNativeBool set_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value) { return false; } - static GDNativeBool get_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret) { return false; } + static GDNativeBool set_bind(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeConstVariantPtr p_value) { return false; } + static GDNativeBool get_bind(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeVariantPtr r_ret) { return false; } static const GDNativePropertyInfo *get_property_list_bind(GDExtensionClassInstancePtr p_instance, uint32_t *r_count) { return nullptr; } static void free_property_list_bind(GDExtensionClassInstancePtr p_instance, const GDNativePropertyInfo *p_list) {} - static GDNativeBool property_can_revert_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name) { return false; } - static GDNativeBool property_get_revert_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret) { return false; } + static GDNativeBool property_can_revert_bind(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name) { return false; } + static GDNativeBool property_get_revert_bind(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeVariantPtr r_ret) { return false; } static void to_string_bind(GDExtensionClassInstancePtr p_instance, GDNativeBool *r_is_valid, GDNativeStringPtr r_out) {} ::godot::List<::godot::PropertyInfo> plist_owned; @@ -184,7 +184,7 @@ public: } \ } \ \ - static GDNativeBool set_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value) { \ + static GDNativeBool set_bind(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeConstVariantPtr p_value) { \ if (p_instance && m_class::_get_set()) { \ if (m_class::_get_set() != m_inherits::_get_set()) { \ m_class *cls = reinterpret_cast(p_instance); \ @@ -195,7 +195,7 @@ public: return false; \ } \ \ - static GDNativeBool get_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret) { \ + static GDNativeBool get_bind(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeVariantPtr r_ret) { \ if (p_instance && m_class::_get_get()) { \ if (m_class::_get_get() != m_inherits::_get_get()) { \ m_class *cls = reinterpret_cast(p_instance); \ @@ -243,7 +243,7 @@ public: } \ } \ \ - static GDNativeBool property_can_revert_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name) { \ + static GDNativeBool property_can_revert_bind(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name) { \ if (p_instance && m_class::_get_property_can_revert()) { \ if (m_class::_get_property_can_revert() != m_inherits::_get_property_can_revert()) { \ m_class *cls = reinterpret_cast(p_instance); \ @@ -254,7 +254,7 @@ public: return false; \ } \ \ - static GDNativeBool property_get_revert_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret) { \ + static GDNativeBool property_get_revert_bind(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeVariantPtr r_ret) { \ if (p_instance && m_class::_get_property_get_revert()) { \ if (m_class::_get_property_get_revert() != m_inherits::_get_property_get_revert()) { \ m_class *cls = reinterpret_cast(p_instance); \ diff --git a/include/godot_cpp/core/binder_common.hpp b/include/godot_cpp/core/binder_common.hpp index 8bee243..93b21ca 100644 --- a/include/godot_cpp/core/binder_common.hpp +++ b/include/godot_cpp/core/binder_common.hpp @@ -41,46 +41,46 @@ namespace godot { -#define VARIANT_ENUM_CAST(m_class, m_enum) \ - namespace godot { \ - MAKE_ENUM_TYPE_INFO(m_class, m_enum) \ - template <> \ - struct VariantCaster { \ - static _FORCE_INLINE_ m_class::m_enum cast(const Variant &p_variant) { \ - return (m_class::m_enum)p_variant.operator int64_t(); \ - } \ - }; \ - template <> \ - struct PtrToArg { \ - _FORCE_INLINE_ static m_class::m_enum convert(const void *p_ptr) { \ - return m_class::m_enum(*reinterpret_cast(p_ptr)); \ - } \ - typedef int64_t EncodeT; \ - _FORCE_INLINE_ static void encode(m_class::m_enum p_val, const void *p_ptr) { \ - *(int64_t *)p_ptr = p_val; \ - } \ - }; \ +#define VARIANT_ENUM_CAST(m_class, m_enum) \ + namespace godot { \ + MAKE_ENUM_TYPE_INFO(m_class, m_enum) \ + template <> \ + struct VariantCaster { \ + static _FORCE_INLINE_ m_class::m_enum cast(const Variant &p_variant) { \ + return (m_class::m_enum)p_variant.operator int64_t(); \ + } \ + }; \ + template <> \ + struct PtrToArg { \ + _FORCE_INLINE_ static m_class::m_enum convert(const void *p_ptr) { \ + return m_class::m_enum(*reinterpret_cast(p_ptr)); \ + } \ + typedef int64_t EncodeT; \ + _FORCE_INLINE_ static void encode(m_class::m_enum p_val, void *p_ptr) { \ + *reinterpret_cast(p_ptr) = p_val; \ + } \ + }; \ } -#define VARIANT_BITFIELD_CAST(m_class, m_enum) \ - namespace godot { \ - MAKE_BITFIELD_TYPE_INFO(m_class, m_enum) \ - template <> \ - struct VariantCaster> { \ - static _FORCE_INLINE_ BitField cast(const Variant &p_variant) { \ - return BitField(p_variant.operator int64_t()); \ - } \ - }; \ - template <> \ - struct PtrToArg> { \ - _FORCE_INLINE_ static BitField convert(const void *p_ptr) { \ - return BitField(*reinterpret_cast(p_ptr)); \ - } \ - typedef int64_t EncodeT; \ - _FORCE_INLINE_ static void encode(BitField p_val, const void *p_ptr) { \ - *(int64_t *)p_ptr = p_val; \ - } \ - }; \ +#define VARIANT_BITFIELD_CAST(m_class, m_enum) \ + namespace godot { \ + MAKE_BITFIELD_TYPE_INFO(m_class, m_enum) \ + template <> \ + struct VariantCaster> { \ + static _FORCE_INLINE_ BitField cast(const Variant &p_variant) { \ + return BitField(p_variant.operator int64_t()); \ + } \ + }; \ + template <> \ + struct PtrToArg> { \ + _FORCE_INLINE_ static BitField convert(const void *p_ptr) { \ + return BitField(*reinterpret_cast(p_ptr)); \ + } \ + typedef int64_t EncodeT; \ + _FORCE_INLINE_ static void encode(BitField p_val, void *p_ptr) { \ + *reinterpret_cast(p_ptr) = p_val; \ + } \ + }; \ } template @@ -169,42 +169,42 @@ struct VariantCasterAndValidate { }; template -void call_with_ptr_args_helper(T *p_instance, void (T::*p_method)(P...), const GDNativeTypePtr *p_args, IndexSequence) { +void call_with_ptr_args_helper(T *p_instance, void (T::*p_method)(P...), GDNativeConstTypePtr *p_args, IndexSequence) { (p_instance->*p_method)(PtrToArg

::convert(p_args[Is])...); } template -void call_with_ptr_argsc_helper(T *p_instance, void (T::*p_method)(P...) const, const GDNativeTypePtr *p_args, IndexSequence) { +void call_with_ptr_argsc_helper(T *p_instance, void (T::*p_method)(P...) const, GDNativeConstTypePtr *p_args, IndexSequence) { (p_instance->*p_method)(PtrToArg

::convert(p_args[Is])...); } template -void call_with_ptr_args_ret_helper(T *p_instance, R (T::*p_method)(P...), const GDNativeTypePtr *p_args, void *r_ret, IndexSequence) { +void call_with_ptr_args_ret_helper(T *p_instance, R (T::*p_method)(P...), GDNativeConstTypePtr *p_args, void *r_ret, IndexSequence) { PtrToArg::encode((p_instance->*p_method)(PtrToArg

::convert(p_args[Is])...), r_ret); } template -void call_with_ptr_args_retc_helper(T *p_instance, R (T::*p_method)(P...) const, const GDNativeTypePtr *p_args, void *r_ret, IndexSequence) { +void call_with_ptr_args_retc_helper(T *p_instance, R (T::*p_method)(P...) const, GDNativeConstTypePtr *p_args, void *r_ret, IndexSequence) { PtrToArg::encode((p_instance->*p_method)(PtrToArg

::convert(p_args[Is])...), r_ret); } template -void call_with_ptr_args(T *p_instance, void (T::*p_method)(P...), const GDNativeTypePtr *p_args, void * /*ret*/) { +void call_with_ptr_args(T *p_instance, void (T::*p_method)(P...), GDNativeConstTypePtr *p_args, void * /*ret*/) { call_with_ptr_args_helper(p_instance, p_method, p_args, BuildIndexSequence{}); } template -void call_with_ptr_args(T *p_instance, void (T::*p_method)(P...) const, const GDNativeTypePtr *p_args, void * /*ret*/) { +void call_with_ptr_args(T *p_instance, void (T::*p_method)(P...) const, GDNativeConstTypePtr *p_args, void * /*ret*/) { call_with_ptr_argsc_helper(p_instance, p_method, p_args, BuildIndexSequence{}); } template -void call_with_ptr_args(T *p_instance, R (T::*p_method)(P...), const GDNativeTypePtr *p_args, void *r_ret) { +void call_with_ptr_args(T *p_instance, R (T::*p_method)(P...), GDNativeConstTypePtr *p_args, void *r_ret) { call_with_ptr_args_ret_helper(p_instance, p_method, p_args, r_ret, BuildIndexSequence{}); } template -void call_with_ptr_args(T *p_instance, R (T::*p_method)(P...) const, const GDNativeTypePtr *p_args, void *r_ret) { +void call_with_ptr_args(T *p_instance, R (T::*p_method)(P...) const, GDNativeConstTypePtr *p_args, void *r_ret) { call_with_ptr_args_retc_helper(p_instance, p_method, p_args, r_ret, BuildIndexSequence{}); } @@ -256,7 +256,7 @@ void call_with_variant_args_retc_helper(T *p_instance, R (T::*p_method)(P...) co } template -void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), const GDNativeVariantPtr *p_args, int p_argcount, GDNativeCallError &r_error, const std::vector &default_values) { +void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), GDNativeConstVariantPtr *p_args, int p_argcount, GDNativeCallError &r_error, const std::vector &default_values) { #ifdef DEBUG_ENABLED if ((size_t)p_argcount > sizeof...(P)) { r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS; @@ -291,7 +291,7 @@ void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), const G } template -void call_with_variant_argsc_dv(T *p_instance, void (T::*p_method)(P...) const, const GDNativeVariantPtr *p_args, int p_argcount, GDNativeCallError &r_error, const std::vector &default_values) { +void call_with_variant_argsc_dv(T *p_instance, void (T::*p_method)(P...) const, GDNativeConstVariantPtr *p_args, int p_argcount, GDNativeCallError &r_error, const std::vector &default_values) { #ifdef DEBUG_ENABLED if ((size_t)p_argcount > sizeof...(P)) { r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS; @@ -326,7 +326,7 @@ void call_with_variant_argsc_dv(T *p_instance, void (T::*p_method)(P...) const, } template -void call_with_variant_args_ret_dv(T *p_instance, R (T::*p_method)(P...), const GDNativeVariantPtr *p_args, int p_argcount, Variant &r_ret, GDNativeCallError &r_error, const std::vector &default_values) { +void call_with_variant_args_ret_dv(T *p_instance, R (T::*p_method)(P...), GDNativeConstVariantPtr *p_args, int p_argcount, Variant &r_ret, GDNativeCallError &r_error, const std::vector &default_values) { #ifdef DEBUG_ENABLED if ((size_t)p_argcount > sizeof...(P)) { r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS; @@ -361,7 +361,7 @@ void call_with_variant_args_ret_dv(T *p_instance, R (T::*p_method)(P...), const } template -void call_with_variant_args_retc_dv(T *p_instance, R (T::*p_method)(P...) const, const GDNativeVariantPtr *p_args, int p_argcount, Variant &r_ret, GDNativeCallError &r_error, const std::vector &default_values) { +void call_with_variant_args_retc_dv(T *p_instance, R (T::*p_method)(P...) const, GDNativeConstVariantPtr *p_args, int p_argcount, Variant &r_ret, GDNativeCallError &r_error, const std::vector &default_values) { #ifdef DEBUG_ENABLED if ((size_t)p_argcount > sizeof...(P)) { r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS; @@ -473,7 +473,7 @@ void call_with_variant_args_static(void (*p_method)(P...), const Variant **p_arg } template -void call_with_variant_args_static_dv(void (*p_method)(P...), const GDNativeVariantPtr *p_args, int p_argcount, GDNativeCallError &r_error, const std::vector &default_values) { +void call_with_variant_args_static_dv(void (*p_method)(P...), GDNativeConstVariantPtr *p_args, int p_argcount, GDNativeCallError &r_error, const std::vector &default_values) { #ifdef DEBUG_ENABLED if ((size_t)p_argcount > sizeof...(P)) { r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS; @@ -508,12 +508,12 @@ void call_with_variant_args_static_dv(void (*p_method)(P...), const GDNativeVari } template -void call_with_ptr_args_static_method_helper(void (*p_method)(P...), const GDNativeTypePtr *p_args, IndexSequence) { +void call_with_ptr_args_static_method_helper(void (*p_method)(P...), GDNativeConstTypePtr *p_args, IndexSequence) { p_method(PtrToArg

::convert(p_args[Is])...); } template -void call_with_ptr_args_static_method(void (*p_method)(P...), const GDNativeTypePtr *p_args) { +void call_with_ptr_args_static_method(void (*p_method)(P...), GDNativeConstTypePtr *p_args) { call_with_ptr_args_static_method_helper(p_method, p_args, BuildIndexSequence{}); } @@ -529,7 +529,7 @@ void call_with_variant_args_static_ret(R (*p_method)(P...), const Variant **p_ar } template -void call_with_variant_args_static_ret_dv(R (*p_method)(P...), const GDNativeVariantPtr *p_args, int p_argcount, Variant &r_ret, GDNativeCallError &r_error, const std::vector &default_values) { +void call_with_variant_args_static_ret_dv(R (*p_method)(P...), GDNativeConstVariantPtr *p_args, int p_argcount, Variant &r_ret, GDNativeCallError &r_error, const std::vector &default_values) { #ifdef DEBUG_ENABLED if ((size_t)p_argcount > sizeof...(P)) { r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS; @@ -564,12 +564,12 @@ void call_with_variant_args_static_ret_dv(R (*p_method)(P...), const GDNativeVar } template -void call_with_ptr_args_static_method_ret_helper(R (*p_method)(P...), const GDNativeTypePtr *p_args, void *r_ret, IndexSequence) { +void call_with_ptr_args_static_method_ret_helper(R (*p_method)(P...), GDNativeConstTypePtr *p_args, void *r_ret, IndexSequence) { PtrToArg::encode(p_method(PtrToArg

::convert(p_args[Is])...), r_ret); } template -void call_with_ptr_args_static_method_ret(R (*p_method)(P...), const GDNativeTypePtr *p_args, void *r_ret) { +void call_with_ptr_args_static_method_ret(R (*p_method)(P...), GDNativeConstTypePtr *p_args, void *r_ret) { call_with_ptr_args_static_method_ret_helper(p_method, p_args, r_ret, BuildIndexSequence{}); } diff --git a/include/godot_cpp/core/builtin_ptrcall.hpp b/include/godot_cpp/core/builtin_ptrcall.hpp index d30a12f..848e86a 100644 --- a/include/godot_cpp/core/builtin_ptrcall.hpp +++ b/include/godot_cpp/core/builtin_ptrcall.hpp @@ -41,33 +41,33 @@ namespace internal { template void _call_builtin_constructor(const GDNativePtrConstructor constructor, GDNativeTypePtr base, Args... args) { - std::array call_args = { { (const GDNativeTypePtr)args... } }; + std::array call_args = { { (GDNativeConstTypePtr)args... } }; constructor(base, call_args.data()); } template T _call_builtin_method_ptr_ret(const GDNativePtrBuiltInMethod method, GDNativeTypePtr base, Args... args) { T ret; - std::array call_args = { { (const GDNativeTypePtr)args... } }; + std::array call_args = { { (GDNativeConstTypePtr)args... } }; method(base, call_args.data(), &ret, sizeof...(Args)); return ret; } template void _call_builtin_method_ptr_no_ret(const GDNativePtrBuiltInMethod method, GDNativeTypePtr base, Args... args) { - std::array call_args = { { (const GDNativeTypePtr)args... } }; + std::array call_args = { { (GDNativeConstTypePtr)args... } }; method(base, call_args.data(), nullptr, sizeof...(Args)); } template -T _call_builtin_operator_ptr(const GDNativePtrOperatorEvaluator op, const GDNativeTypePtr left, const GDNativeTypePtr right) { +T _call_builtin_operator_ptr(const GDNativePtrOperatorEvaluator op, GDNativeConstTypePtr left, GDNativeConstTypePtr right) { T ret; op(left, right, &ret); return ret; } template -T _call_builtin_ptr_getter(const GDNativePtrGetter getter, const GDNativeTypePtr base) { +T _call_builtin_ptr_getter(const GDNativePtrGetter getter, GDNativeConstTypePtr base) { T ret; getter(base, &ret); return ret; diff --git a/include/godot_cpp/core/class_db.hpp b/include/godot_cpp/core/class_db.hpp index 634e55c..8fcedfa 100644 --- a/include/godot_cpp/core/class_db.hpp +++ b/include/godot_cpp/core/class_db.hpp @@ -136,7 +136,7 @@ public: static MethodBind *get_method(const StringName &p_class, const StringName &p_method); - static GDNativeExtensionClassCallVirtual get_virtual_func(void *p_userdata, const GDNativeStringNamePtr p_name); + static GDNativeExtensionClassCallVirtual get_virtual_func(void *p_userdata, GDNativeConstStringNamePtr p_name); static void initialize(GDNativeInitializationLevel p_level); static void deinitialize(GDNativeInitializationLevel p_level); @@ -151,12 +151,12 @@ public: #define BIND_BITFIELD_FLAG(m_constant) \ godot::ClassDB::bind_integer_constant(get_class_static(), godot::__constant_get_bitfield_name(m_constant, #m_constant), #m_constant, m_constant, true); -#define BIND_VIRTUAL_METHOD(m_class, m_method) \ - { \ - auto ___call##m_method = [](GDNativeObjectPtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr p_ret) -> void { \ - call_with_ptr_args(reinterpret_cast(p_instance), &m_class::m_method, p_args, p_ret); \ - }; \ - godot::ClassDB::bind_virtual_method(m_class::get_class_static(), #m_method, ___call##m_method); \ +#define BIND_VIRTUAL_METHOD(m_class, m_method) \ + { \ + auto ___call##m_method = [](GDNativeObjectPtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr p_ret) -> void { \ + call_with_ptr_args(reinterpret_cast(p_instance), &m_class::m_method, p_args, p_ret); \ + }; \ + godot::ClassDB::bind_virtual_method(m_class::get_class_static(), #m_method, ___call##m_method); \ } template diff --git a/include/godot_cpp/core/engine_ptrcall.hpp b/include/godot_cpp/core/engine_ptrcall.hpp index d6de1eb..09e2fe1 100644 --- a/include/godot_cpp/core/engine_ptrcall.hpp +++ b/include/godot_cpp/core/engine_ptrcall.hpp @@ -46,7 +46,7 @@ namespace internal { template O *_call_native_mb_ret_obj(const GDNativeMethodBindPtr mb, void *instance, const Args &...args) { GodotObject *ret = nullptr; - std::array mb_args = { { (const GDNativeTypePtr)args... } }; + std::array mb_args = { { (GDNativeConstTypePtr)args... } }; internal::gdn_interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret); if (ret == nullptr) { return nullptr; @@ -57,21 +57,21 @@ O *_call_native_mb_ret_obj(const GDNativeMethodBindPtr mb, void *instance, const template R _call_native_mb_ret(const GDNativeMethodBindPtr mb, void *instance, const Args &...args) { R ret; - std::array mb_args = { { (const GDNativeTypePtr)args... } }; + std::array mb_args = { { (GDNativeConstTypePtr)args... } }; internal::gdn_interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret); return ret; } template void _call_native_mb_no_ret(const GDNativeMethodBindPtr mb, void *instance, const Args &...args) { - std::array mb_args = { { (const GDNativeTypePtr)args... } }; + std::array mb_args = { { (GDNativeConstTypePtr)args... } }; internal::gdn_interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), nullptr); } template R _call_utility_ret(GDNativePtrUtilityFunction func, const Args &...args) { R ret; - std::array mb_args = { { (const GDNativeTypePtr)args... } }; + std::array mb_args = { { (GDNativeConstTypePtr)args... } }; func(&ret, mb_args.data(), mb_args.size()); return ret; } @@ -79,14 +79,14 @@ R _call_utility_ret(GDNativePtrUtilityFunction func, const Args &...args) { template Object *_call_utility_ret_obj(const GDNativePtrUtilityFunction func, void *instance, const Args &...args) { GodotObject *ret = nullptr; - std::array mb_args = { { (const GDNativeTypePtr)args... } }; + std::array mb_args = { { (GDNativeConstTypePtr)args... } }; func(&ret, mb_args.data(), mb_args.size()); return (Object *)internal::gdn_interface->object_get_instance_binding(ret, internal::token, &Object::___binding_callbacks); } template void _call_utility_no_ret(const GDNativePtrUtilityFunction func, const Args &...args) { - std::array mb_args = { { (const GDNativeTypePtr)args... } }; + std::array mb_args = { { (GDNativeConstTypePtr)args... } }; func(nullptr, mb_args.data(), mb_args.size()); } diff --git a/include/godot_cpp/core/method_bind.hpp b/include/godot_cpp/core/method_bind.hpp index c211676..16f0358 100644 --- a/include/godot_cpp/core/method_bind.hpp +++ b/include/godot_cpp/core/method_bind.hpp @@ -136,11 +136,11 @@ public: return vec; } - virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const = 0; - virtual void ptrcall(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_return) const = 0; + virtual Variant call(GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeCallError &r_error) const = 0; + virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_return) const = 0; - static void bind_call(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error); - static void bind_ptrcall(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_return); + static void bind_call(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error); + static void bind_ptrcall(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_return); virtual ~MethodBind(); }; @@ -171,7 +171,7 @@ public: return GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_NONE; } - virtual void ptrcall(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_return) const { + virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_return) const { ERR_FAIL(); // Can't call. } @@ -211,7 +211,7 @@ class MethodBindVarArgT : public MethodBindVarArgBase, T, v friend class MethodBindVarArgBase, T, void, false>; public: - virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const { + virtual Variant call(GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeCallError &r_error) const { (static_cast(p_instance)->*MethodBindVarArgBase, T, void, false>::method)((const Variant **)p_args, p_argument_count, r_error); return {}; } @@ -241,7 +241,7 @@ class MethodBindVarArgTR : public MethodBindVarArgBase, friend class MethodBindVarArgBase, T, R, true>; public: - virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const { + virtual Variant call(GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeCallError &r_error) const { return (static_cast(p_instance)->*MethodBindVarArgBase, T, R, true>::method)((const Variant **)p_args, p_argument_count, r_error); } @@ -314,7 +314,7 @@ public: return call_get_argument_metadata(p_argument); } - virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const { + virtual Variant call(GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeCallError &r_error) const { #ifdef TYPED_METHOD_BIND call_with_variant_args_dv(static_cast(p_instance), method, p_args, (int)p_argument_count, r_error, get_default_arguments()); #else @@ -322,7 +322,7 @@ public: #endif return Variant(); } - virtual void ptrcall(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret) const { + virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret) const { #ifdef TYPED_METHOD_BIND call_with_ptr_args(static_cast(p_instance), method, p_args, nullptr); #else @@ -390,7 +390,7 @@ public: return call_get_argument_metadata(p_argument); } - virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const { + virtual Variant call(GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeCallError &r_error) const { #ifdef TYPED_METHOD_BIND call_with_variant_argsc_dv(static_cast(p_instance), method, p_args, (int)p_argument_count, r_error, get_default_arguments()); #else @@ -398,7 +398,7 @@ public: #endif return Variant(); } - virtual void ptrcall(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret) const { + virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret) const { #ifdef TYPED_METHOD_BIND call_with_ptr_args(static_cast(p_instance), method, p_args, nullptr); #else @@ -471,7 +471,7 @@ public: } } - virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const { + virtual Variant call(GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeCallError &r_error) const { Variant ret; #ifdef TYPED_METHOD_BIND call_with_variant_args_ret_dv(static_cast(p_instance), method, p_args, (int)p_argument_count, ret, r_error, get_default_arguments()); @@ -480,7 +480,7 @@ public: #endif return ret; } - virtual void ptrcall(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret) const { + virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret) const { #ifdef TYPED_METHOD_BIND call_with_ptr_args(static_cast(p_instance), method, p_args, r_ret); #else @@ -554,7 +554,7 @@ public: } } - virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const { + virtual Variant call(GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeCallError &r_error) const { Variant ret; #ifdef TYPED_METHOD_BIND call_with_variant_args_retc_dv(static_cast(p_instance), method, p_args, (int)p_argument_count, ret, r_error, get_default_arguments()); @@ -563,7 +563,7 @@ public: #endif return ret; } - virtual void ptrcall(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret) const { + virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret) const { #ifdef TYPED_METHOD_BIND call_with_ptr_args(static_cast(p_instance), method, p_args, r_ret); #else @@ -630,13 +630,13 @@ public: return call_get_argument_metadata(p_arg); } - virtual Variant call(GDExtensionClassInstancePtr p_object, const GDNativeVariantPtr *p_args, const GDNativeInt p_arg_count, GDNativeCallError &r_error) const { + virtual Variant call(GDExtensionClassInstancePtr p_object, GDNativeConstVariantPtr *p_args, GDNativeInt p_arg_count, GDNativeCallError &r_error) const { (void)p_object; // unused call_with_variant_args_static_dv(function, p_args, p_arg_count, r_error, get_default_arguments()); return Variant(); } - virtual void ptrcall(GDExtensionClassInstancePtr p_object, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret) const { + virtual void ptrcall(GDExtensionClassInstancePtr p_object, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret) const { (void)p_object; (void)r_ret; call_with_ptr_args_static_method(function, p_args); @@ -700,13 +700,13 @@ public: } } - virtual Variant call(GDExtensionClassInstancePtr p_object, const GDNativeVariantPtr *p_args, const GDNativeInt p_arg_count, GDNativeCallError &r_error) const { + virtual Variant call(GDExtensionClassInstancePtr p_object, GDNativeConstVariantPtr *p_args, GDNativeInt p_arg_count, GDNativeCallError &r_error) const { Variant ret; call_with_variant_args_static_ret_dv(function, p_args, p_arg_count, ret, r_error, get_default_arguments()); return ret; } - virtual void ptrcall(GDExtensionClassInstancePtr p_object, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret) const { + virtual void ptrcall(GDExtensionClassInstancePtr p_object, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret) const { (void)p_object; call_with_ptr_args_static_method_ret(function, p_args, r_ret); } diff --git a/include/godot_cpp/core/method_ptrcall.hpp b/include/godot_cpp/core/method_ptrcall.hpp index e5f64f9..d22b712 100644 --- a/include/godot_cpp/core/method_ptrcall.hpp +++ b/include/godot_cpp/core/method_ptrcall.hpp @@ -49,7 +49,7 @@ struct PtrToArg {}; } \ typedef m_type EncodeT; \ _FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \ - *((m_type *)p_ptr) = p_val; \ + *reinterpret_cast(p_ptr) = p_val; \ } \ }; \ template <> \ @@ -59,7 +59,7 @@ struct PtrToArg {}; } \ typedef m_type EncodeT; \ _FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \ - *((m_type *)p_ptr) = p_val; \ + *reinterpret_cast(p_ptr) = p_val; \ } \ } @@ -71,7 +71,7 @@ struct PtrToArg {}; } \ typedef m_conv EncodeT; \ _FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \ - *((m_conv *)p_ptr) = static_cast(p_val); \ + *reinterpret_cast(p_ptr) = static_cast(p_val); \ } \ _FORCE_INLINE_ static m_conv encode_arg(m_type p_val) { \ return static_cast(p_val); \ @@ -84,7 +84,7 @@ struct PtrToArg {}; } \ typedef m_conv EncodeT; \ _FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \ - *((m_conv *)p_ptr) = static_cast(p_val); \ + *reinterpret_cast(p_ptr) = static_cast(p_val); \ } \ _FORCE_INLINE_ static m_conv encode_arg(m_type p_val) { \ return static_cast(p_val); \ @@ -99,7 +99,7 @@ struct PtrToArg {}; } \ typedef m_type EncodeT; \ _FORCE_INLINE_ static void encode(const m_type &p_val, void *p_ptr) { \ - *((m_type *)p_ptr) = p_val; \ + *reinterpret_cast(p_ptr) = p_val; \ } \ }; \ template <> \ @@ -109,7 +109,7 @@ struct PtrToArg {}; } \ typedef m_type EncodeT; \ _FORCE_INLINE_ static void encode(const m_type &p_val, void *p_ptr) { \ - *((m_type *)p_ptr) = p_val; \ + *reinterpret_cast(p_ptr) = p_val; \ } \ } @@ -168,47 +168,47 @@ MAKE_PTRARG_BY_REFERENCE(Variant); template struct PtrToArg { _FORCE_INLINE_ static T *convert(const void *p_ptr) { - return reinterpret_cast(godot::internal::gdn_interface->object_get_instance_binding(*(const GDNativeObjectPtr *)p_ptr, godot::internal::token, &T::___binding_callbacks)); + return reinterpret_cast(godot::internal::gdn_interface->object_get_instance_binding(*reinterpret_cast(const_cast(p_ptr)), godot::internal::token, &T::___binding_callbacks)); } typedef Object *EncodeT; _FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) { - *((void **)p_ptr) = p_var ? p_var->_owner : nullptr; + *reinterpret_cast(p_ptr) = p_var ? p_var->_owner : nullptr; } }; template struct PtrToArg { _FORCE_INLINE_ static const T *convert(const void *p_ptr) { - return reinterpret_cast(godot::internal::gdn_interface->object_get_instance_binding(*(const GDNativeObjectPtr *)p_ptr, godot::internal::token, &T::___binding_callbacks)); + return reinterpret_cast(godot::internal::gdn_interface->object_get_instance_binding(*reinterpret_cast(const_cast(p_ptr)), godot::internal::token, &T::___binding_callbacks)); } typedef const Object *EncodeT; _FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) { - *((void **)p_ptr) = p_var ? p_var->_owner : nullptr; + *reinterpret_cast(p_ptr) = p_var ? p_var->_owner : nullptr; } }; // Pointers. -#define GDVIRTUAL_NATIVE_PTR(m_type) \ - template <> \ - struct PtrToArg { \ - _FORCE_INLINE_ static m_type *convert(const void *p_ptr) { \ - return (m_type *)(*(void **)p_ptr); \ - } \ - typedef m_type *EncodeT; \ - _FORCE_INLINE_ static void encode(m_type *p_var, void *p_ptr) { \ - *((void **)p_ptr) = p_var; \ - } \ - }; \ - \ - template <> \ - struct PtrToArg { \ - _FORCE_INLINE_ static const m_type *convert(const void *p_ptr) { \ - return (const m_type *)(*(const void **)p_ptr); \ - } \ - typedef const m_type *EncodeT; \ - _FORCE_INLINE_ static void encode(const m_type *p_var, const void *p_ptr) { \ - *((const void **)p_ptr) = p_var; \ - } \ +#define GDVIRTUAL_NATIVE_PTR(m_type) \ + template <> \ + struct PtrToArg { \ + _FORCE_INLINE_ static m_type *convert(const void *p_ptr) { \ + return (m_type *)(*(void **)p_ptr); \ + } \ + typedef m_type *EncodeT; \ + _FORCE_INLINE_ static void encode(m_type *p_var, void *p_ptr) { \ + *reinterpret_cast(p_ptr) = p_var; \ + } \ + }; \ + \ + template <> \ + struct PtrToArg { \ + _FORCE_INLINE_ static const m_type *convert(const void *p_ptr) { \ + return (const m_type *)(*(const void **)p_ptr); \ + } \ + typedef const m_type *EncodeT; \ + _FORCE_INLINE_ static void encode(const m_type *p_var, void *p_ptr) { \ + *reinterpret_cast(p_ptr) = p_var; \ + } \ } GDVIRTUAL_NATIVE_PTR(void); diff --git a/include/godot_cpp/core/type_info.hpp b/include/godot_cpp/core/type_info.hpp index 4c3f1bf..329231a 100644 --- a/include/godot_cpp/core/type_info.hpp +++ b/include/godot_cpp/core/type_info.hpp @@ -292,7 +292,7 @@ struct PtrToArg> { } typedef Array EncodeT; _FORCE_INLINE_ static void encode(TypedArray p_val, void *p_ptr) { - *(Array *)p_ptr = p_val; + *reinterpret_cast(p_ptr) = p_val; } }; diff --git a/include/godot_cpp/godot.hpp b/include/godot_cpp/godot.hpp index d6743fb..c93759e 100644 --- a/include/godot_cpp/godot.hpp +++ b/include/godot_cpp/godot.hpp @@ -57,7 +57,7 @@ public: static Callback init_callback; static Callback terminate_callback; static GDNativeInitializationLevel minimum_initialization_level; - static GDNativeBool init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization); + static GDNativeBool init(const GDNativeInterface *p_interface, GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization); public: static void initialize_level(void *userdata, GDNativeInitializationLevel p_level); @@ -65,11 +65,11 @@ public: class InitObject { const GDNativeInterface *gdn_interface; - const GDNativeExtensionClassLibraryPtr library; + GDNativeExtensionClassLibraryPtr library; GDNativeInitialization *initialization; public: - InitObject(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) : + InitObject(const GDNativeInterface *p_interface, GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) : gdn_interface(p_interface), library(p_library), initialization(r_initialization) {} diff --git a/include/godot_cpp/variant/variant.hpp b/include/godot_cpp/variant/variant.hpp index 1a5c22d..4a430ed 100644 --- a/include/godot_cpp/variant/variant.hpp +++ b/include/godot_cpp/variant/variant.hpp @@ -145,7 +145,7 @@ public: Variant(); Variant(std::nullptr_t n) : Variant() {} - explicit Variant(const GDNativeVariantPtr native_ptr); + explicit Variant(GDNativeConstVariantPtr native_ptr); Variant(const Variant &other); Variant(Variant &&other); Variant(bool v); @@ -257,7 +257,7 @@ public: Variant call(const StringName &method, Args... args) { Variant result; GDNativeCallError error; - std::array call_args = { Variant(args)... }; + std::array call_args = { Variant(args)... }; call(method, call_args.data(), call_args.size(), result, error); return result; } @@ -268,7 +268,7 @@ public: static Variant call_static(Variant::Type type, const StringName &method, Args... args) { Variant result; GDNativeCallError error; - std::array call_args = { Variant(args)... }; + std::array call_args = { Variant(args)... }; call_static(type, method, call_args.data(), call_args.size(), result, error); return result; } diff --git a/src/classes/wrapped.cpp b/src/classes/wrapped.cpp index fead050..ed57f44 100644 --- a/src/classes/wrapped.cpp +++ b/src/classes/wrapped.cpp @@ -43,17 +43,13 @@ const StringName *Wrapped::_get_extension_class_name() const { void Wrapped::_postinitialize() { const StringName *extension_class = _get_extension_class_name(); if (extension_class) { - // TODO: replace C cast by a proper reinterpret_cast once `object_set_instance` signature correctly handles `const GDNativeStringNamePtr` param - // (see: https://github.com/godotengine/godot/pull/67751) - godot::internal::gdn_interface->object_set_instance(_owner, (GDNativeStringNamePtr)(extension_class), this); + godot::internal::gdn_interface->object_set_instance(_owner, reinterpret_cast(extension_class), this); } godot::internal::gdn_interface->object_set_instance_binding(_owner, godot::internal::token, this, _get_bindings_callbacks()); } Wrapped::Wrapped(const StringName p_godot_class) { - // TODO: replace C cast by a proper reinterpret_cast once `classdb_construct_object` signature correctly handles `const GDNativeStringNamePtr` param - // (see: https://github.com/godotengine/godot/pull/67751) - _owner = godot::internal::gdn_interface->classdb_construct_object((GDNativeStringNamePtr)(p_godot_class._native_ptr())); + _owner = godot::internal::gdn_interface->classdb_construct_object(reinterpret_cast(p_godot_class._native_ptr())); } Wrapped::Wrapped(GodotObject *p_godot_object) { diff --git a/src/core/class_db.cpp b/src/core/class_db.cpp index 7985f94..1e2c6e0 100644 --- a/src/core/class_db.cpp +++ b/src/core/class_db.cpp @@ -220,7 +220,7 @@ void ClassDB::bind_method_godot(const StringName &p_class_name, MethodBind *p_me StringName name = p_method->get_name(); GDNativeExtensionClassMethodInfo method_info = { - name._native_ptr(), // const GDNativeStringNamePtr; + name._native_ptr(), // GDNativeStringNamePtr; p_method, // void *method_userdata; MethodBind::bind_call, // GDNativeExtensionClassMethodCall call_func; MethodBind::bind_ptrcall, // GDNativeExtensionClassMethodPtrCall ptrcall_func; @@ -261,10 +261,10 @@ void ClassDB::add_signal(const StringName &p_class, const MethodInfo &p_signal) for (const PropertyInfo &par : p_signal.arguments) { parameters.push_back(GDNativePropertyInfo{ static_cast(par.type), // GDNativeVariantType type; - par.name._native_ptr(), // const GDNativeStringNamePtr name; - par.class_name._native_ptr(), // const GDNativeStringNamePtr class_name; + par.name._native_ptr(), // GDNativeStringNamePtr name; + par.class_name._native_ptr(), // GDNativeStringNamePtr class_name; par.hint, // NONE //uint32_t hint; - par.hint_string._native_ptr(), // const GDNativeStringPtr hint_string; + par.hint_string._native_ptr(), // GDNativeStringPtr hint_string; par.usage, // DEFAULT //uint32_t usage; }); } @@ -288,7 +288,7 @@ void ClassDB::bind_integer_constant(const StringName &p_class_name, const String // Register it with Godot internal::gdn_interface->classdb_register_extension_class_integer_constant(internal::library, p_class_name._native_ptr(), p_enum_name._native_ptr(), p_constant_name._native_ptr(), p_constant_value, p_is_bitfield); } -GDNativeExtensionClassCallVirtual ClassDB::get_virtual_func(void *p_userdata, const GDNativeStringNamePtr p_name) { +GDNativeExtensionClassCallVirtual ClassDB::get_virtual_func(void *p_userdata, GDNativeConstStringNamePtr p_name) { // This is called by Godot the first time it calls a virtual function, and it caches the result, per object instance. // Because of this, it can happen from different threads at once. // It should be ok not using any mutex as long as we only READ data. diff --git a/src/core/method_bind.cpp b/src/core/method_bind.cpp index 9c0ce4b..4987179 100644 --- a/src/core/method_bind.cpp +++ b/src/core/method_bind.cpp @@ -91,7 +91,7 @@ PropertyInfo MethodBind::get_argument_info(int p_argument) const { return info; } -void MethodBind::bind_call(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error) { +void MethodBind::bind_call(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error) { const MethodBind *bind = reinterpret_cast(p_method_userdata); 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. @@ -99,7 +99,7 @@ void MethodBind::bind_call(void *p_method_userdata, GDExtensionClassInstancePtr internal::gdn_interface->variant_new_copy(r_return, ret._native_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, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_return) { const MethodBind *bind = reinterpret_cast(p_method_userdata); bind->ptrcall(p_instance, p_args, r_return); } diff --git a/src/godot.cpp b/src/godot.cpp index 356e7f1..b0d995b 100644 --- a/src/godot.cpp +++ b/src/godot.cpp @@ -51,7 +51,7 @@ GDExtensionBinding::Callback GDExtensionBinding::init_callback = nullptr; GDExtensionBinding::Callback GDExtensionBinding::terminate_callback = nullptr; GDNativeInitializationLevel GDExtensionBinding::minimum_initialization_level = GDNATIVE_INITIALIZATION_CORE; -GDNativeBool GDExtensionBinding::init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) { +GDNativeBool GDExtensionBinding::init(const GDNativeInterface *p_interface, GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) { internal::gdn_interface = p_interface; internal::library = p_library; internal::token = p_library; diff --git a/src/variant/variant.cpp b/src/variant/variant.cpp index 6494bb9..efb7d55 100644 --- a/src/variant/variant.cpp +++ b/src/variant/variant.cpp @@ -72,7 +72,7 @@ Variant::Variant() { internal::gdn_interface->variant_new_nil(_native_ptr()); } -Variant::Variant(const GDNativeVariantPtr native_ptr) { +Variant::Variant(GDNativeConstVariantPtr native_ptr) { internal::gdn_interface->variant_new_copy(_native_ptr(), native_ptr); } @@ -530,11 +530,11 @@ bool Variant::operator<(const Variant &other) const { } void Variant::call(const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDNativeCallError &r_error) { - internal::gdn_interface->variant_call(_native_ptr(), method._native_ptr(), reinterpret_cast(const_cast(args)), argcount, r_ret._native_ptr(), &r_error); + internal::gdn_interface->variant_call(_native_ptr(), method._native_ptr(), reinterpret_cast(args), argcount, r_ret._native_ptr(), &r_error); } void Variant::call_static(Variant::Type type, const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDNativeCallError &r_error) { - internal::gdn_interface->variant_call_static(static_cast(type), method._native_ptr(), reinterpret_cast(const_cast(args)), argcount, r_ret._native_ptr(), &r_error); + internal::gdn_interface->variant_call_static(static_cast(type), method._native_ptr(), reinterpret_cast(args), argcount, r_ret._native_ptr(), &r_error); } void Variant::evaluate(const Operator &op, const Variant &a, const Variant &b, Variant &r_ret, bool &r_valid) { diff --git a/test/src/register_types.cpp b/test/src/register_types.cpp index 873801b..2514835 100644 --- a/test/src/register_types.cpp +++ b/test/src/register_types.cpp @@ -36,7 +36,7 @@ void uninitialize_example_module(ModuleInitializationLevel p_level) { extern "C" { // Initialization. -GDNativeBool GDN_EXPORT example_library_init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) { +GDNativeBool GDN_EXPORT example_library_init(const GDNativeInterface *p_interface, GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) { godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization); init_obj.register_initializer(initialize_example_module);