Generate GDExtension interface header and loader from JSON

This commit is contained in:
David Snopek
2025-12-06 09:44:43 -06:00
parent 4ae2669dcd
commit fe68c22c3e
38 changed files with 10358 additions and 3998 deletions

View File

@@ -4,7 +4,7 @@ default_language_version:
exclude: | exclude: |
(?x)^( (?x)^(
gdextension/extension_api\.json| gdextension/extension_api\.json|
gdextension/gdextension_interface\.h gdextension/gdextension_interface\.json
)$ )$
repos: repos:

View File

@@ -5,6 +5,8 @@ import re
import shutil import shutil
from pathlib import Path from pathlib import Path
from make_interface_header import generate_gdextension_interface_header
def generate_mod_version(argcount, const=False, returns=False): def generate_mod_version(argcount, const=False, returns=False):
s = """ s = """
@@ -68,11 +70,11 @@ def generate_virtual_version(argcount, const=False, returns=False, required=Fals
s = """#define GDVIRTUAL$VER($RET m_name $ARG)\\ s = """#define GDVIRTUAL$VER($RET m_name $ARG)\\
::godot::StringName _gdvirtual_##m_name##_sn = #m_name;\\ ::godot::StringName _gdvirtual_##m_name##_sn = #m_name;\\
_FORCE_INLINE_ bool _gdvirtual_##m_name##_call($CALLARGS) $CONST {\\ _FORCE_INLINE_ bool _gdvirtual_##m_name##_call($CALLARGS) $CONST {\\
if (::godot::internal::gdextension_interface_object_has_script_method(_owner, &_gdvirtual_##m_name##_sn)) { \\ if (::godot::gdextension_interface::object_has_script_method(_owner, &_gdvirtual_##m_name##_sn)) { \\
GDExtensionCallError ce;\\ GDExtensionCallError ce;\\
$CALLSIARGS\\ $CALLSIARGS\\
::godot::Variant ret;\\ ::godot::Variant ret;\\
::godot::internal::gdextension_interface_object_call_script_method(_owner, &_gdvirtual_##m_name##_sn, $CALLSIARGPASS, &ret, &ce);\\ ::godot::gdextension_interface::object_call_script_method(_owner, &_gdvirtual_##m_name##_sn, $CALLSIARGPASS, &ret, &ce);\\
if (ce.error == GDEXTENSION_CALL_OK) {\\ if (ce.error == GDEXTENSION_CALL_OK) {\\
$CALLSIRET\\ $CALLSIRET\\
return true;\\ return true;\\
@@ -83,7 +85,7 @@ def generate_virtual_version(argcount, const=False, returns=False, required=Fals
return false;\\ return false;\\
}\\ }\\
_FORCE_INLINE_ bool _gdvirtual_##m_name##_overridden() const {\\ _FORCE_INLINE_ bool _gdvirtual_##m_name##_overridden() const {\\
return ::godot::internal::gdextension_interface_object_has_script_method(_owner, &_gdvirtual_##m_name##_sn); \\ return ::godot::gdextension_interface::object_has_script_method(_owner, &_gdvirtual_##m_name##_sn); \\
}\\ }\\
_FORCE_INLINE_ static ::godot::MethodInfo _gdvirtual_##m_name##_get_method_info() {\\ _FORCE_INLINE_ static ::godot::MethodInfo _gdvirtual_##m_name##_get_method_info() {\\
::godot::MethodInfo method_info;\\ ::godot::MethodInfo method_info;\\
@@ -211,10 +213,14 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False):
def _get_file_list(api, output_dir, headers=False, sources=False): def _get_file_list(api, output_dir, headers=False, sources=False):
files = [] files = []
gdextension_gen_folder = Path(output_dir) / "gen" / "include"
core_gen_folder = Path(output_dir) / "gen" / "include" / "godot_cpp" / "core" core_gen_folder = Path(output_dir) / "gen" / "include" / "godot_cpp" / "core"
include_gen_folder = Path(output_dir) / "gen" / "include" / "godot_cpp" include_gen_folder = Path(output_dir) / "gen" / "include" / "godot_cpp"
source_gen_folder = Path(output_dir) / "gen" / "src" source_gen_folder = Path(output_dir) / "gen" / "src"
files.append(str((gdextension_gen_folder / "gdextension_interface.h").as_posix()))
files.append(str((core_gen_folder / "gdextension_interface_loader.hpp").as_posix()))
files.append(str((source_gen_folder / "gdextension_interface_loader.cpp").as_posix()))
files.append(str((core_gen_folder / "ext_wrappers.gen.inc").as_posix())) files.append(str((core_gen_folder / "ext_wrappers.gen.inc").as_posix()))
files.append(str((core_gen_folder / "gdvirtual.gen.inc").as_posix())) files.append(str((core_gen_folder / "gdvirtual.gen.inc").as_posix()))
@@ -277,14 +283,18 @@ def print_file_list(api_filepath, output_dir, headers=False, sources=False):
print(*get_file_list(api_filepath, output_dir, headers, sources), sep=";", end=None) print(*get_file_list(api_filepath, output_dir, headers, sources), sep=";", end=None)
def generate_bindings(api_filepath, use_template_get_node, bits="64", precision="single", output_dir="."): def generate_bindings(
api_filepath, interface_filepath, use_template_get_node, bits="64", precision="single", output_dir="."
):
api = {} api = {}
with open(api_filepath, encoding="utf-8") as api_file: with open(api_filepath, encoding="utf-8") as api_file:
api = json.load(api_file) api = json.load(api_file)
_generate_bindings(api, api_filepath, use_template_get_node, bits, precision, output_dir) _generate_bindings(api, api_filepath, interface_filepath, use_template_get_node, bits, precision, output_dir)
def _generate_bindings(api, api_filepath, use_template_get_node, bits="64", precision="single", output_dir="."): def _generate_bindings(
api, api_filepath, interface_filepath, use_template_get_node, bits="64", precision="single", output_dir="."
):
if "precision" in api["header"] and precision != api["header"]["precision"]: if "precision" in api["header"] and precision != api["header"]["precision"]:
raise Exception( raise Exception(
f"Cannot do a precision={precision} build using '{api_filepath}' which was generated by Godot built with precision={api['header']['precision']}" f"Cannot do a precision={precision} build using '{api_filepath}' which was generated by Godot built with precision={api['header']['precision']}"
@@ -298,6 +308,16 @@ def _generate_bindings(api, api_filepath, use_template_get_node, bits="64", prec
real_t = "double" if precision == "double" else "float" real_t = "double" if precision == "double" else "float"
print("Built-in type config: " + real_t + "_" + bits) print("Built-in type config: " + real_t + "_" + bits)
header_lines = []
add_header("gdextension_interface.h", header_lines)
gdextension_gen_folder = Path(output_dir) / "gen" / "include"
gdextension_gen_folder.mkdir(parents=True, exist_ok=True)
generate_gdextension_interface_header(
str((gdextension_gen_folder / "gdextension_interface.h").as_posix()), interface_filepath, header_lines
)
generate_gdextension_interface_loader(interface_filepath, target_dir)
generate_global_constants(api, target_dir) generate_global_constants(api, target_dir)
generate_version_header(api, target_dir) generate_version_header(api, target_dir)
generate_global_constant_binds(api, target_dir) generate_global_constant_binds(api, target_dir)
@@ -306,6 +326,164 @@ def _generate_bindings(api, api_filepath, use_template_get_node, bits="64", prec
generate_utility_functions(api, target_dir) generate_utility_functions(api, target_dir)
def generate_gdextension_interface_loader(interface_filepath, output_dir):
include_gen_folder = Path(output_dir) / "include" / "godot_cpp" / "core"
source_gen_folder = Path(output_dir) / "src"
include_gen_folder.mkdir(parents=True, exist_ok=True)
source_gen_folder.mkdir(parents=True, exist_ok=True)
header_filename = include_gen_folder / "gdextension_interface_loader.hpp"
source_filename = source_gen_folder / "gdextension_interface_loader.cpp"
with open(interface_filepath, "rt") as file:
data = json.load(file)
functions_by_version = {}
for func in data["interface"]:
since = func["since"]
if since not in functions_by_version:
functions_by_version[since] = []
functions_by_version[since].append(func)
with header_filename.open("wt", encoding="utf-8") as header_file:
header_file.write(generate_gdextension_interface_loader_header(functions_by_version))
with source_filename.open("wt", encoding="utf-8") as source_file:
source_file.write(generate_gdextension_interface_loader_source(functions_by_version))
def gdextension_interface_type_name(name):
return "GDExtensionInterface" + "".join(word.capitalize() for word in name.split("_"))
def generate_gdextension_interface_loader_header(data):
result = []
add_header("gdextension_interface_loader.hpp", result)
result.append("#pragma once")
result.append("")
result.append("#include <gdextension_interface.h>")
result.append("#include <godot_cpp/core/version.hpp>")
result.append("")
result.append("namespace godot {")
result.append("")
result.append("namespace gdextension_interface {")
result.append("")
versions = sorted(data.keys())
for version in versions:
(major, minor) = version.split(".")
result.append(f"// Godot 4.{minor} or newer.")
result.append(f"#if GODOT_VERSION_MINOR >= {minor}")
for func in data[version]:
name = func["name"]
fn = gdextension_interface_type_name(name)
if "deprecated" in func:
(deprecated_major, deprecated_minor) = func["deprecated"]["since"].split(".")
result.append(f"#if !defined(DISABLE_DEPRECATED) || GODOT_VERSION_MINOR < {deprecated_minor}")
result.append(f'extern "C" {fn} {name};')
if "deprecated" in func:
result.append("#endif")
result.append(f"#endif // GODOT_VERSION_MINOR >= {minor}")
result.append("")
result.append("} // namespace gdextension_interface")
result.append("")
result.append("namespace internal {")
result.append("")
result.append("bool load_gdextension_interface(GDExtensionInterfaceGetProcAddress p_get_proc_address);")
result.append("")
result.append("} // namespace internal")
result.append("")
result.append("} // namespace godot")
return "\n".join(result)
def generate_gdextension_interface_loader_source(data):
result = []
add_header("gdextension_interface_loader.cpp", result)
result.append("#include <godot_cpp/core/error_macros.hpp>")
result.append("#include <godot_cpp/core/gdextension_interface_loader.hpp>")
result.append("#include <godot_cpp/core/load_proc_address.inc>")
result.append("")
result.append("namespace godot {")
result.append("")
result.append("namespace gdextension_interface {")
result.append("")
versions = sorted(data.keys())
for version in versions:
(major, minor) = version.split(".")
result.append(f"// Godot 4.{minor} or newer.")
result.append(f"#if GODOT_VERSION_MINOR >= {minor}")
for func in data[version]:
name = func["name"]
fn = gdextension_interface_type_name(name)
if "deprecated" in func:
(deprecated_major, deprecated_minor) = func["deprecated"]["since"].split(".")
result.append(f"#if !defined(DISABLE_DEPRECATED) || GODOT_VERSION_MINOR < {deprecated_minor}")
result.append(f"{fn} {name} = nullptr;")
if "deprecated" in func:
result.append("#endif")
result.append(f"#endif // GODOT_VERSION_MINOR >= {minor}")
result.append("")
result.append("} // namespace gdextension_interface")
result.append("")
result.append("namespace internal {")
result.append("")
result.append("bool load_gdextension_interface(GDExtensionInterfaceGetProcAddress p_get_proc_address) {")
for version in versions:
(major, minor) = version.split(".")
result.append(f"\t// Godot 4.{minor} or newer.")
result.append(f"#if GODOT_VERSION_MINOR >= {minor}")
for func in data[version]:
name = func["name"]
fn = gdextension_interface_type_name(name)
if "deprecated" in func:
(deprecated_major, deprecated_minor) = func["deprecated"]["since"].split(".")
result.append(f"#if !defined(DISABLE_DEPRECATED) || GODOT_VERSION_MINOR < {deprecated_minor}")
result.append(f"\tLOAD_PROC_ADDRESS({name}, {fn});")
if "deprecated" in func:
result.append("#endif")
result.append(f"#endif // GODOT_VERSION_MINOR >= {minor}")
result.append("")
result.append("\treturn true;")
result.append("}")
result.append("")
result.append("} // namespace internal")
result.append("")
result.append("} // namespace godot")
return "\n".join(result)
CLASS_ALIASES = { CLASS_ALIASES = {
"ClassDB": "ClassDBSingleton", "ClassDB": "ClassDBSingleton",
} }
@@ -1034,18 +1212,18 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
result.append(f"void {class_name}::_init_bindings_constructors_destructor() {{") result.append(f"void {class_name}::_init_bindings_constructors_destructor() {{")
result.append( result.append(
f"\t_method_bindings.from_variant_constructor = internal::gdextension_interface_get_variant_to_type_constructor({enum_type_name});" f"\t_method_bindings.from_variant_constructor = ::godot::gdextension_interface::get_variant_to_type_constructor({enum_type_name});"
) )
if "constructors" in builtin_api: if "constructors" in builtin_api:
for constructor in builtin_api["constructors"]: for constructor in builtin_api["constructors"]:
result.append( result.append(
f"\t_method_bindings.constructor_{constructor['index']} = internal::gdextension_interface_variant_get_ptr_constructor({enum_type_name}, {constructor['index']});" f"\t_method_bindings.constructor_{constructor['index']} = ::godot::gdextension_interface::variant_get_ptr_constructor({enum_type_name}, {constructor['index']});"
) )
if builtin_api["has_destructor"]: if builtin_api["has_destructor"]:
result.append( result.append(
f"\t_method_bindings.destructor = internal::gdextension_interface_variant_get_ptr_destructor({enum_type_name});" f"\t_method_bindings.destructor = ::godot::gdextension_interface::variant_get_ptr_destructor({enum_type_name});"
) )
result.append("}") result.append("}")
@@ -1064,36 +1242,36 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
# TODO: Add error check for hash mismatch. # TODO: Add error check for hash mismatch.
result.append(f'\t_gde_name = StringName("{method["name"]}");') result.append(f'\t_gde_name = StringName("{method["name"]}");')
result.append( result.append(
f"\t_method_bindings.method_{method['name']} = internal::gdextension_interface_variant_get_ptr_builtin_method({enum_type_name}, _gde_name._native_ptr(), {method['hash']});" f"\t_method_bindings.method_{method['name']} = ::godot::gdextension_interface::variant_get_ptr_builtin_method({enum_type_name}, _gde_name._native_ptr(), {method['hash']});"
) )
if "members" in builtin_api: if "members" in builtin_api:
for member in builtin_api["members"]: for member in builtin_api["members"]:
result.append(f'\t_gde_name = StringName("{member["name"]}");') result.append(f'\t_gde_name = StringName("{member["name"]}");')
result.append( result.append(
f"\t_method_bindings.member_{member['name']}_setter = internal::gdextension_interface_variant_get_ptr_setter({enum_type_name}, _gde_name._native_ptr());" f"\t_method_bindings.member_{member['name']}_setter = ::godot::gdextension_interface::variant_get_ptr_setter({enum_type_name}, _gde_name._native_ptr());"
) )
result.append( result.append(
f"\t_method_bindings.member_{member['name']}_getter = internal::gdextension_interface_variant_get_ptr_getter({enum_type_name}, _gde_name._native_ptr());" f"\t_method_bindings.member_{member['name']}_getter = ::godot::gdextension_interface::variant_get_ptr_getter({enum_type_name}, _gde_name._native_ptr());"
) )
if "indexing_return_type" in builtin_api: if "indexing_return_type" in builtin_api:
result.append( result.append(
f"\t_method_bindings.indexed_setter = internal::gdextension_interface_variant_get_ptr_indexed_setter({enum_type_name});" f"\t_method_bindings.indexed_setter = ::godot::gdextension_interface::variant_get_ptr_indexed_setter({enum_type_name});"
) )
result.append( result.append(
f"\t_method_bindings.indexed_getter = internal::gdextension_interface_variant_get_ptr_indexed_getter({enum_type_name});" f"\t_method_bindings.indexed_getter = ::godot::gdextension_interface::variant_get_ptr_indexed_getter({enum_type_name});"
) )
if "is_keyed" in builtin_api and builtin_api["is_keyed"]: if "is_keyed" in builtin_api and builtin_api["is_keyed"]:
result.append( result.append(
f"\t_method_bindings.keyed_setter = internal::gdextension_interface_variant_get_ptr_keyed_setter({enum_type_name});" f"\t_method_bindings.keyed_setter = ::godot::gdextension_interface::variant_get_ptr_keyed_setter({enum_type_name});"
) )
result.append( result.append(
f"\t_method_bindings.keyed_getter = internal::gdextension_interface_variant_get_ptr_keyed_getter({enum_type_name});" f"\t_method_bindings.keyed_getter = ::godot::gdextension_interface::variant_get_ptr_keyed_getter({enum_type_name});"
) )
result.append( result.append(
f"\t_method_bindings.keyed_checker = internal::gdextension_interface_variant_get_ptr_keyed_checker({enum_type_name});" f"\t_method_bindings.keyed_checker = ::godot::gdextension_interface::variant_get_ptr_keyed_checker({enum_type_name});"
) )
if "operators" in builtin_api: if "operators" in builtin_api:
@@ -1106,11 +1284,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()}" f"GDEXTENSION_VARIANT_TYPE_{camel_to_snake(operator['right_type']).upper()}"
) )
result.append( result.append(
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});" f"\t_method_bindings.operator_{get_operator_id_name(operator['name'])}_{operator['right_type']} = ::godot::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: else:
result.append( result.append(
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);" f"\t_method_bindings.operator_{get_operator_id_name(operator['name'])} = ::godot::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("}") result.append("}")
@@ -1134,9 +1312,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
result.append(method_signature) result.append(method_signature)
method_call = ( method_call = f"\t::godot::internal::_call_builtin_constructor(_method_bindings.constructor_{constructor['index']}, &opaque"
f"\tinternal::_call_builtin_constructor(_method_bindings.constructor_{constructor['index']}, &opaque"
)
if "arguments" in constructor: if "arguments" in constructor:
if len(constructor["arguments"]) == 1 and constructor["arguments"][0]["type"] == class_name: if len(constructor["arguments"]) == 1 and constructor["arguments"][0]["type"] == class_name:
copy_constructor_index = constructor["index"] copy_constructor_index = constructor["index"]
@@ -1161,7 +1337,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
result.append(f"{class_name}::{class_name}({class_name} &&p_other) {{") result.append(f"{class_name}::{class_name}({class_name} &&p_other) {{")
if needs_copy_instead_of_move(class_name) and copy_constructor_index >= 0: if needs_copy_instead_of_move(class_name) and copy_constructor_index >= 0:
result.append( result.append(
f"\tinternal::_call_builtin_constructor(_method_bindings.constructor_{copy_constructor_index}, &opaque, &p_other);" f"\t::godot::internal::_call_builtin_constructor(_method_bindings.constructor_{copy_constructor_index}, &opaque, &p_other);"
) )
else: else:
result.append("\tstd::swap(opaque, p_other.opaque);") result.append("\tstd::swap(opaque, p_other.opaque);")
@@ -1193,16 +1369,16 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
if "return_type" in method: if "return_type" in method:
return_type = method["return_type"] return_type = method["return_type"]
if is_enum(return_type): if is_enum(return_type):
method_call += f"return ({get_gdextension_type(correct_type(return_type))})internal::_call_builtin_method_ptr_ret<int64_t>(" method_call += f"return ({get_gdextension_type(correct_type(return_type))})::godot::internal::_call_builtin_method_ptr_ret<int64_t>("
elif is_pod_type(return_type) or is_variant(return_type): elif is_pod_type(return_type) or is_variant(return_type):
method_call += f"return internal::_call_builtin_method_ptr_ret<{get_gdextension_type(correct_type(return_type))}>(" method_call += f"return ::godot::internal::_call_builtin_method_ptr_ret<{get_gdextension_type(correct_type(return_type))}>("
elif is_refcounted(return_type): elif is_refcounted(return_type):
method_call += f"return Ref<{return_type}>::_gde_internal_constructor(internal::_call_builtin_method_ptr_ret_obj<{return_type}>(" method_call += f"return Ref<{return_type}>::_gde_internal_constructor(::godot::internal::_call_builtin_method_ptr_ret_obj<{return_type}>("
is_ref = True is_ref = True
else: else:
method_call += f"return internal::_call_builtin_method_ptr_ret_obj<{return_type}>(" method_call += f"return ::godot::internal::_call_builtin_method_ptr_ret_obj<{return_type}>("
else: else:
method_call += "internal::_call_builtin_method_ptr_no_ret(" method_call += "::godot::internal::_call_builtin_method_ptr_no_ret("
method_call += f"_method_bindings.method_{method['name']}, " method_call += f"_method_bindings.method_{method['name']}, "
if "is_static" in method and method["is_static"]: if "is_static" in method and method["is_static"]:
method_call += "nullptr" method_call += "nullptr"
@@ -1235,7 +1411,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
if f"get_{member['name']}" not in method_list: if f"get_{member['name']}" not in method_list:
result.append(f"{correct_type(member['type'])} {class_name}::get_{member['name']}() const {{") result.append(f"{correct_type(member['type'])} {class_name}::get_{member['name']}() const {{")
result.append( result.append(
f"\treturn internal::_call_builtin_ptr_getter<{correct_type(member['type'])}>(_method_bindings.member_{member['name']}_getter, (GDExtensionConstTypePtr)&opaque);" f"\treturn ::godot::internal::_call_builtin_ptr_getter<{correct_type(member['type'])}>(_method_bindings.member_{member['name']}_getter, (GDExtensionConstTypePtr)&opaque);"
) )
result.append("}") result.append("}")
@@ -1260,7 +1436,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
(encode, arg_name) = get_encoded_arg("other", operator["right_type"], None) (encode, arg_name) = get_encoded_arg("other", operator["right_type"], None)
result += encode result += encode
result.append( result.append(
f"\treturn internal::_call_builtin_operator_ptr<{get_gdextension_type(correct_type(operator['return_type']))}>(_method_bindings.operator_{get_operator_id_name(operator['name'])}_{operator['right_type']}, (GDExtensionConstTypePtr)&opaque, (GDExtensionConstTypePtr){arg_name});" f"\treturn ::godot::internal::_call_builtin_operator_ptr<{get_gdextension_type(correct_type(operator['return_type']))}>(_method_bindings.operator_{get_operator_id_name(operator['name'])}_{operator['right_type']}, (GDExtensionConstTypePtr)&opaque, (GDExtensionConstTypePtr){arg_name});"
) )
result.append("}") result.append("}")
else: else:
@@ -1268,7 +1444,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
f"{correct_type(operator['return_type'])} {class_name}::operator{get_operator_cpp_name(operator['name'])}() const {{" f"{correct_type(operator['return_type'])} {class_name}::operator{get_operator_cpp_name(operator['name'])}() const {{"
) )
result.append( result.append(
f"\treturn internal::_call_builtin_operator_ptr<{get_gdextension_type(correct_type(operator['return_type']))}>(_method_bindings.operator_{get_operator_id_name(operator['name'])}, (GDExtensionConstTypePtr)&opaque, (GDExtensionConstTypePtr) nullptr);" f"\treturn ::godot::internal::_call_builtin_operator_ptr<{get_gdextension_type(correct_type(operator['return_type']))}>(_method_bindings.operator_{get_operator_id_name(operator['name'])}, (GDExtensionConstTypePtr)&opaque, (GDExtensionConstTypePtr) nullptr);"
) )
result.append("}") result.append("}")
result.append("") result.append("")
@@ -1285,7 +1461,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
) )
result += encode result += encode
result.append( result.append(
f"\tinternal::_call_builtin_constructor(_method_bindings.constructor_{copy_constructor_index}, &opaque, {arg_name});" f"\t::godot::internal::_call_builtin_constructor(_method_bindings.constructor_{copy_constructor_index}, &opaque, {arg_name});"
) )
result.append("\treturn *this;") result.append("\treturn *this;")
result.append("}") result.append("}")
@@ -1295,7 +1471,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
result.append(f"{class_name} &{class_name}::operator=({class_name} &&p_other) {{") result.append(f"{class_name} &{class_name}::operator=({class_name} &&p_other) {{")
if needs_copy_instead_of_move(class_name) and copy_constructor_index >= 0: if needs_copy_instead_of_move(class_name) and copy_constructor_index >= 0:
result.append( result.append(
f"\tinternal::_call_builtin_constructor(_method_bindings.constructor_{copy_constructor_index}, &opaque, &p_other);" f"\t::godot::internal::_call_builtin_constructor(_method_bindings.constructor_{copy_constructor_index}, &opaque, &p_other);"
) )
else: else:
result.append("\tstd::swap(opaque, p_other.opaque);") result.append("\tstd::swap(opaque, p_other.opaque);")
@@ -1916,13 +2092,13 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
# We assume multi-threaded access is OK because each assignment will assign the same value every time # We assume multi-threaded access is OK because each assignment will assign the same value every time
result.append("\tif (unlikely(singleton == nullptr)) {") result.append("\tif (unlikely(singleton == nullptr)) {")
result.append( result.append(
f"\t\tGDExtensionObjectPtr singleton_obj = internal::gdextension_interface_global_get_singleton({class_name}::get_class_static()._native_ptr());" f"\t\tGDExtensionObjectPtr singleton_obj = ::godot::gdextension_interface::global_get_singleton({class_name}::get_class_static()._native_ptr());"
) )
result.append("#ifdef DEBUG_ENABLED") result.append("#ifdef DEBUG_ENABLED")
result.append("\t\tERR_FAIL_NULL_V(singleton_obj, nullptr);") result.append("\t\tERR_FAIL_NULL_V(singleton_obj, nullptr);")
result.append("#endif // DEBUG_ENABLED") result.append("#endif // DEBUG_ENABLED")
result.append( result.append(
f"\t\tsingleton = reinterpret_cast<{class_name} *>(internal::gdextension_interface_object_get_instance_binding(singleton_obj, internal::token, &{class_name}::_gde_binding_callbacks));" f"\t\tsingleton = reinterpret_cast<{class_name} *>(::godot::gdextension_interface::object_get_instance_binding(singleton_obj, ::godot::gdextension_interface::token, &{class_name}::_gde_binding_callbacks));"
) )
result.append("#ifdef DEBUG_ENABLED") result.append("#ifdef DEBUG_ENABLED")
result.append("\t\tERR_FAIL_NULL_V(singleton, nullptr);") result.append("\t\tERR_FAIL_NULL_V(singleton, nullptr);")
@@ -1957,7 +2133,7 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
# Method body. # Method body.
result.append( result.append(
f'\tstatic GDExtensionMethodBindPtr _gde_method_bind = internal::gdextension_interface_classdb_get_method_bind({class_name}::get_class_static()._native_ptr(), StringName("{method["name"]}")._native_ptr(), {method["hash"]});' f'\tstatic GDExtensionMethodBindPtr _gde_method_bind = ::godot::gdextension_interface::classdb_get_method_bind({class_name}::get_class_static()._native_ptr(), StringName("{method["name"]}")._native_ptr(), {method["hash"]});'
) )
method_call = "\t" method_call = "\t"
has_return = "return_value" in method and method["return_value"]["type"] != "void" has_return = "return_value" in method and method["return_value"]["type"] != "void"
@@ -1976,34 +2152,30 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
meta_type = method["return_value"]["meta"] if "meta" in method["return_value"] else None meta_type = method["return_value"]["meta"] if "meta" in method["return_value"] else None
if is_enum(return_type): if is_enum(return_type):
if method["is_static"]: if method["is_static"]:
method_call += f"return ({get_gdextension_type(correct_type(return_type, meta_type))})internal::_call_native_mb_ret<int64_t>(_gde_method_bind, nullptr" method_call += f"return ({get_gdextension_type(correct_type(return_type, meta_type))})::godot::internal::_call_native_mb_ret<int64_t>(_gde_method_bind, nullptr"
else: else:
method_call += f"return ({get_gdextension_type(correct_type(return_type, meta_type))})internal::_call_native_mb_ret<int64_t>(_gde_method_bind, _owner" method_call += f"return ({get_gdextension_type(correct_type(return_type, meta_type))})::godot::internal::_call_native_mb_ret<int64_t>(_gde_method_bind, _owner"
elif is_pod_type(return_type) or is_variant(return_type): elif is_pod_type(return_type) or is_variant(return_type):
if method["is_static"]: if method["is_static"]:
method_call += f"return internal::_call_native_mb_ret<{get_gdextension_type(correct_type(return_type, meta_type))}>(_gde_method_bind, nullptr" method_call += f"return ::godot::internal::_call_native_mb_ret<{get_gdextension_type(correct_type(return_type, meta_type))}>(_gde_method_bind, nullptr"
else: else:
method_call += f"return internal::_call_native_mb_ret<{get_gdextension_type(correct_type(return_type, meta_type))}>(_gde_method_bind, _owner" method_call += f"return ::godot::internal::_call_native_mb_ret<{get_gdextension_type(correct_type(return_type, meta_type))}>(_gde_method_bind, _owner"
elif is_refcounted(return_type): elif is_refcounted(return_type):
if method["is_static"]: if method["is_static"]:
method_call += f"return Ref<{return_type}>::_gde_internal_constructor(internal::_call_native_mb_ret_obj<{return_type}>(_gde_method_bind, nullptr" method_call += f"return Ref<{return_type}>::_gde_internal_constructor(::godot::internal::_call_native_mb_ret_obj<{return_type}>(_gde_method_bind, nullptr"
else: else:
method_call += f"return Ref<{return_type}>::_gde_internal_constructor(internal::_call_native_mb_ret_obj<{return_type}>(_gde_method_bind, _owner" method_call += f"return Ref<{return_type}>::_gde_internal_constructor(::godot::internal::_call_native_mb_ret_obj<{return_type}>(_gde_method_bind, _owner"
is_ref = True is_ref = True
else: else:
if method["is_static"]: if method["is_static"]:
method_call += ( method_call += f"return ::godot::internal::_call_native_mb_ret_obj<{return_type}>(_gde_method_bind, nullptr"
f"return internal::_call_native_mb_ret_obj<{return_type}>(_gde_method_bind, nullptr"
)
else: else:
method_call += ( method_call += f"return ::godot::internal::_call_native_mb_ret_obj<{return_type}>(_gde_method_bind, _owner"
f"return internal::_call_native_mb_ret_obj<{return_type}>(_gde_method_bind, _owner"
)
else: else:
if method["is_static"]: if method["is_static"]:
method_call += "internal::_call_native_mb_no_ret(_gde_method_bind, nullptr" method_call += "::godot::internal::_call_native_mb_no_ret(_gde_method_bind, nullptr"
else: else:
method_call += "internal::_call_native_mb_no_ret(_gde_method_bind, _owner" method_call += "::godot::internal::_call_native_mb_no_ret(_gde_method_bind, _owner"
if "arguments" in method: if "arguments" in method:
method_call += ", " method_call += ", "
@@ -2020,7 +2192,7 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
else: # vararg. else: # vararg.
result.append("\tGDExtensionCallError error;") result.append("\tGDExtensionCallError error;")
result.append("\tVariant ret;") result.append("\tVariant ret;")
method_call += "internal::gdextension_interface_object_method_bind_call(_gde_method_bind, _owner, reinterpret_cast<GDExtensionConstVariantPtr *>(p_args), p_arg_count, &ret, &error" method_call += "::godot::gdextension_interface::object_method_bind_call(_gde_method_bind, _owner, reinterpret_cast<GDExtensionConstVariantPtr *>(p_args), p_arg_count, &ret, &error"
if is_ref: if is_ref:
method_call += ")" # Close Ref<> constructor. method_call += ")" # Close Ref<> constructor.
@@ -2253,7 +2425,7 @@ def generate_utility_functions(api, output_dir):
# Function body. # Function body.
source.append( source.append(
f'\tstatic GDExtensionPtrUtilityFunction _gde_function = internal::gdextension_interface_variant_get_ptr_utility_function(StringName("{function["name"]}")._native_ptr(), {function["hash"]});' f'\tstatic GDExtensionPtrUtilityFunction _gde_function = ::godot::gdextension_interface::variant_get_ptr_utility_function(StringName("{function["name"]}")._native_ptr(), {function["hash"]});'
) )
has_return = "return_type" in function and function["return_type"] != "void" has_return = "return_type" in function and function["return_type"] != "void"
if has_return: if has_return:
@@ -2268,11 +2440,11 @@ def generate_utility_functions(api, output_dir):
if has_return: if has_return:
function_call += "return " function_call += "return "
if function["return_type"] == "Object": if function["return_type"] == "Object":
function_call += "internal::_call_utility_ret_obj(_gde_function" function_call += "::godot::internal::_call_utility_ret_obj(_gde_function"
else: else:
function_call += f"internal::_call_utility_ret<{get_gdextension_type(correct_type(function['return_type']))}>(_gde_function" function_call += f"::godot::internal::_call_utility_ret<{get_gdextension_type(correct_type(function['return_type']))}>(_gde_function"
else: else:
function_call += "internal::_call_utility_no_ret(_gde_function" function_call += "::godot::internal::_call_utility_no_ret(_gde_function"
if "arguments" in function: if "arguments" in function:
function_call += ", " function_call += ", "

View File

@@ -86,6 +86,7 @@ missing. ]]
function( function(
binding_generator_generate_bindings binding_generator_generate_bindings
API_FILE API_FILE
INTERFACE_FILE
USE_TEMPLATE_GET_NODE USE_TEMPLATE_GET_NODE
BITS BITS
PRECISION PRECISION
@@ -96,6 +97,7 @@ function(
"from binding_generator import generate_bindings" "from binding_generator import generate_bindings"
"generate_bindings( "generate_bindings(
api_filepath='${API_FILE}', api_filepath='${API_FILE}',
interface_filepath='${INTERFACE_FILE}',
use_template_get_node='${USE_TEMPLATE_GET_NODE}', use_template_get_node='${USE_TEMPLATE_GET_NODE}',
bits='${BITS}', bits='${BITS}',
precision='${PRECISION}', precision='${PRECISION}',

View File

@@ -170,6 +170,8 @@ function(common_compiler_flags)
$<${IS_MSVC}:$<${DISABLE_EXCEPTIONS}:_HAS_EXCEPTIONS=0>> $<${IS_MSVC}:$<${DISABLE_EXCEPTIONS}:_HAS_EXCEPTIONS=0>>
$<${THREADS_ENABLED}:THREADS_ENABLED> $<${THREADS_ENABLED}:THREADS_ENABLED>
$<$<NOT:$<BOOL:${GODOTCPP_DEPRECATED}>>:DISABLE_DEPRECATED>
) )
target_link_options( target_link_options(

View File

@@ -155,6 +155,7 @@ function(godotcpp_options)
#TODO optimize #TODO optimize
option(GODOTCPP_DEPRECATED "Enable compatibility code for deprecated and removed features" ON)
option(GODOTCPP_DEV_BUILD "Developer build with dev-only debugging code (DEV_ENABLED)" OFF) option(GODOTCPP_DEV_BUILD "Developer build with dev-only debugging code (DEV_ENABLED)" OFF)
#[[ debug_symbols #[[ debug_symbols
@@ -248,6 +249,9 @@ function(godotcpp_generate)
set(GODOTCPP_GDEXTENSION_API_FILE "${GODOTCPP_CUSTOM_API_FILE}") set(GODOTCPP_GDEXTENSION_API_FILE "${GODOTCPP_CUSTOM_API_FILE}")
endif() endif()
# Interface json file.
set(GODOTCPP_GDEXTENSION_INTERFACE_FILE "${GODOTCPP_GDEXTENSION_DIR}/gdextension_interface.json")
# Build Profile # Build Profile
if(GODOTCPP_BUILD_PROFILE) if(GODOTCPP_BUILD_PROFILE)
message(STATUS "Using build profile to trim api file") message(STATUS "Using build profile to trim api file")
@@ -262,6 +266,7 @@ function(godotcpp_generate)
endif() endif()
message(STATUS "GODOTCPP_GDEXTENSION_API_FILE = '${GODOTCPP_GDEXTENSION_API_FILE}'") message(STATUS "GODOTCPP_GDEXTENSION_API_FILE = '${GODOTCPP_GDEXTENSION_API_FILE}'")
message(STATUS "GODOTCPP_GDEXTENSION_INTERFACE_FILE = '${GODOTCPP_GDEXTENSION_INTERFACE_FILE}'")
# generate the file list to use # generate the file list to use
binding_generator_get_file_list( GENERATED_FILES_LIST binding_generator_get_file_list( GENERATED_FILES_LIST
@@ -271,6 +276,7 @@ function(godotcpp_generate)
binding_generator_generate_bindings( binding_generator_generate_bindings(
"${GODOTCPP_GDEXTENSION_API_FILE}" "${GODOTCPP_GDEXTENSION_API_FILE}"
"${GODOTCPP_GDEXTENSION_INTERFACE_FILE}"
"${USE_TEMPLATE_GET_NODE}" "${USE_TEMPLATE_GET_NODE}"
"${BITS}" "${BITS}"
"${GODOTCPP_PRECISION}" "${GODOTCPP_PRECISION}"
@@ -351,7 +357,7 @@ function(godotcpp_generate)
target_include_directories( target_include_directories(
godot-cpp godot-cpp
${GODOTCPP_SYSTEM_HEADERS_ATTRIBUTE} ${GODOTCPP_SYSTEM_HEADERS_ATTRIBUTE}
PUBLIC include ${CMAKE_CURRENT_BINARY_DIR}/gen/include ${GODOTCPP_GDEXTENSION_DIR} PUBLIC include ${CMAKE_CURRENT_BINARY_DIR}/gen/include
) )
# gersemi: off # gersemi: off

View File

@@ -40,7 +40,7 @@ def generate_doc_source(dst, source):
g.write("\n") g.write("\n")
g.write( g.write(
"static godot::internal::DocDataRegistration _doc_data_registration(_doc_data_hash, _doc_data_uncompressed_size, _doc_data_compressed_size, _doc_data_compressed);\n" "static ::godot::internal::DocDataRegistration _doc_data_registration(_doc_data_hash, _doc_data_uncompressed_size, _doc_data_compressed_size, _doc_data_compressed);\n"
) )
g.write("\n") g.write("\n")

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -236,7 +236,7 @@ struct PtrToArg<Ref<T>> {
if (unlikely(!p_ptr)) { if (unlikely(!p_ptr)) {
return Ref<T>(); return Ref<T>();
} }
return Ref<T>(reinterpret_cast<T *>(godot::internal::get_object_instance_binding(godot::internal::gdextension_interface_ref_get_object(ref)))); return Ref<T>(reinterpret_cast<T *>(::godot::internal::get_object_instance_binding(::godot::gdextension_interface::ref_get_object(ref))));
} }
typedef Ref<T> EncodeT; typedef Ref<T> EncodeT;
@@ -248,7 +248,7 @@ struct PtrToArg<Ref<T>> {
// This code assumes that p_ptr points to an unset Ref<T> variable on the Godot side // This code assumes that p_ptr points to an unset Ref<T> variable on the Godot side
// so we only set it if we have an object to set. // so we only set it if we have an object to set.
if (p_val.is_valid()) { if (p_val.is_valid()) {
godot::internal::gdextension_interface_ref_set_object(ref, p_val->_owner); ::godot::gdextension_interface::ref_set_object(ref, p_val->_owner);
} }
} }
}; };
@@ -262,7 +262,7 @@ struct PtrToArg<const Ref<T> &> {
if (unlikely(!p_ptr)) { if (unlikely(!p_ptr)) {
return Ref<T>(); return Ref<T>();
} }
return Ref<T>(reinterpret_cast<T *>(godot::internal::get_object_instance_binding(godot::internal::gdextension_interface_ref_get_object(ref)))); return Ref<T>(reinterpret_cast<T *>(::godot::internal::get_object_instance_binding(::godot::gdextension_interface::ref_get_object(ref))));
} }
}; };

View File

@@ -147,7 +147,7 @@ template <typename T>
struct VariantCasterAndValidate { struct VariantCasterAndValidate {
static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) { static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) {
GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo<T>::VARIANT_TYPE); GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo<T>::VARIANT_TYPE);
if (!internal::gdextension_interface_variant_can_convert_strict(static_cast<GDExtensionVariantType>(p_args[p_arg_idx]->get_type()), argtype) || if (!::godot::gdextension_interface::variant_can_convert_strict(static_cast<GDExtensionVariantType>(p_args[p_arg_idx]->get_type()), argtype) ||
!VariantObjectClassChecker<T>::check(p_args[p_arg_idx])) { !VariantObjectClassChecker<T>::check(p_args[p_arg_idx])) {
r_error.error = GDEXTENSION_CALL_ERROR_INVALID_ARGUMENT; r_error.error = GDEXTENSION_CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = p_arg_idx; r_error.argument = p_arg_idx;
@@ -162,7 +162,7 @@ template <typename T>
struct VariantCasterAndValidate<T &> { struct VariantCasterAndValidate<T &> {
static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) { static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) {
GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo<T>::VARIANT_TYPE); GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo<T>::VARIANT_TYPE);
if (!internal::gdextension_interface_variant_can_convert_strict(static_cast<GDExtensionVariantType>(p_args[p_arg_idx]->get_type()), argtype) || if (!::godot::gdextension_interface::variant_can_convert_strict(static_cast<GDExtensionVariantType>(p_args[p_arg_idx]->get_type()), argtype) ||
!VariantObjectClassChecker<T>::check(p_args[p_arg_idx])) { !VariantObjectClassChecker<T>::check(p_args[p_arg_idx])) {
r_error.error = GDEXTENSION_CALL_ERROR_INVALID_ARGUMENT; r_error.error = GDEXTENSION_CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = p_arg_idx; r_error.argument = p_arg_idx;
@@ -177,7 +177,7 @@ template <typename T>
struct VariantCasterAndValidate<const T &> { struct VariantCasterAndValidate<const T &> {
static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) { static _FORCE_INLINE_ T cast(const Variant **p_args, uint32_t p_arg_idx, GDExtensionCallError &r_error) {
GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo<T>::VARIANT_TYPE); GDExtensionVariantType argtype = GDExtensionVariantType(GetTypeInfo<T>::VARIANT_TYPE);
if (!internal::gdextension_interface_variant_can_convert_strict(static_cast<GDExtensionVariantType>(p_args[p_arg_idx]->get_type()), argtype) || if (!::godot::gdextension_interface::variant_can_convert_strict(static_cast<GDExtensionVariantType>(p_args[p_arg_idx]->get_type()), argtype) ||
!VariantObjectClassChecker<T>::check(p_args[p_arg_idx])) { !VariantObjectClassChecker<T>::check(p_args[p_arg_idx])) {
r_error.error = GDEXTENSION_CALL_ERROR_INVALID_ARGUMENT; r_error.error = GDEXTENSION_CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = p_arg_idx; r_error.argument = p_arg_idx;

View File

@@ -47,7 +47,7 @@ O *_call_builtin_method_ptr_ret_obj(const GDExtensionPtrBuiltInMethod method, GD
if (ret == nullptr) { if (ret == nullptr) {
return nullptr; return nullptr;
} }
return reinterpret_cast<O *>(internal::get_object_instance_binding(ret)); return reinterpret_cast<O *>(::godot::internal::get_object_instance_binding(ret));
} }
template <typename... Args> template <typename... Args>

View File

@@ -268,7 +268,7 @@ void ClassDB::_register_class(bool p_virtual, bool p_exposed, bool p_runtime) {
(void *)&T::get_class_static(), // void *class_userdata; (void *)&T::get_class_static(), // void *class_userdata;
}; };
internal::gdextension_interface_classdb_register_extension_class5(internal::library, cl.name._native_ptr(), cl.parent_name._native_ptr(), &class_info); ::godot::gdextension_interface::classdb_register_extension_class5(::godot::gdextension_interface::library, cl.name._native_ptr(), cl.parent_name._native_ptr(), &class_info);
// call bind_methods etc. to register all members of the class // call bind_methods etc. to register all members of the class
T::initialize_class(); T::initialize_class();

View File

@@ -46,25 +46,25 @@ template <typename O, typename... Args>
O *_call_native_mb_ret_obj(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) { O *_call_native_mb_ret_obj(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) {
GodotObject *ret = nullptr; GodotObject *ret = nullptr;
std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } }; std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } };
internal::gdextension_interface_object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret); ::godot::gdextension_interface::object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret);
if (ret == nullptr) { if (ret == nullptr) {
return nullptr; return nullptr;
} }
return reinterpret_cast<O *>(internal::get_object_instance_binding(ret)); return reinterpret_cast<O *>(::godot::internal::get_object_instance_binding(ret));
} }
template <typename R, typename... Args> template <typename R, typename... Args>
R _call_native_mb_ret(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) { R _call_native_mb_ret(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) {
typename PtrToArg<R>::EncodeT ret; typename PtrToArg<R>::EncodeT ret;
std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } }; std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } };
internal::gdextension_interface_object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret); ::godot::gdextension_interface::object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret);
return static_cast<R>(ret); return static_cast<R>(ret);
} }
template <typename... Args> template <typename... Args>
void _call_native_mb_no_ret(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) { void _call_native_mb_no_ret(const GDExtensionMethodBindPtr mb, void *instance, const Args &...args) {
std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } }; std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } };
internal::gdextension_interface_object_method_bind_ptrcall(mb, instance, mb_args.data(), nullptr); ::godot::gdextension_interface::object_method_bind_ptrcall(mb, instance, mb_args.data(), nullptr);
} }
template <typename R, typename... Args> template <typename R, typename... Args>
@@ -80,7 +80,7 @@ Object *_call_utility_ret_obj(const GDExtensionPtrUtilityFunction func, const Ar
GodotObject *ret = nullptr; GodotObject *ret = nullptr;
std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } }; std::array<GDExtensionConstTypePtr, sizeof...(Args)> mb_args = { { (GDExtensionConstTypePtr)args... } };
func(&ret, mb_args.data(), mb_args.size()); func(&ret, mb_args.data(), mb_args.size());
return (Object *)internal::get_object_instance_binding(ret); return (Object *)::godot::internal::get_object_instance_binding(ret);
} }
template <typename... Args> template <typename... Args>

View File

@@ -0,0 +1,41 @@
/**************************************************************************/
/* load_proc_address.inc */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#pragma once
#define ERR_PRINT_EARLY(m_msg) \
::godot::gdextension_interface::print_error(m_msg, FUNCTION_STR, __FILE__, __LINE__, false)
#define LOAD_PROC_ADDRESS(m_name, m_type) \
::godot::gdextension_interface::m_name = (m_type)p_get_proc_address(#m_name); \
if (!::godot::gdextension_interface::m_name) { \
ERR_PRINT_EARLY("Unable to load GDExtension interface function " #m_name "()"); \
return false; \
}

View File

@@ -112,7 +112,7 @@ void memdelete(T *p_class, typename std::enable_if<!std::is_base_of_v<godot::Wra
template <typename T, std::enable_if_t<std::is_base_of_v<godot::Wrapped, T>, bool> = true> template <typename T, std::enable_if_t<std::is_base_of_v<godot::Wrapped, T>, bool> = true>
void memdelete(T *p_class) { void memdelete(T *p_class) {
godot::internal::gdextension_interface_object_destroy(p_class->_owner); ::godot::gdextension_interface::object_destroy(p_class->_owner);
} }
template <typename T, typename A> template <typename T, typename A>

View File

@@ -173,7 +173,7 @@ template <typename T>
struct PtrToArg<T *> { struct PtrToArg<T *> {
static_assert(std::is_base_of<Object, T>::value, "Cannot encode non-Object value as an Object"); static_assert(std::is_base_of<Object, T>::value, "Cannot encode non-Object value as an Object");
_FORCE_INLINE_ static T *convert(const void *p_ptr) { _FORCE_INLINE_ static T *convert(const void *p_ptr) {
return likely(p_ptr) ? reinterpret_cast<T *>(godot::internal::get_object_instance_binding(*reinterpret_cast<GDExtensionObjectPtr *>(const_cast<void *>(p_ptr)))) : nullptr; return likely(p_ptr) ? reinterpret_cast<T *>(::godot::internal::get_object_instance_binding(*reinterpret_cast<GDExtensionObjectPtr *>(const_cast<void *>(p_ptr)))) : nullptr;
} }
typedef Object *EncodeT; typedef Object *EncodeT;
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) { _FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
@@ -185,7 +185,7 @@ template <typename T>
struct PtrToArg<const T *> { struct PtrToArg<const T *> {
static_assert(std::is_base_of<Object, T>::value, "Cannot encode non-Object value as an Object"); static_assert(std::is_base_of<Object, T>::value, "Cannot encode non-Object value as an Object");
_FORCE_INLINE_ static const T *convert(const void *p_ptr) { _FORCE_INLINE_ static const T *convert(const void *p_ptr) {
return likely(p_ptr) ? reinterpret_cast<const T *>(godot::internal::get_object_instance_binding(*reinterpret_cast<GDExtensionObjectPtr *>(const_cast<void *>(p_ptr)))) : nullptr; return likely(p_ptr) ? reinterpret_cast<const T *>(::godot::internal::get_object_instance_binding(*reinterpret_cast<GDExtensionObjectPtr *>(const_cast<void *>(p_ptr)))) : nullptr;
} }
typedef const Object *EncodeT; typedef const Object *EncodeT;
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) { _FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {

View File

@@ -108,11 +108,11 @@ MethodInfo::MethodInfo(const PropertyInfo &p_ret, StringName p_name, const Args
class ObjectDB { class ObjectDB {
public: public:
static Object *get_instance(uint64_t p_object_id) { static Object *get_instance(uint64_t p_object_id) {
GDExtensionObjectPtr obj = internal::gdextension_interface_object_get_instance_from_id(p_object_id); GDExtensionObjectPtr obj = ::godot::gdextension_interface::object_get_instance_from_id(p_object_id);
if (obj == nullptr) { if (obj == nullptr) {
return nullptr; return nullptr;
} }
return internal::get_object_instance_binding(obj); return ::godot::internal::get_object_instance_binding(obj);
} }
}; };
@@ -122,11 +122,11 @@ T *Object::cast_to(Object *p_object) {
return nullptr; return nullptr;
} }
StringName class_name = T::get_class_static(); StringName class_name = T::get_class_static();
GDExtensionObjectPtr casted = internal::gdextension_interface_object_cast_to(p_object->_owner, internal::gdextension_interface_classdb_get_class_tag(class_name._native_ptr())); GDExtensionObjectPtr casted = ::godot::gdextension_interface::object_cast_to(p_object->_owner, ::godot::gdextension_interface::classdb_get_class_tag(class_name._native_ptr()));
if (casted == nullptr) { if (casted == nullptr) {
return nullptr; return nullptr;
} }
return dynamic_cast<T *>(internal::get_object_instance_binding(casted)); return dynamic_cast<T *>(::godot::internal::get_object_instance_binding(casted));
} }
template <typename T> template <typename T>
@@ -135,11 +135,11 @@ const T *Object::cast_to(const Object *p_object) {
return nullptr; return nullptr;
} }
StringName class_name = T::get_class_static(); StringName class_name = T::get_class_static();
GDExtensionObjectPtr casted = internal::gdextension_interface_object_cast_to(p_object->_owner, internal::gdextension_interface_classdb_get_class_tag(class_name._native_ptr())); GDExtensionObjectPtr casted = ::godot::gdextension_interface::object_cast_to(p_object->_owner, ::godot::gdextension_interface::classdb_get_class_tag(class_name._native_ptr()));
if (casted == nullptr) { if (casted == nullptr) {
return nullptr; return nullptr;
} }
return dynamic_cast<const T *>(internal::get_object_instance_binding(casted)); return dynamic_cast<const T *>(::godot::internal::get_object_instance_binding(casted));
} }
} // namespace godot } // namespace godot

View File

@@ -30,180 +30,21 @@
#pragma once #pragma once
#include <gdextension_interface.h> #include <godot_cpp/core/gdextension_interface_loader.hpp>
namespace godot { namespace godot {
namespace internal { namespace gdextension_interface {
extern "C" GDExtensionInterfaceGetProcAddress gdextension_interface_get_proc_address; extern "C" GDExtensionInterfaceGetProcAddress get_proc_address;
extern "C" GDExtensionClassLibraryPtr library; extern "C" GDExtensionClassLibraryPtr library;
extern "C" void *token; extern "C" void *token;
extern "C" GDExtensionGodotVersion2 godot_version; extern "C" GDExtensionGodotVersion2 godot_version;
// All of the GDExtension interface functions. } // namespace gdextension_interface
extern "C" GDExtensionInterfaceGetGodotVersion2 gdextension_interface_get_godot_version2;
extern "C" GDExtensionInterfaceMemAlloc2 gdextension_interface_mem_alloc2; namespace internal {
extern "C" GDExtensionInterfaceMemRealloc2 gdextension_interface_mem_realloc2;
extern "C" GDExtensionInterfaceMemFree2 gdextension_interface_mem_free2;
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" GDExtensionInterfaceVariantGetObjectInstanceId gdextension_interface_variant_get_object_instance_id;
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" GDExtensionInterfaceGetVariantGetInternalPtrFunc gdextension_interface_variant_get_ptr_internal_getter;
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" GDExtensionInterfaceStringNewWithUtf8CharsAndLen2 gdextension_interface_string_new_with_utf8_chars_and_len2;
extern "C" GDExtensionInterfaceStringNewWithUtf16CharsAndLen gdextension_interface_string_new_with_utf16_chars_and_len;
extern "C" GDExtensionInterfaceStringNewWithUtf16CharsAndLen2 gdextension_interface_string_new_with_utf16_chars_and_len2;
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" GDExtensionInterfaceStringResize gdextension_interface_string_resize;
extern "C" GDExtensionInterfaceStringNameNewWithLatin1Chars gdextension_interface_string_name_new_with_latin1_chars;
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" GDExtensionInterfacePackedVector4ArrayOperatorIndex gdextension_interface_packed_vector4_array_operator_index;
extern "C" GDExtensionInterfacePackedVector4ArrayOperatorIndexConst gdextension_interface_packed_vector4_array_operator_index_const;
extern "C" GDExtensionInterfaceArrayOperatorIndex gdextension_interface_array_operator_index;
extern "C" GDExtensionInterfaceArrayOperatorIndexConst gdextension_interface_array_operator_index_const;
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" GDExtensionInterfaceDictionarySetTyped gdextension_interface_dictionary_set_typed;
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" GDExtensionInterfaceObjectFreeInstanceBinding gdextension_interface_object_free_instance_binding;
extern "C" GDExtensionInterfaceObjectSetInstance gdextension_interface_object_set_instance;
extern "C" GDExtensionInterfaceObjectGetClassName gdextension_interface_object_get_class_name;
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" GDExtensionInterfaceObjectHasScriptMethod gdextension_interface_object_has_script_method;
extern "C" GDExtensionInterfaceObjectCallScriptMethod gdextension_interface_object_call_script_method;
extern "C" GDExtensionInterfaceCallableCustomCreate2 gdextension_interface_callable_custom_create2;
extern "C" GDExtensionInterfaceCallableCustomGetUserData gdextension_interface_callable_custom_get_userdata;
extern "C" GDExtensionInterfaceRefGetObject gdextension_interface_ref_get_object;
extern "C" GDExtensionInterfaceRefSetObject gdextension_interface_ref_set_object;
extern "C" GDExtensionInterfaceScriptInstanceCreate3 gdextension_interface_script_instance_create3;
extern "C" GDExtensionInterfacePlaceHolderScriptInstanceCreate gdextension_interface_placeholder_script_instance_create;
extern "C" GDExtensionInterfacePlaceHolderScriptInstanceUpdate gdextension_interface_placeholder_script_instance_update;
extern "C" GDExtensionInterfaceObjectGetScriptInstance gdextension_interface_object_get_script_instance;
extern "C" GDExtensionInterfaceObjectSetScriptInstance gdextension_interface_object_set_script_instance;
extern "C" GDExtensionInterfaceClassdbConstructObject2 gdextension_interface_classdb_construct_object2;
extern "C" GDExtensionInterfaceClassdbGetMethodBind gdextension_interface_classdb_get_method_bind;
extern "C" GDExtensionInterfaceClassdbGetClassTag gdextension_interface_classdb_get_class_tag;
extern "C" GDExtensionInterfaceClassdbRegisterExtensionClass5 gdextension_interface_classdb_register_extension_class5;
extern "C" GDExtensionInterfaceClassdbRegisterExtensionClassMethod gdextension_interface_classdb_register_extension_class_method;
extern "C" GDExtensionInterfaceClassdbRegisterExtensionClassVirtualMethod gdextension_interface_classdb_register_extension_class_virtual_method;
extern "C" GDExtensionInterfaceClassdbRegisterExtensionClassIntegerConstant gdextension_interface_classdb_register_extension_class_integer_constant;
extern "C" GDExtensionInterfaceClassdbRegisterExtensionClassProperty gdextension_interface_classdb_register_extension_class_property;
extern "C" GDExtensionInterfaceClassdbRegisterExtensionClassPropertyIndexed gdextension_interface_classdb_register_extension_class_property_indexed;
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;
extern "C" GDExtensionInterfaceEditorAddPlugin gdextension_interface_editor_add_plugin;
extern "C" GDExtensionInterfaceEditorRemovePlugin gdextension_interface_editor_remove_plugin;
extern "C" GDExtensionInterfaceEditorRegisterGetClassesUsedCallback gdextension_interface_editor_register_get_classes_used_callback;
extern "C" GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8Chars gdextension_interface_editor_help_load_xml_from_utf8_chars;
extern "C" GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8CharsAndLen gdextension_interface_editor_help_load_xml_from_utf8_chars_and_len;
extern "C" GDExtensionInterfaceImagePtrw gdextension_interface_image_ptrw;
extern "C" GDExtensionInterfaceImagePtr gdextension_interface_image_ptr;
extern "C" GDExtensionInterfaceRegisterMainLoopCallbacks gdextension_interface_register_main_loop_callbacks;
class DocDataRegistration { class DocDataRegistration {
public: public:

View File

@@ -205,12 +205,12 @@ class VariantInternal {
public: public:
template <typename T> template <typename T>
_FORCE_INLINE_ static T *get_internal_value(Variant *v) { _FORCE_INLINE_ static T *get_internal_value(Variant *v) {
return static_cast<T *>(get_internal_func[internal::VariantInternalType<T>::type](v)); return static_cast<T *>(get_internal_func[::godot::internal::VariantInternalType<T>::type](v));
} }
template <typename T> template <typename T>
_FORCE_INLINE_ static const T *get_internal_value(const Variant *v) { _FORCE_INLINE_ static const T *get_internal_value(const Variant *v) {
return static_cast<const T *>(get_internal_func[internal::VariantInternalType<T>::type](const_cast<Variant *>(v))); return static_cast<const T *>(get_internal_func[::godot::internal::VariantInternalType<T>::type](const_cast<Variant *>(v)));
} }
// Atomic types. // Atomic types.
@@ -473,8 +473,8 @@ public:
template <typename T> template <typename T>
struct VariantGetInternalPtr { struct VariantGetInternalPtr {
static internal::VariantInternalType<T> *get_ptr(Variant *v) { return VariantInternal::get_internal_value<T>(v); } static ::godot::internal::VariantInternalType<T> *get_ptr(Variant *v) { return VariantInternal::get_internal_value<T>(v); }
static const internal::VariantInternalType<T> *get_ptr(const Variant *v) { return VariantInternal::get_internal_value<T>(v); } static const ::godot::internal::VariantInternalType<T> *get_ptr(const Variant *v) { return VariantInternal::get_internal_value<T>(v); }
}; };
template <typename T> template <typename T>
@@ -493,7 +493,7 @@ struct VariantInternalAccessor {
// Enable set() only for those types where we can set (all but Object *). // Enable set() only for those types where we can set (all but Object *).
template <typename U = T, typename = std::enable_if_t<can_set_variant_internal_value<U>::value>> template <typename U = T, typename = std::enable_if_t<can_set_variant_internal_value<U>::value>>
static _FORCE_INLINE_ void set(Variant *v, const internal::VariantInternalType<U> &p_value) { static _FORCE_INLINE_ void set(Variant *v, const ::godot::internal::VariantInternalType<U> &p_value) {
*VariantInternal::get_internal_value<U>(v) = p_value; *VariantInternal::get_internal_value<U>(v) = p_value;
} }
}; };

364
make_interface_header.py Normal file
View File

@@ -0,0 +1,364 @@
import difflib
import json
from collections import OrderedDict
BASE_TYPES = [
"void",
"int",
"int8_t",
"uint8_t",
"int16_t",
"uint16_t",
"int32_t",
"uint32_t",
"int64_t",
"uint64_t",
"size_t",
"char",
"char16_t",
"char32_t",
"wchar_t",
"float",
"double",
]
def _get_buffer(path):
with open(path, "rb") as file:
return file.read()
def _generated_wrapper(path, header_lines):
f = open(path, "wt", encoding="utf-8")
for line in header_lines:
f.write(line + "\n")
f.write("#pragma once\n\n")
return f
def scons_run(target, source, env):
target_path = str(target[0])
source_path = str(source[0])
generate_gdextension_interface_header(target_path, source_path)
def generate_gdextension_interface_header(target, source, header_lines=[]):
buffer = _get_buffer(source)
data = json.loads(buffer, object_pairs_hook=OrderedDict)
check_formatting(buffer.decode("utf-8"), data, source)
check_allowed_keys(data, ["_copyright", "$schema", "format_version", "types", "interface"])
valid_data_types = {}
for type in BASE_TYPES:
valid_data_types[type] = True
with _generated_wrapper(target, header_lines) as file:
file.write("""\
#ifndef __cplusplus
#include <stddef.h>
#include <stdint.h>
typedef uint32_t char32_t;
typedef uint16_t char16_t;
#else
#include <cstddef>
#include <cstdint>
extern "C" {
#endif
""")
handles = []
type_replacements = []
for type in data["types"]:
kind = type["kind"]
check_type(kind, type, valid_data_types)
valid_data_types[type["name"]] = type
if "deprecated" in type:
check_allowed_keys(type["deprecated"], ["since"], ["message", "replace_with"])
if "replace_with" in type["deprecated"]:
type_replacements.append((type["name"], type["deprecated"]["replace_with"]))
if "description" in type:
write_doc(file, type["description"])
if kind == "handle":
check_allowed_keys(
type, ["name", "kind"], ["is_const", "is_uninitialized", "parent", "description", "deprecated"]
)
if "parent" in type and type["parent"] not in handles:
raise UnknownTypeError(type["parent"], type["name"])
# @todo In the future, let's write these as `struct *` so the compiler can help us with type checking.
type["type"] = "void*" if not type.get("is_const", False) else "const void*"
write_simple_type(file, type)
handles.append(type["name"])
elif kind == "alias":
check_allowed_keys(type, ["name", "kind", "type"], ["description", "deprecated"])
write_simple_type(file, type)
elif kind == "enum":
check_allowed_keys(type, ["name", "kind", "values"], ["is_bitfield", "description", "deprecated"])
write_enum_type(file, type)
elif kind == "function":
check_allowed_keys(type, ["name", "kind", "return_value", "arguments"], ["description", "deprecated"])
write_function_type(file, type)
elif kind == "struct":
check_allowed_keys(type, ["name", "kind", "members"], ["description", "deprecated"])
write_struct_type(file, type)
else:
raise Exception(f"Unknown kind of type: {kind}")
for type_name, replace_with in type_replacements:
if replace_with not in valid_data_types:
raise Exception(f"Unknown type '{replace_with}' used as replacement for '{type_name}'")
replacement = valid_data_types[replace_with]
if isinstance(replacement, dict) and "deprecated" in replacement:
raise Exception(
f"Cannot use '{replace_with}' as replacement for '{type_name}' because it's deprecated too"
)
interface_replacements = []
valid_interfaces = {}
for interface in data["interface"]:
check_type("function", interface, valid_data_types)
check_allowed_keys(
interface,
["name", "return_value", "arguments", "since", "description"],
["see", "legacy_type_name", "deprecated"],
)
valid_interfaces[interface["name"]] = interface
if "deprecated" in interface:
check_allowed_keys(interface["deprecated"], ["since"], ["message", "replace_with"])
if "replace_with" in interface["deprecated"]:
interface_replacements.append((interface["name"], interface["deprecated"]["replace_with"]))
write_interface(file, interface)
for function_name, replace_with in interface_replacements:
if replace_with not in valid_interfaces:
raise Exception(
f"Unknown interface function '{replace_with}' used as replacement for '{function_name}'"
)
replacement = valid_interfaces[replace_with]
if "deprecated" in replacement:
raise Exception(
f"Cannot use '{replace_with}' as replacement for '{function_name}' because it's deprecated too"
)
file.write("""\
#ifdef __cplusplus
}
#endif
""")
# Serialize back into JSON in order to see if the formatting remains the same.
def check_formatting(buffer, data, filename):
buffer2 = json.dumps(data, indent=4)
lines1 = buffer.splitlines()
lines2 = buffer2.splitlines()
diff = difflib.unified_diff(
lines1,
lines2,
fromfile="a/" + filename,
tofile="b/" + filename,
lineterm="",
)
diff = list(diff)
if len(diff) > 0:
print(" *** Apply this patch to fix: ***\n")
print("\n".join(diff))
raise Exception(f"Formatting issues in {filename}")
def check_allowed_keys(data, required, optional=[]):
keys = data.keys()
allowed = required + optional
for k in keys:
if k not in allowed:
raise Exception(f"Found unknown key '{k}'")
for r in required:
if r not in keys:
raise Exception(f"Missing required key '{r}'")
class UnknownTypeError(Exception):
def __init__(self, unknown, parent, item=None):
self.unknown = unknown
self.parent = parent
if item:
msg = f"Unknown type '{unknown}' for '{item}' used in '{parent}'"
else:
msg = f"Unknown type '{unknown}' used in '{parent}'"
super().__init__(msg)
def base_type_name(type_name):
if type_name.startswith("const "):
type_name = type_name[6:]
if type_name.endswith("*"):
type_name = type_name[:-1]
return type_name
def format_type_and_name(type, name=None):
ret = type
if ret[-1] == "*":
ret = ret[:-1] + " *"
if name:
if ret[-1] == "*":
ret = ret + name
else:
ret = ret + " " + name
return ret
def check_type(kind, type, valid_data_types):
if kind == "alias":
if base_type_name(type["type"]) not in valid_data_types:
raise UnknownTypeError(type["type"], type["name"])
elif kind == "struct":
for member in type["members"]:
if base_type_name(member["type"]) not in valid_data_types:
raise UnknownTypeError(member["type"], type["name"], member["name"])
elif kind == "function":
for arg in type["arguments"]:
if base_type_name(arg["type"]) not in valid_data_types:
raise UnknownTypeError(arg["type"], type["name"], arg.get("name"))
if "return_value" in type:
if base_type_name(type["return_value"]["type"]) not in valid_data_types:
raise UnknownTypeError(type["return_value"]["type"], type["name"])
def write_doc(file, doc, indent=""):
if len(doc) == 1:
file.write(f"{indent}/* {doc[0]} */\n")
return
first = True
for line in doc:
if first:
file.write(indent + "/*")
first = False
else:
file.write(indent + " *")
if line != "":
file.write(" " + line)
file.write("\n")
file.write(indent + " */\n")
def make_deprecated_message(data):
parts = [
f"Deprecated in Godot {data['since']}.",
data["message"] if "message" in data else "",
f"Use `{data['replace_with']}` instead." if "replace_with" in data else "",
]
return " ".join([x for x in parts if x.strip() != ""])
def make_deprecated_comment_for_type(type):
if "deprecated" not in type:
return ""
message = make_deprecated_message(type["deprecated"])
return f" /* {message} */"
def write_simple_type(file, type):
file.write(f"typedef {format_type_and_name(type['type'], type['name'])};{make_deprecated_comment_for_type(type)}\n")
def write_enum_type(file, enum):
file.write("typedef enum {\n")
for value in enum["values"]:
check_allowed_keys(value, ["name", "value"], ["description", "deprecated"])
if "description" in value:
write_doc(file, value["description"], "\t")
file.write(f"\t{value['name']} = {value['value']},\n")
file.write(f"}} {enum['name']};{make_deprecated_comment_for_type(enum)}\n\n")
def make_args_text(args):
combined = []
for arg in args:
check_allowed_keys(arg, ["type"], ["name", "description"])
combined.append(format_type_and_name(arg["type"], arg.get("name")))
return ", ".join(combined)
def write_function_type(file, fn):
args_text = make_args_text(fn["arguments"]) if ("arguments" in fn) else ""
name_and_args = f"(*{fn['name']})({args_text})"
file.write(
f"typedef {format_type_and_name(fn['return_value']['type'], name_and_args)};{make_deprecated_comment_for_type(fn)}\n"
)
def write_struct_type(file, struct):
file.write("typedef struct {\n")
for member in struct["members"]:
check_allowed_keys(member, ["name", "type"], ["description"])
if "description" in member:
write_doc(file, member["description"], "\t")
file.write(f"\t{format_type_and_name(member['type'], member['name'])};\n")
file.write(f"}} {struct['name']};{make_deprecated_comment_for_type(struct)}\n\n")
def write_interface(file, interface):
doc = [
f"@name {interface['name']}",
f"@since {interface['since']}",
]
if "deprecated" in interface:
doc.append(f"@deprecated {make_deprecated_message(interface['deprecated'])}")
doc += [
"",
interface["description"][0],
]
if len(interface["description"]) > 1:
doc.append("")
doc += interface["description"][1:]
if "arguments" in interface:
doc.append("")
for arg in interface["arguments"]:
if "description" not in arg:
raise Exception(f"Interface function {interface['name']} is missing docs for {arg['name']} argument")
arg_doc = " ".join(arg["description"])
doc.append(f"@param {arg['name']} {arg_doc}")
if "return_value" in interface and interface["return_value"]["type"] != "void":
if "description" not in interface["return_value"]:
raise Exception(f"Interface function {interface['name']} is missing docs for return value")
ret_doc = " ".join(interface["return_value"]["description"])
doc.append("")
doc.append(f"@return {ret_doc}")
if "see" in interface:
doc.append("")
for see in interface["see"]:
doc.append(f"@see {see}")
file.write("/**\n")
for d in doc:
if d != "":
file.write(f" * {d}\n")
else:
file.write(" *\n")
file.write(" */\n")
fn = interface.copy()
if "deprecated" in fn:
del fn["deprecated"]
fn["name"] = "GDExtensionInterface" + "".join(word.capitalize() for word in interface["name"].split("_"))
write_function_type(file, fn)
file.write("\n")

View File

@@ -10,6 +10,7 @@ from binding_generator import _generate_bindings, _get_file_list
from build_profile import generate_trimmed_api from build_profile import generate_trimmed_api
api_filepath = "gdextension/extension_api.json" api_filepath = "gdextension/extension_api.json"
interface_filepath = "gdextension/gdextension_interface.json"
bits = "64" bits = "64"
precision = "single" precision = "single"
output_dir = "self_test" output_dir = "self_test"
@@ -20,6 +21,7 @@ def test(profile_filepath=""):
_generate_bindings( _generate_bindings(
api, api,
api_filepath, api_filepath,
interface_filepath,
use_template_get_node=False, use_template_get_node=False,
bits=bits, bits=bits,
precision=precision, precision=precision,

View File

@@ -39,20 +39,20 @@ Vector<StringName> EditorPlugins::plugin_classes;
void EditorPlugins::add_plugin_class(const StringName &p_class_name) { void EditorPlugins::add_plugin_class(const StringName &p_class_name) {
ERR_FAIL_COND_MSG(plugin_classes.find(p_class_name) != -1, vformat("Editor plugin already registered: %s", p_class_name)); ERR_FAIL_COND_MSG(plugin_classes.find(p_class_name) != -1, vformat("Editor plugin already registered: %s", p_class_name));
plugin_classes.push_back(p_class_name); plugin_classes.push_back(p_class_name);
internal::gdextension_interface_editor_add_plugin(p_class_name._native_ptr()); ::godot::gdextension_interface::editor_add_plugin(p_class_name._native_ptr());
} }
void EditorPlugins::remove_plugin_class(const StringName &p_class_name) { void EditorPlugins::remove_plugin_class(const StringName &p_class_name) {
int index = plugin_classes.find(p_class_name); int index = plugin_classes.find(p_class_name);
ERR_FAIL_COND_MSG(index == -1, vformat("Editor plugin is not registered: %s", p_class_name)); ERR_FAIL_COND_MSG(index == -1, vformat("Editor plugin is not registered: %s", p_class_name));
plugin_classes.remove_at(index); plugin_classes.remove_at(index);
internal::gdextension_interface_editor_remove_plugin(p_class_name._native_ptr()); ::godot::gdextension_interface::editor_remove_plugin(p_class_name._native_ptr());
} }
void EditorPlugins::deinitialize(GDExtensionInitializationLevel p_level) { void EditorPlugins::deinitialize(GDExtensionInitializationLevel p_level) {
if (p_level == GDEXTENSION_INITIALIZATION_EDITOR) { if (p_level == GDEXTENSION_INITIALIZATION_EDITOR) {
for (const StringName &class_name : plugin_classes) { for (const StringName &class_name : plugin_classes) {
internal::gdextension_interface_editor_remove_plugin(class_name._native_ptr()); ::godot::gdextension_interface::editor_remove_plugin(class_name._native_ptr());
} }
plugin_classes.clear(); plugin_classes.clear();
} }

View File

@@ -37,31 +37,31 @@
namespace godot { namespace godot {
Error XMLParser::_open_buffer(const uint8_t *p_buffer, size_t p_size) { Error XMLParser::_open_buffer(const uint8_t *p_buffer, size_t p_size) {
return (Error)internal::gdextension_interface_xml_parser_open_buffer(_owner, p_buffer, p_size); return (Error)::godot::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 { uint64_t FileAccess::get_buffer(uint8_t *p_dst, uint64_t p_length) const {
return internal::gdextension_interface_file_access_get_buffer(_owner, p_dst, p_length); return ::godot::gdextension_interface::file_access_get_buffer(_owner, p_dst, p_length);
} }
void FileAccess::store_buffer(const uint8_t *p_src, uint64_t p_length) { void FileAccess::store_buffer(const uint8_t *p_src, uint64_t p_length) {
internal::gdextension_interface_file_access_store_buffer(_owner, p_src, p_length); ::godot::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) { WorkerThreadPool::TaskID WorkerThreadPool::add_native_task(void (*p_func)(void *), void *p_userdata, bool p_high_priority, const String &p_description) {
return (TaskID)internal::gdextension_interface_worker_thread_pool_add_native_task(_owner, p_func, p_userdata, p_high_priority, (GDExtensionConstStringPtr)&p_description); return (TaskID)::godot::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) { 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::gdextension_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)::godot::gdextension_interface::worker_thread_pool_add_native_group_task(_owner, p_func, p_userdata, p_elements, p_tasks, p_high_priority, (GDExtensionConstStringPtr)&p_description);
} }
uint8_t *Image::ptrw() { uint8_t *Image::ptrw() {
return internal::gdextension_interface_image_ptrw(_owner); return ::godot::gdextension_interface::image_ptrw(_owner);
} }
const uint8_t *Image::ptr() { const uint8_t *Image::ptr() {
return internal::gdextension_interface_image_ptr(_owner); return ::godot::gdextension_interface::image_ptr(_owner);
} }
} // namespace godot } // namespace godot

View File

@@ -74,16 +74,16 @@ Wrapped::Wrapped(const StringName &p_godot_class) {
} else } else
#endif #endif
{ {
_owner = godot::internal::gdextension_interface_classdb_construct_object2(reinterpret_cast<GDExtensionConstStringNamePtr>(p_godot_class._native_ptr())); _owner = ::godot::gdextension_interface::classdb_construct_object2(reinterpret_cast<GDExtensionConstStringNamePtr>(p_godot_class._native_ptr()));
} }
if (_constructing_extension_class_name) { if (_constructing_extension_class_name) {
godot::internal::gdextension_interface_object_set_instance(_owner, reinterpret_cast<GDExtensionConstStringNamePtr>(_constructing_extension_class_name), this); ::godot::gdextension_interface::object_set_instance(_owner, reinterpret_cast<GDExtensionConstStringNamePtr>(_constructing_extension_class_name), this);
_constructing_extension_class_name = nullptr; _constructing_extension_class_name = nullptr;
} }
if (likely(_constructing_class_binding_callbacks)) { if (likely(_constructing_class_binding_callbacks)) {
godot::internal::gdextension_interface_object_set_instance_binding(_owner, godot::internal::token, this, _constructing_class_binding_callbacks); ::godot::gdextension_interface::object_set_instance_binding(_owner, ::godot::gdextension_interface::token, this, _constructing_class_binding_callbacks);
_constructing_class_binding_callbacks = nullptr; _constructing_class_binding_callbacks = nullptr;
} else { } else {
CRASH_NOW_MSG("BUG: Godot Object created without binding callbacks. Did you forget to use memnew()?"); CRASH_NOW_MSG("BUG: Godot Object created without binding callbacks. Did you forget to use memnew()?");

View File

@@ -58,13 +58,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) { 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))); 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::gdextension_interface_classdb_register_extension_class_property_group(internal::library, p_class._native_ptr(), p_name._native_ptr(), p_prefix._native_ptr()); ::godot::gdextension_interface::classdb_register_extension_class_property_group(::godot::gdextension_interface::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) { 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))); 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::gdextension_interface_classdb_register_extension_class_property_subgroup(internal::library, p_class._native_ptr(), p_name._native_ptr(), p_prefix._native_ptr()); ::godot::gdextension_interface::classdb_register_extension_class_property_subgroup(::godot::gdextension_interface::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) { void ClassDB::add_property(const StringName &p_class, const PropertyInfo &p_pinfo, const StringName &p_setter, const StringName &p_getter, int p_index) {
@@ -106,7 +106,7 @@ void ClassDB::add_property(const StringName &p_class, const PropertyInfo &p_pinf
p_pinfo.usage, // DEFAULT //uint32_t usage; p_pinfo.usage, // DEFAULT //uint32_t usage;
}; };
internal::gdextension_interface_classdb_register_extension_class_property_indexed(internal::library, info.name._native_ptr(), &prop_info, p_setter._native_ptr(), p_getter._native_ptr(), p_index); ::godot::gdextension_interface::classdb_register_extension_class_property_indexed(::godot::gdextension_interface::library, info.name._native_ptr(), &prop_info, p_setter._native_ptr(), p_getter._native_ptr(), p_index);
} }
MethodBind *ClassDB::get_method(const StringName &p_class, const StringName &p_method) { MethodBind *ClassDB::get_method(const StringName &p_class, const StringName &p_method) {
@@ -229,7 +229,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; (uint32_t)p_method->get_default_argument_count(), // uint32_t default_argument_count;
def_args.ptr(), // GDExtensionVariantPtr *default_arguments; def_args.ptr(), // GDExtensionVariantPtr *default_arguments;
}; };
internal::gdextension_interface_classdb_register_extension_class_method(internal::library, p_class_name._native_ptr(), &method_info); ::godot::gdextension_interface::classdb_register_extension_class_method(::godot::gdextension_interface::library, p_class_name._native_ptr(), &method_info);
} }
void ClassDB::add_signal(const StringName &p_class, const MethodInfo &p_signal) { void ClassDB::add_signal(const StringName &p_class, const MethodInfo &p_signal) {
@@ -264,7 +264,7 @@ void ClassDB::add_signal(const StringName &p_class, const MethodInfo &p_signal)
}); });
} }
internal::gdextension_interface_classdb_register_extension_class_signal(internal::library, cl.name._native_ptr(), p_signal.name._native_ptr(), parameters.ptr(), parameters.size()); ::godot::gdextension_interface::classdb_register_extension_class_signal(::godot::gdextension_interface::library, cl.name._native_ptr(), p_signal.name._native_ptr(), parameters.ptr(), 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) { 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) {
@@ -281,7 +281,7 @@ void ClassDB::bind_integer_constant(const StringName &p_class_name, const String
type.constant_names.insert(p_constant_name); type.constant_names.insert(p_constant_name);
// Register it with Godot // Register it with Godot
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); ::godot::gdextension_interface::classdb_register_extension_class_integer_constant(::godot::gdextension_interface::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, uint32_t p_hash) { GDExtensionClassCallVirtual ClassDB::get_virtual_func(void *p_userdata, GDExtensionConstStringNamePtr p_name, uint32_t p_hash) {
// This is called by Godot the first time it calls a virtual function, and it caches the result, per object instance. // This is called by Godot the first time it calls a virtual function, and it caches the result, per object instance.
@@ -376,7 +376,7 @@ void ClassDB::add_virtual_method(const StringName &p_class, const MethodInfo &p_
} }
} }
internal::gdextension_interface_classdb_register_extension_class_virtual_method(internal::library, &p_class, &mi); ::godot::gdextension_interface::classdb_register_extension_class_virtual_method(::godot::gdextension_interface::library, &p_class, &mi);
if (mi.arguments) { if (mi.arguments) {
memfree(mi.arguments); memfree(mi.arguments);
@@ -419,7 +419,7 @@ void ClassDB::deinitialize(GDExtensionInitializationLevel p_level) {
continue; continue;
} }
internal::gdextension_interface_classdb_unregister_extension_class(internal::library, name._native_ptr()); ::godot::gdextension_interface::classdb_unregister_extension_class(::godot::gdextension_interface::library, name._native_ptr());
for (const KeyValue<StringName, MethodBind *> &method : cl.method_map) { for (const KeyValue<StringName, MethodBind *> &method : cl.method_map) {
memdelete(method.value); memdelete(method.value);
@@ -447,7 +447,7 @@ void ClassDB::deinitialize(GDExtensionInitializationLevel p_level) {
} }
} }
for (const Object *i : singleton_objects) { for (const Object *i : singleton_objects) {
internal::gdextension_interface_object_free_instance_binding((*i)._owner, internal::token); ::godot::gdextension_interface::object_free_instance_binding((*i)._owner, ::godot::gdextension_interface::token);
} }
} }
} }

View File

@@ -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) { 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) { if (p_is_warning) {
internal::gdextension_interface_print_warning(p_error, p_function, p_file, p_line, p_editor_notify); ::godot::gdextension_interface::print_warning(p_error, p_function, p_file, p_line, p_editor_notify);
} else { } else {
internal::gdextension_interface_print_error(p_error, p_function, p_file, p_line, p_editor_notify); ::godot::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) { 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) { if (p_is_warning) {
internal::gdextension_interface_print_warning_with_message(p_error, p_message, p_function, p_file, p_line, p_editor_notify); ::godot::gdextension_interface::print_warning_with_message(p_error, p_message, p_function, p_file, p_line, p_editor_notify);
} else { } else {
internal::gdextension_interface_print_error_with_message(p_error, p_message, p_function, p_file, p_line, p_editor_notify); ::godot::gdextension_interface::print_error_with_message(p_error, p_message, p_function, p_file, p_line, p_editor_notify);
} }
} }

View File

@@ -35,7 +35,19 @@
namespace godot { namespace godot {
void *Memory::alloc_static(size_t p_bytes, bool p_pad_align) { void *Memory::alloc_static(size_t p_bytes, bool p_pad_align) {
return internal::gdextension_interface_mem_alloc2(p_bytes, p_pad_align); #if GODOT_VERSION_MINOR >= 6
return ::godot::gdextension_interface::mem_alloc2(p_bytes, p_pad_align);
#else
void *mem = ::godot::gdextension_interface::mem_alloc(p_bytes + (p_pad_align ? DATA_OFFSET : 0));
ERR_FAIL_NULL_V(mem, nullptr);
if (p_pad_align) {
uint8_t *s8 = (uint8_t *)mem;
return s8 + DATA_OFFSET;
} else {
return mem;
}
#endif
} }
void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) { void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) {
@@ -46,11 +58,31 @@ void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) {
return nullptr; return nullptr;
} }
return internal::gdextension_interface_mem_realloc2(p_memory, p_bytes, p_pad_align); #if GODOT_VERSION_MINOR >= 6
return ::godot::gdextension_interface::mem_realloc2(p_memory, p_bytes, p_pad_align);
#else
uint8_t *mem = (uint8_t *)p_memory;
if (p_pad_align) {
mem -= DATA_OFFSET;
mem = (uint8_t *)::godot::gdextension_interface::mem_realloc(mem, p_bytes + DATA_OFFSET);
ERR_FAIL_NULL_V(mem, nullptr);
return mem + DATA_OFFSET;
} else {
return (uint8_t *)::godot::gdextension_interface::mem_realloc(mem, p_bytes);
}
#endif
} }
void Memory::free_static(void *p_ptr, bool p_pad_align) { void Memory::free_static(void *p_ptr, bool p_pad_align) {
internal::gdextension_interface_mem_free2(p_ptr, p_pad_align); #if GODOT_VERSION_MINOR >= 6
::godot::gdextension_interface::mem_free2(p_ptr, p_pad_align);
#else
uint8_t *mem = (uint8_t *)p_ptr;
if (p_pad_align) {
mem -= DATA_OFFSET;
}
::godot::gdextension_interface::mem_free(mem);
#endif
} }
_GlobalNil::_GlobalNil() { _GlobalNil::_GlobalNil() {

View File

@@ -92,7 +92,7 @@ void MethodBind::bind_call(void *p_method_userdata, GDExtensionClassInstancePtr
Variant ret = bind->call(p_instance, p_args, p_argument_count, *r_error); 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. // 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. // Since only GDExtensionMethodBind calls this from the Godot side, it should always be the case.
internal::gdextension_interface_variant_new_copy(r_return, ret._native_ptr()); ::godot::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) { void MethodBind::bind_ptrcall(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_return) {

View File

@@ -42,7 +42,7 @@ Object *get_object_instance_binding(GodotObject *p_engine_object) {
} }
// Get existing instance binding, if one already exists. // Get existing instance binding, if one already exists.
GDExtensionObjectPtr instance = gdextension_interface_object_get_instance_binding(p_engine_object, token, nullptr); GDExtensionObjectPtr instance = ::godot::gdextension_interface::object_get_instance_binding(p_engine_object, ::godot::gdextension_interface::token, nullptr);
if (instance != nullptr) { if (instance != nullptr) {
return reinterpret_cast<Object *>(instance); return reinterpret_cast<Object *>(instance);
} }
@@ -50,14 +50,14 @@ Object *get_object_instance_binding(GodotObject *p_engine_object) {
// Otherwise, try to look up the correct binding callbacks. // Otherwise, try to look up the correct binding callbacks.
const GDExtensionInstanceBindingCallbacks *binding_callbacks = nullptr; const GDExtensionInstanceBindingCallbacks *binding_callbacks = nullptr;
StringName class_name; StringName class_name;
if (gdextension_interface_object_get_class_name(p_engine_object, library, reinterpret_cast<GDExtensionStringNamePtr>(class_name._native_ptr()))) { if (::godot::gdextension_interface::object_get_class_name(p_engine_object, ::godot::gdextension_interface::library, reinterpret_cast<GDExtensionStringNamePtr>(class_name._native_ptr()))) {
binding_callbacks = ClassDB::get_instance_binding_callbacks(class_name); binding_callbacks = ClassDB::get_instance_binding_callbacks(class_name);
} }
if (binding_callbacks == nullptr) { if (binding_callbacks == nullptr) {
binding_callbacks = &Object::_gde_binding_callbacks; binding_callbacks = &Object::_gde_binding_callbacks;
} }
return reinterpret_cast<Object *>(gdextension_interface_object_get_instance_binding(p_engine_object, token, binding_callbacks)); return reinterpret_cast<Object *>(::godot::gdextension_interface::object_get_instance_binding(p_engine_object, ::godot::gdextension_interface::token, binding_callbacks));
} }
TypedArray<Dictionary> convert_property_list(const LocalVector<PropertyInfo> &p_list) { TypedArray<Dictionary> convert_property_list(const LocalVector<PropertyInfo> &p_list) {
@@ -73,7 +73,7 @@ TypedArray<Dictionary> convert_property_list(const LocalVector<PropertyInfo> &p_
MethodInfo::operator Dictionary() const { MethodInfo::operator Dictionary() const {
Dictionary dict; Dictionary dict;
dict["name"] = name; dict["name"] = name;
dict["args"] = internal::convert_property_list(arguments); dict["args"] = ::godot::internal::convert_property_list(arguments);
Array da; Array da;
for (size_t i = 0; i < default_arguments.size(); i++) { for (size_t i = 0; i < default_arguments.size(); i++) {
da.push_back(default_arguments[i]); da.push_back(default_arguments[i]);

View File

@@ -33,6 +33,7 @@
#include <godot_cpp/classes/editor_plugin_registration.hpp> #include <godot_cpp/classes/editor_plugin_registration.hpp>
#include <godot_cpp/classes/wrapped.hpp> #include <godot_cpp/classes/wrapped.hpp>
#include <godot_cpp/core/class_db.hpp> #include <godot_cpp/core/class_db.hpp>
#include <godot_cpp/core/load_proc_address.inc>
#include <godot_cpp/core/memory.hpp> #include <godot_cpp/core/memory.hpp>
#include <godot_cpp/core/version.hpp> #include <godot_cpp/core/version.hpp>
#include <godot_cpp/variant/variant.hpp> #include <godot_cpp/variant/variant.hpp>
@@ -43,176 +44,17 @@
namespace godot { namespace godot {
namespace internal { namespace gdextension_interface {
GDExtensionInterfaceGetProcAddress gdextension_interface_get_proc_address = nullptr; GDExtensionInterfaceGetProcAddress get_proc_address = nullptr;
GDExtensionClassLibraryPtr library = nullptr; GDExtensionClassLibraryPtr library = nullptr;
void *token = nullptr; void *token = nullptr;
GDExtensionGodotVersion2 godot_version = {}; GDExtensionGodotVersion2 godot_version = {};
// All of the GDExtension interface functions. } // namespace gdextension_interface
GDExtensionInterfaceGetGodotVersion2 gdextension_interface_get_godot_version2 = nullptr;
GDExtensionInterfaceMemAlloc2 gdextension_interface_mem_alloc2 = nullptr; namespace internal {
GDExtensionInterfaceMemRealloc2 gdextension_interface_mem_realloc2 = nullptr;
GDExtensionInterfaceMemFree2 gdextension_interface_mem_free2 = 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;
GDExtensionInterfaceVariantGetObjectInstanceId gdextension_interface_variant_get_object_instance_id = 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;
GDExtensionInterfaceGetVariantGetInternalPtrFunc gdextension_interface_variant_get_ptr_internal_getter = 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;
GDExtensionInterfaceStringNewWithUtf8CharsAndLen2 gdextension_interface_string_new_with_utf8_chars_and_len2 = nullptr;
GDExtensionInterfaceStringNewWithUtf16CharsAndLen gdextension_interface_string_new_with_utf16_chars_and_len = nullptr;
GDExtensionInterfaceStringNewWithUtf16CharsAndLen2 gdextension_interface_string_new_with_utf16_chars_and_len2 = 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;
GDExtensionInterfaceStringResize gdextension_interface_string_resize = nullptr;
GDExtensionInterfaceStringNameNewWithLatin1Chars gdextension_interface_string_name_new_with_latin1_chars = 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;
GDExtensionInterfacePackedVector4ArrayOperatorIndex gdextension_interface_packed_vector4_array_operator_index = nullptr;
GDExtensionInterfacePackedVector4ArrayOperatorIndexConst gdextension_interface_packed_vector4_array_operator_index_const = nullptr;
GDExtensionInterfaceArrayOperatorIndex gdextension_interface_array_operator_index = nullptr;
GDExtensionInterfaceArrayOperatorIndexConst gdextension_interface_array_operator_index_const = nullptr;
GDExtensionInterfaceArraySetTyped gdextension_interface_array_set_typed = nullptr;
GDExtensionInterfaceDictionaryOperatorIndex gdextension_interface_dictionary_operator_index = nullptr;
GDExtensionInterfaceDictionaryOperatorIndexConst gdextension_interface_dictionary_operator_index_const = nullptr;
GDExtensionInterfaceDictionarySetTyped gdextension_interface_dictionary_set_typed = 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;
GDExtensionInterfaceObjectFreeInstanceBinding gdextension_interface_object_free_instance_binding = nullptr;
GDExtensionInterfaceObjectSetInstance gdextension_interface_object_set_instance = nullptr;
GDExtensionInterfaceObjectGetClassName gdextension_interface_object_get_class_name = 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;
GDExtensionInterfaceObjectHasScriptMethod gdextension_interface_object_has_script_method = nullptr;
GDExtensionInterfaceObjectCallScriptMethod gdextension_interface_object_call_script_method = nullptr;
GDExtensionInterfaceCallableCustomCreate2 gdextension_interface_callable_custom_create2 = nullptr;
GDExtensionInterfaceCallableCustomGetUserData gdextension_interface_callable_custom_get_userdata = nullptr;
GDExtensionInterfaceRefGetObject gdextension_interface_ref_get_object = nullptr;
GDExtensionInterfaceRefSetObject gdextension_interface_ref_set_object = nullptr;
GDExtensionInterfaceScriptInstanceCreate3 gdextension_interface_script_instance_create3 = nullptr;
GDExtensionInterfacePlaceHolderScriptInstanceCreate gdextension_interface_placeholder_script_instance_create = nullptr;
GDExtensionInterfacePlaceHolderScriptInstanceUpdate gdextension_interface_placeholder_script_instance_update = nullptr;
GDExtensionInterfaceObjectGetScriptInstance gdextension_interface_object_get_script_instance = nullptr;
GDExtensionInterfaceObjectSetScriptInstance gdextension_interface_object_set_script_instance = nullptr;
GDExtensionInterfaceClassdbConstructObject2 gdextension_interface_classdb_construct_object2 = nullptr;
GDExtensionInterfaceClassdbGetMethodBind gdextension_interface_classdb_get_method_bind = nullptr;
GDExtensionInterfaceClassdbGetClassTag gdextension_interface_classdb_get_class_tag = nullptr;
GDExtensionInterfaceClassdbRegisterExtensionClass5 gdextension_interface_classdb_register_extension_class5 = nullptr;
GDExtensionInterfaceClassdbRegisterExtensionClassMethod gdextension_interface_classdb_register_extension_class_method = nullptr;
GDExtensionInterfaceClassdbRegisterExtensionClassVirtualMethod gdextension_interface_classdb_register_extension_class_virtual_method = nullptr;
GDExtensionInterfaceClassdbRegisterExtensionClassIntegerConstant gdextension_interface_classdb_register_extension_class_integer_constant = nullptr;
GDExtensionInterfaceClassdbRegisterExtensionClassProperty gdextension_interface_classdb_register_extension_class_property = nullptr;
GDExtensionInterfaceClassdbRegisterExtensionClassPropertyIndexed gdextension_interface_classdb_register_extension_class_property_indexed = 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;
GDExtensionInterfaceEditorAddPlugin gdextension_interface_editor_add_plugin = nullptr;
GDExtensionInterfaceEditorRemovePlugin gdextension_interface_editor_remove_plugin = nullptr;
GDExtensionInterfaceEditorRegisterGetClassesUsedCallback gdextension_interface_editor_register_get_classes_used_callback = nullptr;
GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8Chars gdextension_interface_editor_help_load_xml_from_utf8_chars = nullptr;
GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8CharsAndLen gdextension_interface_editor_help_load_xml_from_utf8_chars_and_len = nullptr;
GDExtensionInterfaceImagePtrw gdextension_interface_image_ptrw = nullptr;
GDExtensionInterfaceImagePtr gdextension_interface_image_ptr = nullptr;
GDExtensionInterfaceRegisterMainLoopCallbacks gdextension_interface_register_main_loop_callbacks = nullptr;
struct DocData { struct DocData {
const char *hash = nullptr; const char *hash = nullptr;
@@ -250,16 +92,6 @@ bool GDExtensionBinding::api_initialized = false;
int GDExtensionBinding::level_initialized[MODULE_INITIALIZATION_LEVEL_MAX] = { 0 }; int GDExtensionBinding::level_initialized[MODULE_INITIALIZATION_LEVEL_MAX] = { 0 };
GDExtensionBinding::InitDataList GDExtensionBinding::initdata; GDExtensionBinding::InitDataList GDExtensionBinding::initdata;
#define ERR_PRINT_EARLY(m_msg) \
internal::gdextension_interface_print_error(m_msg, FUNCTION_STR, __FILE__, __LINE__, false)
#define LOAD_PROC_ADDRESS(m_name, m_type) \
internal::gdextension_interface_##m_name = (m_type)p_get_proc_address(#m_name); \
if (!internal::gdextension_interface_##m_name) { \
ERR_PRINT_EARLY("Unable to load GDExtension interface function " #m_name "()"); \
return false; \
}
// Partial definition of the legacy interface so we can detect it and show an error. // Partial definition of the legacy interface so we can detect it and show an error.
typedef struct { typedef struct {
uint32_t version_major; uint32_t version_major;
@@ -294,35 +126,35 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
if (uintptr_t(p_get_proc_address) % alignof(LegacyGDExtensionInterface) == 0 && raw_interface[0] == 4 && raw_interface[1] == 0) { if (uintptr_t(p_get_proc_address) % alignof(LegacyGDExtensionInterface) == 0 && raw_interface[0] == 4 && raw_interface[1] == 0) {
// Use the legacy interface only to give a nice error. // Use the legacy interface only to give a nice error.
LegacyGDExtensionInterface *legacy_interface = (LegacyGDExtensionInterface *)p_get_proc_address; LegacyGDExtensionInterface *legacy_interface = (LegacyGDExtensionInterface *)p_get_proc_address;
internal::gdextension_interface_print_error = (GDExtensionInterfacePrintError)legacy_interface->print_error; ::godot::gdextension_interface::print_error = (GDExtensionInterfacePrintError)legacy_interface->print_error;
ERR_PRINT_EARLY("Cannot load a GDExtension built for Godot 4.1+ in Godot 4.0."); ERR_PRINT_EARLY("Cannot load a GDExtension built for Godot 4.1+ in Godot 4.0.");
return false; return false;
} }
// Load the "print_error" function first (needed by the ERR_PRINT_EARLY() macro). // Load the "print_error" function first (needed by the ERR_PRINT_EARLY() macro).
internal::gdextension_interface_print_error = (GDExtensionInterfacePrintError)p_get_proc_address("print_error"); ::godot::gdextension_interface::print_error = (GDExtensionInterfacePrintError)p_get_proc_address("print_error");
if (!internal::gdextension_interface_print_error) { if (!::godot::gdextension_interface::print_error) {
printf("ERROR: Unable to load GDExtension interface function print_error().\n"); printf("ERROR: Unable to load GDExtension interface function print_error().\n");
return false; return false;
} }
internal::gdextension_interface_get_proc_address = p_get_proc_address; ::godot::gdextension_interface::get_proc_address = p_get_proc_address;
internal::library = p_library; ::godot::gdextension_interface::library = p_library;
internal::token = p_library; ::godot::gdextension_interface::token = p_library;
LOAD_PROC_ADDRESS(get_godot_version2, GDExtensionInterfaceGetGodotVersion2); LOAD_PROC_ADDRESS(get_godot_version2, GDExtensionInterfaceGetGodotVersion2);
internal::gdextension_interface_get_godot_version2(&internal::godot_version); ::godot::gdextension_interface::get_godot_version2(&::godot::gdextension_interface::godot_version);
// Check that godot-cpp was compiled using an extension_api.json older or at the // Check that godot-cpp was compiled using an extension_api.json older or at the
// same version as the Godot that is loading it. // same version as the Godot that is loading it.
bool compatible; bool compatible;
if (internal::godot_version.major != GODOT_VERSION_MAJOR) { if (::godot::gdextension_interface::godot_version.major != GODOT_VERSION_MAJOR) {
compatible = internal::godot_version.major > GODOT_VERSION_MAJOR; compatible = ::godot::gdextension_interface::godot_version.major > GODOT_VERSION_MAJOR;
} else if (internal::godot_version.minor != GODOT_VERSION_MINOR) { } else if (::godot::gdextension_interface::godot_version.minor != GODOT_VERSION_MINOR) {
compatible = internal::godot_version.minor > GODOT_VERSION_MINOR; compatible = ::godot::gdextension_interface::godot_version.minor > GODOT_VERSION_MINOR;
} else { } else {
#if GODOT_VERSION_PATCH > 0 #if GODOT_VERSION_PATCH > 0
compatible = internal::godot_version.patch >= GODOT_VERSION_PATCH; compatible = ::godot::gdextension_interface::godot_version.patch >= GODOT_VERSION_PATCH;
#else #else
// Prevent -Wtype-limits warning due to unsigned comparison. // Prevent -Wtype-limits warning due to unsigned comparison.
compatible = true; compatible = true;
@@ -334,170 +166,14 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
char msg[128]; char msg[128];
snprintf(msg, 128, "Cannot load a GDExtension built for Godot %d.%d.%d using an older version of Godot (%d.%d.%d).", snprintf(msg, 128, "Cannot load a GDExtension built for Godot %d.%d.%d using an older version of Godot (%d.%d.%d).",
GODOT_VERSION_MAJOR, GODOT_VERSION_MINOR, GODOT_VERSION_PATCH, GODOT_VERSION_MAJOR, GODOT_VERSION_MINOR, GODOT_VERSION_PATCH,
internal::godot_version.major, internal::godot_version.minor, internal::godot_version.patch); ::godot::gdextension_interface::godot_version.major, ::godot::gdextension_interface::godot_version.minor, ::godot::gdextension_interface::godot_version.patch);
ERR_PRINT_EARLY(msg); ERR_PRINT_EARLY(msg);
return false; return false;
} }
LOAD_PROC_ADDRESS(mem_alloc2, GDExtensionInterfaceMemAlloc2); if (!::godot::internal::load_gdextension_interface(p_get_proc_address)) {
LOAD_PROC_ADDRESS(mem_realloc2, GDExtensionInterfaceMemRealloc2); return false;
LOAD_PROC_ADDRESS(mem_free2, GDExtensionInterfaceMemFree2); }
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_object_instance_id, GDExtensionInterfaceVariantGetObjectInstanceId);
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_internal_getter, GDExtensionInterfaceGetVariantGetInternalPtrFunc);
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_utf8_chars_and_len2, GDExtensionInterfaceStringNewWithUtf8CharsAndLen2);
LOAD_PROC_ADDRESS(string_new_with_utf16_chars_and_len, GDExtensionInterfaceStringNewWithUtf16CharsAndLen);
LOAD_PROC_ADDRESS(string_new_with_utf16_chars_and_len2, GDExtensionInterfaceStringNewWithUtf16CharsAndLen2);
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(string_resize, GDExtensionInterfaceStringResize);
LOAD_PROC_ADDRESS(string_name_new_with_latin1_chars, GDExtensionInterfaceStringNameNewWithLatin1Chars);
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(packed_vector4_array_operator_index, GDExtensionInterfacePackedVector4ArrayOperatorIndex);
LOAD_PROC_ADDRESS(packed_vector4_array_operator_index_const, GDExtensionInterfacePackedVector4ArrayOperatorIndexConst);
LOAD_PROC_ADDRESS(array_operator_index, GDExtensionInterfaceArrayOperatorIndex);
LOAD_PROC_ADDRESS(array_operator_index_const, GDExtensionInterfaceArrayOperatorIndexConst);
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(dictionary_set_typed, GDExtensionInterfaceDictionarySetTyped);
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_free_instance_binding, GDExtensionInterfaceObjectFreeInstanceBinding);
LOAD_PROC_ADDRESS(object_set_instance, GDExtensionInterfaceObjectSetInstance);
LOAD_PROC_ADDRESS(object_get_class_name, GDExtensionInterfaceObjectGetClassName);
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(object_has_script_method, GDExtensionInterfaceObjectHasScriptMethod);
LOAD_PROC_ADDRESS(object_call_script_method, GDExtensionInterfaceObjectCallScriptMethod);
LOAD_PROC_ADDRESS(callable_custom_create2, GDExtensionInterfaceCallableCustomCreate2);
LOAD_PROC_ADDRESS(callable_custom_get_userdata, GDExtensionInterfaceCallableCustomGetUserData);
LOAD_PROC_ADDRESS(ref_get_object, GDExtensionInterfaceRefGetObject);
LOAD_PROC_ADDRESS(ref_set_object, GDExtensionInterfaceRefSetObject);
LOAD_PROC_ADDRESS(script_instance_create3, GDExtensionInterfaceScriptInstanceCreate3);
LOAD_PROC_ADDRESS(placeholder_script_instance_create, GDExtensionInterfacePlaceHolderScriptInstanceCreate);
LOAD_PROC_ADDRESS(placeholder_script_instance_update, GDExtensionInterfacePlaceHolderScriptInstanceUpdate);
LOAD_PROC_ADDRESS(object_get_script_instance, GDExtensionInterfaceObjectGetScriptInstance);
LOAD_PROC_ADDRESS(object_set_script_instance, GDExtensionInterfaceObjectSetScriptInstance);
LOAD_PROC_ADDRESS(classdb_construct_object2, GDExtensionInterfaceClassdbConstructObject2);
LOAD_PROC_ADDRESS(classdb_get_method_bind, GDExtensionInterfaceClassdbGetMethodBind);
LOAD_PROC_ADDRESS(classdb_get_class_tag, GDExtensionInterfaceClassdbGetClassTag);
LOAD_PROC_ADDRESS(classdb_register_extension_class5, GDExtensionInterfaceClassdbRegisterExtensionClass5);
LOAD_PROC_ADDRESS(classdb_register_extension_class_method, GDExtensionInterfaceClassdbRegisterExtensionClassMethod);
LOAD_PROC_ADDRESS(classdb_register_extension_class_virtual_method, GDExtensionInterfaceClassdbRegisterExtensionClassVirtualMethod);
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_indexed, GDExtensionInterfaceClassdbRegisterExtensionClassPropertyIndexed);
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_PROC_ADDRESS(editor_add_plugin, GDExtensionInterfaceEditorAddPlugin);
LOAD_PROC_ADDRESS(editor_remove_plugin, GDExtensionInterfaceEditorRemovePlugin);
LOAD_PROC_ADDRESS(editor_register_get_classes_used_callback, GDExtensionInterfaceEditorRegisterGetClassesUsedCallback);
LOAD_PROC_ADDRESS(editor_help_load_xml_from_utf8_chars, GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8Chars);
LOAD_PROC_ADDRESS(editor_help_load_xml_from_utf8_chars_and_len, GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8CharsAndLen);
LOAD_PROC_ADDRESS(image_ptrw, GDExtensionInterfaceImagePtrw);
LOAD_PROC_ADDRESS(image_ptr, GDExtensionInterfaceImagePtr);
LOAD_PROC_ADDRESS(register_main_loop_callbacks, GDExtensionInterfaceRegisterMainLoopCallbacks);
r_initialization->initialize = initialize_level; r_initialization->initialize = initialize_level;
r_initialization->deinitialize = deinitialize_level; r_initialization->deinitialize = deinitialize_level;
@@ -505,7 +181,7 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
r_initialization->minimum_initialization_level = p_init_data->minimum_initialization_level; r_initialization->minimum_initialization_level = p_init_data->minimum_initialization_level;
Variant::init_bindings(); Variant::init_bindings();
godot::internal::register_engine_classes(); ::godot::internal::register_engine_classes();
api_initialized = true; api_initialized = true;
return true; return true;
@@ -529,13 +205,13 @@ void GDExtensionBinding::initialize_level(void *p_userdata, GDExtensionInitializ
level_initialized[p_level]++; level_initialized[p_level]++;
if ((ModuleInitializationLevel)p_level == MODULE_INITIALIZATION_LEVEL_CORE && init_data && init_data->has_main_loop_callbacks()) { if ((ModuleInitializationLevel)p_level == MODULE_INITIALIZATION_LEVEL_CORE && init_data && init_data->has_main_loop_callbacks()) {
internal::gdextension_interface_register_main_loop_callbacks(internal::library, &init_data->main_loop_callbacks); ::godot::gdextension_interface::register_main_loop_callbacks(::godot::gdextension_interface::library, &init_data->main_loop_callbacks);
} }
if ((ModuleInitializationLevel)p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) { if ((ModuleInitializationLevel)p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
internal::gdextension_interface_editor_register_get_classes_used_callback(internal::library, &ClassDB::_editor_get_classes_used_callback); ::godot::gdextension_interface::editor_register_get_classes_used_callback(::godot::gdextension_interface::library, &ClassDB::_editor_get_classes_used_callback);
const internal::DocData &doc_data = internal::get_doc_data(); const ::godot::internal::DocData &doc_data = ::godot::internal::get_doc_data();
if (doc_data.is_valid()) { if (doc_data.is_valid()) {
doc_data.load_data(); doc_data.load_data();
} }
@@ -618,7 +294,7 @@ GDExtensionBool GDExtensionBinding::InitObject::init() const {
return GDExtensionBinding::init(get_proc_address, library, init_data, initialization); return GDExtensionBinding::init(get_proc_address, library, init_data, initialization);
} }
void internal::DocData::load_data() const { void ::godot::internal::DocData::load_data() const {
PackedByteArray compressed; PackedByteArray compressed;
compressed.resize(compressed_size); compressed.resize(compressed_size);
memcpy(compressed.ptrw(), data, compressed_size); memcpy(compressed.ptrw(), data, compressed_size);
@@ -626,7 +302,7 @@ void internal::DocData::load_data() const {
// FileAccess::COMPRESSION_DEFLATE = 1 // FileAccess::COMPRESSION_DEFLATE = 1
PackedByteArray decompressed = compressed.decompress(uncompressed_size, 1); PackedByteArray decompressed = compressed.decompress(uncompressed_size, 1);
internal::gdextension_interface_editor_help_load_xml_from_utf8_chars_and_len(reinterpret_cast<const char *>(decompressed.ptr()), uncompressed_size); ::godot::gdextension_interface::editor_help_load_xml_from_utf8_chars_and_len(reinterpret_cast<const char *>(decompressed.ptr()), uncompressed_size);
} }
} // namespace godot } // namespace godot

View File

@@ -105,7 +105,7 @@ bool CallableCustom::is_valid() const {
Callable::Callable(CallableCustom *p_callable_custom) { Callable::Callable(CallableCustom *p_callable_custom) {
GDExtensionCallableCustomInfo2 info = {}; GDExtensionCallableCustomInfo2 info = {};
info.callable_userdata = p_callable_custom; info.callable_userdata = p_callable_custom;
info.token = internal::token; info.token = ::godot::gdextension_interface::token;
info.object_id = p_callable_custom->get_object(); info.object_id = p_callable_custom->get_object();
info.call_func = &callable_custom_call; info.call_func = &callable_custom_call;
info.is_valid_func = &callable_custom_is_valid; info.is_valid_func = &callable_custom_is_valid;
@@ -116,11 +116,11 @@ Callable::Callable(CallableCustom *p_callable_custom) {
info.to_string_func = &callable_custom_to_string; info.to_string_func = &callable_custom_to_string;
info.get_argument_count_func = &custom_callable_get_argument_count_func; info.get_argument_count_func = &custom_callable_get_argument_count_func;
::godot::internal::gdextension_interface_callable_custom_create2(_native_ptr(), &info); ::godot::gdextension_interface::callable_custom_create2(_native_ptr(), &info);
} }
CallableCustom *Callable::get_custom() const { CallableCustom *Callable::get_custom() const {
CallableCustomBase *callable_custom = (CallableCustomBase *)::godot::internal::gdextension_interface_callable_custom_get_userdata(_native_ptr(), internal::token); CallableCustomBase *callable_custom = (CallableCustomBase *)::godot::gdextension_interface::callable_custom_get_userdata(_native_ptr(), ::godot::gdextension_interface::token);
return dynamic_cast<CallableCustom *>(callable_custom); return dynamic_cast<CallableCustom *>(callable_custom);
} }

View File

@@ -103,7 +103,7 @@ namespace internal {
Callable create_callable_from_ccmp(CallableCustomMethodPointerBase *p_callable_method_pointer) { Callable create_callable_from_ccmp(CallableCustomMethodPointerBase *p_callable_method_pointer) {
GDExtensionCallableCustomInfo2 info = {}; GDExtensionCallableCustomInfo2 info = {};
info.callable_userdata = p_callable_method_pointer; info.callable_userdata = p_callable_method_pointer;
info.token = internal::token; info.token = ::godot::gdextension_interface::token;
info.object_id = p_callable_method_pointer->get_object(); info.object_id = p_callable_method_pointer->get_object();
info.call_func = &custom_callable_mp_call; info.call_func = &custom_callable_mp_call;
info.is_valid_func = &custom_callable_mp_is_valid; info.is_valid_func = &custom_callable_mp_is_valid;
@@ -114,7 +114,7 @@ Callable create_callable_from_ccmp(CallableCustomMethodPointerBase *p_callable_m
info.get_argument_count_func = &custom_callable_mp_get_argument_count_func; info.get_argument_count_func = &custom_callable_mp_get_argument_count_func;
Callable callable; Callable callable;
::godot::internal::gdextension_interface_callable_custom_create2(callable._native_ptr(), &info); ::godot::gdextension_interface::callable_custom_create2(callable._native_ptr(), &info);
return callable; return callable;
} }

View File

@@ -157,19 +157,19 @@ template class CharStringT<wchar_t>;
// It's easier to have them written in C++ directly than in a Python script that generates them. // It's easier to have them written in C++ directly than in a Python script that generates them.
String::String(const char *from) { String::String(const char *from) {
internal::gdextension_interface_string_new_with_latin1_chars(_native_ptr(), from); ::godot::gdextension_interface::string_new_with_latin1_chars(_native_ptr(), from);
} }
String::String(const wchar_t *from) { String::String(const wchar_t *from) {
internal::gdextension_interface_string_new_with_wide_chars(_native_ptr(), from); ::godot::gdextension_interface::string_new_with_wide_chars(_native_ptr(), from);
} }
String::String(const char16_t *from) { String::String(const char16_t *from) {
internal::gdextension_interface_string_new_with_utf16_chars(_native_ptr(), from); ::godot::gdextension_interface::string_new_with_utf16_chars(_native_ptr(), from);
} }
String::String(const char32_t *from) { String::String(const char32_t *from) {
internal::gdextension_interface_string_new_with_utf32_chars(_native_ptr(), from); ::godot::gdextension_interface::string_new_with_utf32_chars(_native_ptr(), from);
} }
String String::utf8(const char *from, int64_t len) { String String::utf8(const char *from, int64_t len) {
@@ -179,7 +179,7 @@ String String::utf8(const char *from, int64_t len) {
} }
Error String::parse_utf8(const char *from, int64_t len) { Error String::parse_utf8(const char *from, int64_t len) {
return (Error)internal::gdextension_interface_string_new_with_utf8_chars_and_len2(_native_ptr(), from, len); return (Error)::godot::gdextension_interface::string_new_with_utf8_chars_and_len2(_native_ptr(), from, len);
} }
String String::utf16(const char16_t *from, int64_t len) { String String::utf16(const char16_t *from, int64_t len) {
@@ -189,7 +189,7 @@ String String::utf16(const char16_t *from, int64_t len) {
} }
Error String::parse_utf16(const char16_t *from, int64_t len, bool default_little_endian) { Error String::parse_utf16(const char16_t *from, int64_t len, bool default_little_endian) {
return (Error)internal::gdextension_interface_string_new_with_utf16_chars_and_len2(_native_ptr(), from, len, default_little_endian); return (Error)::godot::gdextension_interface::string_new_with_utf16_chars_and_len2(_native_ptr(), from, len, default_little_endian);
} }
String String::num_real(double p_num, bool p_trailing) { String String::num_real(double p_num, bool p_trailing) {
@@ -230,11 +230,11 @@ String rtoss(double p_val) {
} }
CharString String::utf8() const { CharString String::utf8() const {
int64_t length = internal::gdextension_interface_string_to_utf8_chars(_native_ptr(), nullptr, 0); int64_t length = ::godot::gdextension_interface::string_to_utf8_chars(_native_ptr(), nullptr, 0);
int64_t size = length + 1; int64_t size = length + 1;
CharString str; CharString str;
str.resize(size); str.resize(size);
internal::gdextension_interface_string_to_utf8_chars(_native_ptr(), str.ptrw(), length); ::godot::gdextension_interface::string_to_utf8_chars(_native_ptr(), str.ptrw(), length);
str[length] = '\0'; str[length] = '\0';
@@ -242,11 +242,11 @@ CharString String::utf8() const {
} }
CharString String::ascii() const { CharString String::ascii() const {
int64_t length = internal::gdextension_interface_string_to_latin1_chars(_native_ptr(), nullptr, 0); int64_t length = ::godot::gdextension_interface::string_to_latin1_chars(_native_ptr(), nullptr, 0);
int64_t size = length + 1; int64_t size = length + 1;
CharString str; CharString str;
str.resize(size); str.resize(size);
internal::gdextension_interface_string_to_latin1_chars(_native_ptr(), str.ptrw(), length); ::godot::gdextension_interface::string_to_latin1_chars(_native_ptr(), str.ptrw(), length);
str[length] = '\0'; str[length] = '\0';
@@ -254,11 +254,11 @@ CharString String::ascii() const {
} }
Char16String String::utf16() const { Char16String String::utf16() const {
int64_t length = internal::gdextension_interface_string_to_utf16_chars(_native_ptr(), nullptr, 0); int64_t length = ::godot::gdextension_interface::string_to_utf16_chars(_native_ptr(), nullptr, 0);
int64_t size = length + 1; int64_t size = length + 1;
Char16String str; Char16String str;
str.resize(size); str.resize(size);
internal::gdextension_interface_string_to_utf16_chars(_native_ptr(), str.ptrw(), length); ::godot::gdextension_interface::string_to_utf16_chars(_native_ptr(), str.ptrw(), length);
str[length] = '\0'; str[length] = '\0';
@@ -266,11 +266,11 @@ Char16String String::utf16() const {
} }
Char32String String::utf32() const { Char32String String::utf32() const {
int64_t length = internal::gdextension_interface_string_to_utf32_chars(_native_ptr(), nullptr, 0); int64_t length = ::godot::gdextension_interface::string_to_utf32_chars(_native_ptr(), nullptr, 0);
int64_t size = length + 1; int64_t size = length + 1;
Char32String str; Char32String str;
str.resize(size); str.resize(size);
internal::gdextension_interface_string_to_utf32_chars(_native_ptr(), str.ptrw(), length); ::godot::gdextension_interface::string_to_utf32_chars(_native_ptr(), str.ptrw(), length);
str[length] = '\0'; str[length] = '\0';
@@ -278,11 +278,11 @@ Char32String String::utf32() const {
} }
CharWideString String::wide_string() const { CharWideString String::wide_string() const {
int64_t length = internal::gdextension_interface_string_to_wide_chars(_native_ptr(), nullptr, 0); int64_t length = ::godot::gdextension_interface::string_to_wide_chars(_native_ptr(), nullptr, 0);
int64_t size = length + 1; int64_t size = length + 1;
CharWideString str; CharWideString str;
str.resize(size); str.resize(size);
internal::gdextension_interface_string_to_wide_chars(_native_ptr(), str.ptrw(), length); ::godot::gdextension_interface::string_to_wide_chars(_native_ptr(), str.ptrw(), length);
str[length] = '\0'; str[length] = '\0';
@@ -290,7 +290,7 @@ CharWideString String::wide_string() const {
} }
Error String::resize(int64_t p_size) { Error String::resize(int64_t p_size) {
return (Error)internal::gdextension_interface_string_resize(_native_ptr(), p_size); return (Error)::godot::gdextension_interface::string_resize(_native_ptr(), p_size);
} }
String &String::operator=(const char *p_str) { String &String::operator=(const char *p_str) {
@@ -366,44 +366,44 @@ String String::operator+(const char32_t p_char) {
} }
String &String::operator+=(const String &p_str) { String &String::operator+=(const String &p_str) {
internal::gdextension_interface_string_operator_plus_eq_string((GDExtensionStringPtr)this, (GDExtensionConstStringPtr)&p_str); ::godot::gdextension_interface::string_operator_plus_eq_string((GDExtensionStringPtr)this, (GDExtensionConstStringPtr)&p_str);
return *this; return *this;
} }
String &String::operator+=(char32_t p_char) { String &String::operator+=(char32_t p_char) {
internal::gdextension_interface_string_operator_plus_eq_char((GDExtensionStringPtr)this, p_char); ::godot::gdextension_interface::string_operator_plus_eq_char((GDExtensionStringPtr)this, p_char);
return *this; return *this;
} }
String &String::operator+=(const char *p_str) { String &String::operator+=(const char *p_str) {
internal::gdextension_interface_string_operator_plus_eq_cstr((GDExtensionStringPtr)this, p_str); ::godot::gdextension_interface::string_operator_plus_eq_cstr((GDExtensionStringPtr)this, p_str);
return *this; return *this;
} }
String &String::operator+=(const wchar_t *p_str) { String &String::operator+=(const wchar_t *p_str) {
internal::gdextension_interface_string_operator_plus_eq_wcstr((GDExtensionStringPtr)this, p_str); ::godot::gdextension_interface::string_operator_plus_eq_wcstr((GDExtensionStringPtr)this, p_str);
return *this; return *this;
} }
String &String::operator+=(const char32_t *p_str) { String &String::operator+=(const char32_t *p_str) {
internal::gdextension_interface_string_operator_plus_eq_c32str((GDExtensionStringPtr)this, p_str); ::godot::gdextension_interface::string_operator_plus_eq_c32str((GDExtensionStringPtr)this, p_str);
return *this; return *this;
} }
const char32_t &String::operator[](int64_t p_index) const { const char32_t &String::operator[](int64_t p_index) const {
return *internal::gdextension_interface_string_operator_index_const((GDExtensionStringPtr)this, p_index); return *::godot::gdextension_interface::string_operator_index_const((GDExtensionStringPtr)this, p_index);
} }
char32_t &String::operator[](int64_t p_index) { char32_t &String::operator[](int64_t p_index) {
return *internal::gdextension_interface_string_operator_index((GDExtensionStringPtr)this, p_index); return *::godot::gdextension_interface::string_operator_index((GDExtensionStringPtr)this, p_index);
} }
const char32_t *String::ptr() const { const char32_t *String::ptr() const {
return internal::gdextension_interface_string_operator_index_const((GDExtensionStringPtr)this, 0); return ::godot::gdextension_interface::string_operator_index_const((GDExtensionStringPtr)this, 0);
} }
char32_t *String::ptrw() { char32_t *String::ptrw() {
return internal::gdextension_interface_string_operator_index((GDExtensionStringPtr)this, 0); return ::godot::gdextension_interface::string_operator_index((GDExtensionStringPtr)this, 0);
} }
bool operator==(const char *p_chr, const String &p_str) { bool operator==(const char *p_chr, const String &p_str) {
@@ -459,7 +459,7 @@ String operator+(char32_t p_char, const String &p_str) {
} }
StringName::StringName(const char *from, bool p_static) { StringName::StringName(const char *from, bool p_static) {
internal::gdextension_interface_string_name_new_with_latin1_chars(&opaque, from, p_static); ::godot::gdextension_interface::string_name_new_with_latin1_chars(&opaque, from, p_static);
} }
StringName::StringName(const wchar_t *from) : StringName::StringName(const wchar_t *from) :

View File

@@ -48,211 +48,211 @@
namespace godot { namespace godot {
const uint8_t &PackedByteArray::operator[](int64_t p_index) const { const uint8_t &PackedByteArray::operator[](int64_t p_index) const {
return *internal::gdextension_interface_packed_byte_array_operator_index_const((GDExtensionTypePtr *)this, p_index); return *::godot::gdextension_interface::packed_byte_array_operator_index_const((GDExtensionTypePtr *)this, p_index);
} }
uint8_t &PackedByteArray::operator[](int64_t p_index) { uint8_t &PackedByteArray::operator[](int64_t p_index) {
return *internal::gdextension_interface_packed_byte_array_operator_index((GDExtensionTypePtr *)this, p_index); return *::godot::gdextension_interface::packed_byte_array_operator_index((GDExtensionTypePtr *)this, p_index);
} }
const uint8_t *PackedByteArray::ptr() const { const uint8_t *PackedByteArray::ptr() const {
return internal::gdextension_interface_packed_byte_array_operator_index_const((GDExtensionTypePtr *)this, 0); return ::godot::gdextension_interface::packed_byte_array_operator_index_const((GDExtensionTypePtr *)this, 0);
} }
uint8_t *PackedByteArray::ptrw() { uint8_t *PackedByteArray::ptrw() {
return internal::gdextension_interface_packed_byte_array_operator_index((GDExtensionTypePtr *)this, 0); return ::godot::gdextension_interface::packed_byte_array_operator_index((GDExtensionTypePtr *)this, 0);
} }
const Color &PackedColorArray::operator[](int64_t p_index) const { const Color &PackedColorArray::operator[](int64_t p_index) const {
const Color *color = (const Color *)internal::gdextension_interface_packed_color_array_operator_index_const((GDExtensionTypePtr *)this, p_index); const Color *color = (const Color *)::godot::gdextension_interface::packed_color_array_operator_index_const((GDExtensionTypePtr *)this, p_index);
return *color; return *color;
} }
Color &PackedColorArray::operator[](int64_t p_index) { Color &PackedColorArray::operator[](int64_t p_index) {
Color *color = (Color *)internal::gdextension_interface_packed_color_array_operator_index((GDExtensionTypePtr *)this, p_index); Color *color = (Color *)::godot::gdextension_interface::packed_color_array_operator_index((GDExtensionTypePtr *)this, p_index);
return *color; return *color;
} }
const Color *PackedColorArray::ptr() const { const Color *PackedColorArray::ptr() const {
return (const Color *)internal::gdextension_interface_packed_color_array_operator_index_const((GDExtensionTypePtr *)this, 0); return (const Color *)::godot::gdextension_interface::packed_color_array_operator_index_const((GDExtensionTypePtr *)this, 0);
} }
Color *PackedColorArray::ptrw() { Color *PackedColorArray::ptrw() {
return (Color *)internal::gdextension_interface_packed_color_array_operator_index((GDExtensionTypePtr *)this, 0); return (Color *)::godot::gdextension_interface::packed_color_array_operator_index((GDExtensionTypePtr *)this, 0);
} }
const float &PackedFloat32Array::operator[](int64_t p_index) const { const float &PackedFloat32Array::operator[](int64_t p_index) const {
return *internal::gdextension_interface_packed_float32_array_operator_index_const((GDExtensionTypePtr *)this, p_index); return *::godot::gdextension_interface::packed_float32_array_operator_index_const((GDExtensionTypePtr *)this, p_index);
} }
float &PackedFloat32Array::operator[](int64_t p_index) { float &PackedFloat32Array::operator[](int64_t p_index) {
return *internal::gdextension_interface_packed_float32_array_operator_index((GDExtensionTypePtr *)this, p_index); return *::godot::gdextension_interface::packed_float32_array_operator_index((GDExtensionTypePtr *)this, p_index);
} }
const float *PackedFloat32Array::ptr() const { const float *PackedFloat32Array::ptr() const {
return internal::gdextension_interface_packed_float32_array_operator_index_const((GDExtensionTypePtr *)this, 0); return ::godot::gdextension_interface::packed_float32_array_operator_index_const((GDExtensionTypePtr *)this, 0);
} }
float *PackedFloat32Array::ptrw() { float *PackedFloat32Array::ptrw() {
return internal::gdextension_interface_packed_float32_array_operator_index((GDExtensionTypePtr *)this, 0); return ::godot::gdextension_interface::packed_float32_array_operator_index((GDExtensionTypePtr *)this, 0);
} }
const double &PackedFloat64Array::operator[](int64_t p_index) const { const double &PackedFloat64Array::operator[](int64_t p_index) const {
return *internal::gdextension_interface_packed_float64_array_operator_index_const((GDExtensionTypePtr *)this, p_index); return *::godot::gdextension_interface::packed_float64_array_operator_index_const((GDExtensionTypePtr *)this, p_index);
} }
double &PackedFloat64Array::operator[](int64_t p_index) { double &PackedFloat64Array::operator[](int64_t p_index) {
return *internal::gdextension_interface_packed_float64_array_operator_index((GDExtensionTypePtr *)this, p_index); return *::godot::gdextension_interface::packed_float64_array_operator_index((GDExtensionTypePtr *)this, p_index);
} }
const double *PackedFloat64Array::ptr() const { const double *PackedFloat64Array::ptr() const {
return internal::gdextension_interface_packed_float64_array_operator_index_const((GDExtensionTypePtr *)this, 0); return ::godot::gdextension_interface::packed_float64_array_operator_index_const((GDExtensionTypePtr *)this, 0);
} }
double *PackedFloat64Array::ptrw() { double *PackedFloat64Array::ptrw() {
return internal::gdextension_interface_packed_float64_array_operator_index((GDExtensionTypePtr *)this, 0); return ::godot::gdextension_interface::packed_float64_array_operator_index((GDExtensionTypePtr *)this, 0);
} }
const int32_t &PackedInt32Array::operator[](int64_t p_index) const { const int32_t &PackedInt32Array::operator[](int64_t p_index) const {
return *internal::gdextension_interface_packed_int32_array_operator_index_const((GDExtensionTypePtr *)this, p_index); return *::godot::gdextension_interface::packed_int32_array_operator_index_const((GDExtensionTypePtr *)this, p_index);
} }
int32_t &PackedInt32Array::operator[](int64_t p_index) { int32_t &PackedInt32Array::operator[](int64_t p_index) {
return *internal::gdextension_interface_packed_int32_array_operator_index((GDExtensionTypePtr *)this, p_index); return *::godot::gdextension_interface::packed_int32_array_operator_index((GDExtensionTypePtr *)this, p_index);
} }
const int32_t *PackedInt32Array::ptr() const { const int32_t *PackedInt32Array::ptr() const {
return internal::gdextension_interface_packed_int32_array_operator_index_const((GDExtensionTypePtr *)this, 0); return ::godot::gdextension_interface::packed_int32_array_operator_index_const((GDExtensionTypePtr *)this, 0);
} }
int32_t *PackedInt32Array::ptrw() { int32_t *PackedInt32Array::ptrw() {
return internal::gdextension_interface_packed_int32_array_operator_index((GDExtensionTypePtr *)this, 0); return ::godot::gdextension_interface::packed_int32_array_operator_index((GDExtensionTypePtr *)this, 0);
} }
const int64_t &PackedInt64Array::operator[](int64_t p_index) const { const int64_t &PackedInt64Array::operator[](int64_t p_index) const {
return *internal::gdextension_interface_packed_int64_array_operator_index_const((GDExtensionTypePtr *)this, p_index); return *::godot::gdextension_interface::packed_int64_array_operator_index_const((GDExtensionTypePtr *)this, p_index);
} }
int64_t &PackedInt64Array::operator[](int64_t p_index) { int64_t &PackedInt64Array::operator[](int64_t p_index) {
return *internal::gdextension_interface_packed_int64_array_operator_index((GDExtensionTypePtr *)this, p_index); return *::godot::gdextension_interface::packed_int64_array_operator_index((GDExtensionTypePtr *)this, p_index);
} }
const int64_t *PackedInt64Array::ptr() const { const int64_t *PackedInt64Array::ptr() const {
return internal::gdextension_interface_packed_int64_array_operator_index_const((GDExtensionTypePtr *)this, 0); return ::godot::gdextension_interface::packed_int64_array_operator_index_const((GDExtensionTypePtr *)this, 0);
} }
int64_t *PackedInt64Array::ptrw() { int64_t *PackedInt64Array::ptrw() {
return internal::gdextension_interface_packed_int64_array_operator_index((GDExtensionTypePtr *)this, 0); return ::godot::gdextension_interface::packed_int64_array_operator_index((GDExtensionTypePtr *)this, 0);
} }
const String &PackedStringArray::operator[](int64_t p_index) const { const String &PackedStringArray::operator[](int64_t p_index) const {
const String *string = (const String *)internal::gdextension_interface_packed_string_array_operator_index_const((GDExtensionTypePtr *)this, p_index); const String *string = (const String *)::godot::gdextension_interface::packed_string_array_operator_index_const((GDExtensionTypePtr *)this, p_index);
return *string; return *string;
} }
String &PackedStringArray::operator[](int64_t p_index) { String &PackedStringArray::operator[](int64_t p_index) {
String *string = (String *)internal::gdextension_interface_packed_string_array_operator_index((GDExtensionTypePtr *)this, p_index); String *string = (String *)::godot::gdextension_interface::packed_string_array_operator_index((GDExtensionTypePtr *)this, p_index);
return *string; return *string;
} }
const String *PackedStringArray::ptr() const { const String *PackedStringArray::ptr() const {
return (const String *)internal::gdextension_interface_packed_string_array_operator_index_const((GDExtensionTypePtr *)this, 0); return (const String *)::godot::gdextension_interface::packed_string_array_operator_index_const((GDExtensionTypePtr *)this, 0);
} }
String *PackedStringArray::ptrw() { String *PackedStringArray::ptrw() {
return (String *)internal::gdextension_interface_packed_string_array_operator_index((GDExtensionTypePtr *)this, 0); return (String *)::godot::gdextension_interface::packed_string_array_operator_index((GDExtensionTypePtr *)this, 0);
} }
const Vector2 &PackedVector2Array::operator[](int64_t p_index) const { const Vector2 &PackedVector2Array::operator[](int64_t p_index) const {
const Vector2 *vec = (const Vector2 *)internal::gdextension_interface_packed_vector2_array_operator_index_const((GDExtensionTypePtr *)this, p_index); const Vector2 *vec = (const Vector2 *)::godot::gdextension_interface::packed_vector2_array_operator_index_const((GDExtensionTypePtr *)this, p_index);
return *vec; return *vec;
} }
Vector2 &PackedVector2Array::operator[](int64_t p_index) { Vector2 &PackedVector2Array::operator[](int64_t p_index) {
Vector2 *vec = (Vector2 *)internal::gdextension_interface_packed_vector2_array_operator_index((GDExtensionTypePtr *)this, p_index); Vector2 *vec = (Vector2 *)::godot::gdextension_interface::packed_vector2_array_operator_index((GDExtensionTypePtr *)this, p_index);
return *vec; return *vec;
} }
const Vector2 *PackedVector2Array::ptr() const { const Vector2 *PackedVector2Array::ptr() const {
return (const Vector2 *)internal::gdextension_interface_packed_vector2_array_operator_index_const((GDExtensionTypePtr *)this, 0); return (const Vector2 *)::godot::gdextension_interface::packed_vector2_array_operator_index_const((GDExtensionTypePtr *)this, 0);
} }
Vector2 *PackedVector2Array::ptrw() { Vector2 *PackedVector2Array::ptrw() {
return (Vector2 *)internal::gdextension_interface_packed_vector2_array_operator_index((GDExtensionTypePtr *)this, 0); return (Vector2 *)::godot::gdextension_interface::packed_vector2_array_operator_index((GDExtensionTypePtr *)this, 0);
} }
const Vector3 &PackedVector3Array::operator[](int64_t p_index) const { const Vector3 &PackedVector3Array::operator[](int64_t p_index) const {
const Vector3 *vec = (const Vector3 *)internal::gdextension_interface_packed_vector3_array_operator_index_const((GDExtensionTypePtr *)this, p_index); const Vector3 *vec = (const Vector3 *)::godot::gdextension_interface::packed_vector3_array_operator_index_const((GDExtensionTypePtr *)this, p_index);
return *vec; return *vec;
} }
Vector3 &PackedVector3Array::operator[](int64_t p_index) { Vector3 &PackedVector3Array::operator[](int64_t p_index) {
Vector3 *vec = (Vector3 *)internal::gdextension_interface_packed_vector3_array_operator_index((GDExtensionTypePtr *)this, p_index); Vector3 *vec = (Vector3 *)::godot::gdextension_interface::packed_vector3_array_operator_index((GDExtensionTypePtr *)this, p_index);
return *vec; return *vec;
} }
const Vector3 *PackedVector3Array::ptr() const { const Vector3 *PackedVector3Array::ptr() const {
return (const Vector3 *)internal::gdextension_interface_packed_vector3_array_operator_index_const((GDExtensionTypePtr *)this, 0); return (const Vector3 *)::godot::gdextension_interface::packed_vector3_array_operator_index_const((GDExtensionTypePtr *)this, 0);
} }
Vector3 *PackedVector3Array::ptrw() { Vector3 *PackedVector3Array::ptrw() {
return (Vector3 *)internal::gdextension_interface_packed_vector3_array_operator_index((GDExtensionTypePtr *)this, 0); return (Vector3 *)::godot::gdextension_interface::packed_vector3_array_operator_index((GDExtensionTypePtr *)this, 0);
} }
const Vector4 &PackedVector4Array::operator[](int64_t p_index) const { const Vector4 &PackedVector4Array::operator[](int64_t p_index) const {
const Vector4 *vec = (const Vector4 *)internal::gdextension_interface_packed_vector4_array_operator_index_const((GDExtensionTypePtr *)this, p_index); const Vector4 *vec = (const Vector4 *)::godot::gdextension_interface::packed_vector4_array_operator_index_const((GDExtensionTypePtr *)this, p_index);
return *vec; return *vec;
} }
Vector4 &PackedVector4Array::operator[](int64_t p_index) { Vector4 &PackedVector4Array::operator[](int64_t p_index) {
Vector4 *vec = (Vector4 *)internal::gdextension_interface_packed_vector4_array_operator_index((GDExtensionTypePtr *)this, p_index); Vector4 *vec = (Vector4 *)::godot::gdextension_interface::packed_vector4_array_operator_index((GDExtensionTypePtr *)this, p_index);
return *vec; return *vec;
} }
const Vector4 *PackedVector4Array::ptr() const { const Vector4 *PackedVector4Array::ptr() const {
return (const Vector4 *)internal::gdextension_interface_packed_vector4_array_operator_index_const((GDExtensionTypePtr *)this, 0); return (const Vector4 *)::godot::gdextension_interface::packed_vector4_array_operator_index_const((GDExtensionTypePtr *)this, 0);
} }
Vector4 *PackedVector4Array::ptrw() { Vector4 *PackedVector4Array::ptrw() {
return (Vector4 *)internal::gdextension_interface_packed_vector4_array_operator_index((GDExtensionTypePtr *)this, 0); return (Vector4 *)::godot::gdextension_interface::packed_vector4_array_operator_index((GDExtensionTypePtr *)this, 0);
} }
const Variant &Array::operator[](int64_t p_index) const { const Variant &Array::operator[](int64_t p_index) const {
const Variant *var = (const Variant *)internal::gdextension_interface_array_operator_index_const((GDExtensionTypePtr *)this, p_index); const Variant *var = (const Variant *)::godot::gdextension_interface::array_operator_index_const((GDExtensionTypePtr *)this, p_index);
return *var; return *var;
} }
Variant &Array::operator[](int64_t p_index) { Variant &Array::operator[](int64_t p_index) {
Variant *var = (Variant *)internal::gdextension_interface_array_operator_index((GDExtensionTypePtr *)this, p_index); Variant *var = (Variant *)::godot::gdextension_interface::array_operator_index((GDExtensionTypePtr *)this, p_index);
return *var; return *var;
} }
void Array::set_typed(uint32_t p_type, const StringName &p_class_name, const Variant &p_script) { 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 <variant.hpp>. // p_type is not Variant::Type so that header doesn't depend on <variant.hpp>.
internal::gdextension_interface_array_set_typed((GDExtensionTypePtr *)this, (GDExtensionVariantType)p_type, (GDExtensionConstStringNamePtr)&p_class_name, (GDExtensionConstVariantPtr)&p_script); ::godot::gdextension_interface::array_set_typed((GDExtensionTypePtr *)this, (GDExtensionVariantType)p_type, (GDExtensionConstStringNamePtr)&p_class_name, (GDExtensionConstVariantPtr)&p_script);
} }
const Variant *Array::ptr() const { const Variant *Array::ptr() const {
return (const Variant *)internal::gdextension_interface_array_operator_index_const((GDExtensionTypePtr *)this, 0); return (const Variant *)::godot::gdextension_interface::array_operator_index_const((GDExtensionTypePtr *)this, 0);
} }
Variant *Array::ptrw() { Variant *Array::ptrw() {
return (Variant *)internal::gdextension_interface_array_operator_index((GDExtensionTypePtr *)this, 0); return (Variant *)::godot::gdextension_interface::array_operator_index((GDExtensionTypePtr *)this, 0);
} }
const Variant &Dictionary::operator[](const Variant &p_key) const { const Variant &Dictionary::operator[](const Variant &p_key) const {
const Variant *var = (const Variant *)internal::gdextension_interface_dictionary_operator_index_const((GDExtensionTypePtr *)this, (GDExtensionVariantPtr)&p_key); const Variant *var = (const Variant *)::godot::gdextension_interface::dictionary_operator_index_const((GDExtensionTypePtr *)this, (GDExtensionVariantPtr)&p_key);
return *var; return *var;
} }
Variant &Dictionary::operator[](const Variant &p_key) { Variant &Dictionary::operator[](const Variant &p_key) {
Variant *var = (Variant *)internal::gdextension_interface_dictionary_operator_index((GDExtensionTypePtr *)this, (GDExtensionVariantPtr)&p_key); Variant *var = (Variant *)::godot::gdextension_interface::dictionary_operator_index((GDExtensionTypePtr *)this, (GDExtensionVariantPtr)&p_key);
return *var; return *var;
} }
void Dictionary::set_typed(uint32_t p_key_type, const StringName &p_key_class_name, const Variant &p_key_script, uint32_t p_value_type, const StringName &p_value_class_name, const Variant &p_value_script) { void Dictionary::set_typed(uint32_t p_key_type, const StringName &p_key_class_name, const Variant &p_key_script, uint32_t p_value_type, const StringName &p_value_class_name, const Variant &p_value_script) {
// p_key_type/p_value_type are not Variant::Type so that header doesn't depend on <variant.hpp>. // p_key_type/p_value_type are not Variant::Type so that header doesn't depend on <variant.hpp>.
internal::gdextension_interface_dictionary_set_typed((GDExtensionTypePtr *)this, (GDExtensionVariantType)p_key_type, (GDExtensionConstStringNamePtr)&p_key_class_name, (GDExtensionConstVariantPtr)&p_key_script, ::godot::gdextension_interface::dictionary_set_typed((GDExtensionTypePtr *)this, (GDExtensionVariantType)p_key_type, (GDExtensionConstStringNamePtr)&p_key_class_name, (GDExtensionConstVariantPtr)&p_key_script,
(GDExtensionVariantType)p_value_type, (GDExtensionConstStringNamePtr)&p_value_class_name, (GDExtensionConstVariantPtr)&p_value_script); (GDExtensionVariantType)p_value_type, (GDExtensionConstStringNamePtr)&p_value_class_name, (GDExtensionConstVariantPtr)&p_value_script);
} }

View File

@@ -47,8 +47,8 @@ GDExtensionTypeFromVariantConstructorFunc Variant::to_type_constructor[Variant::
void Variant::init_bindings() { void Variant::init_bindings() {
// Start from 1 to skip NIL. // Start from 1 to skip NIL.
for (int i = 1; i < VARIANT_MAX; i++) { for (int i = 1; i < VARIANT_MAX; i++) {
from_type_constructor[i] = internal::gdextension_interface_get_variant_from_type_constructor((GDExtensionVariantType)i); from_type_constructor[i] = ::godot::gdextension_interface::get_variant_from_type_constructor((GDExtensionVariantType)i);
to_type_constructor[i] = internal::gdextension_interface_get_variant_to_type_constructor((GDExtensionVariantType)i); to_type_constructor[i] = ::godot::gdextension_interface::get_variant_to_type_constructor((GDExtensionVariantType)i);
} }
VariantInternal::init_bindings(); VariantInternal::init_bindings();
@@ -73,15 +73,15 @@ void Variant::init_bindings() {
} }
Variant::Variant() { Variant::Variant() {
internal::gdextension_interface_variant_new_nil(_native_ptr()); ::godot::gdextension_interface::variant_new_nil(_native_ptr());
} }
Variant::Variant(GDExtensionConstVariantPtr native_ptr) { Variant::Variant(GDExtensionConstVariantPtr native_ptr) {
internal::gdextension_interface_variant_new_copy(_native_ptr(), native_ptr); ::godot::gdextension_interface::variant_new_copy(_native_ptr(), native_ptr);
} }
Variant::Variant(const Variant &other) { Variant::Variant(const Variant &other) {
internal::gdextension_interface_variant_new_copy(_native_ptr(), other._native_ptr()); ::godot::gdextension_interface::variant_new_copy(_native_ptr(), other._native_ptr());
} }
Variant::Variant(Variant &&other) { Variant::Variant(Variant &&other) {
@@ -256,7 +256,7 @@ Variant::Variant(const PackedVector4Array &v) {
} }
Variant::~Variant() { Variant::~Variant() {
internal::gdextension_interface_variant_destroy(_native_ptr()); ::godot::gdextension_interface::variant_destroy(_native_ptr());
} }
Variant::operator bool() const { Variant::operator bool() const {
@@ -443,14 +443,14 @@ Variant::operator Object *() const {
if (obj == nullptr) { if (obj == nullptr) {
return nullptr; return nullptr;
} }
return internal::get_object_instance_binding(obj); return ::godot::internal::get_object_instance_binding(obj);
} }
Variant::operator ObjectID() const { Variant::operator ObjectID() const {
if (get_type() == Type::INT) { if (get_type() == Type::INT) {
return ObjectID(operator uint64_t()); return ObjectID(operator uint64_t());
} else if (get_type() == Type::OBJECT) { } else if (get_type() == Type::OBJECT) {
return ObjectID(internal::gdextension_interface_variant_get_object_instance_id(_native_ptr())); return ObjectID(::godot::gdextension_interface::variant_get_object_instance_id(_native_ptr()));
} else { } else {
return ObjectID(); return ObjectID();
} }
@@ -518,7 +518,7 @@ Object *Variant::get_validated_object() const {
Variant &Variant::operator=(const Variant &other) { Variant &Variant::operator=(const Variant &other) {
clear(); clear();
internal::gdextension_interface_variant_new_copy(_native_ptr(), other._native_ptr()); ::godot::gdextension_interface::variant_new_copy(_native_ptr(), other._native_ptr());
return *this; return *this;
} }
@@ -558,22 +558,22 @@ bool Variant::operator<(const Variant &other) const {
} }
void Variant::callp(const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDExtensionCallError &r_error) { void Variant::callp(const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDExtensionCallError &r_error) {
internal::gdextension_interface_variant_call(_native_ptr(), method._native_ptr(), reinterpret_cast<GDExtensionConstVariantPtr *>(args), argcount, r_ret._native_ptr(), &r_error); ::godot::gdextension_interface::variant_call(_native_ptr(), method._native_ptr(), reinterpret_cast<GDExtensionConstVariantPtr *>(args), argcount, r_ret._native_ptr(), &r_error);
} }
void Variant::callp_static(Variant::Type type, const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDExtensionCallError &r_error) { void Variant::callp_static(Variant::Type type, const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDExtensionCallError &r_error) {
internal::gdextension_interface_variant_call_static(static_cast<GDExtensionVariantType>(type), method._native_ptr(), reinterpret_cast<GDExtensionConstVariantPtr *>(args), argcount, r_ret._native_ptr(), &r_error); ::godot::gdextension_interface::variant_call_static(static_cast<GDExtensionVariantType>(type), method._native_ptr(), reinterpret_cast<GDExtensionConstVariantPtr *>(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) { void Variant::evaluate(const Operator &op, const Variant &a, const Variant &b, Variant &r_ret, bool &r_valid) {
GDExtensionBool valid; GDExtensionBool valid;
internal::gdextension_interface_variant_evaluate(static_cast<GDExtensionVariantOperator>(op), a._native_ptr(), b._native_ptr(), r_ret._native_ptr(), &valid); ::godot::gdextension_interface::variant_evaluate(static_cast<GDExtensionVariantOperator>(op), a._native_ptr(), b._native_ptr(), r_ret._native_ptr(), &valid);
r_valid = PtrToArg<bool>::convert(&valid); r_valid = PtrToArg<bool>::convert(&valid);
} }
void Variant::set(const Variant &key, const Variant &value, bool *r_valid) { void Variant::set(const Variant &key, const Variant &value, bool *r_valid) {
GDExtensionBool valid; GDExtensionBool valid;
internal::gdextension_interface_variant_set(_native_ptr(), key._native_ptr(), value._native_ptr(), &valid); ::godot::gdextension_interface::variant_set(_native_ptr(), key._native_ptr(), value._native_ptr(), &valid);
if (r_valid) { if (r_valid) {
*r_valid = PtrToArg<bool>::convert(&valid); *r_valid = PtrToArg<bool>::convert(&valid);
} }
@@ -581,27 +581,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) { void Variant::set_named(const StringName &name, const Variant &value, bool &r_valid) {
GDExtensionBool valid; GDExtensionBool valid;
internal::gdextension_interface_variant_set_named(_native_ptr(), name._native_ptr(), value._native_ptr(), &valid); ::godot::gdextension_interface::variant_set_named(_native_ptr(), name._native_ptr(), value._native_ptr(), &valid);
r_valid = PtrToArg<bool>::convert(&valid); r_valid = PtrToArg<bool>::convert(&valid);
} }
void Variant::set_indexed(int64_t index, const Variant &value, bool &r_valid, bool &r_oob) { void Variant::set_indexed(int64_t index, const Variant &value, bool &r_valid, bool &r_oob) {
GDExtensionBool valid, oob; GDExtensionBool valid, oob;
internal::gdextension_interface_variant_set_indexed(_native_ptr(), index, value._native_ptr(), &valid, &oob); ::godot::gdextension_interface::variant_set_indexed(_native_ptr(), index, value._native_ptr(), &valid, &oob);
r_valid = PtrToArg<bool>::convert(&valid); r_valid = PtrToArg<bool>::convert(&valid);
r_oob = PtrToArg<bool>::convert(&oob); r_oob = PtrToArg<bool>::convert(&oob);
} }
void Variant::set_keyed(const Variant &key, const Variant &value, bool &r_valid) { void Variant::set_keyed(const Variant &key, const Variant &value, bool &r_valid) {
GDExtensionBool valid; GDExtensionBool valid;
internal::gdextension_interface_variant_set_keyed(_native_ptr(), key._native_ptr(), value._native_ptr(), &valid); ::godot::gdextension_interface::variant_set_keyed(_native_ptr(), key._native_ptr(), value._native_ptr(), &valid);
r_valid = PtrToArg<bool>::convert(&valid); r_valid = PtrToArg<bool>::convert(&valid);
} }
Variant Variant::get(const Variant &key, bool *r_valid) const { Variant Variant::get(const Variant &key, bool *r_valid) const {
Variant result; Variant result;
GDExtensionBool valid; GDExtensionBool valid;
internal::gdextension_interface_variant_get(_native_ptr(), key._native_ptr(), result._native_ptr(), &valid); ::godot::gdextension_interface::variant_get(_native_ptr(), key._native_ptr(), result._native_ptr(), &valid);
if (r_valid) { if (r_valid) {
*r_valid = PtrToArg<bool>::convert(&valid); *r_valid = PtrToArg<bool>::convert(&valid);
} }
@@ -611,7 +611,7 @@ Variant Variant::get(const Variant &key, bool *r_valid) const {
Variant Variant::get_named(const StringName &name, bool &r_valid) const { Variant Variant::get_named(const StringName &name, bool &r_valid) const {
Variant result; Variant result;
GDExtensionBool valid; GDExtensionBool valid;
internal::gdextension_interface_variant_get_named(_native_ptr(), name._native_ptr(), result._native_ptr(), &valid); ::godot::gdextension_interface::variant_get_named(_native_ptr(), name._native_ptr(), result._native_ptr(), &valid);
r_valid = PtrToArg<bool>::convert(&valid); r_valid = PtrToArg<bool>::convert(&valid);
return result; return result;
} }
@@ -620,7 +620,7 @@ Variant Variant::get_indexed(int64_t index, bool &r_valid, bool &r_oob) const {
Variant result; Variant result;
GDExtensionBool valid; GDExtensionBool valid;
GDExtensionBool oob; GDExtensionBool oob;
internal::gdextension_interface_variant_get_indexed(_native_ptr(), index, result._native_ptr(), &valid, &oob); ::godot::gdextension_interface::variant_get_indexed(_native_ptr(), index, result._native_ptr(), &valid, &oob);
r_valid = PtrToArg<bool>::convert(&valid); r_valid = PtrToArg<bool>::convert(&valid);
r_oob = PtrToArg<bool>::convert(&oob); r_oob = PtrToArg<bool>::convert(&oob);
return result; return result;
@@ -629,7 +629,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 Variant::get_keyed(const Variant &key, bool &r_valid) const {
Variant result; Variant result;
GDExtensionBool valid; GDExtensionBool valid;
internal::gdextension_interface_variant_get_keyed(_native_ptr(), key._native_ptr(), result._native_ptr(), &valid); ::godot::gdextension_interface::variant_get_keyed(_native_ptr(), key._native_ptr(), result._native_ptr(), &valid);
r_valid = PtrToArg<bool>::convert(&valid); r_valid = PtrToArg<bool>::convert(&valid);
return result; return result;
} }
@@ -646,14 +646,14 @@ bool Variant::in(const Variant &index, bool *r_valid) const {
bool Variant::iter_init(Variant &r_iter, bool &r_valid) const { bool Variant::iter_init(Variant &r_iter, bool &r_valid) const {
GDExtensionBool valid; GDExtensionBool valid;
GDExtensionBool result = internal::gdextension_interface_variant_iter_init(_native_ptr(), r_iter._native_ptr(), &valid); GDExtensionBool result = ::godot::gdextension_interface::variant_iter_init(_native_ptr(), r_iter._native_ptr(), &valid);
r_valid = PtrToArg<bool>::convert(&valid); r_valid = PtrToArg<bool>::convert(&valid);
return PtrToArg<bool>::convert(&result); return PtrToArg<bool>::convert(&result);
} }
bool Variant::iter_next(Variant &r_iter, bool &r_valid) const { bool Variant::iter_next(Variant &r_iter, bool &r_valid) const {
GDExtensionBool valid; GDExtensionBool valid;
GDExtensionBool result = internal::gdextension_interface_variant_iter_next(_native_ptr(), r_iter._native_ptr(), &valid); GDExtensionBool result = ::godot::gdextension_interface::variant_iter_next(_native_ptr(), r_iter._native_ptr(), &valid);
r_valid = PtrToArg<bool>::convert(&valid); r_valid = PtrToArg<bool>::convert(&valid);
return PtrToArg<bool>::convert(&result); return PtrToArg<bool>::convert(&result);
} }
@@ -661,23 +661,23 @@ bool Variant::iter_next(Variant &r_iter, bool &r_valid) const {
Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const { Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
Variant result; Variant result;
GDExtensionBool valid; GDExtensionBool valid;
internal::gdextension_interface_variant_iter_get(_native_ptr(), r_iter._native_ptr(), result._native_ptr(), &valid); ::godot::gdextension_interface::variant_iter_get(_native_ptr(), r_iter._native_ptr(), result._native_ptr(), &valid);
r_valid = PtrToArg<bool>::convert(&valid); r_valid = PtrToArg<bool>::convert(&valid);
return result; return result;
} }
Variant::Type Variant::get_type() const { Variant::Type Variant::get_type() const {
return static_cast<Variant::Type>(internal::gdextension_interface_variant_get_type(_native_ptr())); return static_cast<Variant::Type>(::godot::gdextension_interface::variant_get_type(_native_ptr()));
} }
bool Variant::has_method(const StringName &method) const { bool Variant::has_method(const StringName &method) const {
GDExtensionBool has = internal::gdextension_interface_variant_has_method(_native_ptr(), method._native_ptr()); GDExtensionBool has = ::godot::gdextension_interface::variant_has_method(_native_ptr(), method._native_ptr());
return PtrToArg<bool>::convert(&has); return PtrToArg<bool>::convert(&has);
} }
bool Variant::has_key(const Variant &key, bool *r_valid) const { bool Variant::has_key(const Variant &key, bool *r_valid) const {
GDExtensionBool valid; GDExtensionBool valid;
GDExtensionBool has = internal::gdextension_interface_variant_has_key(_native_ptr(), key._native_ptr(), &valid); GDExtensionBool has = ::godot::gdextension_interface::variant_has_key(_native_ptr(), key._native_ptr(), &valid);
if (r_valid) { if (r_valid) {
*r_valid = PtrToArg<bool>::convert(&valid); *r_valid = PtrToArg<bool>::convert(&valid);
} }
@@ -685,33 +685,33 @@ bool Variant::has_key(const Variant &key, bool *r_valid) const {
} }
bool Variant::has_member(Variant::Type type, const StringName &member) { bool Variant::has_member(Variant::Type type, const StringName &member) {
GDExtensionBool has = internal::gdextension_interface_variant_has_member(static_cast<GDExtensionVariantType>(type), member._native_ptr()); GDExtensionBool has = ::godot::gdextension_interface::variant_has_member(static_cast<GDExtensionVariantType>(type), member._native_ptr());
return PtrToArg<bool>::convert(&has); return PtrToArg<bool>::convert(&has);
} }
uint32_t Variant::hash() const { uint32_t Variant::hash() const {
GDExtensionInt hash = internal::gdextension_interface_variant_hash(_native_ptr()); GDExtensionInt hash = ::godot::gdextension_interface::variant_hash(_native_ptr());
return PtrToArg<uint32_t>::convert(&hash); return PtrToArg<uint32_t>::convert(&hash);
} }
uint32_t Variant::recursive_hash(int recursion_count) const { uint32_t Variant::recursive_hash(int recursion_count) const {
GDExtensionInt hash = internal::gdextension_interface_variant_recursive_hash(_native_ptr(), recursion_count); GDExtensionInt hash = ::godot::gdextension_interface::variant_recursive_hash(_native_ptr(), recursion_count);
return PtrToArg<uint32_t>::convert(&hash); return PtrToArg<uint32_t>::convert(&hash);
} }
bool Variant::hash_compare(const Variant &variant) const { bool Variant::hash_compare(const Variant &variant) const {
GDExtensionBool compare = internal::gdextension_interface_variant_hash_compare(_native_ptr(), variant._native_ptr()); GDExtensionBool compare = ::godot::gdextension_interface::variant_hash_compare(_native_ptr(), variant._native_ptr());
return PtrToArg<bool>::convert(&compare); return PtrToArg<bool>::convert(&compare);
} }
bool Variant::booleanize() const { bool Variant::booleanize() const {
GDExtensionBool booleanized = internal::gdextension_interface_variant_booleanize(_native_ptr()); GDExtensionBool booleanized = ::godot::gdextension_interface::variant_booleanize(_native_ptr());
return PtrToArg<bool>::convert(&booleanized); return PtrToArg<bool>::convert(&booleanized);
} }
String Variant::stringify() const { String Variant::stringify() const {
String result; String result;
internal::gdextension_interface_variant_stringify(_native_ptr(), result._native_ptr()); ::godot::gdextension_interface::variant_stringify(_native_ptr(), result._native_ptr());
return result; return result;
} }
@@ -719,23 +719,23 @@ Variant Variant::duplicate(bool deep) const {
Variant result; Variant result;
GDExtensionBool _deep; GDExtensionBool _deep;
PtrToArg<bool>::encode(deep, &_deep); PtrToArg<bool>::encode(deep, &_deep);
internal::gdextension_interface_variant_duplicate(_native_ptr(), result._native_ptr(), _deep); ::godot::gdextension_interface::variant_duplicate(_native_ptr(), result._native_ptr(), _deep);
return result; return result;
} }
String Variant::get_type_name(Variant::Type type) { String Variant::get_type_name(Variant::Type type) {
String result; String result;
internal::gdextension_interface_variant_get_type_name(static_cast<GDExtensionVariantType>(type), result._native_ptr()); ::godot::gdextension_interface::variant_get_type_name(static_cast<GDExtensionVariantType>(type), result._native_ptr());
return result; return result;
} }
bool Variant::can_convert(Variant::Type from, Variant::Type to) { bool Variant::can_convert(Variant::Type from, Variant::Type to) {
GDExtensionBool can = internal::gdextension_interface_variant_can_convert(static_cast<GDExtensionVariantType>(from), static_cast<GDExtensionVariantType>(to)); GDExtensionBool can = ::godot::gdextension_interface::variant_can_convert(static_cast<GDExtensionVariantType>(from), static_cast<GDExtensionVariantType>(to));
return PtrToArg<bool>::convert(&can); return PtrToArg<bool>::convert(&can);
} }
bool Variant::can_convert_strict(Variant::Type from, Variant::Type to) { bool Variant::can_convert_strict(Variant::Type from, Variant::Type to) {
GDExtensionBool can = internal::gdextension_interface_variant_can_convert_strict(static_cast<GDExtensionVariantType>(from), static_cast<GDExtensionVariantType>(to)); GDExtensionBool can = ::godot::gdextension_interface::variant_can_convert_strict(static_cast<GDExtensionVariantType>(from), static_cast<GDExtensionVariantType>(to));
return PtrToArg<bool>::convert(&can); return PtrToArg<bool>::convert(&can);
} }
@@ -786,9 +786,9 @@ void Variant::clear() {
}; };
if (unlikely(needs_deinit[get_type()])) { // Make it fast for types that don't need deinit. if (unlikely(needs_deinit[get_type()])) { // Make it fast for types that don't need deinit.
internal::gdextension_interface_variant_destroy(_native_ptr()); ::godot::gdextension_interface::variant_destroy(_native_ptr());
} }
internal::gdextension_interface_variant_new_nil(_native_ptr()); ::godot::gdextension_interface::variant_new_nil(_native_ptr());
} }
} // namespace godot } // namespace godot

View File

@@ -36,7 +36,7 @@ GDExtensionVariantGetInternalPtrFunc VariantInternal::get_internal_func[Variant:
void VariantInternal::init_bindings() { void VariantInternal::init_bindings() {
for (int i = 1; i < Variant::VARIANT_MAX; i++) { for (int i = 1; i < Variant::VARIANT_MAX; i++) {
get_internal_func[i] = internal::gdextension_interface_variant_get_ptr_internal_getter((GDExtensionVariantType)i); get_internal_func[i] = ::godot::gdextension_interface::variant_get_ptr_internal_getter((GDExtensionVariantType)i);
} }
} }

View File

@@ -306,7 +306,7 @@ void Example::_bind_methods() {
} }
bool Example::has_object_instance_binding() const { bool Example::has_object_instance_binding() const {
return internal::gdextension_interface_object_get_instance_binding(_owner, internal::token, nullptr); return ::godot::gdextension_interface::object_get_instance_binding(_owner, ::godot::gdextension_interface::token, nullptr);
} }
Example::Example() : Example::Example() :
@@ -748,7 +748,7 @@ String Example::test_use_engine_singleton() const {
String Example::test_library_path() { String Example::test_library_path() {
String library_path; String library_path;
internal::gdextension_interface_get_library_path(internal::library, library_path._native_ptr()); ::godot::gdextension_interface::get_library_path(::godot::gdextension_interface::library, library_path._native_ptr());
return library_path; return library_path;
} }

View File

@@ -149,6 +149,11 @@ def scons_emit_files(target, source, env):
env.Depends(file, profile_filepath) env.Depends(file, profile_filepath)
files.append(file) files.append(file)
env["godot_cpp_gen_dir"] = target[0].abspath env["godot_cpp_gen_dir"] = target[0].abspath
# gdextension_interface.h shouldn't depend on extension_api.json or the build_profile.json.
gdextension_interface_header = os.path.join(str(target[0]), "gen", "include", "gdextension_interface.h")
env.Ignore(gdextension_interface_header, [source[0], profile_filepath])
return files, source return files, source
@@ -162,6 +167,7 @@ def scons_generate_bindings(target, source, env):
_generate_bindings( _generate_bindings(
api, api,
str(source[0]), str(source[0]),
str(source[1]),
env["generate_template_get_node"], env["generate_template_get_node"],
"32" if "32" in env["arch"] else "64", "32" if "32" in env["arch"] else "64",
env["precision"], env["precision"],
@@ -376,6 +382,7 @@ def options(opts, env):
) )
) )
opts.Add(BoolVariable("debug_symbols", "Build with debugging symbols", True)) opts.Add(BoolVariable("debug_symbols", "Build with debugging symbols", True))
opts.Add(BoolVariable("deprecated", "Enable compatibility code for deprecated and removed features", True))
opts.Add(BoolVariable("dev_build", "Developer build with dev-only debugging code (DEV_ENABLED)", False)) opts.Add(BoolVariable("dev_build", "Developer build with dev-only debugging code (DEV_ENABLED)", False))
opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", False)) opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", False))
@@ -488,6 +495,9 @@ def generate(env):
if env["precision"] == "double": if env["precision"] == "double":
env.Append(CPPDEFINES=["REAL_T_IS_DOUBLE"]) env.Append(CPPDEFINES=["REAL_T_IS_DOUBLE"])
if not env["deprecated"]:
env.Append(CPPDEFINES=["DISABLE_DEPRECATED"])
# Allow detecting when building as a GDExtension. # Allow detecting when building as a GDExtension.
env.Append(CPPDEFINES=["GDEXTENSION"]) env.Append(CPPDEFINES=["GDEXTENSION"])
@@ -538,8 +548,9 @@ def _godot_cpp(env):
env.Dir("."), env.Dir("."),
[ [
api_file, api_file,
os.path.join(extension_dir, "gdextension_interface.h"), os.path.join(extension_dir, "gdextension_interface.json"),
"binding_generator.py", "binding_generator.py",
"make_interface_header.py",
], ],
) )
# Forces bindings regeneration. # Forces bindings regeneration.
@@ -559,7 +570,6 @@ def _godot_cpp(env):
# Includes # Includes
env.AppendUnique( env.AppendUnique(
CPPPATH=[ CPPPATH=[
env.Dir(extension_dir),
env.Dir("include").srcnode(), env.Dir("include").srcnode(),
env.Dir("gen/include"), env.Dir("gen/include"),
] ]