diff --git a/binding_generator.py b/binding_generator.py index 7634942b..30def353 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -772,12 +772,12 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl if "constructors" in builtin_api: for constructor in builtin_api["constructors"]: result.append( - f'\t_method_bindings.constructor_{constructor["index"]} = internal::gde_interface->variant_get_ptr_constructor({enum_type_name}, {constructor["index"]});' + f'\t_method_bindings.constructor_{constructor["index"]} = internal::gdextension_interface_variant_get_ptr_constructor({enum_type_name}, {constructor["index"]});' ) if builtin_api["has_destructor"]: result.append( - f"\t_method_bindings.destructor = internal::gde_interface->variant_get_ptr_destructor({enum_type_name});" + f"\t_method_bindings.destructor = internal::gdextension_interface_variant_get_ptr_destructor({enum_type_name});" ) result.append("}") @@ -796,36 +796,36 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl # TODO: Add error check for hash mismatch. result.append(f'\t__name = StringName("{method["name"]}");') result.append( - f'\t_method_bindings.method_{method["name"]} = internal::gde_interface->variant_get_ptr_builtin_method({enum_type_name}, __name._native_ptr(), {method["hash"]});' + f'\t_method_bindings.method_{method["name"]} = internal::gdextension_interface_variant_get_ptr_builtin_method({enum_type_name}, __name._native_ptr(), {method["hash"]});' ) if "members" in builtin_api: for member in builtin_api["members"]: result.append(f'\t__name = StringName("{member["name"]}");') result.append( - f'\t_method_bindings.member_{member["name"]}_setter = internal::gde_interface->variant_get_ptr_setter({enum_type_name}, __name._native_ptr());' + f'\t_method_bindings.member_{member["name"]}_setter = internal::gdextension_interface_variant_get_ptr_setter({enum_type_name}, __name._native_ptr());' ) result.append( - f'\t_method_bindings.member_{member["name"]}_getter = internal::gde_interface->variant_get_ptr_getter({enum_type_name}, __name._native_ptr());' + f'\t_method_bindings.member_{member["name"]}_getter = internal::gdextension_interface_variant_get_ptr_getter({enum_type_name}, __name._native_ptr());' ) if "indexing_return_type" in builtin_api: result.append( - f"\t_method_bindings.indexed_setter = internal::gde_interface->variant_get_ptr_indexed_setter({enum_type_name});" + f"\t_method_bindings.indexed_setter = internal::gdextension_interface_variant_get_ptr_indexed_setter({enum_type_name});" ) result.append( - f"\t_method_bindings.indexed_getter = internal::gde_interface->variant_get_ptr_indexed_getter({enum_type_name});" + f"\t_method_bindings.indexed_getter = internal::gdextension_interface_variant_get_ptr_indexed_getter({enum_type_name});" ) if "is_keyed" in builtin_api and builtin_api["is_keyed"]: result.append( - f"\t_method_bindings.keyed_setter = internal::gde_interface->variant_get_ptr_keyed_setter({enum_type_name});" + f"\t_method_bindings.keyed_setter = internal::gdextension_interface_variant_get_ptr_keyed_setter({enum_type_name});" ) result.append( - f"\t_method_bindings.keyed_getter = internal::gde_interface->variant_get_ptr_keyed_getter({enum_type_name});" + f"\t_method_bindings.keyed_getter = internal::gdextension_interface_variant_get_ptr_keyed_getter({enum_type_name});" ) result.append( - f"\t_method_bindings.keyed_checker = internal::gde_interface->variant_get_ptr_keyed_checker({enum_type_name});" + f"\t_method_bindings.keyed_checker = internal::gdextension_interface_variant_get_ptr_keyed_checker({enum_type_name});" ) if "operators" in builtin_api: @@ -838,11 +838,11 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl f"GDEXTENSION_VARIANT_TYPE_{camel_to_snake(operator['right_type']).upper()}" ) result.append( - f'\t_method_bindings.operator_{get_operator_id_name(operator["name"])}_{operator["right_type"]} = internal::gde_interface->variant_get_ptr_operator_evaluator(GDEXTENSION_VARIANT_OP_{get_operator_id_name(operator["name"]).upper()}, {enum_type_name}, {right_type_variant_type});' + f'\t_method_bindings.operator_{get_operator_id_name(operator["name"])}_{operator["right_type"]} = internal::gdextension_interface_variant_get_ptr_operator_evaluator(GDEXTENSION_VARIANT_OP_{get_operator_id_name(operator["name"]).upper()}, {enum_type_name}, {right_type_variant_type});' ) else: result.append( - f'\t_method_bindings.operator_{get_operator_id_name(operator["name"])} = internal::gde_interface->variant_get_ptr_operator_evaluator(GDEXTENSION_VARIANT_OP_{get_operator_id_name(operator["name"]).upper()}, {enum_type_name}, GDEXTENSION_VARIANT_TYPE_NIL);' + f'\t_method_bindings.operator_{get_operator_id_name(operator["name"])} = internal::gdextension_interface_variant_get_ptr_operator_evaluator(GDEXTENSION_VARIANT_OP_{get_operator_id_name(operator["name"]).upper()}, {enum_type_name}, GDEXTENSION_VARIANT_TYPE_NIL);' ) result.append("}") @@ -1421,13 +1421,13 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us result.append(f"{class_name} *{class_name}::get_singleton() {{") result.append(f"\tconst StringName __class_name = {class_name}::get_class_static();") result.append( - "\tstatic GDExtensionObjectPtr singleton_obj = internal::gde_interface->global_get_singleton(__class_name._native_ptr());" + "\tstatic GDExtensionObjectPtr singleton_obj = internal::gdextension_interface_global_get_singleton(__class_name._native_ptr());" ) result.append("#ifdef DEBUG_ENABLED") result.append("\tERR_FAIL_COND_V(singleton_obj == nullptr, nullptr);") result.append("#endif // DEBUG_ENABLED") result.append( - f"\tstatic {class_name} *singleton = reinterpret_cast<{class_name} *>(internal::gde_interface->object_get_instance_binding(singleton_obj, internal::token, &{class_name}::___binding_callbacks));" + f"\tstatic {class_name} *singleton = reinterpret_cast<{class_name} *>(internal::gdextension_interface_object_get_instance_binding(singleton_obj, internal::token, &{class_name}::___binding_callbacks));" ) result.append("\treturn singleton;") result.append("}") @@ -1449,7 +1449,7 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us result.append(f"\tconst StringName __class_name = {class_name}::get_class_static();") result.append(f'\tconst StringName __method_name = "{method["name"]}";') result.append( - f'\tstatic GDExtensionMethodBindPtr ___method_bind = internal::gde_interface->classdb_get_method_bind(__class_name._native_ptr(), __method_name._native_ptr(), {method["hash"]});' + f'\tstatic GDExtensionMethodBindPtr ___method_bind = internal::gdextension_interface_classdb_get_method_bind(__class_name._native_ptr(), __method_name._native_ptr(), {method["hash"]});' ) method_call = "\t" has_return = "return_value" in method and method["return_value"]["type"] != "void" @@ -1512,7 +1512,7 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us else: # vararg. result.append("\tGDExtensionCallError error;") result.append("\tVariant ret;") - method_call += "internal::gde_interface->object_method_bind_call(___method_bind, _owner, reinterpret_cast(args), arg_count, &ret, &error" + method_call += "internal::gdextension_interface_object_method_bind_call(___method_bind, _owner, reinterpret_cast(args), arg_count, &ret, &error" if is_ref: method_call += ")" # Close Ref<> constructor. @@ -1709,7 +1709,7 @@ def generate_utility_functions(api, output_dir): source.append(f'\tconst StringName __function_name = "{function["name"]}";') source.append( - f'\tstatic GDExtensionPtrUtilityFunction ___function = internal::gde_interface->variant_get_ptr_utility_function(__function_name._native_ptr(), {function["hash"]});' + f'\tstatic GDExtensionPtrUtilityFunction ___function = internal::gdextension_interface_variant_get_ptr_utility_function(__function_name._native_ptr(), {function["hash"]});' ) has_return = "return_type" in function and function["return_type"] != "void" if has_return: diff --git a/gdextension/gdextension_interface.h b/gdextension/gdextension_interface.h index f323b2aa..44cea710 100644 --- a/gdextension/gdextension_interface.h +++ b/gdextension/gdextension_interface.h @@ -400,214 +400,6 @@ typedef struct { } GDExtensionScriptInstanceInfo; -/* INTERFACE */ - -typedef struct { - uint32_t version_major; - uint32_t version_minor; - uint32_t version_patch; - const char *version_string; - - /* GODOT CORE */ - - void *(*mem_alloc)(size_t p_bytes); - void *(*mem_realloc)(void *p_ptr, size_t p_bytes); - void (*mem_free)(void *p_ptr); - - void (*print_error)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); - void (*print_error_with_message)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); - void (*print_warning)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); - void (*print_warning_with_message)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); - void (*print_script_error)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); - void (*print_script_error_with_message)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); - - uint64_t (*get_native_struct_size)(GDExtensionConstStringNamePtr p_name); - - /* GODOT VARIANT */ - - /* variant general */ - void (*variant_new_copy)(GDExtensionVariantPtr r_dest, GDExtensionConstVariantPtr p_src); - void (*variant_new_nil)(GDExtensionVariantPtr r_dest); - void (*variant_destroy)(GDExtensionVariantPtr p_self); - - /* variant type */ - void (*variant_call)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error); - void (*variant_call_static)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error); - void (*variant_evaluate)(GDExtensionVariantOperator p_op, GDExtensionConstVariantPtr p_a, GDExtensionConstVariantPtr p_b, GDExtensionVariantPtr r_return, GDExtensionBool *r_valid); - void (*variant_set)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid); - void (*variant_set_named)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid); - void (*variant_set_keyed)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid); - void (*variant_set_indexed)(GDExtensionVariantPtr p_self, GDExtensionInt p_index, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid, GDExtensionBool *r_oob); - void (*variant_get)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid); - void (*variant_get_named)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid); - void (*variant_get_keyed)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid); - void (*variant_get_indexed)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_index, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid, GDExtensionBool *r_oob); - GDExtensionBool (*variant_iter_init)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionBool *r_valid); - GDExtensionBool (*variant_iter_next)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionBool *r_valid); - void (*variant_iter_get)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid); - GDExtensionInt (*variant_hash)(GDExtensionConstVariantPtr p_self); - GDExtensionInt (*variant_recursive_hash)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_recursion_count); - GDExtensionBool (*variant_hash_compare)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_other); - GDExtensionBool (*variant_booleanize)(GDExtensionConstVariantPtr p_self); - void (*variant_duplicate)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_ret, GDExtensionBool p_deep); - void (*variant_stringify)(GDExtensionConstVariantPtr p_self, GDExtensionStringPtr r_ret); - - GDExtensionVariantType (*variant_get_type)(GDExtensionConstVariantPtr p_self); - GDExtensionBool (*variant_has_method)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_method); - GDExtensionBool (*variant_has_member)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member); - GDExtensionBool (*variant_has_key)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionBool *r_valid); - void (*variant_get_type_name)(GDExtensionVariantType p_type, GDExtensionStringPtr r_name); - GDExtensionBool (*variant_can_convert)(GDExtensionVariantType p_from, GDExtensionVariantType p_to); - GDExtensionBool (*variant_can_convert_strict)(GDExtensionVariantType p_from, GDExtensionVariantType p_to); - - /* ptrcalls */ - GDExtensionVariantFromTypeConstructorFunc (*get_variant_from_type_constructor)(GDExtensionVariantType p_type); - GDExtensionTypeFromVariantConstructorFunc (*get_variant_to_type_constructor)(GDExtensionVariantType p_type); - GDExtensionPtrOperatorEvaluator (*variant_get_ptr_operator_evaluator)(GDExtensionVariantOperator p_operator, GDExtensionVariantType p_type_a, GDExtensionVariantType p_type_b); - GDExtensionPtrBuiltInMethod (*variant_get_ptr_builtin_method)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, GDExtensionInt p_hash); - GDExtensionPtrConstructor (*variant_get_ptr_constructor)(GDExtensionVariantType p_type, int32_t p_constructor); - GDExtensionPtrDestructor (*variant_get_ptr_destructor)(GDExtensionVariantType p_type); - void (*variant_construct)(GDExtensionVariantType p_type, GDExtensionVariantPtr p_base, const GDExtensionConstVariantPtr *p_args, int32_t p_argument_count, GDExtensionCallError *r_error); - GDExtensionPtrSetter (*variant_get_ptr_setter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member); - GDExtensionPtrGetter (*variant_get_ptr_getter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member); - GDExtensionPtrIndexedSetter (*variant_get_ptr_indexed_setter)(GDExtensionVariantType p_type); - GDExtensionPtrIndexedGetter (*variant_get_ptr_indexed_getter)(GDExtensionVariantType p_type); - GDExtensionPtrKeyedSetter (*variant_get_ptr_keyed_setter)(GDExtensionVariantType p_type); - GDExtensionPtrKeyedGetter (*variant_get_ptr_keyed_getter)(GDExtensionVariantType p_type); - GDExtensionPtrKeyedChecker (*variant_get_ptr_keyed_checker)(GDExtensionVariantType p_type); - void (*variant_get_constant_value)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_constant, GDExtensionVariantPtr r_ret); - GDExtensionPtrUtilityFunction (*variant_get_ptr_utility_function)(GDExtensionConstStringNamePtr p_function, GDExtensionInt p_hash); - - /* extra utilities */ - void (*string_new_with_latin1_chars)(GDExtensionStringPtr r_dest, const char *p_contents); - void (*string_new_with_utf8_chars)(GDExtensionStringPtr r_dest, const char *p_contents); - void (*string_new_with_utf16_chars)(GDExtensionStringPtr r_dest, const char16_t *p_contents); - void (*string_new_with_utf32_chars)(GDExtensionStringPtr r_dest, const char32_t *p_contents); - void (*string_new_with_wide_chars)(GDExtensionStringPtr r_dest, const wchar_t *p_contents); - void (*string_new_with_latin1_chars_and_len)(GDExtensionStringPtr r_dest, const char *p_contents, GDExtensionInt p_size); - void (*string_new_with_utf8_chars_and_len)(GDExtensionStringPtr r_dest, const char *p_contents, GDExtensionInt p_size); - void (*string_new_with_utf16_chars_and_len)(GDExtensionStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_size); - void (*string_new_with_utf32_chars_and_len)(GDExtensionStringPtr r_dest, const char32_t *p_contents, GDExtensionInt p_size); - void (*string_new_with_wide_chars_and_len)(GDExtensionStringPtr r_dest, const wchar_t *p_contents, GDExtensionInt 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. - * - These functions also do not write trailing zero, If you need it, write it yourself at the position indicated by the length (and make sure to allocate it). - * - Passing NULL in r_text means only the length is computed (again, without including trailing zero). - * - 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. - */ - GDExtensionInt (*string_to_latin1_chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length); - GDExtensionInt (*string_to_utf8_chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length); - GDExtensionInt (*string_to_utf16_chars)(GDExtensionConstStringPtr p_self, char16_t *r_text, GDExtensionInt p_max_write_length); - GDExtensionInt (*string_to_utf32_chars)(GDExtensionConstStringPtr p_self, char32_t *r_text, GDExtensionInt p_max_write_length); - GDExtensionInt (*string_to_wide_chars)(GDExtensionConstStringPtr p_self, wchar_t *r_text, GDExtensionInt p_max_write_length); - char32_t *(*string_operator_index)(GDExtensionStringPtr p_self, GDExtensionInt p_index); - const char32_t *(*string_operator_index_const)(GDExtensionConstStringPtr p_self, GDExtensionInt p_index); - - void (*string_operator_plus_eq_string)(GDExtensionStringPtr p_self, GDExtensionConstStringPtr p_b); - void (*string_operator_plus_eq_char)(GDExtensionStringPtr p_self, char32_t p_b); - void (*string_operator_plus_eq_cstr)(GDExtensionStringPtr p_self, const char *p_b); - void (*string_operator_plus_eq_wcstr)(GDExtensionStringPtr p_self, const wchar_t *p_b); - void (*string_operator_plus_eq_c32str)(GDExtensionStringPtr p_self, const char32_t *p_b); - - /* XMLParser extra utilities */ - - GDExtensionInt (*xml_parser_open_buffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_buffer, size_t p_size); - - /* FileAccess extra utilities */ - - void (*file_access_store_buffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_src, uint64_t p_length); - uint64_t (*file_access_get_buffer)(GDExtensionConstObjectPtr p_instance, uint8_t *p_dst, uint64_t p_length); - - /* WorkerThreadPool extra utilities */ - - int64_t (*worker_thread_pool_add_native_group_task)(GDExtensionObjectPtr p_instance, void (*p_func)(void *, uint32_t), void *p_userdata, int p_elements, int p_tasks, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description); - int64_t (*worker_thread_pool_add_native_task)(GDExtensionObjectPtr p_instance, void (*p_func)(void *), void *p_userdata, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description); - - /* Packed array functions */ - - uint8_t *(*packed_byte_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedByteArray - const uint8_t *(*packed_byte_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedByteArray - - GDExtensionTypePtr (*packed_color_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedColorArray, returns Color ptr - GDExtensionTypePtr (*packed_color_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedColorArray, returns Color ptr - - float *(*packed_float32_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedFloat32Array - const float *(*packed_float32_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedFloat32Array - double *(*packed_float64_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedFloat64Array - const double *(*packed_float64_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedFloat64Array - - int32_t *(*packed_int32_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedInt32Array - const int32_t *(*packed_int32_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedInt32Array - int64_t *(*packed_int64_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedInt32Array - const int64_t *(*packed_int64_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedInt32Array - - GDExtensionStringPtr (*packed_string_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedStringArray - GDExtensionStringPtr (*packed_string_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedStringArray - - GDExtensionTypePtr (*packed_vector2_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedVector2Array, returns Vector2 ptr - GDExtensionTypePtr (*packed_vector2_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedVector2Array, returns Vector2 ptr - GDExtensionTypePtr (*packed_vector3_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedVector3Array, returns Vector3 ptr - GDExtensionTypePtr (*packed_vector3_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedVector3Array, returns Vector3 ptr - - GDExtensionVariantPtr (*array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be an Array ptr - GDExtensionVariantPtr (*array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be an Array ptr - void (*array_ref)(GDExtensionTypePtr p_self, GDExtensionConstTypePtr p_from); // p_self should be an Array ptr - void (*array_set_typed)(GDExtensionTypePtr p_self, GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstVariantPtr p_script); // p_self should be an Array ptr - - /* Dictionary functions */ - - GDExtensionVariantPtr (*dictionary_operator_index)(GDExtensionTypePtr p_self, GDExtensionConstVariantPtr p_key); // p_self should be an Dictionary ptr - GDExtensionVariantPtr (*dictionary_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionConstVariantPtr p_key); // p_self should be an Dictionary ptr - - /* OBJECT */ - - void (*object_method_bind_call)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_arg_count, GDExtensionVariantPtr r_ret, GDExtensionCallError *r_error); - void (*object_method_bind_ptrcall)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret); - void (*object_destroy)(GDExtensionObjectPtr p_o); - GDExtensionObjectPtr (*global_get_singleton)(GDExtensionConstStringNamePtr p_name); - - void *(*object_get_instance_binding)(GDExtensionObjectPtr p_o, void *p_token, const GDExtensionInstanceBindingCallbacks *p_callbacks); - void (*object_set_instance_binding)(GDExtensionObjectPtr p_o, void *p_token, void *p_binding, const GDExtensionInstanceBindingCallbacks *p_callbacks); - - void (*object_set_instance)(GDExtensionObjectPtr p_o, GDExtensionConstStringNamePtr p_classname, GDExtensionClassInstancePtr p_instance); /* p_classname should be a registered extension class and should extend the p_o object's class. */ - - GDExtensionObjectPtr (*object_cast_to)(GDExtensionConstObjectPtr p_object, void *p_class_tag); - GDExtensionObjectPtr (*object_get_instance_from_id)(GDObjectInstanceID p_instance_id); - GDObjectInstanceID (*object_get_instance_id)(GDExtensionConstObjectPtr p_object); - - /* REFERENCE */ - - GDExtensionObjectPtr (*ref_get_object)(GDExtensionConstRefPtr p_ref); - void (*ref_set_object)(GDExtensionRefPtr p_ref, GDExtensionObjectPtr p_object); - - /* SCRIPT INSTANCE */ - - GDExtensionScriptInstancePtr (*script_instance_create)(const GDExtensionScriptInstanceInfo *p_info, GDExtensionScriptInstanceDataPtr p_instance_data); - - /* CLASSDB */ - - GDExtensionObjectPtr (*classdb_construct_object)(GDExtensionConstStringNamePtr 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. */ - GDExtensionMethodBindPtr (*classdb_get_method_bind)(GDExtensionConstStringNamePtr p_classname, GDExtensionConstStringNamePtr p_methodname, GDExtensionInt p_hash); - void *(*classdb_get_class_tag)(GDExtensionConstStringNamePtr p_classname); - - /* CLASSDB EXTENSION */ - - /* Provided parameters for `classdb_register_extension_*` can be safely freed once the function returns. */ - void (*classdb_register_extension_class)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo *p_extension_funcs); - void (*classdb_register_extension_class_method)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassMethodInfo *p_method_info); - void (*classdb_register_extension_class_integer_constant)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_enum_name, GDExtensionConstStringNamePtr p_constant_name, GDExtensionInt p_constant_value, GDExtensionBool p_is_bitfield); - void (*classdb_register_extension_class_property)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionPropertyInfo *p_info, GDExtensionConstStringNamePtr p_setter, GDExtensionConstStringNamePtr p_getter); - void (*classdb_register_extension_class_property_group)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_group_name, GDExtensionConstStringPtr p_prefix); - void (*classdb_register_extension_class_property_subgroup)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_subgroup_name, GDExtensionConstStringPtr p_prefix); - void (*classdb_register_extension_class_signal)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_signal_name, const GDExtensionPropertyInfo *p_argument_info, GDExtensionInt p_argument_count); - void (*classdb_unregister_extension_class)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr 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)(GDExtensionClassLibraryPtr p_library, GDExtensionStringPtr r_path); - -} GDExtensionInterface; - /* INITIALIZATION */ typedef enum { @@ -629,12 +421,1690 @@ typedef struct { void (*deinitialize)(void *userdata, GDExtensionInitializationLevel p_level); } GDExtensionInitialization; -/* Define a C function prototype that implements the function below and expose it to dlopen() (or similar). - * This is the entry point of the GDExtension library and will be called on initialization. - * 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 void (*GDExtensionInterfaceFunctionPtr)(); +typedef GDExtensionInterfaceFunctionPtr (*GDExtensionInterfaceGetProcAddress)(const char *p_function_name); + +/* + * Each GDExtension should define a C function that matches the signature of GDExtensionInitializationFunction, + * and export it so that it can be loaded via dlopen() or equivalent for the given platform. + * + * For example: + * + * GDExtensionBool my_extension_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization); + * + * This function's name must be specified as the 'entry_symbol' in the .gdextension file. + * + * This makes it the entry point of the GDExtension and will be called on initialization. + * + * The GDExtension can then modify the r_initialization structure, setting the minimum initialization level, + * and providing pointers to functions that will be called at various stages of initialization/shutdown. + * + * The rest of the GDExtension's interface to Godot consists of function pointers that can be loaded + * by calling p_get_proc_address("...") with the name of the function. + * + * For example: + * + * GDExtensionInterfaceGetGodotVersion *get_godot_version = (GDExtensionInterfaceGetGodotVersion)p_get_proc_address("get_godot_version"); + * + * You can then call it like a normal function: + * + * GDExtensionGodotVersion godot_version; + * get_godot_version(&godot_version); + * printf("Godot v%d.%d.%d\n", godot_version.major, godot_version.minor, godot_version.patch); + * + * All of these interface functions are described below, together with the name that's used to load it, + * and the function pointer typedef that shows its signature. */ -typedef GDExtensionBool (*GDExtensionInitializationFunction)(const GDExtensionInterface *p_interface, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization); +typedef GDExtensionBool (*GDExtensionInitializationFunction)(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization); + +/* INTERFACE */ + +typedef struct { + uint32_t major; + uint32_t minor; + uint32_t patch; + const char *string; +} GDExtensionGodotVersion; + +/** + * @name get_godot_version + * + * Gets the Godot version that the GDExtension was loaded into. + * + * @param r_godot_version A pointer to the structure to write the version information into. + */ +typedef void (*GDExtensionInterfaceGetGodotVersion)(GDExtensionGodotVersion *r_godot_version); + +/* INTERFACE: Memory */ + +/** + * @name mem_alloc + * + * Allocates memory. + * + * @param p_bytes The amount of memory to allocate in bytes. + * + * @return A pointer to the allocated memory, or NULL if unsuccessful. + */ +typedef void *(*GDExtensionInterfaceMemAlloc)(size_t p_bytes); + +/** + * @name mem_realloc + * + * Reallocates memory. + * + * @param p_ptr A pointer to the previously allocated memory. + * @param p_bytes The number of bytes to resize the memory block to. + * + * @return A pointer to the allocated memory, or NULL if unsuccessful. + */ +typedef void *(*GDExtensionInterfaceMemRealloc)(void *p_ptr, size_t p_bytes); + +/** + * @name mem_free + * + * Frees memory. + * + * @param p_ptr A pointer to the previously allocated memory. + */ +typedef void (*GDExtensionInterfaceMemFree)(void *p_ptr); + +/* INTERFACE: Godot Core */ + +/** + * @name print_error + * + * Logs an error to Godot's built-in debugger and to the OS terminal. + * + * @param p_description The code trigging the error. + * @param p_function The function name where the error occurred. + * @param p_file The file where the error occurred. + * @param p_line The line where the error occurred. + * @param p_editor_notify Whether or not to notify the editor. + */ +typedef void (*GDExtensionInterfacePrintError)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); + +/** + * @name print_error_with_message + * + * Logs an error with a message to Godot's built-in debugger and to the OS terminal. + * + * @param p_description The code trigging the error. + * @param p_message The message to show along with the error. + * @param p_function The function name where the error occurred. + * @param p_file The file where the error occurred. + * @param p_line The line where the error occurred. + * @param p_editor_notify Whether or not to notify the editor. + */ +typedef void (*GDExtensionInterfacePrintErrorWithMessage)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); + +/** + * @name print_warning + * + * Logs a warning to Godot's built-in debugger and to the OS terminal. + * + * @param p_description The code trigging the warning. + * @param p_function The function name where the warning occurred. + * @param p_file The file where the warning occurred. + * @param p_line The line where the warning occurred. + * @param p_editor_notify Whether or not to notify the editor. + */ +typedef void (*GDExtensionInterfacePrintWarning)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); + +/** + * @name print_warning_with_message + * + * Logs a warning with a message to Godot's built-in debugger and to the OS terminal. + * + * @param p_description The code trigging the warning. + * @param p_message The message to show along with the warning. + * @param p_function The function name where the warning occurred. + * @param p_file The file where the warning occurred. + * @param p_line The line where the warning occurred. + * @param p_editor_notify Whether or not to notify the editor. + */ +typedef void (*GDExtensionInterfacePrintWarningWithMessage)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); + +/** + * @name print_script_error + * + * Logs a script error to Godot's built-in debugger and to the OS terminal. + * + * @param p_description The code trigging the error. + * @param p_function The function name where the error occurred. + * @param p_file The file where the error occurred. + * @param p_line The line where the error occurred. + * @param p_editor_notify Whether or not to notify the editor. + */ +typedef void (*GDExtensionInterfacePrintScriptError)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); + +/** + * @name print_script_error_with_message + * + * Logs a script error with a message to Godot's built-in debugger and to the OS terminal. + * + * @param p_description The code trigging the error. + * @param p_message The message to show along with the error. + * @param p_function The function name where the error occurred. + * @param p_file The file where the error occurred. + * @param p_line The line where the error occurred. + * @param p_editor_notify Whether or not to notify the editor. + */ +typedef void (*GDExtensionInterfacePrintScriptErrorWithMessage)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify); + +/** + * @name get_native_struct_size + * + * Gets the size of a native struct (ex. ObjectID) in bytes. + * + * @param p_name A pointer to a StringName identifying the struct name. + * + * @return The size in bytes. + */ +typedef uint64_t (*GDExtensionInterfaceGetNativeStructSize)(GDExtensionConstStringNamePtr p_name); + +/* INTERFACE: Variant */ + +/** + * @name variant_new_copy + * + * Copies one Variant into a another. + * + * @param r_dest A pointer to the destination Variant. + * @param p_src A pointer to the source Variant. + */ +typedef void (*GDExtensionInterfaceVariantNewCopy)(GDExtensionVariantPtr r_dest, GDExtensionConstVariantPtr p_src); + +/** + * @name variant_new_nil + * + * Creates a new Variant containing nil. + * + * @param r_dest A pointer to the destination Variant. + */ +typedef void (*GDExtensionInterfaceVariantNewNil)(GDExtensionVariantPtr r_dest); + +/** + * @name variant_destroy + * + * Destroys a Variant. + * + * @param p_self A pointer to the Variant to destroy. + */ +typedef void (*GDExtensionInterfaceVariantDestroy)(GDExtensionVariantPtr p_self); + +/** + * @name variant_call + * + * Calls a method on a Variant. + * + * @param p_self A pointer to the Variant. + * @param p_method A pointer to a StringName identifying the method. + * @param p_args A pointer to a C array of Variant. + * @param p_argument_count The number of arguments. + * @param r_return A pointer a Variant which will be assigned the return value. + * @param r_error A pointer the structure which will hold error information. + * + * @see Variant::callp() + */ +typedef void (*GDExtensionInterfaceVariantCall)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error); + +/** + * @name variant_call_static + * + * Calls a static method on a Variant. + * + * @param p_self A pointer to the Variant. + * @param p_method A pointer to a StringName identifying the method. + * @param p_args A pointer to a C array of Variant. + * @param p_argument_count The number of arguments. + * @param r_return A pointer a Variant which will be assigned the return value. + * @param r_error A pointer the structure which will be updated with error information. + * + * @see Variant::call_static() + */ +typedef void (*GDExtensionInterfaceVariantCallStatic)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error); + +/** + * @name variant_evaluate + * + * Evaluate an operator on two Variants. + * + * @param p_op The operator to evaluate. + * @param p_a The first Variant. + * @param p_b The second Variant. + * @param r_return A pointer a Variant which will be assigned the return value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * + * @see Variant::evaluate() + */ +typedef void (*GDExtensionInterfaceVariantEvaluate)(GDExtensionVariantOperator p_op, GDExtensionConstVariantPtr p_a, GDExtensionConstVariantPtr p_b, GDExtensionVariantPtr r_return, GDExtensionBool *r_valid); + +/** + * @name variant_set + * + * Sets a key on a Variant to a value. + * + * @param p_self A pointer to the Variant. + * @param p_key A pointer to a Variant representing the key. + * @param p_value A pointer to a Variant representing the value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * + * @see Variant::set() + */ +typedef void (*GDExtensionInterfaceVariantSet)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid); + +/** + * @name variant_set_named + * + * Sets a named key on a Variant to a value. + * + * @param p_self A pointer to the Variant. + * @param p_key A pointer to a StringName representing the key. + * @param p_value A pointer to a Variant representing the value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * + * @see Variant::set_named() + */ +typedef void (*GDExtensionInterfaceVariantSetNamed)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid); + +/** + * @name variant_set_keyed + * + * Sets a keyed property on a Variant to a value. + * + * @param p_self A pointer to the Variant. + * @param p_key A pointer to a Variant representing the key. + * @param p_value A pointer to a Variant representing the value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * + * @see Variant::set_keyed() + */ +typedef void (*GDExtensionInterfaceVariantSetKeyed)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid); + +/** + * @name variant_set_indexed + * + * Sets an index on a Variant to a value. + * + * @param p_self A pointer to the Variant. + * @param p_index The index. + * @param p_value A pointer to a Variant representing the value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * @param r_oob A pointer to a boolean which will be set to true if the index is out of bounds. + */ +typedef void (*GDExtensionInterfaceVariantSetIndexed)(GDExtensionVariantPtr p_self, GDExtensionInt p_index, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid, GDExtensionBool *r_oob); + +/** + * @name variant_get + * + * Gets the value of a key from a Variant. + * + * @param p_self A pointer to the Variant. + * @param p_key A pointer to a Variant representing the key. + * @param r_ret A pointer to a Variant which will be assigned the value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + */ +typedef void (*GDExtensionInterfaceVariantGet)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid); + +/** + * @name variant_get_named + * + * Gets the value of a named key from a Variant. + * + * @param p_self A pointer to the Variant. + * @param p_key A pointer to a StringName representing the key. + * @param r_ret A pointer to a Variant which will be assigned the value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + */ +typedef void (*GDExtensionInterfaceVariantGetNamed)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid); + +/** + * @name variant_get_keyed + * + * Gets the value of a keyed property from a Variant. + * + * @param p_self A pointer to the Variant. + * @param p_key A pointer to a Variant representing the key. + * @param r_ret A pointer to a Variant which will be assigned the value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + */ +typedef void (*GDExtensionInterfaceVariantGetKeyed)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid); + +/** + * @name variant_get_indexed + * + * Gets the value of an index from a Variant. + * + * @param p_self A pointer to the Variant. + * @param p_index The index. + * @param r_ret A pointer to a Variant which will be assigned the value. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * @param r_oob A pointer to a boolean which will be set to true if the index is out of bounds. + */ +typedef void (*GDExtensionInterfaceVariantGetIndexed)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_index, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid, GDExtensionBool *r_oob); + +/** + * @name variant_iter_init + * + * Initializes an iterator over a Variant. + * + * @param p_self A pointer to the Variant. + * @param r_iter A pointer to a Variant which will be assigned the iterator. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * + * @return true if the operation is valid; otherwise false. + * + * @see Variant::iter_init() + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantIterInit)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionBool *r_valid); + +/** + * @name variant_iter_next + * + * Gets the next value for an iterator over a Variant. + * + * @param p_self A pointer to the Variant. + * @param r_iter A pointer to a Variant which will be assigned the iterator. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * + * @return true if the operation is valid; otherwise false. + * + * @see Variant::iter_next() + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantIterNext)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionBool *r_valid); + +/** + * @name variant_iter_get + * + * Gets the next value for an iterator over a Variant. + * + * @param p_self A pointer to the Variant. + * @param r_iter A pointer to a Variant which will be assigned the iterator. + * @param r_ret A pointer to a Variant which will be assigned false if the operation is invalid. + * @param r_valid A pointer to a boolean which will be set to false if the operation is invalid. + * + * @see Variant::iter_next() + */ +typedef void (*GDExtensionInterfaceVariantIterGet)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid); + +/** + * @name variant_hash + * + * Gets the hash of a Variant. + * + * @param p_self A pointer to the Variant. + * + * @return The hash value. + * + * @see Variant::hash() + */ +typedef GDExtensionInt (*GDExtensionInterfaceVariantHash)(GDExtensionConstVariantPtr p_self); + +/** + * @name variant_recursive_hash + * + * Gets the recursive hash of a Variant. + * + * @param p_self A pointer to the Variant. + * @param p_recursion_count The number of recursive loops so far. + * + * @return The hash value. + * + * @see Variant::recursive_hash() + */ +typedef GDExtensionInt (*GDExtensionInterfaceVariantRecursiveHash)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_recursion_count); + +/** + * @name variant_hash_compare + * + * Compares two Variants by their hash. + * + * @param p_self A pointer to the Variant. + * @param p_other A pointer to the other Variant to compare it to. + * + * @return The hash value. + * + * @see Variant::hash_compare() + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantHashCompare)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_other); + +/** + * @name variant_booleanize + * + * Converts a Variant to a boolean. + * + * @param p_self A pointer to the Variant. + * + * @return The boolean value of the Variant. + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantBooleanize)(GDExtensionConstVariantPtr p_self); + +/** + * @name variant_duplicate + * + * Duplicates a Variant. + * + * @param p_self A pointer to the Variant. + * @param r_ret A pointer to a Variant to store the duplicated value. + * @param p_deep Whether or not to duplicate deeply (when supported by the Variant type). + */ +typedef void (*GDExtensionInterfaceVariantDuplicate)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_ret, GDExtensionBool p_deep); + +/** + * @name variant_stringify + * + * Converts a Variant to a string. + * + * @param p_self A pointer to the Variant. + * @param r_ret A pointer to a String to store the resulting value. + */ +typedef void (*GDExtensionInterfaceVariantStringify)(GDExtensionConstVariantPtr p_self, GDExtensionStringPtr r_ret); + +/** + * @name variant_get_type + * + * Gets the type of a Variant. + * + * @param p_self A pointer to the Variant. + * + * @return The variant type. + */ +typedef GDExtensionVariantType (*GDExtensionInterfaceVariantGetType)(GDExtensionConstVariantPtr p_self); + +/** + * @name variant_has_method + * + * Checks if a Variant has the given method. + * + * @param p_self A pointer to the Variant. + * @param p_method A pointer to a StringName with the method name. + * + * @return + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMethod)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_method); + +/** + * @name variant_has_member + * + * Checks if a type of Variant has the given member. + * + * @param p_type The Variant type. + * @param p_member A pointer to a StringName with the member name. + * + * @return + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMember)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member); + +/** + * @name variant_has_key + * + * Checks if a Variant has a key. + * + * @param p_self A pointer to the Variant. + * @param p_key A pointer to a Variant representing the key. + * @param r_valid A pointer to a boolean which will be set to false if the key doesn't exist. + * + * @return true if the key exists; otherwise false. + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantHasKey)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionBool *r_valid); + +/** + * @name variant_get_type_name + * + * Gets the name of a Variant type. + * + * @param p_type The Variant type. + * @param r_name A pointer to a String to store the Variant type name. + */ +typedef void (*GDExtensionInterfaceVariantGetTypeName)(GDExtensionVariantType p_type, GDExtensionStringPtr r_name); + +/** + * @name variant_can_convert + * + * Checks if Variants can be converted from one type to another. + * + * @param p_from The Variant type to convert from. + * @param p_to The Variant type to convert to. + * + * @return true if the conversion is possible; otherwise false. + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantCanConvert)(GDExtensionVariantType p_from, GDExtensionVariantType p_to); + +/** + * @name variant_can_convert_strict + * + * Checks if Variant can be converted from one type to another using stricter rules. + * + * @param p_from The Variant type to convert from. + * @param p_to The Variant type to convert to. + * + * @return true if the conversion is possible; otherwise false. + */ +typedef GDExtensionBool (*GDExtensionInterfaceVariantCanConvertStrict)(GDExtensionVariantType p_from, GDExtensionVariantType p_to); + +/** + * @name get_variant_from_type_constructor + * + * Gets a pointer to a function that can create a Variant of the given type from a raw value. + * + * @param p_type The Variant type. + * + * @return A pointer to a function that can create a Variant of the given type from a raw value. + */ +typedef GDExtensionVariantFromTypeConstructorFunc (*GDExtensionInterfaceGetVariantFromTypeConstructor)(GDExtensionVariantType p_type); + +/** + * @name get_variant_to_type_constructor + * + * Gets a pointer to a function that can get the raw value from a Variant of the given type. + * + * @param p_type The Variant type. + * + * @return A pointer to a function that can get the raw value from a Variant of the given type. + */ +typedef GDExtensionTypeFromVariantConstructorFunc (*GDExtensionInterfaceGetVariantToTypeConstructor)(GDExtensionVariantType p_type); + +/** + * @name variant_get_ptr_operator_evaluator + * + * Gets a pointer to a function that can evaluate the given Variant operator on the given Variant types. + * + * @param p_operator The variant operator. + * @param p_type_a The type of the first Variant. + * @param p_type_b The type of the second Variant. + * + * @return A pointer to a function that can evaluate the given Variant operator on the given Variant types. + */ +typedef GDExtensionPtrOperatorEvaluator (*GDExtensionInterfaceVariantGetPtrOperatorEvaluator)(GDExtensionVariantOperator p_operator, GDExtensionVariantType p_type_a, GDExtensionVariantType p_type_b); + +/** + * @name variant_get_ptr_builtin_method + * + * Gets a pointer to a function that can call a builtin method on a type of Variant. + * + * @param p_type The Variant type. + * @param p_method A pointer to a StringName with the method name. + * @param p_hash A hash representing the method signature. + * + * @return A pointer to a function that can call a builtin method on a type of Variant. + */ +typedef GDExtensionPtrBuiltInMethod (*GDExtensionInterfaceVariantGetPtrBuiltinMethod)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, GDExtensionInt p_hash); + +/** + * @name variant_get_ptr_constructor + * + * Gets a pointer to a function that can call one of the constructors for a type of Variant. + * + * @param p_type The Variant type. + * @param p_constructor The index of the constructor. + * + * @return A pointer to a function that can call one of the constructors for a type of Variant. + */ +typedef GDExtensionPtrConstructor (*GDExtensionInterfaceVariantGetPtrConstructor)(GDExtensionVariantType p_type, int32_t p_constructor); + +/** + * @name variant_get_ptr_destructor + * + * Gets a pointer to a function than can call the destructor for a type of Variant. + * + * @param p_type The Variant type. + * + * @return A pointer to a function than can call the destructor for a type of Variant. + */ +typedef GDExtensionPtrDestructor (*GDExtensionInterfaceVariantGetPtrDestructor)(GDExtensionVariantType p_type); + +/** + * @name variant_construct + * + * Constructs a Variant of the given type, using the first constructor that matches the given arguments. + * + * @param p_type The Variant type. + * @param p_base A pointer to a Variant to store the constructed value. + * @param p_args A pointer to a C array of Variant pointers representing the arguments for the constructor. + * @param p_argument_count The number of arguments to pass to the constructor. + * @param r_error A pointer the structure which will be updated with error information. + */ +typedef void (*GDExtensionInterfaceVariantConstruct)(GDExtensionVariantType p_type, GDExtensionVariantPtr p_base, const GDExtensionConstVariantPtr *p_args, int32_t p_argument_count, GDExtensionCallError *r_error); + +/** + * @name variant_get_ptr_setter + * + * Gets a pointer to a function that can call a member's setter on the given Variant type. + * + * @param p_type The Variant type. + * @param p_member A pointer to a StringName with the member name. + * + * @return A pointer to a function that can call a member's setter on the given Variant type. + */ +typedef GDExtensionPtrSetter (*GDExtensionInterfaceVariantGetPtrSetter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member); + +/** + * @name variant_get_ptr_getter + * + * Gets a pointer to a function that can call a member's getter on the given Variant type. + * + * @param p_type The Variant type. + * @param p_member A pointer to a StringName with the member name. + * + * @return A pointer to a function that can call a member's getter on the given Variant type. + */ +typedef GDExtensionPtrGetter (*GDExtensionInterfaceVariantGetPtrGetter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member); + +/** + * @name variant_get_ptr_indexed_setter + * + * Gets a pointer to a function that can set an index on the given Variant type. + * + * @param p_type The Variant type. + * + * @return A pointer to a function that can set an index on the given Variant type. + */ +typedef GDExtensionPtrIndexedSetter (*GDExtensionInterfaceVariantGetPtrIndexedSetter)(GDExtensionVariantType p_type); + +/** + * @name variant_get_ptr_indexed_getter + * + * Gets a pointer to a function that can get an index on the given Variant type. + * + * @param p_type The Variant type. + * + * @return A pointer to a function that can get an index on the given Variant type. + */ +typedef GDExtensionPtrIndexedGetter (*GDExtensionInterfaceVariantGetPtrIndexedGetter)(GDExtensionVariantType p_type); + +/** + * @name variant_get_ptr_keyed_setter + * + * Gets a pointer to a function that can set a key on the given Variant type. + * + * @param p_type The Variant type. + * + * @return A pointer to a function that can set a key on the given Variant type. + */ +typedef GDExtensionPtrKeyedSetter (*GDExtensionInterfaceVariantGetPtrKeyedSetter)(GDExtensionVariantType p_type); + +/** + * @name variant_get_ptr_keyed_getter + * + * Gets a pointer to a function that can get a key on the given Variant type. + * + * @param p_type The Variant type. + * + * @return A pointer to a function that can get a key on the given Variant type. + */ +typedef GDExtensionPtrKeyedGetter (*GDExtensionInterfaceVariantGetPtrKeyedGetter)(GDExtensionVariantType p_type); + +/** + * @name variant_get_ptr_keyed_checker + * + * Gets a pointer to a function that can check a key on the given Variant type. + * + * @param p_type The Variant type. + * + * @return A pointer to a function that can check a key on the given Variant type. + */ +typedef GDExtensionPtrKeyedChecker (*GDExtensionInterfaceVariantGetPtrKeyedChecker)(GDExtensionVariantType p_type); + +/** + * @name variant_get_constant_value + * + * Gets the value of a constant from the given Variant type. + * + * @param p_type The Variant type. + * @param p_constant A pointer to a StringName with the constant name. + * @param r_ret A pointer to a Variant to store the value. + */ +typedef void (*GDExtensionInterfaceVariantGetConstantValue)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_constant, GDExtensionVariantPtr r_ret); + +/** + * @name variant_get_ptr_utility_function + * + * Gets a pointer to a function that can call a Variant utility function. + * + * @param p_function A pointer to a StringName with the function name. + * @param p_hash A hash representing the function signature. + * + * @return A pointer to a function that can call a Variant utility function. + */ +typedef GDExtensionPtrUtilityFunction (*GDExtensionInterfaceVariantGetPtrUtilityFunction)(GDExtensionConstStringNamePtr p_function, GDExtensionInt p_hash); + +/* INTERFACE: String Utilities */ + +/** + * @name string_new_with_latin1_chars + * + * Creates a String from a Latin-1 encoded C string. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a Latin-1 encoded C string (null terminated). + */ +typedef void (*GDExtensionInterfaceStringNewWithLatin1Chars)(GDExtensionStringPtr r_dest, const char *p_contents); + +/** + * @name string_new_with_utf8_chars + * + * Creates a String from a UTF-8 encoded C string. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a UTF-8 encoded C string (null terminated). + */ +typedef void (*GDExtensionInterfaceStringNewWithUtf8Chars)(GDExtensionStringPtr r_dest, const char *p_contents); + +/** + * @name string_new_with_utf16_chars + * + * Creates a String from a UTF-16 encoded C string. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a UTF-16 encoded C string (null terminated). + */ +typedef void (*GDExtensionInterfaceStringNewWithUtf16Chars)(GDExtensionStringPtr r_dest, const char16_t *p_contents); + +/** + * @name string_new_with_utf32_chars + * + * Creates a String from a UTF-32 encoded C string. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a UTF-32 encoded C string (null terminated). + */ +typedef void (*GDExtensionInterfaceStringNewWithUtf32Chars)(GDExtensionStringPtr r_dest, const char32_t *p_contents); + +/** + * @name string_new_with_wide_chars + * + * Creates a String from a wide C string. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a wide C string (null terminated). + */ +typedef void (*GDExtensionInterfaceStringNewWithWideChars)(GDExtensionStringPtr r_dest, const wchar_t *p_contents); + +/** + * @name string_new_with_latin1_chars_and_len + * + * Creates a String from a Latin-1 encoded C string with the given length. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a Latin-1 encoded C string. + * @param p_size The number of characters. + */ +typedef void (*GDExtensionInterfaceStringNewWithLatin1CharsAndLen)(GDExtensionStringPtr r_dest, const char *p_contents, GDExtensionInt p_size); + +/** + * @name string_new_with_utf8_chars_and_len + * + * Creates a String from a UTF-8 encoded C string with the given length. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a UTF-8 encoded C string. + * @param p_size The number of characters. + */ +typedef void (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen)(GDExtensionStringPtr r_dest, const char *p_contents, GDExtensionInt p_size); + +/** + * @name string_new_with_utf16_chars_and_len + * + * Creates a String from a UTF-16 encoded C string with the given length. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a UTF-16 encoded C string. + * @param p_size The number of characters. + */ +typedef void (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen)(GDExtensionStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_size); + +/** + * @name string_new_with_utf32_chars_and_len + * + * Creates a String from a UTF-32 encoded C string with the given length. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a UTF-32 encoded C string. + * @param p_size The number of characters. + */ +typedef void (*GDExtensionInterfaceStringNewWithUtf32CharsAndLen)(GDExtensionStringPtr r_dest, const char32_t *p_contents, GDExtensionInt p_size); + +/** + * @name string_new_with_wide_chars_and_len + * + * Creates a String from a wide C string with the given length. + * + * @param r_dest A pointer to a Variant to hold the newly created String. + * @param p_contents A pointer to a wide C string. + * @param p_size The number of characters. + */ +typedef void (*GDExtensionInterfaceStringNewWithWideCharsAndLen)(GDExtensionStringPtr r_dest, const wchar_t *p_contents, GDExtensionInt p_size); + +/** + * @name string_to_latin1_chars + * + * Converts a String to a Latin-1 encoded C string. + * + * It doesn't write a null terminator. + * + * @param p_self A pointer to the String. + * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed. + * @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value. + * + * @return The resulting encoded string length in characters (not bytes), not including a null terminator. + */ +typedef GDExtensionInt (*GDExtensionInterfaceStringToLatin1Chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length); + +/** + * @name string_to_utf8_chars + * + * Converts a String to a UTF-8 encoded C string. + * + * It doesn't write a null terminator. + * + * @param p_self A pointer to the String. + * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed. + * @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value. + * + * @return The resulting encoded string length in characters (not bytes), not including a null terminator. + */ +typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf8Chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length); + +/** + * @name string_to_utf16_chars + * + * Converts a String to a UTF-16 encoded C string. + * + * It doesn't write a null terminator. + * + * @param p_self A pointer to the String. + * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed. + * @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value. + * + * @return The resulting encoded string length in characters (not bytes), not including a null terminator. + */ +typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf16Chars)(GDExtensionConstStringPtr p_self, char16_t *r_text, GDExtensionInt p_max_write_length); + +/** + * @name string_to_utf32_chars + * + * Converts a String to a UTF-32 encoded C string. + * + * It doesn't write a null terminator. + * + * @param p_self A pointer to the String. + * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed. + * @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value. + * + * @return The resulting encoded string length in characters (not bytes), not including a null terminator. + */ +typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf32Chars)(GDExtensionConstStringPtr p_self, char32_t *r_text, GDExtensionInt p_max_write_length); + +/** + * @name string_to_wide_chars + * + * Converts a String to a wide C string. + * + * It doesn't write a null terminator. + * + * @param p_self A pointer to the String. + * @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed. + * @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value. + * + * @return The resulting encoded string length in characters (not bytes), not including a null terminator. + */ +typedef GDExtensionInt (*GDExtensionInterfaceStringToWideChars)(GDExtensionConstStringPtr p_self, wchar_t *r_text, GDExtensionInt p_max_write_length); + +/** + * @name string_operator_index + * + * Gets a pointer to the character at the given index from a String. + * + * @param p_self A pointer to the String. + * @param p_index The index. + * + * @return A pointer to the requested character. + */ +typedef char32_t *(*GDExtensionInterfaceStringOperatorIndex)(GDExtensionStringPtr p_self, GDExtensionInt p_index); + +/** + * @name string_operator_index_const + * + * Gets a const pointer to the character at the given index from a String. + * + * @param p_self A pointer to the String. + * @param p_index The index. + * + * @return A const pointer to the requested character. + */ +typedef const char32_t *(*GDExtensionInterfaceStringOperatorIndexConst)(GDExtensionConstStringPtr p_self, GDExtensionInt p_index); + +/** + * @name string_operator_plus_eq_string + * + * Appends another String to a String. + * + * @param p_self A pointer to the String. + * @param p_b A pointer to the other String to append. + */ +typedef void (*GDExtensionInterfaceStringOperatorPlusEqString)(GDExtensionStringPtr p_self, GDExtensionConstStringPtr p_b); + +/** + * @name string_operator_plus_eq_char + * + * Appends a character to a String. + * + * @param p_self A pointer to the String. + * @param p_b A pointer to the character to append. + */ +typedef void (*GDExtensionInterfaceStringOperatorPlusEqChar)(GDExtensionStringPtr p_self, char32_t p_b); + +/** + * @name string_operator_plus_eq_cstr + * + * Appends a Latin-1 encoded C string to a String. + * + * @param p_self A pointer to the String. + * @param p_b A pointer to a Latin-1 encoded C string (null terminated). + */ +typedef void (*GDExtensionInterfaceStringOperatorPlusEqCstr)(GDExtensionStringPtr p_self, const char *p_b); + +/** + * @name string_operator_plus_eq_wcstr + * + * Appends a wide C string to a String. + * + * @param p_self A pointer to the String. + * @param p_b A pointer to a wide C string (null terminated). + */ +typedef void (*GDExtensionInterfaceStringOperatorPlusEqWcstr)(GDExtensionStringPtr p_self, const wchar_t *p_b); + +/** + * @name string_operator_plus_eq_c32str + * + * Appends a UTF-32 encoded C string to a String. + * + * @param p_self A pointer to the String. + * @param p_b A pointer to a UTF-32 encoded C string (null terminated). + */ +typedef void (*GDExtensionInterfaceStringOperatorPlusEqC32str)(GDExtensionStringPtr p_self, const char32_t *p_b); + +/* INTERFACE: XMLParser Utilities */ + +/** + * @name xml_parser_open_buffer + * + * Opens a raw XML buffer on an XMLParser instance. + * + * @param p_instance A pointer to an XMLParser object. + * @param p_buffer A pointer to the buffer. + * @param p_size The size of the buffer. + * + * @return A Godot error code (ex. OK, ERR_INVALID_DATA, etc). + * + * @see XMLParser::open_buffer() + */ +typedef GDExtensionInt (*GDExtensionInterfaceXmlParserOpenBuffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_buffer, size_t p_size); + +/* INTERFACE: FileAccess Utilities */ + +/** + * @name file_access_store_buffer + * + * Stores the given buffer using an instance of FileAccess. + * + * @param p_instance A pointer to a FileAccess object. + * @param p_src A pointer to the buffer. + * @param p_length The size of the buffer. + * + * @see FileAccess::store_buffer() + */ +typedef void (*GDExtensionInterfaceFileAccessStoreBuffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_src, uint64_t p_length); + +/** + * @name file_access_get_buffer + * + * Reads the next p_length bytes into the given buffer using an instance of FileAccess. + * + * @param p_instance A pointer to a FileAccess object. + * @param p_dst A pointer to the buffer to store the data. + * @param p_length The requested number of bytes to read. + * + * @return The actual number of bytes read (may be less than requested). + */ +typedef uint64_t (*GDExtensionInterfaceFileAccessGetBuffer)(GDExtensionConstObjectPtr p_instance, uint8_t *p_dst, uint64_t p_length); + +/* INTERFACE: WorkerThreadPool Utilities */ + +/** + * @name worker_thread_pool_add_native_group_task + * + * Adds a group task to an instance of WorkerThreadPool. + * + * @param p_instance A pointer to a WorkerThreadPool object. + * @param p_func A pointer to a function to run in the thread pool. + * @param p_userdata A pointer to arbitrary data which will be passed to p_func. + * @param p_tasks The number of tasks needed in the group. + * @param p_high_priority Whether or not this is a high priority task. + * @param p_description A pointer to a String with the task description. + * + * @return The task group ID. + * + * @see WorkerThreadPool::add_group_task() + */ +typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeGroupTask)(GDExtensionObjectPtr p_instance, void (*p_func)(void *, uint32_t), void *p_userdata, int p_elements, int p_tasks, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description); + +/** + * @name worker_thread_pool_add_native_task + * + * Adds a task to an instance of WorkerThreadPool. + * + * @param p_instance A pointer to a WorkerThreadPool object. + * @param p_func A pointer to a function to run in the thread pool. + * @param p_userdata A pointer to arbitrary data which will be passed to p_func. + * @param p_high_priority Whether or not this is a high priority task. + * @param p_description A pointer to a String with the task description. + * + * @return The task ID. + */ +typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeTask)(GDExtensionObjectPtr p_instance, void (*p_func)(void *), void *p_userdata, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description); + +/* INTERFACE: Packed Array */ + +/** + * @name packed_byte_array_operator_index + * + * Gets a pointer to a byte in a PackedByteArray. + * + * @param p_self A pointer to a PackedByteArray object. + * @param p_index The index of the byte to get. + * + * @return A pointer to the requested byte. + */ +typedef uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_byte_array_operator_index_const + * + * Gets a const pointer to a byte in a PackedByteArray. + * + * @param p_self A const pointer to a PackedByteArray object. + * @param p_index The index of the byte to get. + * + * @return A const pointer to the requested byte. + */ +typedef const uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_color_array_operator_index + * + * Gets a pointer to a color in a PackedColorArray. + * + * @param p_self A pointer to a PackedColorArray object. + * @param p_index The index of the Color to get. + * + * @return A pointer to the requested Color. + */ +typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_color_array_operator_index_const + * + * Gets a const pointer to a color in a PackedColorArray. + * + * @param p_self A const pointer to a const PackedColorArray object. + * @param p_index The index of the Color to get. + * + * @return A const pointer to the requested Color. + */ +typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_float32_array_operator_index + * + * Gets a pointer to a 32-bit float in a PackedFloat32Array. + * + * @param p_self A pointer to a PackedFloat32Array object. + * @param p_index The index of the float to get. + * + * @return A pointer to the requested 32-bit float. + */ +typedef float *(*GDExtensionInterfacePackedFloat32ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_float32_array_operator_index_const + * + * Gets a const pointer to a 32-bit float in a PackedFloat32Array. + * + * @param p_self A const pointer to a PackedFloat32Array object. + * @param p_index The index of the float to get. + * + * @return A const pointer to the requested 32-bit float. + */ +typedef const float *(*GDExtensionInterfacePackedFloat32ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_float64_array_operator_index + * + * Gets a pointer to a 64-bit float in a PackedFloat64Array. + * + * @param p_self A pointer to a PackedFloat64Array object. + * @param p_index The index of the float to get. + * + * @return A pointer to the requested 64-bit float. + */ +typedef double *(*GDExtensionInterfacePackedFloat64ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_float64_array_operator_index_const + * + * Gets a const pointer to a 64-bit float in a PackedFloat64Array. + * + * @param p_self A const pointer to a PackedFloat64Array object. + * @param p_index The index of the float to get. + * + * @return A const pointer to the requested 64-bit float. + */ +typedef const double *(*GDExtensionInterfacePackedFloat64ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_int32_array_operator_index + * + * Gets a pointer to a 32-bit integer in a PackedInt32Array. + * + * @param p_self A pointer to a PackedInt32Array object. + * @param p_index The index of the integer to get. + * + * @return A pointer to the requested 32-bit integer. + */ +typedef int32_t *(*GDExtensionInterfacePackedInt32ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_int32_array_operator_index_const + * + * Gets a const pointer to a 32-bit integer in a PackedInt32Array. + * + * @param p_self A const pointer to a PackedInt32Array object. + * @param p_index The index of the integer to get. + * + * @return A const pointer to the requested 32-bit integer. + */ +typedef const int32_t *(*GDExtensionInterfacePackedInt32ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_int64_array_operator_index + * + * Gets a pointer to a 64-bit integer in a PackedInt64Array. + * + * @param p_self A pointer to a PackedInt64Array object. + * @param p_index The index of the integer to get. + * + * @return A pointer to the requested 64-bit integer. + */ +typedef int64_t *(*GDExtensionInterfacePackedInt64ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_int64_array_operator_index_const + * + * Gets a const pointer to a 64-bit integer in a PackedInt64Array. + * + * @param p_self A const pointer to a PackedInt64Array object. + * @param p_index The index of the integer to get. + * + * @return A const pointer to the requested 64-bit integer. + */ +typedef const int64_t *(*GDExtensionInterfacePackedInt64ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_string_array_operator_index + * + * Gets a pointer to a string in a PackedStringArray. + * + * @param p_self A pointer to a PackedStringArray object. + * @param p_index The index of the String to get. + * + * @return A pointer to the requested String. + */ +typedef GDExtensionStringPtr (*GDExtensionInterfacePackedStringArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_string_array_operator_index_const + * + * Gets a const pointer to a string in a PackedStringArray. + * + * @param p_self A const pointer to a PackedStringArray object. + * @param p_index The index of the String to get. + * + * @return A const pointer to the requested String. + */ +typedef GDExtensionStringPtr (*GDExtensionInterfacePackedStringArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_vector2_array_operator_index + * + * Gets a pointer to a Vector2 in a PackedVector2Array. + * + * @param p_self A pointer to a PackedVector2Array object. + * @param p_index The index of the Vector2 to get. + * + * @return A pointer to the requested Vector2. + */ +typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector2ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_vector2_array_operator_index_const + * + * Gets a const pointer to a Vector2 in a PackedVector2Array. + * + * @param p_self A const pointer to a PackedVector2Array object. + * @param p_index The index of the Vector2 to get. + * + * @return A const pointer to the requested Vector2. + */ +typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector2ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_vector3_array_operator_index + * + * Gets a pointer to a Vector3 in a PackedVector3Array. + * + * @param p_self A pointer to a PackedVector3Array object. + * @param p_index The index of the Vector3 to get. + * + * @return A pointer to the requested Vector3. + */ +typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name packed_vector3_array_operator_index_const + * + * Gets a const pointer to a Vector3 in a PackedVector3Array. + * + * @param p_self A const pointer to a PackedVector3Array object. + * @param p_index The index of the Vector3 to get. + * + * @return A const pointer to the requested Vector3. + */ +typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name array_operator_index + * + * Gets a pointer to a Variant in an Array. + * + * @param p_self A pointer to an Array object. + * @param p_index The index of the Variant to get. + * + * @return A pointer to the requested Variant. + */ +typedef GDExtensionVariantPtr (*GDExtensionInterfaceArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index); + +/** + * @name array_operator_index_const + * + * Gets a const pointer to a Variant in an Array. + * + * @param p_self A const pointer to an Array object. + * @param p_index The index of the Variant to get. + * + * @return A const pointer to the requested Variant. + */ +typedef GDExtensionVariantPtr (*GDExtensionInterfaceArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); + +/** + * @name array_ref + * + * Sets an Array to be a reference to another Array object. + * + * @param p_self A pointer to the Array object to update. + * @param p_from A pointer to the Array object to reference. + */ +typedef void (*GDExtensionInterfaceArrayRef)(GDExtensionTypePtr p_self, GDExtensionConstTypePtr p_from); + +/** + * @name array_set_typed + * + * Makes an Array into a typed Array. + * + * @param p_self A pointer to the Array. + * @param p_type The type of Variant the Array will store. + * @param p_class_name A pointer to a StringName with the name of the object (if p_type is GDEXTENSION_VARIANT_TYPE_OBJECT). + * @param p_script A pointer to a Script object (if p_type is GDEXTENSION_VARIANT_TYPE_OBJECT and the base class is extended by a script). + */ +typedef void (*GDExtensionInterfaceArraySetTyped)(GDExtensionTypePtr p_self, GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstVariantPtr p_script); + +/* INTERFACE: Dictionary */ + +/** + * @name dictionary_operator_index + * + * Gets a pointer to a Variant in a Dictionary with the given key. + * + * @param p_self A pointer to a Dictionary object. + * @param p_key A pointer to a Variant representing the key. + * + * @return A pointer to a Variant representing the value at the given key. + */ +typedef GDExtensionVariantPtr (*GDExtensionInterfaceDictionaryOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionConstVariantPtr p_key); + +/** + * @name dictionary_operator_index_const + * + * Gets a const pointer to a Variant in a Dictionary with the given key. + * + * @param p_self A const pointer to a Dictionary object. + * @param p_key A pointer to a Variant representing the key. + * + * @return A const pointer to a Variant representing the value at the given key. + */ +typedef GDExtensionVariantPtr (*GDExtensionInterfaceDictionaryOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionConstVariantPtr p_key); + +/* INTERFACE: Object */ + +/** + * @name object_method_bind_call + * + * Calls a method on an Object. + * + * @param p_method_bind A pointer to the MethodBind representing the method on the Object's class. + * @param p_instance A pointer to the Object. + * @param p_args A pointer to a C array of Variants representing the arguments. + * @param p_arg_count The number of arguments. + * @param r_ret A pointer to Variant which will receive the return value. + * @param r_error A pointer to a GDExtensionCallError struct that will receive error information. + */ +typedef void (*GDExtensionInterfaceObjectMethodBindCall)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_arg_count, GDExtensionVariantPtr r_ret, GDExtensionCallError *r_error); + +/** + * @name object_method_bind_ptrcall + * + * Calls a method on an Object (using a "ptrcall"). + * + * @param p_method_bind A pointer to the MethodBind representing the method on the Object's class. + * @param p_instance A pointer to the Object. + * @param p_args A pointer to a C array representing the arguments. + * @param r_ret A pointer to the Object that will receive the return value. + */ +typedef void (*GDExtensionInterfaceObjectMethodBindPtrcall)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret); + +/** + * @name object_destroy + * + * Destroys an Object. + * + * @param p_o A pointer to the Object. + */ +typedef void (*GDExtensionInterfaceObjectDestroy)(GDExtensionObjectPtr p_o); + +/** + * @name global_get_singleton + * + * Gets a global singleton by name. + * + * @param p_name A pointer to a StringName with the singleton name. + * + * @return A pointer to the singleton Object. + */ +typedef GDExtensionObjectPtr (*GDExtensionInterfaceGlobalGetSingleton)(GDExtensionConstStringNamePtr p_name); + +/** + * @name object_get_instance_binding + * + * Gets a pointer representing an Object's instance binding. + * + * @param p_o A pointer to the Object. + * @param p_library A token the library received by the GDExtension's entry point function. + * @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct. + * + * @return + */ +typedef void *(*GDExtensionInterfaceObjectGetInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token, const GDExtensionInstanceBindingCallbacks *p_callbacks); + +/** + * @name object_set_instance_binding + * + * Sets an Object's instance binding. + * + * @param p_o A pointer to the Object. + * @param p_library A token the library received by the GDExtension's entry point function. + * @param p_binding A pointer to the instance binding. + * @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct. + */ +typedef void (*GDExtensionInterfaceObjectSetInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token, void *p_binding, const GDExtensionInstanceBindingCallbacks *p_callbacks); + +/** + * @name object_set_instance + * + * Sets an extension class instance on a Object. + * + * @param p_o A pointer to the Object. + * @param p_classname A pointer to a StringName with the registered extension class's name. + * @param p_instance A pointer to the extension class instance. + */ +typedef void (*GDExtensionInterfaceObjectSetInstance)(GDExtensionObjectPtr p_o, GDExtensionConstStringNamePtr p_classname, GDExtensionClassInstancePtr p_instance); /* p_classname should be a registered extension class and should extend the p_o object's class. */ + +/** + * @name object_cast_to + * + * Casts an Object to a different type. + * + * @param p_object A pointer to the Object. + * @param p_class_tag A pointer uniquely identifying a built-in class in the ClassDB. + * + * @return Returns a pointer to the Object, or NULL if it can't be cast to the requested type. + */ +typedef GDExtensionObjectPtr (*GDExtensionInterfaceObjectCastTo)(GDExtensionConstObjectPtr p_object, void *p_class_tag); + +/** + * @name object_get_instance_from_id + * + * Gets an Object by its instance ID. + * + * @param p_instance_id The instance ID. + * + * @return A pointer to the Object. + */ +typedef GDExtensionObjectPtr (*GDExtensionInterfaceObjectGetInstanceFromId)(GDObjectInstanceID p_instance_id); + +/** + * @name object_get_instance_id + * + * Gets the instance ID from an Object. + * + * @param p_object A pointer to the Object. + * + * @return The instance ID. + */ +typedef GDObjectInstanceID (*GDExtensionInterfaceObjectGetInstanceId)(GDExtensionConstObjectPtr p_object); + +/* INTERFACE: Reference */ + +/** + * @name ref_get_object + * + * Gets the Object from a reference. + * + * @param p_ref A pointer to the reference. + * + * @return A pointer to the Object from the reference or NULL. + */ +typedef GDExtensionObjectPtr (*GDExtensionInterfaceRefGetObject)(GDExtensionConstRefPtr p_ref); + +/** + * @name ref_set_object + * + * Sets the Object referred to by a reference. + * + * @param p_ref A pointer to the reference. + * @param p_object A pointer to the Object to refer to. + */ +typedef void (*GDExtensionInterfaceRefSetObject)(GDExtensionRefPtr p_ref, GDExtensionObjectPtr p_object); + +/* INTERFACE: Script Instance */ + +/** + * @name script_instance_create + * + * Creates a script instance that contains the given info and instance data. + * + * @param p_info A pointer to a GDExtensionScriptInstanceInfo struct. + * @param p_instance_data A pointer to a data representing the script instance in the GDExtension. This will be passed to all the function pointers on p_info. + * + * @return A pointer to a ScriptInstanceExtension object. + */ +typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate)(const GDExtensionScriptInstanceInfo *p_info, GDExtensionScriptInstanceDataPtr p_instance_data); + +/* INTERFACE: ClassDB */ + +/** + * @name classdb_construct_object + * + * Constructs an Object of the requested class. + * + * The passed class must be a built-in godot class, or an already-registered extension class. In both cases, object_set_instance() should be called to fully initialize the object. + * + * @param p_classname A pointer to a StringName with the class name. + * + * @return A pointer to the newly created Object. + */ +typedef GDExtensionObjectPtr (*GDExtensionInterfaceClassdbConstructObject)(GDExtensionConstStringNamePtr p_classname); + +/** + * @name classdb_get_method_bind + * + * Gets a pointer to the MethodBind in ClassDB for the given class, method and hash. + * + * @param p_classname A pointer to a StringName with the class name. + * @param p_methodname A pointer to a StringName with the method name. + * @param p_hash A hash representing the function signature. + * + * @return A pointer to the MethodBind from ClassDB. + */ +typedef GDExtensionMethodBindPtr (*GDExtensionInterfaceClassdbGetMethodBind)(GDExtensionConstStringNamePtr p_classname, GDExtensionConstStringNamePtr p_methodname, GDExtensionInt p_hash); + +/** + * @name classdb_get_class_tag + * + * Gets a pointer uniquely identifying the given built-in class in the ClassDB. + * + * @param p_classname A pointer to a StringName with the class name. + * + * @return A pointer uniquely identifying the built-in class in the ClassDB. + */ +typedef void *(*GDExtensionInterfaceClassdbGetClassTag)(GDExtensionConstStringNamePtr p_classname); + +/* INTERFACE: ClassDB Extension */ + +/** + * @name classdb_register_extension_class + * + * Registers an extension class in the ClassDB. + * + * Provided struct can be safely freed once the function returns. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_parent_class_name A pointer to a StringName with the parent class name. + * @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo struct. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo *p_extension_funcs); + +/** + * @name classdb_register_extension_class_method + * + * Registers a method on an extension class in the ClassDB. + * + * Provided struct can be safely freed once the function returns. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_method_info A pointer to a GDExtensionClassMethodInfo struct. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassMethod)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassMethodInfo *p_method_info); + +/** + * @name classdb_register_extension_class_integer_constant + * + * Registers an integer constant on an extension class in the ClassDB. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_enum_name A pointer to a StringName with the enum name. + * @param p_constant_name A pointer to a StringName with the constant name. + * @param p_constant_value The constant value. + * @param p_is_bitfield Whether or not this is a bit field. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassIntegerConstant)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_enum_name, GDExtensionConstStringNamePtr p_constant_name, GDExtensionInt p_constant_value, GDExtensionBool p_is_bitfield); + +/** + * @name classdb_register_extension_class_property + * + * Registers a property on an extension class in the ClassDB. + * + * Provided struct can be safely freed once the function returns. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_info A pointer to a GDExtensionPropertyInfo struct. + * @param p_setter A pointer to a StringName with the name of the setter method. + * @param p_getter A pointer to a StringName with the name of the getter method. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassProperty)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionPropertyInfo *p_info, GDExtensionConstStringNamePtr p_setter, GDExtensionConstStringNamePtr p_getter); + +/** + * @name classdb_register_extension_class_property_group + * + * Registers a property group on an extension class in the ClassDB. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_group_name A pointer to a String with the group name. + * @param p_prefix A pointer to a String with the prefix used by properties in this group. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertyGroup)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_group_name, GDExtensionConstStringPtr p_prefix); + +/** + * @name classdb_register_extension_class_property_subgroup + * + * Registers a property subgroup on an extension class in the ClassDB. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_subgroup_name A pointer to a String with the subgroup name. + * @param p_prefix A pointer to a String with the prefix used by properties in this subgroup. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertySubgroup)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_subgroup_name, GDExtensionConstStringPtr p_prefix); + +/** + * @name classdb_register_extension_class_signal + * + * Registers a signal on an extension class in the ClassDB. + * + * Provided structs can be safely freed once the function returns. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + * @param p_signal_name A pointer to a StringName with the signal name. + * @param p_argument_info A pointer to a GDExtensionPropertyInfo struct. + * @param p_argument_count The number of arguments the signal receives. + */ +typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassSignal)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_signal_name, const GDExtensionPropertyInfo *p_argument_info, GDExtensionInt p_argument_count); + +/** + * @name classdb_unregister_extension_class + * + * Unregisters an extension class in the ClassDB. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param p_class_name A pointer to a StringName with the class name. + */ +typedef void (*GDExtensionInterfaceClassdbUnregisterExtensionClass)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name); /* Unregistering a parent class before a class that inherits it will result in failure. Inheritors must be unregistered first. */ + +/** + * @name get_library_path + * + * Gets the path to the current GDExtension library. + * + * @param p_library A pointer the library received by the GDExtension's entry point function. + * @param r_path A pointer to a String which will receive the path. + */ +typedef void (*GDExtensionInterfaceGetLibraryPath)(GDExtensionClassLibraryPtr p_library, GDExtensionStringPtr r_path); #ifdef __cplusplus } diff --git a/include/godot_cpp/classes/ref.hpp b/include/godot_cpp/classes/ref.hpp index af7711c5..301f847d 100644 --- a/include/godot_cpp/classes/ref.hpp +++ b/include/godot_cpp/classes/ref.hpp @@ -242,7 +242,7 @@ struct PtrToArg> { _FORCE_INLINE_ static Ref convert(const void *p_ptr) { // Important: p_ptr is T*, not Ref*, since Object* is what engine gives to ptrcall. ERR_FAIL_NULL_V(p_ptr, Ref()); - return Ref(reinterpret_cast(godot::internal::gde_interface->object_get_instance_binding( + return Ref(reinterpret_cast(godot::internal::gdextension_interface_object_get_instance_binding( reinterpret_cast(const_cast(p_ptr)), godot::internal::token, &T::___binding_callbacks))); } @@ -256,7 +256,7 @@ struct PtrToArg> { // This code assumes that p_ptr points to an unset Ref variable on the Godot side // so we only set it if we have an object to set. if (p_val.is_valid()) { - godot::internal::gde_interface->ref_set_object(ref, p_val->_owner); + godot::internal::gdextension_interface_ref_set_object(ref, p_val->_owner); } } }; @@ -267,7 +267,7 @@ struct PtrToArg &> { _FORCE_INLINE_ static Ref convert(const void *p_ptr) { ERR_FAIL_NULL_V(p_ptr, Ref()); - return Ref(reinterpret_cast(godot::internal::gde_interface->object_get_instance_binding( + return Ref(reinterpret_cast(godot::internal::gdextension_interface_object_get_instance_binding( reinterpret_cast(const_cast(p_ptr)), godot::internal::token, &T::___binding_callbacks))); } diff --git a/include/godot_cpp/core/binder_common.hpp b/include/godot_cpp/core/binder_common.hpp index ed7c487d..09da62b1 100644 --- a/include/godot_cpp/core/binder_common.hpp +++ b/include/godot_cpp/core/binder_common.hpp @@ -148,7 +148,7 @@ template struct VariantCasterAndValidate { static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) { GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo::VARIANT_TYPE); - if (!internal::gde_interface->variant_can_convert_strict(static_cast(p_args[p_arg_idx]->get_type()), argtype) || + if (!internal::gdextension_interface_variant_can_convert_strict(static_cast(p_args[p_arg_idx]->get_type()), argtype) || !VariantObjectClassChecker::check(p_args[p_arg_idx])) { r_error.error = GDEXTENSION_CALL_ERROR_INVALID_ARGUMENT; r_error.argument = p_arg_idx; @@ -163,7 +163,7 @@ template struct VariantCasterAndValidate { static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) { GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo::VARIANT_TYPE); - if (!internal::gde_interface->variant_can_convert_strict(static_cast(p_args[p_arg_idx]->get_type()), argtype) || + if (!internal::gdextension_interface_variant_can_convert_strict(static_cast(p_args[p_arg_idx]->get_type()), argtype) || !VariantObjectClassChecker::check(p_args[p_arg_idx])) { r_error.error = GDEXTENSION_CALL_ERROR_INVALID_ARGUMENT; r_error.argument = p_arg_idx; @@ -178,7 +178,7 @@ template struct VariantCasterAndValidate { static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) { GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo::VARIANT_TYPE); - if (!internal::gde_interface->variant_can_convert_strict(static_cast(p_args[p_arg_idx]->get_type()), argtype) || + if (!internal::gdextension_interface_variant_can_convert_strict(static_cast(p_args[p_arg_idx]->get_type()), argtype) || !VariantObjectClassChecker::check(p_args[p_arg_idx])) { r_error.error = GDEXTENSION_CALL_ERROR_INVALID_ARGUMENT; r_error.argument = p_arg_idx; diff --git a/include/godot_cpp/core/class_db.hpp b/include/godot_cpp/core/class_db.hpp index 35542992..1ac1f914 100644 --- a/include/godot_cpp/core/class_db.hpp +++ b/include/godot_cpp/core/class_db.hpp @@ -194,7 +194,7 @@ void ClassDB::_register_class(bool p_virtual) { (void *)&T::get_class_static(), // void *class_userdata; }; - internal::gde_interface->classdb_register_extension_class(internal::library, cl.name._native_ptr(), cl.parent_name._native_ptr(), &class_info); + internal::gdextension_interface_classdb_register_extension_class(internal::library, cl.name._native_ptr(), cl.parent_name._native_ptr(), &class_info); // call bind_methods etc. to register all members of the class T::initialize_class(); diff --git a/include/godot_cpp/core/engine_ptrcall.hpp b/include/godot_cpp/core/engine_ptrcall.hpp index 94da3c50..a5fd1143 100644 --- a/include/godot_cpp/core/engine_ptrcall.hpp +++ b/include/godot_cpp/core/engine_ptrcall.hpp @@ -47,25 +47,25 @@ template O *_call_native_mb_ret_obj(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) { GodotObject *ret = nullptr; std::array mb_args = { { (GDExtensionConstTypePtr)args... } }; - internal::gde_interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret); + internal::gdextension_interface_object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret); if (ret == nullptr) { return nullptr; } - return reinterpret_cast(internal::gde_interface->object_get_instance_binding(ret, internal::token, &O::___binding_callbacks)); + return reinterpret_cast(internal::gdextension_interface_object_get_instance_binding(ret, internal::token, &O::___binding_callbacks)); } template R _call_native_mb_ret(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) { R ret; std::array mb_args = { { (GDExtensionConstTypePtr)args... } }; - internal::gde_interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret); + internal::gdextension_interface_object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret); return ret; } template void _call_native_mb_no_ret(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) { std::array mb_args = { { (GDExtensionConstTypePtr)args... } }; - internal::gde_interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), nullptr); + internal::gdextension_interface_object_method_bind_ptrcall(mb, instance, mb_args.data(), nullptr); } template @@ -81,7 +81,7 @@ Object *_call_utility_ret_obj(const GDExtensionPtrUtilityFunction func, void *in GodotObject *ret = nullptr; std::array mb_args = { { (GDExtensionConstTypePtr)args... } }; func(&ret, mb_args.data(), mb_args.size()); - return (Object *)internal::gde_interface->object_get_instance_binding(ret, internal::token, &Object::___binding_callbacks); + return (Object *)internal::gdextension_interface_object_get_instance_binding(ret, internal::token, &Object::___binding_callbacks); } template diff --git a/include/godot_cpp/core/memory.hpp b/include/godot_cpp/core/memory.hpp index 55cdb8b4..dd4a155d 100644 --- a/include/godot_cpp/core/memory.hpp +++ b/include/godot_cpp/core/memory.hpp @@ -107,7 +107,7 @@ void memdelete(T *p_class, typename std::enable_if, bool> = true> void memdelete(T *p_class) { - godot::internal::gde_interface->object_destroy(p_class->_owner); + godot::internal::gdextension_interface_object_destroy(p_class->_owner); } template diff --git a/include/godot_cpp/core/method_ptrcall.hpp b/include/godot_cpp/core/method_ptrcall.hpp index 6a5227a2..1c99fd9e 100644 --- a/include/godot_cpp/core/method_ptrcall.hpp +++ b/include/godot_cpp/core/method_ptrcall.hpp @@ -168,7 +168,7 @@ MAKE_PTRARG_BY_REFERENCE(Variant); template struct PtrToArg { _FORCE_INLINE_ static T *convert(const void *p_ptr) { - return reinterpret_cast(godot::internal::gde_interface->object_get_instance_binding( + return reinterpret_cast(godot::internal::gdextension_interface_object_get_instance_binding( reinterpret_cast(const_cast(p_ptr)), godot::internal::token, &T::___binding_callbacks)); } @@ -181,7 +181,7 @@ struct PtrToArg { template struct PtrToArg { _FORCE_INLINE_ static const T *convert(const void *p_ptr) { - return reinterpret_cast(godot::internal::gde_interface->object_get_instance_binding( + return reinterpret_cast(godot::internal::gdextension_interface_object_get_instance_binding( reinterpret_cast(const_cast(p_ptr)), godot::internal::token, &T::___binding_callbacks)); } diff --git a/include/godot_cpp/core/object.hpp b/include/godot_cpp/core/object.hpp index f5c790aa..54ca4be3 100644 --- a/include/godot_cpp/core/object.hpp +++ b/include/godot_cpp/core/object.hpp @@ -124,11 +124,11 @@ public: class ObjectDB { public: static Object *get_instance(uint64_t p_object_id) { - GDExtensionObjectPtr obj = internal::gde_interface->object_get_instance_from_id(p_object_id); + GDExtensionObjectPtr obj = internal::gdextension_interface_object_get_instance_from_id(p_object_id); if (obj == nullptr) { return nullptr; } - return reinterpret_cast(internal::gde_interface->object_get_instance_binding(obj, internal::token, &Object::___binding_callbacks)); + return reinterpret_cast(internal::gdextension_interface_object_get_instance_binding(obj, internal::token, &Object::___binding_callbacks)); } }; @@ -138,11 +138,11 @@ T *Object::cast_to(Object *p_object) { return nullptr; } StringName class_name = T::get_class_static(); - GDExtensionObjectPtr casted = internal::gde_interface->object_cast_to(p_object->_owner, internal::gde_interface->classdb_get_class_tag(class_name._native_ptr())); + GDExtensionObjectPtr casted = internal::gdextension_interface_object_cast_to(p_object->_owner, internal::gdextension_interface_classdb_get_class_tag(class_name._native_ptr())); if (casted == nullptr) { return nullptr; } - return reinterpret_cast(internal::gde_interface->object_get_instance_binding(casted, internal::token, &T::___binding_callbacks)); + return reinterpret_cast(internal::gdextension_interface_object_get_instance_binding(casted, internal::token, &T::___binding_callbacks)); } template @@ -151,11 +151,11 @@ const T *Object::cast_to(const Object *p_object) { return nullptr; } StringName class_name = T::get_class_static(); - GDExtensionObjectPtr casted = internal::gde_interface->object_cast_to(p_object->_owner, internal::gde_interface->classdb_get_class_tag(class_name._native_ptr())); + GDExtensionObjectPtr casted = internal::gdextension_interface_object_cast_to(p_object->_owner, internal::gdextension_interface_classdb_get_class_tag(class_name._native_ptr())); if (casted == nullptr) { return nullptr; } - return reinterpret_cast(internal::gde_interface->object_get_instance_binding(casted, internal::token, &T::___binding_callbacks)); + return reinterpret_cast(internal::gdextension_interface_object_get_instance_binding(casted, internal::token, &T::___binding_callbacks)); } } // namespace godot diff --git a/include/godot_cpp/godot.hpp b/include/godot_cpp/godot.hpp index 35ed9f7e..20e94008 100644 --- a/include/godot_cpp/godot.hpp +++ b/include/godot_cpp/godot.hpp @@ -37,10 +37,147 @@ namespace godot { namespace internal { -extern "C" const GDExtensionInterface *gde_interface; +extern "C" GDExtensionInterfaceGetProcAddress gdextension_interface_get_proc_address; extern "C" GDExtensionClassLibraryPtr library; extern "C" void *token; +extern "C" GDExtensionGodotVersion godot_version; + +// All of the GDExtension interface functions. +extern "C" GDExtensionInterfaceGetGodotVersion gdextension_interface_get_godot_version; +extern "C" GDExtensionInterfaceMemAlloc gdextension_interface_mem_alloc; +extern "C" GDExtensionInterfaceMemRealloc gdextension_interface_mem_realloc; +extern "C" GDExtensionInterfaceMemFree gdextension_interface_mem_free; +extern "C" GDExtensionInterfacePrintError gdextension_interface_print_error; +extern "C" GDExtensionInterfacePrintErrorWithMessage gdextension_interface_print_error_with_message; +extern "C" GDExtensionInterfacePrintWarning gdextension_interface_print_warning; +extern "C" GDExtensionInterfacePrintWarningWithMessage gdextension_interface_print_warning_with_message; +extern "C" GDExtensionInterfacePrintScriptError gdextension_interface_print_script_error; +extern "C" GDExtensionInterfacePrintScriptErrorWithMessage gdextension_interface_print_script_error_with_message; +extern "C" GDExtensionInterfaceGetNativeStructSize gdextension_interface_get_native_struct_size; +extern "C" GDExtensionInterfaceVariantNewCopy gdextension_interface_variant_new_copy; +extern "C" GDExtensionInterfaceVariantNewNil gdextension_interface_variant_new_nil; +extern "C" GDExtensionInterfaceVariantDestroy gdextension_interface_variant_destroy; +extern "C" GDExtensionInterfaceVariantCall gdextension_interface_variant_call; +extern "C" GDExtensionInterfaceVariantCallStatic gdextension_interface_variant_call_static; +extern "C" GDExtensionInterfaceVariantEvaluate gdextension_interface_variant_evaluate; +extern "C" GDExtensionInterfaceVariantSet gdextension_interface_variant_set; +extern "C" GDExtensionInterfaceVariantSetNamed gdextension_interface_variant_set_named; +extern "C" GDExtensionInterfaceVariantSetKeyed gdextension_interface_variant_set_keyed; +extern "C" GDExtensionInterfaceVariantSetIndexed gdextension_interface_variant_set_indexed; +extern "C" GDExtensionInterfaceVariantGet gdextension_interface_variant_get; +extern "C" GDExtensionInterfaceVariantGetNamed gdextension_interface_variant_get_named; +extern "C" GDExtensionInterfaceVariantGetKeyed gdextension_interface_variant_get_keyed; +extern "C" GDExtensionInterfaceVariantGetIndexed gdextension_interface_variant_get_indexed; +extern "C" GDExtensionInterfaceVariantIterInit gdextension_interface_variant_iter_init; +extern "C" GDExtensionInterfaceVariantIterNext gdextension_interface_variant_iter_next; +extern "C" GDExtensionInterfaceVariantIterGet gdextension_interface_variant_iter_get; +extern "C" GDExtensionInterfaceVariantHash gdextension_interface_variant_hash; +extern "C" GDExtensionInterfaceVariantRecursiveHash gdextension_interface_variant_recursive_hash; +extern "C" GDExtensionInterfaceVariantHashCompare gdextension_interface_variant_hash_compare; +extern "C" GDExtensionInterfaceVariantBooleanize gdextension_interface_variant_booleanize; +extern "C" GDExtensionInterfaceVariantDuplicate gdextension_interface_variant_duplicate; +extern "C" GDExtensionInterfaceVariantStringify gdextension_interface_variant_stringify; +extern "C" GDExtensionInterfaceVariantGetType gdextension_interface_variant_get_type; +extern "C" GDExtensionInterfaceVariantHasMethod gdextension_interface_variant_has_method; +extern "C" GDExtensionInterfaceVariantHasMember gdextension_interface_variant_has_member; +extern "C" GDExtensionInterfaceVariantHasKey gdextension_interface_variant_has_key; +extern "C" GDExtensionInterfaceVariantGetTypeName gdextension_interface_variant_get_type_name; +extern "C" GDExtensionInterfaceVariantCanConvert gdextension_interface_variant_can_convert; +extern "C" GDExtensionInterfaceVariantCanConvertStrict gdextension_interface_variant_can_convert_strict; +extern "C" GDExtensionInterfaceGetVariantFromTypeConstructor gdextension_interface_get_variant_from_type_constructor; +extern "C" GDExtensionInterfaceGetVariantToTypeConstructor gdextension_interface_get_variant_to_type_constructor; +extern "C" GDExtensionInterfaceVariantGetPtrOperatorEvaluator gdextension_interface_variant_get_ptr_operator_evaluator; +extern "C" GDExtensionInterfaceVariantGetPtrBuiltinMethod gdextension_interface_variant_get_ptr_builtin_method; +extern "C" GDExtensionInterfaceVariantGetPtrConstructor gdextension_interface_variant_get_ptr_constructor; +extern "C" GDExtensionInterfaceVariantGetPtrDestructor gdextension_interface_variant_get_ptr_destructor; +extern "C" GDExtensionInterfaceVariantConstruct gdextension_interface_variant_construct; +extern "C" GDExtensionInterfaceVariantGetPtrSetter gdextension_interface_variant_get_ptr_setter; +extern "C" GDExtensionInterfaceVariantGetPtrGetter gdextension_interface_variant_get_ptr_getter; +extern "C" GDExtensionInterfaceVariantGetPtrIndexedSetter gdextension_interface_variant_get_ptr_indexed_setter; +extern "C" GDExtensionInterfaceVariantGetPtrIndexedGetter gdextension_interface_variant_get_ptr_indexed_getter; +extern "C" GDExtensionInterfaceVariantGetPtrKeyedSetter gdextension_interface_variant_get_ptr_keyed_setter; +extern "C" GDExtensionInterfaceVariantGetPtrKeyedGetter gdextension_interface_variant_get_ptr_keyed_getter; +extern "C" GDExtensionInterfaceVariantGetPtrKeyedChecker gdextension_interface_variant_get_ptr_keyed_checker; +extern "C" GDExtensionInterfaceVariantGetConstantValue gdextension_interface_variant_get_constant_value; +extern "C" GDExtensionInterfaceVariantGetPtrUtilityFunction gdextension_interface_variant_get_ptr_utility_function; +extern "C" GDExtensionInterfaceStringNewWithLatin1Chars gdextension_interface_string_new_with_latin1_chars; +extern "C" GDExtensionInterfaceStringNewWithUtf8Chars gdextension_interface_string_new_with_utf8_chars; +extern "C" GDExtensionInterfaceStringNewWithUtf16Chars gdextension_interface_string_new_with_utf16_chars; +extern "C" GDExtensionInterfaceStringNewWithUtf32Chars gdextension_interface_string_new_with_utf32_chars; +extern "C" GDExtensionInterfaceStringNewWithWideChars gdextension_interface_string_new_with_wide_chars; +extern "C" GDExtensionInterfaceStringNewWithLatin1CharsAndLen gdextension_interface_string_new_with_latin1_chars_and_len; +extern "C" GDExtensionInterfaceStringNewWithUtf8CharsAndLen gdextension_interface_string_new_with_utf8_chars_and_len; +extern "C" GDExtensionInterfaceStringNewWithUtf16CharsAndLen gdextension_interface_string_new_with_utf16_chars_and_len; +extern "C" GDExtensionInterfaceStringNewWithUtf32CharsAndLen gdextension_interface_string_new_with_utf32_chars_and_len; +extern "C" GDExtensionInterfaceStringNewWithWideCharsAndLen gdextension_interface_string_new_with_wide_chars_and_len; +extern "C" GDExtensionInterfaceStringToLatin1Chars gdextension_interface_string_to_latin1_chars; +extern "C" GDExtensionInterfaceStringToUtf8Chars gdextension_interface_string_to_utf8_chars; +extern "C" GDExtensionInterfaceStringToUtf16Chars gdextension_interface_string_to_utf16_chars; +extern "C" GDExtensionInterfaceStringToUtf32Chars gdextension_interface_string_to_utf32_chars; +extern "C" GDExtensionInterfaceStringToWideChars gdextension_interface_string_to_wide_chars; +extern "C" GDExtensionInterfaceStringOperatorIndex gdextension_interface_string_operator_index; +extern "C" GDExtensionInterfaceStringOperatorIndexConst gdextension_interface_string_operator_index_const; +extern "C" GDExtensionInterfaceStringOperatorPlusEqString gdextension_interface_string_operator_plus_eq_string; +extern "C" GDExtensionInterfaceStringOperatorPlusEqChar gdextension_interface_string_operator_plus_eq_char; +extern "C" GDExtensionInterfaceStringOperatorPlusEqCstr gdextension_interface_string_operator_plus_eq_cstr; +extern "C" GDExtensionInterfaceStringOperatorPlusEqWcstr gdextension_interface_string_operator_plus_eq_wcstr; +extern "C" GDExtensionInterfaceStringOperatorPlusEqC32str gdextension_interface_string_operator_plus_eq_c32str; +extern "C" GDExtensionInterfaceXmlParserOpenBuffer gdextension_interface_xml_parser_open_buffer; +extern "C" GDExtensionInterfaceFileAccessStoreBuffer gdextension_interface_file_access_store_buffer; +extern "C" GDExtensionInterfaceFileAccessGetBuffer gdextension_interface_file_access_get_buffer; +extern "C" GDExtensionInterfaceWorkerThreadPoolAddNativeGroupTask gdextension_interface_worker_thread_pool_add_native_group_task; +extern "C" GDExtensionInterfaceWorkerThreadPoolAddNativeTask gdextension_interface_worker_thread_pool_add_native_task; +extern "C" GDExtensionInterfacePackedByteArrayOperatorIndex gdextension_interface_packed_byte_array_operator_index; +extern "C" GDExtensionInterfacePackedByteArrayOperatorIndexConst gdextension_interface_packed_byte_array_operator_index_const; +extern "C" GDExtensionInterfacePackedColorArrayOperatorIndex gdextension_interface_packed_color_array_operator_index; +extern "C" GDExtensionInterfacePackedColorArrayOperatorIndexConst gdextension_interface_packed_color_array_operator_index_const; +extern "C" GDExtensionInterfacePackedFloat32ArrayOperatorIndex gdextension_interface_packed_float32_array_operator_index; +extern "C" GDExtensionInterfacePackedFloat32ArrayOperatorIndexConst gdextension_interface_packed_float32_array_operator_index_const; +extern "C" GDExtensionInterfacePackedFloat64ArrayOperatorIndex gdextension_interface_packed_float64_array_operator_index; +extern "C" GDExtensionInterfacePackedFloat64ArrayOperatorIndexConst gdextension_interface_packed_float64_array_operator_index_const; +extern "C" GDExtensionInterfacePackedInt32ArrayOperatorIndex gdextension_interface_packed_int32_array_operator_index; +extern "C" GDExtensionInterfacePackedInt32ArrayOperatorIndexConst gdextension_interface_packed_int32_array_operator_index_const; +extern "C" GDExtensionInterfacePackedInt64ArrayOperatorIndex gdextension_interface_packed_int64_array_operator_index; +extern "C" GDExtensionInterfacePackedInt64ArrayOperatorIndexConst gdextension_interface_packed_int64_array_operator_index_const; +extern "C" GDExtensionInterfacePackedStringArrayOperatorIndex gdextension_interface_packed_string_array_operator_index; +extern "C" GDExtensionInterfacePackedStringArrayOperatorIndexConst gdextension_interface_packed_string_array_operator_index_const; +extern "C" GDExtensionInterfacePackedVector2ArrayOperatorIndex gdextension_interface_packed_vector2_array_operator_index; +extern "C" GDExtensionInterfacePackedVector2ArrayOperatorIndexConst gdextension_interface_packed_vector2_array_operator_index_const; +extern "C" GDExtensionInterfacePackedVector3ArrayOperatorIndex gdextension_interface_packed_vector3_array_operator_index; +extern "C" GDExtensionInterfacePackedVector3ArrayOperatorIndexConst gdextension_interface_packed_vector3_array_operator_index_const; +extern "C" GDExtensionInterfaceArrayOperatorIndex gdextension_interface_array_operator_index; +extern "C" GDExtensionInterfaceArrayOperatorIndexConst gdextension_interface_array_operator_index_const; +extern "C" GDExtensionInterfaceArrayRef gdextension_interface_array_ref; +extern "C" GDExtensionInterfaceArraySetTyped gdextension_interface_array_set_typed; +extern "C" GDExtensionInterfaceDictionaryOperatorIndex gdextension_interface_dictionary_operator_index; +extern "C" GDExtensionInterfaceDictionaryOperatorIndexConst gdextension_interface_dictionary_operator_index_const; +extern "C" GDExtensionInterfaceObjectMethodBindCall gdextension_interface_object_method_bind_call; +extern "C" GDExtensionInterfaceObjectMethodBindPtrcall gdextension_interface_object_method_bind_ptrcall; +extern "C" GDExtensionInterfaceObjectDestroy gdextension_interface_object_destroy; +extern "C" GDExtensionInterfaceGlobalGetSingleton gdextension_interface_global_get_singleton; +extern "C" GDExtensionInterfaceObjectGetInstanceBinding gdextension_interface_object_get_instance_binding; +extern "C" GDExtensionInterfaceObjectSetInstanceBinding gdextension_interface_object_set_instance_binding; +extern "C" GDExtensionInterfaceObjectSetInstance gdextension_interface_object_set_instance; +extern "C" GDExtensionInterfaceObjectCastTo gdextension_interface_object_cast_to; +extern "C" GDExtensionInterfaceObjectGetInstanceFromId gdextension_interface_object_get_instance_from_id; +extern "C" GDExtensionInterfaceObjectGetInstanceId gdextension_interface_object_get_instance_id; +extern "C" GDExtensionInterfaceRefGetObject gdextension_interface_ref_get_object; +extern "C" GDExtensionInterfaceRefSetObject gdextension_interface_ref_set_object; +extern "C" GDExtensionInterfaceScriptInstanceCreate gdextension_interface_script_instance_create; +extern "C" GDExtensionInterfaceClassdbConstructObject gdextension_interface_classdb_construct_object; +extern "C" GDExtensionInterfaceClassdbGetMethodBind gdextension_interface_classdb_get_method_bind; +extern "C" GDExtensionInterfaceClassdbGetClassTag gdextension_interface_classdb_get_class_tag; +extern "C" GDExtensionInterfaceClassdbRegisterExtensionClass gdextension_interface_classdb_register_extension_class; +extern "C" GDExtensionInterfaceClassdbRegisterExtensionClassMethod gdextension_interface_classdb_register_extension_class_method; +extern "C" GDExtensionInterfaceClassdbRegisterExtensionClassIntegerConstant gdextension_interface_classdb_register_extension_class_integer_constant; +extern "C" GDExtensionInterfaceClassdbRegisterExtensionClassProperty gdextension_interface_classdb_register_extension_class_property; +extern "C" GDExtensionInterfaceClassdbRegisterExtensionClassPropertyGroup gdextension_interface_classdb_register_extension_class_property_group; +extern "C" GDExtensionInterfaceClassdbRegisterExtensionClassPropertySubgroup gdextension_interface_classdb_register_extension_class_property_subgroup; +extern "C" GDExtensionInterfaceClassdbRegisterExtensionClassSignal gdextension_interface_classdb_register_extension_class_signal; +extern "C" GDExtensionInterfaceClassdbUnregisterExtensionClass gdextension_interface_classdb_unregister_extension_class; +extern "C" GDExtensionInterfaceGetLibraryPath gdextension_interface_get_library_path; + } // namespace internal enum ModuleInitializationLevel { @@ -57,22 +194,19 @@ public: static Callback init_callback; static Callback terminate_callback; static GDExtensionInitializationLevel minimum_initialization_level; - static GDExtensionBool init(const GDExtensionInterface *p_interface, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization); + static GDExtensionBool init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization); public: static void initialize_level(void *userdata, GDExtensionInitializationLevel p_level); static void deinitialize_level(void *userdata, GDExtensionInitializationLevel p_level); class InitObject { - const GDExtensionInterface *gde_interface; + GDExtensionInterfaceGetProcAddress get_proc_address; GDExtensionClassLibraryPtr library; GDExtensionInitialization *initialization; public: - InitObject(const GDExtensionInterface *p_interface, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) : - gde_interface(p_interface), - library(p_library), - initialization(r_initialization) {} + InitObject(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization); void register_initializer(Callback p_init) const; void register_terminator(Callback p_init) const; diff --git a/src/classes/low_level.cpp b/src/classes/low_level.cpp index 681b2b40..b9d0a072 100644 --- a/src/classes/low_level.cpp +++ b/src/classes/low_level.cpp @@ -36,23 +36,23 @@ namespace godot { Error XMLParser::_open_buffer(const uint8_t *p_buffer, size_t p_size) { - return (Error)internal::gde_interface->xml_parser_open_buffer(_owner, p_buffer, p_size); + return (Error)internal::gdextension_interface_xml_parser_open_buffer(_owner, p_buffer, p_size); } uint64_t FileAccess::get_buffer(uint8_t *p_dst, uint64_t p_length) const { - return internal::gde_interface->file_access_get_buffer(_owner, p_dst, p_length); + return internal::gdextension_interface_file_access_get_buffer(_owner, p_dst, p_length); } void FileAccess::store_buffer(const uint8_t *p_src, uint64_t p_length) { - internal::gde_interface->file_access_store_buffer(_owner, p_src, p_length); + internal::gdextension_interface_file_access_store_buffer(_owner, p_src, p_length); } WorkerThreadPool::TaskID WorkerThreadPool::add_native_task(void (*p_func)(void *), void *p_userdata, bool p_high_priority, const String &p_description) { - return (TaskID)internal::gde_interface->worker_thread_pool_add_native_task(_owner, p_func, p_userdata, p_high_priority, (GDExtensionConstStringPtr)&p_description); + return (TaskID)internal::gdextension_interface_worker_thread_pool_add_native_task(_owner, p_func, p_userdata, p_high_priority, (GDExtensionConstStringPtr)&p_description); } WorkerThreadPool::GroupID WorkerThreadPool::add_native_group_task(void (*p_func)(void *, uint32_t), void *p_userdata, int p_elements, int p_tasks, bool p_high_priority, const String &p_description) { - return (GroupID)internal::gde_interface->worker_thread_pool_add_native_group_task(_owner, p_func, p_userdata, p_elements, p_tasks, p_high_priority, (GDExtensionConstStringPtr)&p_description); + return (GroupID)internal::gdextension_interface_worker_thread_pool_add_native_group_task(_owner, p_func, p_userdata, p_elements, p_tasks, p_high_priority, (GDExtensionConstStringPtr)&p_description); } } // namespace godot diff --git a/src/classes/wrapped.cpp b/src/classes/wrapped.cpp index da99613d..62088a51 100644 --- a/src/classes/wrapped.cpp +++ b/src/classes/wrapped.cpp @@ -43,13 +43,13 @@ const StringName *Wrapped::_get_extension_class_name() const { void Wrapped::_postinitialize() { const StringName *extension_class = _get_extension_class_name(); if (extension_class) { - godot::internal::gde_interface->object_set_instance(_owner, reinterpret_cast(extension_class), this); + godot::internal::gdextension_interface_object_set_instance(_owner, reinterpret_cast(extension_class), this); } - godot::internal::gde_interface->object_set_instance_binding(_owner, godot::internal::token, this, _get_bindings_callbacks()); + godot::internal::gdextension_interface_object_set_instance_binding(_owner, godot::internal::token, this, _get_bindings_callbacks()); } Wrapped::Wrapped(const StringName p_godot_class) { - _owner = godot::internal::gde_interface->classdb_construct_object(reinterpret_cast(p_godot_class._native_ptr())); + _owner = godot::internal::gdextension_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 bdce68c8..a90a389b 100644 --- a/src/core/class_db.cpp +++ b/src/core/class_db.cpp @@ -55,13 +55,13 @@ MethodDefinition D_METHOD(StringName p_name, StringName p_arg1) { void ClassDB::add_property_group(const StringName &p_class, const String &p_name, const String &p_prefix) { ERR_FAIL_COND_MSG(classes.find(p_class) == classes.end(), String("Trying to add property '{0}{1}' to non-existing class '{2}'.").format(Array::make(p_prefix, p_name, p_class))); - internal::gde_interface->classdb_register_extension_class_property_group(internal::library, p_class._native_ptr(), p_name._native_ptr(), p_prefix._native_ptr()); + internal::gdextension_interface_classdb_register_extension_class_property_group(internal::library, p_class._native_ptr(), p_name._native_ptr(), p_prefix._native_ptr()); } void ClassDB::add_property_subgroup(const StringName &p_class, const String &p_name, const String &p_prefix) { ERR_FAIL_COND_MSG(classes.find(p_class) == classes.end(), String("Trying to add property '{0}{1}' to non-existing class '{2}'.").format(Array::make(p_prefix, p_name, p_class))); - internal::gde_interface->classdb_register_extension_class_property_subgroup(internal::library, p_class._native_ptr(), p_name._native_ptr(), p_prefix._native_ptr()); + internal::gdextension_interface_classdb_register_extension_class_property_subgroup(internal::library, p_class._native_ptr(), p_name._native_ptr(), p_prefix._native_ptr()); } void ClassDB::add_property(const StringName &p_class, const PropertyInfo &p_pinfo, const StringName &p_setter, const StringName &p_getter, int p_index) { @@ -111,7 +111,7 @@ void ClassDB::add_property(const StringName &p_class, const PropertyInfo &p_pinf setget.index = p_index; setget.type = p_pinfo.type; - internal::gde_interface->classdb_register_extension_class_property(internal::library, info.name._native_ptr(), &prop_info, setget.setter._native_ptr(), setget.getter._native_ptr()); + internal::gdextension_interface_classdb_register_extension_class_property(internal::library, info.name._native_ptr(), &prop_info, setget.setter._native_ptr(), setget.getter._native_ptr()); } MethodBind *ClassDB::get_method(const StringName &p_class, const StringName &p_method) { @@ -234,7 +234,7 @@ void ClassDB::bind_method_godot(const StringName &p_class_name, MethodBind *p_me (uint32_t)p_method->get_default_argument_count(), // uint32_t default_argument_count; def_args.data(), // GDExtensionVariantPtr *default_arguments; }; - internal::gde_interface->classdb_register_extension_class_method(internal::library, p_class_name._native_ptr(), &method_info); + internal::gdextension_interface_classdb_register_extension_class_method(internal::library, p_class_name._native_ptr(), &method_info); } void ClassDB::add_signal(const StringName &p_class, const MethodInfo &p_signal) { @@ -269,7 +269,7 @@ void ClassDB::add_signal(const StringName &p_class, const MethodInfo &p_signal) }); } - internal::gde_interface->classdb_register_extension_class_signal(internal::library, cl.name._native_ptr(), p_signal.name._native_ptr(), parameters.data(), parameters.size()); + internal::gdextension_interface_classdb_register_extension_class_signal(internal::library, cl.name._native_ptr(), p_signal.name._native_ptr(), parameters.data(), parameters.size()); } void ClassDB::bind_integer_constant(const StringName &p_class_name, const StringName &p_enum_name, const StringName &p_constant_name, GDExtensionInt p_constant_value, bool p_is_bitfield) { @@ -286,7 +286,7 @@ void ClassDB::bind_integer_constant(const StringName &p_class_name, const String type.constant_names.insert(p_constant_name); // Register it with Godot - internal::gde_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); + internal::gdextension_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); } GDExtensionClassCallVirtual ClassDB::get_virtual_func(void *p_userdata, GDExtensionConstStringNamePtr p_name) { // This is called by Godot the first time it calls a virtual function, and it caches the result, per object instance. @@ -347,7 +347,7 @@ void ClassDB::deinitialize(GDExtensionInitializationLevel p_level) { continue; } - internal::gde_interface->classdb_unregister_extension_class(internal::library, cl.name._native_ptr()); + internal::gdextension_interface_classdb_unregister_extension_class(internal::library, cl.name._native_ptr()); for (auto method : cl.method_map) { memdelete(method.second); diff --git a/src/core/error_macros.cpp b/src/core/error_macros.cpp index 12a9ece7..685f70de 100644 --- a/src/core/error_macros.cpp +++ b/src/core/error_macros.cpp @@ -39,9 +39,9 @@ namespace godot { void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, bool p_editor_notify, bool p_is_warning) { if (p_is_warning) { - internal::gde_interface->print_warning(p_error, p_function, p_file, p_line, p_editor_notify); + internal::gdextension_interface_print_warning(p_error, p_function, p_file, p_line, p_editor_notify); } else { - internal::gde_interface->print_error(p_error, p_function, p_file, p_line, p_editor_notify); + internal::gdextension_interface_print_error(p_error, p_function, p_file, p_line, p_editor_notify); } } @@ -51,9 +51,9 @@ void _err_print_error(const char *p_function, const char *p_file, int p_line, co void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, const char *p_message, bool p_editor_notify, bool p_is_warning) { if (p_is_warning) { - internal::gde_interface->print_warning_with_message(p_error, p_message, p_function, p_file, p_line, p_editor_notify); + internal::gdextension_interface_print_warning_with_message(p_error, p_message, p_function, p_file, p_line, p_editor_notify); } else { - internal::gde_interface->print_error_with_message(p_error, p_message, p_function, p_file, p_line, p_editor_notify); + internal::gdextension_interface_print_error_with_message(p_error, p_message, p_function, p_file, p_line, p_editor_notify); } } diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 8feda578..17b06964 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -41,7 +41,7 @@ void *Memory::alloc_static(size_t p_bytes, bool p_pad_align) { bool prepad = p_pad_align; #endif - void *mem = internal::gde_interface->mem_alloc(p_bytes + (prepad ? PAD_ALIGN : 0)); + void *mem = internal::gdextension_interface_mem_alloc(p_bytes + (prepad ? PAD_ALIGN : 0)); ERR_FAIL_COND_V(!mem, nullptr); if (prepad) { @@ -70,11 +70,11 @@ void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) { if (prepad) { mem -= PAD_ALIGN; - mem = (uint8_t *)internal::gde_interface->mem_realloc(mem, p_bytes + PAD_ALIGN); + mem = (uint8_t *)internal::gdextension_interface_mem_realloc(mem, p_bytes + PAD_ALIGN); ERR_FAIL_COND_V(!mem, nullptr); return mem + PAD_ALIGN; } else { - return (uint8_t *)internal::gde_interface->mem_realloc(mem, p_bytes); + return (uint8_t *)internal::gdextension_interface_mem_realloc(mem, p_bytes); } } @@ -90,7 +90,7 @@ void Memory::free_static(void *p_ptr, bool p_pad_align) { if (prepad) { mem -= PAD_ALIGN; } - internal::gde_interface->mem_free(mem); + internal::gdextension_interface_mem_free(mem); } _GlobalNil::_GlobalNil() { diff --git a/src/core/method_bind.cpp b/src/core/method_bind.cpp index 2b28e186..0b9b5eba 100644 --- a/src/core/method_bind.cpp +++ b/src/core/method_bind.cpp @@ -96,7 +96,7 @@ void MethodBind::bind_call(void *p_method_userdata, GDExtensionClassInstancePtr 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. // Since only GDExtensionMethodBind calls this from the Godot side, it should always be the case. - internal::gde_interface->variant_new_copy(r_return, ret._native_ptr()); + internal::gdextension_interface_variant_new_copy(r_return, ret._native_ptr()); } void MethodBind::bind_ptrcall(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_return) { diff --git a/src/godot.cpp b/src/godot.cpp index 9dd93dd3..25828a79 100644 --- a/src/godot.cpp +++ b/src/godot.cpp @@ -41,21 +41,329 @@ namespace godot { namespace internal { -const GDExtensionInterface *gde_interface = nullptr; +GDExtensionInterfaceGetProcAddress gdextension_interface_get_proc_address = nullptr; GDExtensionClassLibraryPtr library = nullptr; void *token = nullptr; +GDExtensionGodotVersion godot_version = { 0, 0, 0, nullptr }; + +// All of the GDExtension interface functions. +GDExtensionInterfaceGetGodotVersion gdextension_interface_get_godot_version = nullptr; +GDExtensionInterfaceMemAlloc gdextension_interface_mem_alloc = nullptr; +GDExtensionInterfaceMemRealloc gdextension_interface_mem_realloc = nullptr; +GDExtensionInterfaceMemFree gdextension_interface_mem_free = nullptr; +GDExtensionInterfacePrintError gdextension_interface_print_error = nullptr; +GDExtensionInterfacePrintErrorWithMessage gdextension_interface_print_error_with_message = nullptr; +GDExtensionInterfacePrintWarning gdextension_interface_print_warning = nullptr; +GDExtensionInterfacePrintWarningWithMessage gdextension_interface_print_warning_with_message = nullptr; +GDExtensionInterfacePrintScriptError gdextension_interface_print_script_error = nullptr; +GDExtensionInterfacePrintScriptErrorWithMessage gdextension_interface_print_script_error_with_message = nullptr; +GDExtensionInterfaceGetNativeStructSize gdextension_interface_get_native_struct_size = nullptr; +GDExtensionInterfaceVariantNewCopy gdextension_interface_variant_new_copy = nullptr; +GDExtensionInterfaceVariantNewNil gdextension_interface_variant_new_nil = nullptr; +GDExtensionInterfaceVariantDestroy gdextension_interface_variant_destroy = nullptr; +GDExtensionInterfaceVariantCall gdextension_interface_variant_call = nullptr; +GDExtensionInterfaceVariantCallStatic gdextension_interface_variant_call_static = nullptr; +GDExtensionInterfaceVariantEvaluate gdextension_interface_variant_evaluate = nullptr; +GDExtensionInterfaceVariantSet gdextension_interface_variant_set = nullptr; +GDExtensionInterfaceVariantSetNamed gdextension_interface_variant_set_named = nullptr; +GDExtensionInterfaceVariantSetKeyed gdextension_interface_variant_set_keyed = nullptr; +GDExtensionInterfaceVariantSetIndexed gdextension_interface_variant_set_indexed = nullptr; +GDExtensionInterfaceVariantGet gdextension_interface_variant_get = nullptr; +GDExtensionInterfaceVariantGetNamed gdextension_interface_variant_get_named = nullptr; +GDExtensionInterfaceVariantGetKeyed gdextension_interface_variant_get_keyed = nullptr; +GDExtensionInterfaceVariantGetIndexed gdextension_interface_variant_get_indexed = nullptr; +GDExtensionInterfaceVariantIterInit gdextension_interface_variant_iter_init = nullptr; +GDExtensionInterfaceVariantIterNext gdextension_interface_variant_iter_next = nullptr; +GDExtensionInterfaceVariantIterGet gdextension_interface_variant_iter_get = nullptr; +GDExtensionInterfaceVariantHash gdextension_interface_variant_hash = nullptr; +GDExtensionInterfaceVariantRecursiveHash gdextension_interface_variant_recursive_hash = nullptr; +GDExtensionInterfaceVariantHashCompare gdextension_interface_variant_hash_compare = nullptr; +GDExtensionInterfaceVariantBooleanize gdextension_interface_variant_booleanize = nullptr; +GDExtensionInterfaceVariantDuplicate gdextension_interface_variant_duplicate = nullptr; +GDExtensionInterfaceVariantStringify gdextension_interface_variant_stringify = nullptr; +GDExtensionInterfaceVariantGetType gdextension_interface_variant_get_type = nullptr; +GDExtensionInterfaceVariantHasMethod gdextension_interface_variant_has_method = nullptr; +GDExtensionInterfaceVariantHasMember gdextension_interface_variant_has_member = nullptr; +GDExtensionInterfaceVariantHasKey gdextension_interface_variant_has_key = nullptr; +GDExtensionInterfaceVariantGetTypeName gdextension_interface_variant_get_type_name = nullptr; +GDExtensionInterfaceVariantCanConvert gdextension_interface_variant_can_convert = nullptr; +GDExtensionInterfaceVariantCanConvertStrict gdextension_interface_variant_can_convert_strict = nullptr; +GDExtensionInterfaceGetVariantFromTypeConstructor gdextension_interface_get_variant_from_type_constructor = nullptr; +GDExtensionInterfaceGetVariantToTypeConstructor gdextension_interface_get_variant_to_type_constructor = nullptr; +GDExtensionInterfaceVariantGetPtrOperatorEvaluator gdextension_interface_variant_get_ptr_operator_evaluator = nullptr; +GDExtensionInterfaceVariantGetPtrBuiltinMethod gdextension_interface_variant_get_ptr_builtin_method = nullptr; +GDExtensionInterfaceVariantGetPtrConstructor gdextension_interface_variant_get_ptr_constructor = nullptr; +GDExtensionInterfaceVariantGetPtrDestructor gdextension_interface_variant_get_ptr_destructor = nullptr; +GDExtensionInterfaceVariantConstruct gdextension_interface_variant_construct = nullptr; +GDExtensionInterfaceVariantGetPtrSetter gdextension_interface_variant_get_ptr_setter = nullptr; +GDExtensionInterfaceVariantGetPtrGetter gdextension_interface_variant_get_ptr_getter = nullptr; +GDExtensionInterfaceVariantGetPtrIndexedSetter gdextension_interface_variant_get_ptr_indexed_setter = nullptr; +GDExtensionInterfaceVariantGetPtrIndexedGetter gdextension_interface_variant_get_ptr_indexed_getter = nullptr; +GDExtensionInterfaceVariantGetPtrKeyedSetter gdextension_interface_variant_get_ptr_keyed_setter = nullptr; +GDExtensionInterfaceVariantGetPtrKeyedGetter gdextension_interface_variant_get_ptr_keyed_getter = nullptr; +GDExtensionInterfaceVariantGetPtrKeyedChecker gdextension_interface_variant_get_ptr_keyed_checker = nullptr; +GDExtensionInterfaceVariantGetConstantValue gdextension_interface_variant_get_constant_value = nullptr; +GDExtensionInterfaceVariantGetPtrUtilityFunction gdextension_interface_variant_get_ptr_utility_function = nullptr; +GDExtensionInterfaceStringNewWithLatin1Chars gdextension_interface_string_new_with_latin1_chars = nullptr; +GDExtensionInterfaceStringNewWithUtf8Chars gdextension_interface_string_new_with_utf8_chars = nullptr; +GDExtensionInterfaceStringNewWithUtf16Chars gdextension_interface_string_new_with_utf16_chars = nullptr; +GDExtensionInterfaceStringNewWithUtf32Chars gdextension_interface_string_new_with_utf32_chars = nullptr; +GDExtensionInterfaceStringNewWithWideChars gdextension_interface_string_new_with_wide_chars = nullptr; +GDExtensionInterfaceStringNewWithLatin1CharsAndLen gdextension_interface_string_new_with_latin1_chars_and_len = nullptr; +GDExtensionInterfaceStringNewWithUtf8CharsAndLen gdextension_interface_string_new_with_utf8_chars_and_len = nullptr; +GDExtensionInterfaceStringNewWithUtf16CharsAndLen gdextension_interface_string_new_with_utf16_chars_and_len = nullptr; +GDExtensionInterfaceStringNewWithUtf32CharsAndLen gdextension_interface_string_new_with_utf32_chars_and_len = nullptr; +GDExtensionInterfaceStringNewWithWideCharsAndLen gdextension_interface_string_new_with_wide_chars_and_len = nullptr; +GDExtensionInterfaceStringToLatin1Chars gdextension_interface_string_to_latin1_chars = nullptr; +GDExtensionInterfaceStringToUtf8Chars gdextension_interface_string_to_utf8_chars = nullptr; +GDExtensionInterfaceStringToUtf16Chars gdextension_interface_string_to_utf16_chars = nullptr; +GDExtensionInterfaceStringToUtf32Chars gdextension_interface_string_to_utf32_chars = nullptr; +GDExtensionInterfaceStringToWideChars gdextension_interface_string_to_wide_chars = nullptr; +GDExtensionInterfaceStringOperatorIndex gdextension_interface_string_operator_index = nullptr; +GDExtensionInterfaceStringOperatorIndexConst gdextension_interface_string_operator_index_const = nullptr; +GDExtensionInterfaceStringOperatorPlusEqString gdextension_interface_string_operator_plus_eq_string = nullptr; +GDExtensionInterfaceStringOperatorPlusEqChar gdextension_interface_string_operator_plus_eq_char = nullptr; +GDExtensionInterfaceStringOperatorPlusEqCstr gdextension_interface_string_operator_plus_eq_cstr = nullptr; +GDExtensionInterfaceStringOperatorPlusEqWcstr gdextension_interface_string_operator_plus_eq_wcstr = nullptr; +GDExtensionInterfaceStringOperatorPlusEqC32str gdextension_interface_string_operator_plus_eq_c32str = nullptr; +GDExtensionInterfaceXmlParserOpenBuffer gdextension_interface_xml_parser_open_buffer = nullptr; +GDExtensionInterfaceFileAccessStoreBuffer gdextension_interface_file_access_store_buffer = nullptr; +GDExtensionInterfaceFileAccessGetBuffer gdextension_interface_file_access_get_buffer = nullptr; +GDExtensionInterfaceWorkerThreadPoolAddNativeGroupTask gdextension_interface_worker_thread_pool_add_native_group_task = nullptr; +GDExtensionInterfaceWorkerThreadPoolAddNativeTask gdextension_interface_worker_thread_pool_add_native_task = nullptr; +GDExtensionInterfacePackedByteArrayOperatorIndex gdextension_interface_packed_byte_array_operator_index = nullptr; +GDExtensionInterfacePackedByteArrayOperatorIndexConst gdextension_interface_packed_byte_array_operator_index_const = nullptr; +GDExtensionInterfacePackedColorArrayOperatorIndex gdextension_interface_packed_color_array_operator_index = nullptr; +GDExtensionInterfacePackedColorArrayOperatorIndexConst gdextension_interface_packed_color_array_operator_index_const = nullptr; +GDExtensionInterfacePackedFloat32ArrayOperatorIndex gdextension_interface_packed_float32_array_operator_index = nullptr; +GDExtensionInterfacePackedFloat32ArrayOperatorIndexConst gdextension_interface_packed_float32_array_operator_index_const = nullptr; +GDExtensionInterfacePackedFloat64ArrayOperatorIndex gdextension_interface_packed_float64_array_operator_index = nullptr; +GDExtensionInterfacePackedFloat64ArrayOperatorIndexConst gdextension_interface_packed_float64_array_operator_index_const = nullptr; +GDExtensionInterfacePackedInt32ArrayOperatorIndex gdextension_interface_packed_int32_array_operator_index = nullptr; +GDExtensionInterfacePackedInt32ArrayOperatorIndexConst gdextension_interface_packed_int32_array_operator_index_const = nullptr; +GDExtensionInterfacePackedInt64ArrayOperatorIndex gdextension_interface_packed_int64_array_operator_index = nullptr; +GDExtensionInterfacePackedInt64ArrayOperatorIndexConst gdextension_interface_packed_int64_array_operator_index_const = nullptr; +GDExtensionInterfacePackedStringArrayOperatorIndex gdextension_interface_packed_string_array_operator_index = nullptr; +GDExtensionInterfacePackedStringArrayOperatorIndexConst gdextension_interface_packed_string_array_operator_index_const = nullptr; +GDExtensionInterfacePackedVector2ArrayOperatorIndex gdextension_interface_packed_vector2_array_operator_index = nullptr; +GDExtensionInterfacePackedVector2ArrayOperatorIndexConst gdextension_interface_packed_vector2_array_operator_index_const = nullptr; +GDExtensionInterfacePackedVector3ArrayOperatorIndex gdextension_interface_packed_vector3_array_operator_index = nullptr; +GDExtensionInterfacePackedVector3ArrayOperatorIndexConst gdextension_interface_packed_vector3_array_operator_index_const = nullptr; +GDExtensionInterfaceArrayOperatorIndex gdextension_interface_array_operator_index = nullptr; +GDExtensionInterfaceArrayOperatorIndexConst gdextension_interface_array_operator_index_const = nullptr; +GDExtensionInterfaceArrayRef gdextension_interface_array_ref = nullptr; +GDExtensionInterfaceArraySetTyped gdextension_interface_array_set_typed = nullptr; +GDExtensionInterfaceDictionaryOperatorIndex gdextension_interface_dictionary_operator_index = nullptr; +GDExtensionInterfaceDictionaryOperatorIndexConst gdextension_interface_dictionary_operator_index_const = nullptr; +GDExtensionInterfaceObjectMethodBindCall gdextension_interface_object_method_bind_call = nullptr; +GDExtensionInterfaceObjectMethodBindPtrcall gdextension_interface_object_method_bind_ptrcall = nullptr; +GDExtensionInterfaceObjectDestroy gdextension_interface_object_destroy = nullptr; +GDExtensionInterfaceGlobalGetSingleton gdextension_interface_global_get_singleton = nullptr; +GDExtensionInterfaceObjectGetInstanceBinding gdextension_interface_object_get_instance_binding = nullptr; +GDExtensionInterfaceObjectSetInstanceBinding gdextension_interface_object_set_instance_binding = nullptr; +GDExtensionInterfaceObjectSetInstance gdextension_interface_object_set_instance = nullptr; +GDExtensionInterfaceObjectCastTo gdextension_interface_object_cast_to = nullptr; +GDExtensionInterfaceObjectGetInstanceFromId gdextension_interface_object_get_instance_from_id = nullptr; +GDExtensionInterfaceObjectGetInstanceId gdextension_interface_object_get_instance_id = nullptr; +GDExtensionInterfaceRefGetObject gdextension_interface_ref_get_object = nullptr; +GDExtensionInterfaceRefSetObject gdextension_interface_ref_set_object = nullptr; +GDExtensionInterfaceScriptInstanceCreate gdextension_interface_script_instance_create = nullptr; +GDExtensionInterfaceClassdbConstructObject gdextension_interface_classdb_construct_object = nullptr; +GDExtensionInterfaceClassdbGetMethodBind gdextension_interface_classdb_get_method_bind = nullptr; +GDExtensionInterfaceClassdbGetClassTag gdextension_interface_classdb_get_class_tag = nullptr; +GDExtensionInterfaceClassdbRegisterExtensionClass gdextension_interface_classdb_register_extension_class = nullptr; +GDExtensionInterfaceClassdbRegisterExtensionClassMethod gdextension_interface_classdb_register_extension_class_method = nullptr; +GDExtensionInterfaceClassdbRegisterExtensionClassIntegerConstant gdextension_interface_classdb_register_extension_class_integer_constant = nullptr; +GDExtensionInterfaceClassdbRegisterExtensionClassProperty gdextension_interface_classdb_register_extension_class_property = nullptr; +GDExtensionInterfaceClassdbRegisterExtensionClassPropertyGroup gdextension_interface_classdb_register_extension_class_property_group = nullptr; +GDExtensionInterfaceClassdbRegisterExtensionClassPropertySubgroup gdextension_interface_classdb_register_extension_class_property_subgroup = nullptr; +GDExtensionInterfaceClassdbRegisterExtensionClassSignal gdextension_interface_classdb_register_extension_class_signal = nullptr; +GDExtensionInterfaceClassdbUnregisterExtensionClass gdextension_interface_classdb_unregister_extension_class = nullptr; +GDExtensionInterfaceGetLibraryPath gdextension_interface_get_library_path = nullptr; + } // namespace internal GDExtensionBinding::Callback GDExtensionBinding::init_callback = nullptr; GDExtensionBinding::Callback GDExtensionBinding::terminate_callback = nullptr; GDExtensionInitializationLevel GDExtensionBinding::minimum_initialization_level = GDEXTENSION_INITIALIZATION_CORE; -GDExtensionBool GDExtensionBinding::init(const GDExtensionInterface *p_interface, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) { - internal::gde_interface = p_interface; +#define LOAD_PROC_ADDRESS(m_name, m_type) \ + internal::gdextension_interface_##m_name = (m_type)p_get_proc_address(#m_name); \ + ERR_FAIL_NULL_V_MSG(internal::gdextension_interface_##m_name, false, "Unable to load GDExtension interface function " #m_name "()") + +// Partial definition of the legacy interface so we can detect it and show an error. +typedef struct { + uint32_t version_major; + uint32_t version_minor; + uint32_t version_patch; + const char *version_string; + + GDExtensionInterfaceFunctionPtr unused1; + GDExtensionInterfaceFunctionPtr unused2; + GDExtensionInterfaceFunctionPtr unused3; + + GDExtensionInterfacePrintError print_error; + GDExtensionInterfacePrintErrorWithMessage print_error_with_message; +} LegacyGDExtensionInterface; + +GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) { + // Make sure we weren't passed the legacy struct. + uint32_t *raw_interface = (uint32_t *)(void *)p_get_proc_address; + if (raw_interface[0] == 4 && raw_interface[1] == 0) { + // Use the legacy interface only to give a nice error. + LegacyGDExtensionInterface *legacy_interface = (LegacyGDExtensionInterface *)p_get_proc_address; + internal::gdextension_interface_print_error_with_message = (GDExtensionInterfacePrintErrorWithMessage)legacy_interface->print_error_with_message; + ERR_FAIL_V_MSG(false, "Cannot load a GDExtension built for Godot 4.1+ in legacy Godot 4.0 mode."); + } + + // Load the "print_error_with_message" function first (needed by the ERR_FAIL_NULL_V_MSG() macro). + internal::gdextension_interface_print_error_with_message = (GDExtensionInterfacePrintErrorWithMessage)p_get_proc_address("print_error_with_message"); + if (!internal::gdextension_interface_print_error_with_message) { + printf("ERROR: Unable to load GDExtension interface function print_error_with_message().\n"); + return false; + } + + internal::gdextension_interface_get_proc_address = p_get_proc_address; internal::library = p_library; internal::token = p_library; + LOAD_PROC_ADDRESS(get_godot_version, GDExtensionInterfaceGetGodotVersion); + LOAD_PROC_ADDRESS(mem_alloc, GDExtensionInterfaceMemAlloc); + LOAD_PROC_ADDRESS(mem_realloc, GDExtensionInterfaceMemRealloc); + LOAD_PROC_ADDRESS(mem_free, GDExtensionInterfaceMemFree); + LOAD_PROC_ADDRESS(print_error_with_message, GDExtensionInterfacePrintErrorWithMessage); + LOAD_PROC_ADDRESS(print_warning, GDExtensionInterfacePrintWarning); + LOAD_PROC_ADDRESS(print_warning_with_message, GDExtensionInterfacePrintWarningWithMessage); + LOAD_PROC_ADDRESS(print_script_error, GDExtensionInterfacePrintScriptError); + LOAD_PROC_ADDRESS(print_script_error_with_message, GDExtensionInterfacePrintScriptErrorWithMessage); + LOAD_PROC_ADDRESS(get_native_struct_size, GDExtensionInterfaceGetNativeStructSize); + LOAD_PROC_ADDRESS(variant_new_copy, GDExtensionInterfaceVariantNewCopy); + LOAD_PROC_ADDRESS(variant_new_nil, GDExtensionInterfaceVariantNewNil); + LOAD_PROC_ADDRESS(variant_destroy, GDExtensionInterfaceVariantDestroy); + LOAD_PROC_ADDRESS(variant_call, GDExtensionInterfaceVariantCall); + LOAD_PROC_ADDRESS(variant_call_static, GDExtensionInterfaceVariantCallStatic); + LOAD_PROC_ADDRESS(variant_evaluate, GDExtensionInterfaceVariantEvaluate); + LOAD_PROC_ADDRESS(variant_set, GDExtensionInterfaceVariantSet); + LOAD_PROC_ADDRESS(variant_set_named, GDExtensionInterfaceVariantSetNamed); + LOAD_PROC_ADDRESS(variant_set_keyed, GDExtensionInterfaceVariantSetKeyed); + LOAD_PROC_ADDRESS(variant_set_indexed, GDExtensionInterfaceVariantSetIndexed); + LOAD_PROC_ADDRESS(variant_get, GDExtensionInterfaceVariantGet); + LOAD_PROC_ADDRESS(variant_get_named, GDExtensionInterfaceVariantGetNamed); + LOAD_PROC_ADDRESS(variant_get_keyed, GDExtensionInterfaceVariantGetKeyed); + LOAD_PROC_ADDRESS(variant_get_indexed, GDExtensionInterfaceVariantGetIndexed); + LOAD_PROC_ADDRESS(variant_iter_init, GDExtensionInterfaceVariantIterInit); + LOAD_PROC_ADDRESS(variant_iter_next, GDExtensionInterfaceVariantIterNext); + LOAD_PROC_ADDRESS(variant_iter_get, GDExtensionInterfaceVariantIterGet); + LOAD_PROC_ADDRESS(variant_hash, GDExtensionInterfaceVariantHash); + LOAD_PROC_ADDRESS(variant_recursive_hash, GDExtensionInterfaceVariantRecursiveHash); + LOAD_PROC_ADDRESS(variant_hash_compare, GDExtensionInterfaceVariantHashCompare); + LOAD_PROC_ADDRESS(variant_booleanize, GDExtensionInterfaceVariantBooleanize); + LOAD_PROC_ADDRESS(variant_duplicate, GDExtensionInterfaceVariantDuplicate); + LOAD_PROC_ADDRESS(variant_stringify, GDExtensionInterfaceVariantStringify); + LOAD_PROC_ADDRESS(variant_get_type, GDExtensionInterfaceVariantGetType); + LOAD_PROC_ADDRESS(variant_has_method, GDExtensionInterfaceVariantHasMethod); + LOAD_PROC_ADDRESS(variant_has_member, GDExtensionInterfaceVariantHasMember); + LOAD_PROC_ADDRESS(variant_has_key, GDExtensionInterfaceVariantHasKey); + LOAD_PROC_ADDRESS(variant_get_type_name, GDExtensionInterfaceVariantGetTypeName); + LOAD_PROC_ADDRESS(variant_can_convert, GDExtensionInterfaceVariantCanConvert); + LOAD_PROC_ADDRESS(variant_can_convert_strict, GDExtensionInterfaceVariantCanConvertStrict); + LOAD_PROC_ADDRESS(get_variant_from_type_constructor, GDExtensionInterfaceGetVariantFromTypeConstructor); + LOAD_PROC_ADDRESS(get_variant_to_type_constructor, GDExtensionInterfaceGetVariantToTypeConstructor); + LOAD_PROC_ADDRESS(variant_get_ptr_operator_evaluator, GDExtensionInterfaceVariantGetPtrOperatorEvaluator); + LOAD_PROC_ADDRESS(variant_get_ptr_builtin_method, GDExtensionInterfaceVariantGetPtrBuiltinMethod); + LOAD_PROC_ADDRESS(variant_get_ptr_constructor, GDExtensionInterfaceVariantGetPtrConstructor); + LOAD_PROC_ADDRESS(variant_get_ptr_destructor, GDExtensionInterfaceVariantGetPtrDestructor); + LOAD_PROC_ADDRESS(variant_construct, GDExtensionInterfaceVariantConstruct); + LOAD_PROC_ADDRESS(variant_get_ptr_setter, GDExtensionInterfaceVariantGetPtrSetter); + LOAD_PROC_ADDRESS(variant_get_ptr_getter, GDExtensionInterfaceVariantGetPtrGetter); + LOAD_PROC_ADDRESS(variant_get_ptr_indexed_setter, GDExtensionInterfaceVariantGetPtrIndexedSetter); + LOAD_PROC_ADDRESS(variant_get_ptr_indexed_getter, GDExtensionInterfaceVariantGetPtrIndexedGetter); + LOAD_PROC_ADDRESS(variant_get_ptr_keyed_setter, GDExtensionInterfaceVariantGetPtrKeyedSetter); + LOAD_PROC_ADDRESS(variant_get_ptr_keyed_getter, GDExtensionInterfaceVariantGetPtrKeyedGetter); + LOAD_PROC_ADDRESS(variant_get_ptr_keyed_checker, GDExtensionInterfaceVariantGetPtrKeyedChecker); + LOAD_PROC_ADDRESS(variant_get_constant_value, GDExtensionInterfaceVariantGetConstantValue); + LOAD_PROC_ADDRESS(variant_get_ptr_utility_function, GDExtensionInterfaceVariantGetPtrUtilityFunction); + LOAD_PROC_ADDRESS(string_new_with_latin1_chars, GDExtensionInterfaceStringNewWithLatin1Chars); + LOAD_PROC_ADDRESS(string_new_with_utf8_chars, GDExtensionInterfaceStringNewWithUtf8Chars); + LOAD_PROC_ADDRESS(string_new_with_utf16_chars, GDExtensionInterfaceStringNewWithUtf16Chars); + LOAD_PROC_ADDRESS(string_new_with_utf32_chars, GDExtensionInterfaceStringNewWithUtf32Chars); + LOAD_PROC_ADDRESS(string_new_with_wide_chars, GDExtensionInterfaceStringNewWithWideChars); + LOAD_PROC_ADDRESS(string_new_with_latin1_chars_and_len, GDExtensionInterfaceStringNewWithLatin1CharsAndLen); + LOAD_PROC_ADDRESS(string_new_with_utf8_chars_and_len, GDExtensionInterfaceStringNewWithUtf8CharsAndLen); + LOAD_PROC_ADDRESS(string_new_with_utf16_chars_and_len, GDExtensionInterfaceStringNewWithUtf16CharsAndLen); + LOAD_PROC_ADDRESS(string_new_with_utf32_chars_and_len, GDExtensionInterfaceStringNewWithUtf32CharsAndLen); + LOAD_PROC_ADDRESS(string_new_with_wide_chars_and_len, GDExtensionInterfaceStringNewWithWideCharsAndLen); + LOAD_PROC_ADDRESS(string_to_latin1_chars, GDExtensionInterfaceStringToLatin1Chars); + LOAD_PROC_ADDRESS(string_to_utf8_chars, GDExtensionInterfaceStringToUtf8Chars); + LOAD_PROC_ADDRESS(string_to_utf16_chars, GDExtensionInterfaceStringToUtf16Chars); + LOAD_PROC_ADDRESS(string_to_utf32_chars, GDExtensionInterfaceStringToUtf32Chars); + LOAD_PROC_ADDRESS(string_to_wide_chars, GDExtensionInterfaceStringToWideChars); + LOAD_PROC_ADDRESS(string_operator_index, GDExtensionInterfaceStringOperatorIndex); + LOAD_PROC_ADDRESS(string_operator_index_const, GDExtensionInterfaceStringOperatorIndexConst); + LOAD_PROC_ADDRESS(string_operator_plus_eq_string, GDExtensionInterfaceStringOperatorPlusEqString); + LOAD_PROC_ADDRESS(string_operator_plus_eq_char, GDExtensionInterfaceStringOperatorPlusEqChar); + LOAD_PROC_ADDRESS(string_operator_plus_eq_cstr, GDExtensionInterfaceStringOperatorPlusEqCstr); + LOAD_PROC_ADDRESS(string_operator_plus_eq_wcstr, GDExtensionInterfaceStringOperatorPlusEqWcstr); + LOAD_PROC_ADDRESS(string_operator_plus_eq_c32str, GDExtensionInterfaceStringOperatorPlusEqC32str); + LOAD_PROC_ADDRESS(xml_parser_open_buffer, GDExtensionInterfaceXmlParserOpenBuffer); + LOAD_PROC_ADDRESS(file_access_store_buffer, GDExtensionInterfaceFileAccessStoreBuffer); + LOAD_PROC_ADDRESS(file_access_get_buffer, GDExtensionInterfaceFileAccessGetBuffer); + LOAD_PROC_ADDRESS(worker_thread_pool_add_native_group_task, GDExtensionInterfaceWorkerThreadPoolAddNativeGroupTask); + LOAD_PROC_ADDRESS(worker_thread_pool_add_native_task, GDExtensionInterfaceWorkerThreadPoolAddNativeTask); + LOAD_PROC_ADDRESS(packed_byte_array_operator_index, GDExtensionInterfacePackedByteArrayOperatorIndex); + LOAD_PROC_ADDRESS(packed_byte_array_operator_index_const, GDExtensionInterfacePackedByteArrayOperatorIndexConst); + LOAD_PROC_ADDRESS(packed_color_array_operator_index, GDExtensionInterfacePackedColorArrayOperatorIndex); + LOAD_PROC_ADDRESS(packed_color_array_operator_index_const, GDExtensionInterfacePackedColorArrayOperatorIndexConst); + LOAD_PROC_ADDRESS(packed_float32_array_operator_index, GDExtensionInterfacePackedFloat32ArrayOperatorIndex); + LOAD_PROC_ADDRESS(packed_float32_array_operator_index_const, GDExtensionInterfacePackedFloat32ArrayOperatorIndexConst); + LOAD_PROC_ADDRESS(packed_float64_array_operator_index, GDExtensionInterfacePackedFloat64ArrayOperatorIndex); + LOAD_PROC_ADDRESS(packed_float64_array_operator_index_const, GDExtensionInterfacePackedFloat64ArrayOperatorIndexConst); + LOAD_PROC_ADDRESS(packed_int32_array_operator_index, GDExtensionInterfacePackedInt32ArrayOperatorIndex); + LOAD_PROC_ADDRESS(packed_int32_array_operator_index_const, GDExtensionInterfacePackedInt32ArrayOperatorIndexConst); + LOAD_PROC_ADDRESS(packed_int64_array_operator_index, GDExtensionInterfacePackedInt64ArrayOperatorIndex); + LOAD_PROC_ADDRESS(packed_int64_array_operator_index_const, GDExtensionInterfacePackedInt64ArrayOperatorIndexConst); + LOAD_PROC_ADDRESS(packed_string_array_operator_index, GDExtensionInterfacePackedStringArrayOperatorIndex); + LOAD_PROC_ADDRESS(packed_string_array_operator_index_const, GDExtensionInterfacePackedStringArrayOperatorIndexConst); + LOAD_PROC_ADDRESS(packed_vector2_array_operator_index, GDExtensionInterfacePackedVector2ArrayOperatorIndex); + LOAD_PROC_ADDRESS(packed_vector2_array_operator_index_const, GDExtensionInterfacePackedVector2ArrayOperatorIndexConst); + LOAD_PROC_ADDRESS(packed_vector3_array_operator_index, GDExtensionInterfacePackedVector3ArrayOperatorIndex); + LOAD_PROC_ADDRESS(packed_vector3_array_operator_index_const, GDExtensionInterfacePackedVector3ArrayOperatorIndexConst); + LOAD_PROC_ADDRESS(array_operator_index, GDExtensionInterfaceArrayOperatorIndex); + LOAD_PROC_ADDRESS(array_operator_index_const, GDExtensionInterfaceArrayOperatorIndexConst); + LOAD_PROC_ADDRESS(array_ref, GDExtensionInterfaceArrayRef); + LOAD_PROC_ADDRESS(array_set_typed, GDExtensionInterfaceArraySetTyped); + LOAD_PROC_ADDRESS(dictionary_operator_index, GDExtensionInterfaceDictionaryOperatorIndex); + LOAD_PROC_ADDRESS(dictionary_operator_index_const, GDExtensionInterfaceDictionaryOperatorIndexConst); + LOAD_PROC_ADDRESS(object_method_bind_call, GDExtensionInterfaceObjectMethodBindCall); + LOAD_PROC_ADDRESS(object_method_bind_ptrcall, GDExtensionInterfaceObjectMethodBindPtrcall); + LOAD_PROC_ADDRESS(object_destroy, GDExtensionInterfaceObjectDestroy); + LOAD_PROC_ADDRESS(global_get_singleton, GDExtensionInterfaceGlobalGetSingleton); + LOAD_PROC_ADDRESS(object_get_instance_binding, GDExtensionInterfaceObjectGetInstanceBinding); + LOAD_PROC_ADDRESS(object_set_instance_binding, GDExtensionInterfaceObjectSetInstanceBinding); + LOAD_PROC_ADDRESS(object_set_instance, GDExtensionInterfaceObjectSetInstance); + LOAD_PROC_ADDRESS(object_cast_to, GDExtensionInterfaceObjectCastTo); + LOAD_PROC_ADDRESS(object_get_instance_from_id, GDExtensionInterfaceObjectGetInstanceFromId); + LOAD_PROC_ADDRESS(object_get_instance_id, GDExtensionInterfaceObjectGetInstanceId); + LOAD_PROC_ADDRESS(ref_get_object, GDExtensionInterfaceRefGetObject); + LOAD_PROC_ADDRESS(ref_set_object, GDExtensionInterfaceRefSetObject); + LOAD_PROC_ADDRESS(script_instance_create, GDExtensionInterfaceScriptInstanceCreate); + LOAD_PROC_ADDRESS(classdb_construct_object, GDExtensionInterfaceClassdbConstructObject); + LOAD_PROC_ADDRESS(classdb_get_method_bind, GDExtensionInterfaceClassdbGetMethodBind); + LOAD_PROC_ADDRESS(classdb_get_class_tag, GDExtensionInterfaceClassdbGetClassTag); + LOAD_PROC_ADDRESS(classdb_register_extension_class, GDExtensionInterfaceClassdbRegisterExtensionClass); + LOAD_PROC_ADDRESS(classdb_register_extension_class_method, GDExtensionInterfaceClassdbRegisterExtensionClassMethod); + LOAD_PROC_ADDRESS(classdb_register_extension_class_integer_constant, GDExtensionInterfaceClassdbRegisterExtensionClassIntegerConstant); + LOAD_PROC_ADDRESS(classdb_register_extension_class_property, GDExtensionInterfaceClassdbRegisterExtensionClassProperty); + LOAD_PROC_ADDRESS(classdb_register_extension_class_property_group, GDExtensionInterfaceClassdbRegisterExtensionClassPropertyGroup); + LOAD_PROC_ADDRESS(classdb_register_extension_class_property_subgroup, GDExtensionInterfaceClassdbRegisterExtensionClassPropertySubgroup); + LOAD_PROC_ADDRESS(classdb_register_extension_class_signal, GDExtensionInterfaceClassdbRegisterExtensionClassSignal); + LOAD_PROC_ADDRESS(classdb_unregister_extension_class, GDExtensionInterfaceClassdbUnregisterExtensionClass); + LOAD_PROC_ADDRESS(get_library_path, GDExtensionInterfaceGetLibraryPath); + + // Load the Godot version. + internal::gdextension_interface_get_godot_version(&internal::godot_version); + r_initialization->initialize = initialize_level; r_initialization->deinitialize = deinitialize_level; r_initialization->minimum_initialization_level = minimum_initialization_level; @@ -67,6 +375,8 @@ GDExtensionBool GDExtensionBinding::init(const GDExtensionInterface *p_interface return true; } +#undef LOAD_PROC_ADDRESS + void GDExtensionBinding::initialize_level(void *userdata, GDExtensionInitializationLevel p_level) { ClassDB::current_level = p_level; @@ -86,6 +396,11 @@ void GDExtensionBinding::deinitialize_level(void *userdata, GDExtensionInitializ ClassDB::deinitialize(p_level); } +GDExtensionBinding::InitObject::InitObject(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) { + get_proc_address = p_get_proc_address; + library = p_library; + initialization = r_initialization; +} void GDExtensionBinding::InitObject::register_initializer(Callback p_init) const { GDExtensionBinding::init_callback = p_init; @@ -100,7 +415,7 @@ void GDExtensionBinding::InitObject::set_minimum_library_initialization_level(Mo } GDExtensionBool GDExtensionBinding::InitObject::init() const { - return GDExtensionBinding::init(gde_interface, library, initialization); + return GDExtensionBinding::init(get_proc_address, library, initialization); } } // namespace godot diff --git a/src/variant/char_string.cpp b/src/variant/char_string.cpp index bd0bc3ff..0c8cd0fb 100644 --- a/src/variant/char_string.cpp +++ b/src/variant/char_string.cpp @@ -153,19 +153,19 @@ CharWideString::~CharWideString() { // It's easier to have them written in C++ directly than in a Python script that generates them. String::String(const char *from) { - internal::gde_interface->string_new_with_latin1_chars(_native_ptr(), from); + internal::gdextension_interface_string_new_with_latin1_chars(_native_ptr(), from); } String::String(const wchar_t *from) { - internal::gde_interface->string_new_with_wide_chars(_native_ptr(), from); + internal::gdextension_interface_string_new_with_wide_chars(_native_ptr(), from); } String::String(const char16_t *from) { - internal::gde_interface->string_new_with_utf16_chars(_native_ptr(), from); + internal::gdextension_interface_string_new_with_utf16_chars(_native_ptr(), from); } String::String(const char32_t *from) { - internal::gde_interface->string_new_with_utf32_chars(_native_ptr(), from); + internal::gdextension_interface_string_new_with_utf32_chars(_native_ptr(), from); } String String::utf8(const char *from, int len) { @@ -175,7 +175,7 @@ String String::utf8(const char *from, int len) { } void String::parse_utf8(const char *from, int len) { - internal::gde_interface->string_new_with_utf8_chars_and_len(_native_ptr(), from, len); + internal::gdextension_interface_string_new_with_utf8_chars_and_len(_native_ptr(), from, len); } String String::utf16(const char16_t *from, int len) { @@ -185,7 +185,7 @@ String String::utf16(const char16_t *from, int len) { } void String::parse_utf16(const char16_t *from, int len) { - internal::gde_interface->string_new_with_utf16_chars_and_len(_native_ptr(), from, len); + internal::gdextension_interface_string_new_with_utf16_chars_and_len(_native_ptr(), from, len); } String String::num_real(double p_num, bool p_trailing) { @@ -226,10 +226,10 @@ String rtoss(double p_val) { } CharString String::utf8() const { - int length = internal::gde_interface->string_to_utf8_chars(_native_ptr(), nullptr, 0); + int length = internal::gdextension_interface_string_to_utf8_chars(_native_ptr(), nullptr, 0); int size = length + 1; char *cstr = memnew_arr(char, size); - internal::gde_interface->string_to_utf8_chars(_native_ptr(), cstr, length); + internal::gdextension_interface_string_to_utf8_chars(_native_ptr(), cstr, length); cstr[length] = '\0'; @@ -237,10 +237,10 @@ CharString String::utf8() const { } CharString String::ascii() const { - int length = internal::gde_interface->string_to_latin1_chars(_native_ptr(), nullptr, 0); + int length = internal::gdextension_interface_string_to_latin1_chars(_native_ptr(), nullptr, 0); int size = length + 1; char *cstr = memnew_arr(char, size); - internal::gde_interface->string_to_latin1_chars(_native_ptr(), cstr, length); + internal::gdextension_interface_string_to_latin1_chars(_native_ptr(), cstr, length); cstr[length] = '\0'; @@ -248,10 +248,10 @@ CharString String::ascii() const { } Char16String String::utf16() const { - int length = internal::gde_interface->string_to_utf16_chars(_native_ptr(), nullptr, 0); + int length = internal::gdextension_interface_string_to_utf16_chars(_native_ptr(), nullptr, 0); int size = length + 1; char16_t *cstr = memnew_arr(char16_t, size); - internal::gde_interface->string_to_utf16_chars(_native_ptr(), cstr, length); + internal::gdextension_interface_string_to_utf16_chars(_native_ptr(), cstr, length); cstr[length] = '\0'; @@ -259,10 +259,10 @@ Char16String String::utf16() const { } Char32String String::utf32() const { - int length = internal::gde_interface->string_to_utf32_chars(_native_ptr(), nullptr, 0); + int length = internal::gdextension_interface_string_to_utf32_chars(_native_ptr(), nullptr, 0); int size = length + 1; char32_t *cstr = memnew_arr(char32_t, size); - internal::gde_interface->string_to_utf32_chars(_native_ptr(), cstr, length); + internal::gdextension_interface_string_to_utf32_chars(_native_ptr(), cstr, length); cstr[length] = '\0'; @@ -270,10 +270,10 @@ Char32String String::utf32() const { } CharWideString String::wide_string() const { - int length = internal::gde_interface->string_to_wide_chars(_native_ptr(), nullptr, 0); + int length = internal::gdextension_interface_string_to_wide_chars(_native_ptr(), nullptr, 0); int size = length + 1; wchar_t *cstr = memnew_arr(wchar_t, size); - internal::gde_interface->string_to_wide_chars(_native_ptr(), cstr, length); + internal::gdextension_interface_string_to_wide_chars(_native_ptr(), cstr, length); cstr[length] = '\0'; @@ -353,44 +353,44 @@ String String::operator+(const char32_t p_char) { } String &String::operator+=(const String &p_str) { - internal::gde_interface->string_operator_plus_eq_string((GDExtensionStringPtr)this, (GDExtensionConstStringPtr)&p_str); + internal::gdextension_interface_string_operator_plus_eq_string((GDExtensionStringPtr)this, (GDExtensionConstStringPtr)&p_str); return *this; } String &String::operator+=(char32_t p_char) { - internal::gde_interface->string_operator_plus_eq_char((GDExtensionStringPtr)this, p_char); + internal::gdextension_interface_string_operator_plus_eq_char((GDExtensionStringPtr)this, p_char); return *this; } String &String::operator+=(const char *p_str) { - internal::gde_interface->string_operator_plus_eq_cstr((GDExtensionStringPtr)this, p_str); + internal::gdextension_interface_string_operator_plus_eq_cstr((GDExtensionStringPtr)this, p_str); return *this; } String &String::operator+=(const wchar_t *p_str) { - internal::gde_interface->string_operator_plus_eq_wcstr((GDExtensionStringPtr)this, p_str); + internal::gdextension_interface_string_operator_plus_eq_wcstr((GDExtensionStringPtr)this, p_str); return *this; } String &String::operator+=(const char32_t *p_str) { - internal::gde_interface->string_operator_plus_eq_c32str((GDExtensionStringPtr)this, p_str); + internal::gdextension_interface_string_operator_plus_eq_c32str((GDExtensionStringPtr)this, p_str); return *this; } const char32_t &String::operator[](int p_index) const { - return *internal::gde_interface->string_operator_index_const((GDExtensionStringPtr)this, p_index); + return *internal::gdextension_interface_string_operator_index_const((GDExtensionStringPtr)this, p_index); } char32_t &String::operator[](int p_index) { - return *internal::gde_interface->string_operator_index((GDExtensionStringPtr)this, p_index); + return *internal::gdextension_interface_string_operator_index((GDExtensionStringPtr)this, p_index); } const char32_t *String::ptr() const { - return internal::gde_interface->string_operator_index_const((GDExtensionStringPtr)this, 0); + return internal::gdextension_interface_string_operator_index_const((GDExtensionStringPtr)this, 0); } char32_t *String::ptrw() { - return internal::gde_interface->string_operator_index((GDExtensionStringPtr)this, 0); + return internal::gdextension_interface_string_operator_index((GDExtensionStringPtr)this, 0); } bool operator==(const char *p_chr, const String &p_str) { diff --git a/src/variant/packed_arrays.cpp b/src/variant/packed_arrays.cpp index a6dfabf5..65b00025 100644 --- a/src/variant/packed_arrays.cpp +++ b/src/variant/packed_arrays.cpp @@ -47,183 +47,183 @@ namespace godot { const uint8_t &PackedByteArray::operator[](int p_index) const { - return *internal::gde_interface->packed_byte_array_operator_index_const((GDExtensionTypePtr *)this, p_index); + return *internal::gdextension_interface_packed_byte_array_operator_index_const((GDExtensionTypePtr *)this, p_index); } uint8_t &PackedByteArray::operator[](int p_index) { - return *internal::gde_interface->packed_byte_array_operator_index((GDExtensionTypePtr *)this, p_index); + return *internal::gdextension_interface_packed_byte_array_operator_index((GDExtensionTypePtr *)this, p_index); } const uint8_t *PackedByteArray::ptr() const { - return internal::gde_interface->packed_byte_array_operator_index_const((GDExtensionTypePtr *)this, 0); + return internal::gdextension_interface_packed_byte_array_operator_index_const((GDExtensionTypePtr *)this, 0); } uint8_t *PackedByteArray::ptrw() { - return internal::gde_interface->packed_byte_array_operator_index((GDExtensionTypePtr *)this, 0); + return internal::gdextension_interface_packed_byte_array_operator_index((GDExtensionTypePtr *)this, 0); } const Color &PackedColorArray::operator[](int p_index) const { - const Color *color = (const Color *)internal::gde_interface->packed_color_array_operator_index_const((GDExtensionTypePtr *)this, p_index); + const Color *color = (const Color *)internal::gdextension_interface_packed_color_array_operator_index_const((GDExtensionTypePtr *)this, p_index); return *color; } Color &PackedColorArray::operator[](int p_index) { - Color *color = (Color *)internal::gde_interface->packed_color_array_operator_index((GDExtensionTypePtr *)this, p_index); + Color *color = (Color *)internal::gdextension_interface_packed_color_array_operator_index((GDExtensionTypePtr *)this, p_index); return *color; } const Color *PackedColorArray::ptr() const { - return (const Color *)internal::gde_interface->packed_color_array_operator_index_const((GDExtensionTypePtr *)this, 0); + return (const Color *)internal::gdextension_interface_packed_color_array_operator_index_const((GDExtensionTypePtr *)this, 0); } Color *PackedColorArray::ptrw() { - return (Color *)internal::gde_interface->packed_color_array_operator_index((GDExtensionTypePtr *)this, 0); + return (Color *)internal::gdextension_interface_packed_color_array_operator_index((GDExtensionTypePtr *)this, 0); } const float &PackedFloat32Array::operator[](int p_index) const { - return *internal::gde_interface->packed_float32_array_operator_index_const((GDExtensionTypePtr *)this, p_index); + return *internal::gdextension_interface_packed_float32_array_operator_index_const((GDExtensionTypePtr *)this, p_index); } float &PackedFloat32Array::operator[](int p_index) { - return *internal::gde_interface->packed_float32_array_operator_index((GDExtensionTypePtr *)this, p_index); + return *internal::gdextension_interface_packed_float32_array_operator_index((GDExtensionTypePtr *)this, p_index); } const float *PackedFloat32Array::ptr() const { - return internal::gde_interface->packed_float32_array_operator_index_const((GDExtensionTypePtr *)this, 0); + return internal::gdextension_interface_packed_float32_array_operator_index_const((GDExtensionTypePtr *)this, 0); } float *PackedFloat32Array::ptrw() { - return internal::gde_interface->packed_float32_array_operator_index((GDExtensionTypePtr *)this, 0); + return internal::gdextension_interface_packed_float32_array_operator_index((GDExtensionTypePtr *)this, 0); } const double &PackedFloat64Array::operator[](int p_index) const { - return *internal::gde_interface->packed_float64_array_operator_index_const((GDExtensionTypePtr *)this, p_index); + return *internal::gdextension_interface_packed_float64_array_operator_index_const((GDExtensionTypePtr *)this, p_index); } double &PackedFloat64Array::operator[](int p_index) { - return *internal::gde_interface->packed_float64_array_operator_index((GDExtensionTypePtr *)this, p_index); + return *internal::gdextension_interface_packed_float64_array_operator_index((GDExtensionTypePtr *)this, p_index); } const double *PackedFloat64Array::ptr() const { - return internal::gde_interface->packed_float64_array_operator_index_const((GDExtensionTypePtr *)this, 0); + return internal::gdextension_interface_packed_float64_array_operator_index_const((GDExtensionTypePtr *)this, 0); } double *PackedFloat64Array::ptrw() { - return internal::gde_interface->packed_float64_array_operator_index((GDExtensionTypePtr *)this, 0); + return internal::gdextension_interface_packed_float64_array_operator_index((GDExtensionTypePtr *)this, 0); } const int32_t &PackedInt32Array::operator[](int p_index) const { - return *internal::gde_interface->packed_int32_array_operator_index_const((GDExtensionTypePtr *)this, p_index); + return *internal::gdextension_interface_packed_int32_array_operator_index_const((GDExtensionTypePtr *)this, p_index); } int32_t &PackedInt32Array::operator[](int p_index) { - return *internal::gde_interface->packed_int32_array_operator_index((GDExtensionTypePtr *)this, p_index); + return *internal::gdextension_interface_packed_int32_array_operator_index((GDExtensionTypePtr *)this, p_index); } const int32_t *PackedInt32Array::ptr() const { - return internal::gde_interface->packed_int32_array_operator_index_const((GDExtensionTypePtr *)this, 0); + return internal::gdextension_interface_packed_int32_array_operator_index_const((GDExtensionTypePtr *)this, 0); } int32_t *PackedInt32Array::ptrw() { - return internal::gde_interface->packed_int32_array_operator_index((GDExtensionTypePtr *)this, 0); + return internal::gdextension_interface_packed_int32_array_operator_index((GDExtensionTypePtr *)this, 0); } const int64_t &PackedInt64Array::operator[](int p_index) const { - return *internal::gde_interface->packed_int64_array_operator_index_const((GDExtensionTypePtr *)this, p_index); + return *internal::gdextension_interface_packed_int64_array_operator_index_const((GDExtensionTypePtr *)this, p_index); } int64_t &PackedInt64Array::operator[](int p_index) { - return *internal::gde_interface->packed_int64_array_operator_index((GDExtensionTypePtr *)this, p_index); + return *internal::gdextension_interface_packed_int64_array_operator_index((GDExtensionTypePtr *)this, p_index); } const int64_t *PackedInt64Array::ptr() const { - return internal::gde_interface->packed_int64_array_operator_index_const((GDExtensionTypePtr *)this, 0); + return internal::gdextension_interface_packed_int64_array_operator_index_const((GDExtensionTypePtr *)this, 0); } int64_t *PackedInt64Array::ptrw() { - return internal::gde_interface->packed_int64_array_operator_index((GDExtensionTypePtr *)this, 0); + return internal::gdextension_interface_packed_int64_array_operator_index((GDExtensionTypePtr *)this, 0); } const String &PackedStringArray::operator[](int p_index) const { - const String *string = (const String *)internal::gde_interface->packed_string_array_operator_index_const((GDExtensionTypePtr *)this, p_index); + const String *string = (const String *)internal::gdextension_interface_packed_string_array_operator_index_const((GDExtensionTypePtr *)this, p_index); return *string; } String &PackedStringArray::operator[](int p_index) { - String *string = (String *)internal::gde_interface->packed_string_array_operator_index((GDExtensionTypePtr *)this, p_index); + String *string = (String *)internal::gdextension_interface_packed_string_array_operator_index((GDExtensionTypePtr *)this, p_index); return *string; } const String *PackedStringArray::ptr() const { - return (const String *)internal::gde_interface->packed_string_array_operator_index_const((GDExtensionTypePtr *)this, 0); + return (const String *)internal::gdextension_interface_packed_string_array_operator_index_const((GDExtensionTypePtr *)this, 0); } String *PackedStringArray::ptrw() { - return (String *)internal::gde_interface->packed_string_array_operator_index((GDExtensionTypePtr *)this, 0); + return (String *)internal::gdextension_interface_packed_string_array_operator_index((GDExtensionTypePtr *)this, 0); } const Vector2 &PackedVector2Array::operator[](int p_index) const { - const Vector2 *vec = (const Vector2 *)internal::gde_interface->packed_vector2_array_operator_index_const((GDExtensionTypePtr *)this, p_index); + const Vector2 *vec = (const Vector2 *)internal::gdextension_interface_packed_vector2_array_operator_index_const((GDExtensionTypePtr *)this, p_index); return *vec; } Vector2 &PackedVector2Array::operator[](int p_index) { - Vector2 *vec = (Vector2 *)internal::gde_interface->packed_vector2_array_operator_index((GDExtensionTypePtr *)this, p_index); + Vector2 *vec = (Vector2 *)internal::gdextension_interface_packed_vector2_array_operator_index((GDExtensionTypePtr *)this, p_index); return *vec; } const Vector2 *PackedVector2Array::ptr() const { - return (const Vector2 *)internal::gde_interface->packed_vector2_array_operator_index_const((GDExtensionTypePtr *)this, 0); + return (const Vector2 *)internal::gdextension_interface_packed_vector2_array_operator_index_const((GDExtensionTypePtr *)this, 0); } Vector2 *PackedVector2Array::ptrw() { - return (Vector2 *)internal::gde_interface->packed_vector2_array_operator_index((GDExtensionTypePtr *)this, 0); + return (Vector2 *)internal::gdextension_interface_packed_vector2_array_operator_index((GDExtensionTypePtr *)this, 0); } const Vector3 &PackedVector3Array::operator[](int p_index) const { - const Vector3 *vec = (const Vector3 *)internal::gde_interface->packed_vector3_array_operator_index_const((GDExtensionTypePtr *)this, p_index); + const Vector3 *vec = (const Vector3 *)internal::gdextension_interface_packed_vector3_array_operator_index_const((GDExtensionTypePtr *)this, p_index); return *vec; } Vector3 &PackedVector3Array::operator[](int p_index) { - Vector3 *vec = (Vector3 *)internal::gde_interface->packed_vector3_array_operator_index((GDExtensionTypePtr *)this, p_index); + Vector3 *vec = (Vector3 *)internal::gdextension_interface_packed_vector3_array_operator_index((GDExtensionTypePtr *)this, p_index); return *vec; } const Vector3 *PackedVector3Array::ptr() const { - return (const Vector3 *)internal::gde_interface->packed_vector3_array_operator_index_const((GDExtensionTypePtr *)this, 0); + return (const Vector3 *)internal::gdextension_interface_packed_vector3_array_operator_index_const((GDExtensionTypePtr *)this, 0); } Vector3 *PackedVector3Array::ptrw() { - return (Vector3 *)internal::gde_interface->packed_vector3_array_operator_index((GDExtensionTypePtr *)this, 0); + return (Vector3 *)internal::gdextension_interface_packed_vector3_array_operator_index((GDExtensionTypePtr *)this, 0); } const Variant &Array::operator[](int p_index) const { - const Variant *var = (const Variant *)internal::gde_interface->array_operator_index_const((GDExtensionTypePtr *)this, p_index); + const Variant *var = (const Variant *)internal::gdextension_interface_array_operator_index_const((GDExtensionTypePtr *)this, p_index); return *var; } Variant &Array::operator[](int p_index) { - Variant *var = (Variant *)internal::gde_interface->array_operator_index((GDExtensionTypePtr *)this, p_index); + Variant *var = (Variant *)internal::gdextension_interface_array_operator_index((GDExtensionTypePtr *)this, p_index); return *var; } void Array::set_typed(uint32_t p_type, const StringName &p_class_name, const Variant &p_script) { // p_type is not Variant::Type so that header doesn't depend on . - internal::gde_interface->array_set_typed((GDExtensionTypePtr *)this, (GDExtensionVariantType)p_type, (GDExtensionConstStringNamePtr)&p_class_name, (GDExtensionConstVariantPtr)&p_script); + internal::gdextension_interface_array_set_typed((GDExtensionTypePtr *)this, (GDExtensionVariantType)p_type, (GDExtensionConstStringNamePtr)&p_class_name, (GDExtensionConstVariantPtr)&p_script); } void Array::_ref(const Array &p_from) const { - internal::gde_interface->array_ref((GDExtensionTypePtr *)this, (GDExtensionConstTypePtr *)&p_from); + internal::gdextension_interface_array_ref((GDExtensionTypePtr *)this, (GDExtensionConstTypePtr *)&p_from); } const Variant &Dictionary::operator[](const Variant &p_key) const { - const Variant *var = (const Variant *)internal::gde_interface->dictionary_operator_index_const((GDExtensionTypePtr *)this, (GDExtensionVariantPtr)&p_key); + const Variant *var = (const Variant *)internal::gdextension_interface_dictionary_operator_index_const((GDExtensionTypePtr *)this, (GDExtensionVariantPtr)&p_key); return *var; } Variant &Dictionary::operator[](const Variant &p_key) { - Variant *var = (Variant *)internal::gde_interface->dictionary_operator_index((GDExtensionTypePtr *)this, (GDExtensionVariantPtr)&p_key); + Variant *var = (Variant *)internal::gdextension_interface_dictionary_operator_index((GDExtensionTypePtr *)this, (GDExtensionVariantPtr)&p_key); return *var; } diff --git a/src/variant/variant.cpp b/src/variant/variant.cpp index 1627367d..6c1e9640 100644 --- a/src/variant/variant.cpp +++ b/src/variant/variant.cpp @@ -45,8 +45,8 @@ GDExtensionTypeFromVariantConstructorFunc Variant::to_type_constructor[Variant:: void Variant::init_bindings() { // Start from 1 to skip NIL. for (int i = 1; i < VARIANT_MAX; i++) { - from_type_constructor[i] = internal::gde_interface->get_variant_from_type_constructor((GDExtensionVariantType)i); - to_type_constructor[i] = internal::gde_interface->get_variant_to_type_constructor((GDExtensionVariantType)i); + from_type_constructor[i] = internal::gdextension_interface_get_variant_from_type_constructor((GDExtensionVariantType)i); + to_type_constructor[i] = internal::gdextension_interface_get_variant_to_type_constructor((GDExtensionVariantType)i); } StringName::init_bindings(); @@ -69,15 +69,15 @@ void Variant::init_bindings() { } Variant::Variant() { - internal::gde_interface->variant_new_nil(_native_ptr()); + internal::gdextension_interface_variant_new_nil(_native_ptr()); } Variant::Variant(GDExtensionConstVariantPtr native_ptr) { - internal::gde_interface->variant_new_copy(_native_ptr(), native_ptr); + internal::gdextension_interface_variant_new_copy(_native_ptr(), native_ptr); } Variant::Variant(const Variant &other) { - internal::gde_interface->variant_new_copy(_native_ptr(), other._native_ptr()); + internal::gdextension_interface_variant_new_copy(_native_ptr(), other._native_ptr()); } Variant::Variant(Variant &&other) { @@ -248,7 +248,7 @@ Variant::Variant(const PackedColorArray &v) { } Variant::~Variant() { - internal::gde_interface->variant_destroy(_native_ptr()); + internal::gdextension_interface_variant_destroy(_native_ptr()); } Variant::operator bool() const { @@ -411,7 +411,7 @@ Variant::operator Object *() const { if (obj == nullptr) { return nullptr; } - return reinterpret_cast(internal::gde_interface->object_get_instance_binding(obj, internal::token, &Object::___binding_callbacks)); + return reinterpret_cast(internal::gdextension_interface_object_get_instance_binding(obj, internal::token, &Object::___binding_callbacks)); } Variant::operator ObjectID() const { @@ -509,7 +509,7 @@ Variant::operator PackedColorArray() const { Variant &Variant::operator=(const Variant &other) { clear(); - internal::gde_interface->variant_new_copy(_native_ptr(), other._native_ptr()); + internal::gdextension_interface_variant_new_copy(_native_ptr(), other._native_ptr()); return *this; } @@ -549,22 +549,22 @@ bool Variant::operator<(const Variant &other) const { } void Variant::call(const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDExtensionCallError &r_error) { - internal::gde_interface->variant_call(_native_ptr(), method._native_ptr(), reinterpret_cast(args), argcount, r_ret._native_ptr(), &r_error); + internal::gdextension_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, GDExtensionCallError &r_error) { - internal::gde_interface->variant_call_static(static_cast(type), method._native_ptr(), reinterpret_cast(args), argcount, r_ret._native_ptr(), &r_error); + internal::gdextension_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) { GDExtensionBool valid; - internal::gde_interface->variant_evaluate(static_cast(op), a._native_ptr(), b._native_ptr(), r_ret._native_ptr(), &valid); + internal::gdextension_interface_variant_evaluate(static_cast(op), a._native_ptr(), b._native_ptr(), r_ret._native_ptr(), &valid); r_valid = PtrToArg::convert(&valid); } void Variant::set(const Variant &key, const Variant &value, bool *r_valid) { GDExtensionBool valid; - internal::gde_interface->variant_set(_native_ptr(), key._native_ptr(), value._native_ptr(), &valid); + internal::gdextension_interface_variant_set(_native_ptr(), key._native_ptr(), value._native_ptr(), &valid); if (r_valid) { *r_valid = PtrToArg::convert(&valid); } @@ -572,27 +572,27 @@ void Variant::set(const Variant &key, const Variant &value, bool *r_valid) { void Variant::set_named(const StringName &name, const Variant &value, bool &r_valid) { GDExtensionBool valid; - internal::gde_interface->variant_set_named(_native_ptr(), name._native_ptr(), value._native_ptr(), &valid); + internal::gdextension_interface_variant_set_named(_native_ptr(), name._native_ptr(), value._native_ptr(), &valid); r_valid = PtrToArg::convert(&valid); } void Variant::set_indexed(int64_t index, const Variant &value, bool &r_valid, bool &r_oob) { GDExtensionBool valid, oob; - internal::gde_interface->variant_set_indexed(_native_ptr(), index, value._native_ptr(), &valid, &oob); + internal::gdextension_interface_variant_set_indexed(_native_ptr(), index, value._native_ptr(), &valid, &oob); r_valid = PtrToArg::convert(&valid); r_oob = PtrToArg::convert(&oob); } void Variant::set_keyed(const Variant &key, const Variant &value, bool &r_valid) { GDExtensionBool valid; - internal::gde_interface->variant_set_keyed(_native_ptr(), key._native_ptr(), value._native_ptr(), &valid); + internal::gdextension_interface_variant_set_keyed(_native_ptr(), key._native_ptr(), value._native_ptr(), &valid); r_valid = PtrToArg::convert(&valid); } Variant Variant::get(const Variant &key, bool *r_valid) const { Variant result; GDExtensionBool valid; - internal::gde_interface->variant_get(_native_ptr(), key._native_ptr(), result._native_ptr(), &valid); + internal::gdextension_interface_variant_get(_native_ptr(), key._native_ptr(), result._native_ptr(), &valid); if (r_valid) { *r_valid = PtrToArg::convert(&valid); } @@ -602,7 +602,7 @@ Variant Variant::get(const Variant &key, bool *r_valid) const { Variant Variant::get_named(const StringName &name, bool &r_valid) const { Variant result; GDExtensionBool valid; - internal::gde_interface->variant_get_named(_native_ptr(), name._native_ptr(), result._native_ptr(), &valid); + internal::gdextension_interface_variant_get_named(_native_ptr(), name._native_ptr(), result._native_ptr(), &valid); r_valid = PtrToArg::convert(&valid); return result; } @@ -611,7 +611,7 @@ Variant Variant::get_indexed(int64_t index, bool &r_valid, bool &r_oob) const { Variant result; GDExtensionBool valid; GDExtensionBool oob; - internal::gde_interface->variant_get_indexed(_native_ptr(), index, result._native_ptr(), &valid, &oob); + internal::gdextension_interface_variant_get_indexed(_native_ptr(), index, result._native_ptr(), &valid, &oob); r_valid = PtrToArg::convert(&valid); r_oob = PtrToArg::convert(&oob); return result; @@ -620,7 +620,7 @@ Variant Variant::get_indexed(int64_t index, bool &r_valid, bool &r_oob) const { Variant Variant::get_keyed(const Variant &key, bool &r_valid) const { Variant result; GDExtensionBool valid; - internal::gde_interface->variant_get_keyed(_native_ptr(), key._native_ptr(), result._native_ptr(), &valid); + internal::gdextension_interface_variant_get_keyed(_native_ptr(), key._native_ptr(), result._native_ptr(), &valid); r_valid = PtrToArg::convert(&valid); return result; } @@ -637,36 +637,36 @@ bool Variant::in(const Variant &index, bool *r_valid) const { bool Variant::iter_init(Variant &r_iter, bool &r_valid) const { GDExtensionBool valid; - internal::gde_interface->variant_iter_init(_native_ptr(), r_iter._native_ptr(), &valid); + internal::gdextension_interface_variant_iter_init(_native_ptr(), r_iter._native_ptr(), &valid); return PtrToArg::convert(&valid); } bool Variant::iter_next(Variant &r_iter, bool &r_valid) const { GDExtensionBool valid; - internal::gde_interface->variant_iter_next(_native_ptr(), r_iter._native_ptr(), &valid); + internal::gdextension_interface_variant_iter_next(_native_ptr(), r_iter._native_ptr(), &valid); return PtrToArg::convert(&valid); } Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const { Variant result; GDExtensionBool valid; - internal::gde_interface->variant_iter_get(_native_ptr(), r_iter._native_ptr(), result._native_ptr(), &valid); + internal::gdextension_interface_variant_iter_get(_native_ptr(), r_iter._native_ptr(), result._native_ptr(), &valid); r_valid = PtrToArg::convert(&valid); return result; } Variant::Type Variant::get_type() const { - return static_cast(internal::gde_interface->variant_get_type(_native_ptr())); + return static_cast(internal::gdextension_interface_variant_get_type(_native_ptr())); } bool Variant::has_method(const StringName &method) const { - GDExtensionBool has = internal::gde_interface->variant_has_method(_native_ptr(), method._native_ptr()); + GDExtensionBool has = internal::gdextension_interface_variant_has_method(_native_ptr(), method._native_ptr()); return PtrToArg::convert(&has); } bool Variant::has_key(const Variant &key, bool *r_valid) const { GDExtensionBool valid; - GDExtensionBool has = internal::gde_interface->variant_has_key(_native_ptr(), key._native_ptr(), &valid); + GDExtensionBool has = internal::gdextension_interface_variant_has_key(_native_ptr(), key._native_ptr(), &valid); if (r_valid) { *r_valid = PtrToArg::convert(&valid); } @@ -674,33 +674,33 @@ bool Variant::has_key(const Variant &key, bool *r_valid) const { } bool Variant::has_member(Variant::Type type, const StringName &member) { - GDExtensionBool has = internal::gde_interface->variant_has_member(static_cast(type), member._native_ptr()); + GDExtensionBool has = internal::gdextension_interface_variant_has_member(static_cast(type), member._native_ptr()); return PtrToArg::convert(&has); } uint32_t Variant::hash() const { - GDExtensionInt hash = internal::gde_interface->variant_hash(_native_ptr()); + GDExtensionInt hash = internal::gdextension_interface_variant_hash(_native_ptr()); return PtrToArg::convert(&hash); } uint32_t Variant::recursive_hash(int recursion_count) const { - GDExtensionInt hash = internal::gde_interface->variant_recursive_hash(_native_ptr(), recursion_count); + GDExtensionInt hash = internal::gdextension_interface_variant_recursive_hash(_native_ptr(), recursion_count); return PtrToArg::convert(&hash); } bool Variant::hash_compare(const Variant &variant) const { - GDExtensionBool compare = internal::gde_interface->variant_hash_compare(_native_ptr(), variant._native_ptr()); + GDExtensionBool compare = internal::gdextension_interface_variant_hash_compare(_native_ptr(), variant._native_ptr()); return PtrToArg::convert(&compare); } bool Variant::booleanize() const { - GDExtensionBool booleanized = internal::gde_interface->variant_booleanize(_native_ptr()); + GDExtensionBool booleanized = internal::gdextension_interface_variant_booleanize(_native_ptr()); return PtrToArg::convert(&booleanized); } String Variant::stringify() const { String result; - internal::gde_interface->variant_stringify(_native_ptr(), result._native_ptr()); + internal::gdextension_interface_variant_stringify(_native_ptr(), result._native_ptr()); return result; } @@ -708,23 +708,23 @@ Variant Variant::duplicate(bool deep) const { Variant result; GDExtensionBool _deep; PtrToArg::encode(deep, &_deep); - internal::gde_interface->variant_duplicate(_native_ptr(), result._native_ptr(), _deep); + internal::gdextension_interface_variant_duplicate(_native_ptr(), result._native_ptr(), _deep); return result; } String Variant::get_type_name(Variant::Type type) { String result; - internal::gde_interface->variant_get_type_name(static_cast(type), result._native_ptr()); + internal::gdextension_interface_variant_get_type_name(static_cast(type), result._native_ptr()); return result; } bool Variant::can_convert(Variant::Type from, Variant::Type to) { - GDExtensionBool can = internal::gde_interface->variant_can_convert(static_cast(from), static_cast(to)); + GDExtensionBool can = internal::gdextension_interface_variant_can_convert(static_cast(from), static_cast(to)); return PtrToArg::convert(&can); } bool Variant::can_convert_strict(Variant::Type from, Variant::Type to) { - GDExtensionBool can = internal::gde_interface->variant_can_convert_strict(static_cast(from), static_cast(to)); + GDExtensionBool can = internal::gdextension_interface_variant_can_convert_strict(static_cast(from), static_cast(to)); return PtrToArg::convert(&can); } @@ -775,9 +775,9 @@ void Variant::clear() { }; if (unlikely(needs_deinit[get_type()])) { // Make it fast for types that don't need deinit. - internal::gde_interface->variant_destroy(_native_ptr()); + internal::gdextension_interface_variant_destroy(_native_ptr()); } - internal::gde_interface->variant_new_nil(_native_ptr()); + internal::gdextension_interface_variant_new_nil(_native_ptr()); } } // namespace godot diff --git a/test/demo/example.gdextension b/test/demo/example.gdextension index 6d534056..90fd53a0 100644 --- a/test/demo/example.gdextension +++ b/test/demo/example.gdextension @@ -1,6 +1,7 @@ [configuration] entry_symbol = "example_library_init" +compatibility_minimum = 4.1 [libraries] diff --git a/test/src/register_types.cpp b/test/src/register_types.cpp index e22662fc..dbb37d90 100644 --- a/test/src/register_types.cpp +++ b/test/src/register_types.cpp @@ -36,8 +36,8 @@ void uninitialize_example_module(ModuleInitializationLevel p_level) { extern "C" { // Initialization. -GDExtensionBool GDE_EXPORT example_library_init(const GDExtensionInterface *p_interface, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) { - godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization); +GDExtensionBool GDE_EXPORT example_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) { + godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization); init_obj.register_initializer(initialize_example_module); init_obj.register_terminator(uninitialize_example_module);