godot.cpp 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. /**************************************************************************/
  2. /* godot.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include <godot_cpp/godot.hpp>
  31. #include <godot_cpp/classes/editor_plugin_registration.hpp>
  32. #include <godot_cpp/classes/wrapped.hpp>
  33. #include <godot_cpp/core/class_db.hpp>
  34. #include <godot_cpp/core/memory.hpp>
  35. #include <godot_cpp/core/version.hpp>
  36. #include <godot_cpp/variant/variant.hpp>
  37. #include <godot_cpp/core/error_macros.hpp>
  38. namespace godot {
  39. namespace internal {
  40. GDExtensionInterfaceGetProcAddress gdextension_interface_get_proc_address = nullptr;
  41. GDExtensionClassLibraryPtr library = nullptr;
  42. void *token = nullptr;
  43. GDExtensionGodotVersion godot_version = { 0, 0, 0, nullptr };
  44. // All of the GDExtension interface functions.
  45. GDExtensionInterfaceGetGodotVersion gdextension_interface_get_godot_version = nullptr;
  46. GDExtensionInterfaceMemAlloc gdextension_interface_mem_alloc = nullptr;
  47. GDExtensionInterfaceMemRealloc gdextension_interface_mem_realloc = nullptr;
  48. GDExtensionInterfaceMemFree gdextension_interface_mem_free = nullptr;
  49. GDExtensionInterfacePrintError gdextension_interface_print_error = nullptr;
  50. GDExtensionInterfacePrintErrorWithMessage gdextension_interface_print_error_with_message = nullptr;
  51. GDExtensionInterfacePrintWarning gdextension_interface_print_warning = nullptr;
  52. GDExtensionInterfacePrintWarningWithMessage gdextension_interface_print_warning_with_message = nullptr;
  53. GDExtensionInterfacePrintScriptError gdextension_interface_print_script_error = nullptr;
  54. GDExtensionInterfacePrintScriptErrorWithMessage gdextension_interface_print_script_error_with_message = nullptr;
  55. GDExtensionInterfaceGetNativeStructSize gdextension_interface_get_native_struct_size = nullptr;
  56. GDExtensionInterfaceVariantNewCopy gdextension_interface_variant_new_copy = nullptr;
  57. GDExtensionInterfaceVariantNewNil gdextension_interface_variant_new_nil = nullptr;
  58. GDExtensionInterfaceVariantDestroy gdextension_interface_variant_destroy = nullptr;
  59. GDExtensionInterfaceVariantCall gdextension_interface_variant_call = nullptr;
  60. GDExtensionInterfaceVariantCallStatic gdextension_interface_variant_call_static = nullptr;
  61. GDExtensionInterfaceVariantEvaluate gdextension_interface_variant_evaluate = nullptr;
  62. GDExtensionInterfaceVariantSet gdextension_interface_variant_set = nullptr;
  63. GDExtensionInterfaceVariantSetNamed gdextension_interface_variant_set_named = nullptr;
  64. GDExtensionInterfaceVariantSetKeyed gdextension_interface_variant_set_keyed = nullptr;
  65. GDExtensionInterfaceVariantSetIndexed gdextension_interface_variant_set_indexed = nullptr;
  66. GDExtensionInterfaceVariantGet gdextension_interface_variant_get = nullptr;
  67. GDExtensionInterfaceVariantGetNamed gdextension_interface_variant_get_named = nullptr;
  68. GDExtensionInterfaceVariantGetKeyed gdextension_interface_variant_get_keyed = nullptr;
  69. GDExtensionInterfaceVariantGetIndexed gdextension_interface_variant_get_indexed = nullptr;
  70. GDExtensionInterfaceVariantIterInit gdextension_interface_variant_iter_init = nullptr;
  71. GDExtensionInterfaceVariantIterNext gdextension_interface_variant_iter_next = nullptr;
  72. GDExtensionInterfaceVariantIterGet gdextension_interface_variant_iter_get = nullptr;
  73. GDExtensionInterfaceVariantHash gdextension_interface_variant_hash = nullptr;
  74. GDExtensionInterfaceVariantRecursiveHash gdextension_interface_variant_recursive_hash = nullptr;
  75. GDExtensionInterfaceVariantHashCompare gdextension_interface_variant_hash_compare = nullptr;
  76. GDExtensionInterfaceVariantBooleanize gdextension_interface_variant_booleanize = nullptr;
  77. GDExtensionInterfaceVariantDuplicate gdextension_interface_variant_duplicate = nullptr;
  78. GDExtensionInterfaceVariantStringify gdextension_interface_variant_stringify = nullptr;
  79. GDExtensionInterfaceVariantGetType gdextension_interface_variant_get_type = nullptr;
  80. GDExtensionInterfaceVariantHasMethod gdextension_interface_variant_has_method = nullptr;
  81. GDExtensionInterfaceVariantHasMember gdextension_interface_variant_has_member = nullptr;
  82. GDExtensionInterfaceVariantHasKey gdextension_interface_variant_has_key = nullptr;
  83. GDExtensionInterfaceVariantGetTypeName gdextension_interface_variant_get_type_name = nullptr;
  84. GDExtensionInterfaceVariantCanConvert gdextension_interface_variant_can_convert = nullptr;
  85. GDExtensionInterfaceVariantCanConvertStrict gdextension_interface_variant_can_convert_strict = nullptr;
  86. GDExtensionInterfaceGetVariantFromTypeConstructor gdextension_interface_get_variant_from_type_constructor = nullptr;
  87. GDExtensionInterfaceGetVariantToTypeConstructor gdextension_interface_get_variant_to_type_constructor = nullptr;
  88. GDExtensionInterfaceVariantGetPtrOperatorEvaluator gdextension_interface_variant_get_ptr_operator_evaluator = nullptr;
  89. GDExtensionInterfaceVariantGetPtrBuiltinMethod gdextension_interface_variant_get_ptr_builtin_method = nullptr;
  90. GDExtensionInterfaceVariantGetPtrConstructor gdextension_interface_variant_get_ptr_constructor = nullptr;
  91. GDExtensionInterfaceVariantGetPtrDestructor gdextension_interface_variant_get_ptr_destructor = nullptr;
  92. GDExtensionInterfaceVariantConstruct gdextension_interface_variant_construct = nullptr;
  93. GDExtensionInterfaceVariantGetPtrSetter gdextension_interface_variant_get_ptr_setter = nullptr;
  94. GDExtensionInterfaceVariantGetPtrGetter gdextension_interface_variant_get_ptr_getter = nullptr;
  95. GDExtensionInterfaceVariantGetPtrIndexedSetter gdextension_interface_variant_get_ptr_indexed_setter = nullptr;
  96. GDExtensionInterfaceVariantGetPtrIndexedGetter gdextension_interface_variant_get_ptr_indexed_getter = nullptr;
  97. GDExtensionInterfaceVariantGetPtrKeyedSetter gdextension_interface_variant_get_ptr_keyed_setter = nullptr;
  98. GDExtensionInterfaceVariantGetPtrKeyedGetter gdextension_interface_variant_get_ptr_keyed_getter = nullptr;
  99. GDExtensionInterfaceVariantGetPtrKeyedChecker gdextension_interface_variant_get_ptr_keyed_checker = nullptr;
  100. GDExtensionInterfaceVariantGetConstantValue gdextension_interface_variant_get_constant_value = nullptr;
  101. GDExtensionInterfaceVariantGetPtrUtilityFunction gdextension_interface_variant_get_ptr_utility_function = nullptr;
  102. GDExtensionInterfaceStringNewWithLatin1Chars gdextension_interface_string_new_with_latin1_chars = nullptr;
  103. GDExtensionInterfaceStringNewWithUtf8Chars gdextension_interface_string_new_with_utf8_chars = nullptr;
  104. GDExtensionInterfaceStringNewWithUtf16Chars gdextension_interface_string_new_with_utf16_chars = nullptr;
  105. GDExtensionInterfaceStringNewWithUtf32Chars gdextension_interface_string_new_with_utf32_chars = nullptr;
  106. GDExtensionInterfaceStringNewWithWideChars gdextension_interface_string_new_with_wide_chars = nullptr;
  107. GDExtensionInterfaceStringNewWithLatin1CharsAndLen gdextension_interface_string_new_with_latin1_chars_and_len = nullptr;
  108. GDExtensionInterfaceStringNewWithUtf8CharsAndLen gdextension_interface_string_new_with_utf8_chars_and_len = nullptr;
  109. GDExtensionInterfaceStringNewWithUtf16CharsAndLen gdextension_interface_string_new_with_utf16_chars_and_len = nullptr;
  110. GDExtensionInterfaceStringNewWithUtf32CharsAndLen gdextension_interface_string_new_with_utf32_chars_and_len = nullptr;
  111. GDExtensionInterfaceStringNewWithWideCharsAndLen gdextension_interface_string_new_with_wide_chars_and_len = nullptr;
  112. GDExtensionInterfaceStringToLatin1Chars gdextension_interface_string_to_latin1_chars = nullptr;
  113. GDExtensionInterfaceStringToUtf8Chars gdextension_interface_string_to_utf8_chars = nullptr;
  114. GDExtensionInterfaceStringToUtf16Chars gdextension_interface_string_to_utf16_chars = nullptr;
  115. GDExtensionInterfaceStringToUtf32Chars gdextension_interface_string_to_utf32_chars = nullptr;
  116. GDExtensionInterfaceStringToWideChars gdextension_interface_string_to_wide_chars = nullptr;
  117. GDExtensionInterfaceStringOperatorIndex gdextension_interface_string_operator_index = nullptr;
  118. GDExtensionInterfaceStringOperatorIndexConst gdextension_interface_string_operator_index_const = nullptr;
  119. GDExtensionInterfaceStringOperatorPlusEqString gdextension_interface_string_operator_plus_eq_string = nullptr;
  120. GDExtensionInterfaceStringOperatorPlusEqChar gdextension_interface_string_operator_plus_eq_char = nullptr;
  121. GDExtensionInterfaceStringOperatorPlusEqCstr gdextension_interface_string_operator_plus_eq_cstr = nullptr;
  122. GDExtensionInterfaceStringOperatorPlusEqWcstr gdextension_interface_string_operator_plus_eq_wcstr = nullptr;
  123. GDExtensionInterfaceStringOperatorPlusEqC32str gdextension_interface_string_operator_plus_eq_c32str = nullptr;
  124. GDExtensionInterfaceStringResize gdextension_interface_string_resize = nullptr;
  125. GDExtensionInterfaceStringNameNewWithLatin1Chars gdextension_interface_string_name_new_with_latin1_chars = nullptr;
  126. GDExtensionInterfaceXmlParserOpenBuffer gdextension_interface_xml_parser_open_buffer = nullptr;
  127. GDExtensionInterfaceFileAccessStoreBuffer gdextension_interface_file_access_store_buffer = nullptr;
  128. GDExtensionInterfaceFileAccessGetBuffer gdextension_interface_file_access_get_buffer = nullptr;
  129. GDExtensionInterfaceWorkerThreadPoolAddNativeGroupTask gdextension_interface_worker_thread_pool_add_native_group_task = nullptr;
  130. GDExtensionInterfaceWorkerThreadPoolAddNativeTask gdextension_interface_worker_thread_pool_add_native_task = nullptr;
  131. GDExtensionInterfacePackedByteArrayOperatorIndex gdextension_interface_packed_byte_array_operator_index = nullptr;
  132. GDExtensionInterfacePackedByteArrayOperatorIndexConst gdextension_interface_packed_byte_array_operator_index_const = nullptr;
  133. GDExtensionInterfacePackedColorArrayOperatorIndex gdextension_interface_packed_color_array_operator_index = nullptr;
  134. GDExtensionInterfacePackedColorArrayOperatorIndexConst gdextension_interface_packed_color_array_operator_index_const = nullptr;
  135. GDExtensionInterfacePackedFloat32ArrayOperatorIndex gdextension_interface_packed_float32_array_operator_index = nullptr;
  136. GDExtensionInterfacePackedFloat32ArrayOperatorIndexConst gdextension_interface_packed_float32_array_operator_index_const = nullptr;
  137. GDExtensionInterfacePackedFloat64ArrayOperatorIndex gdextension_interface_packed_float64_array_operator_index = nullptr;
  138. GDExtensionInterfacePackedFloat64ArrayOperatorIndexConst gdextension_interface_packed_float64_array_operator_index_const = nullptr;
  139. GDExtensionInterfacePackedInt32ArrayOperatorIndex gdextension_interface_packed_int32_array_operator_index = nullptr;
  140. GDExtensionInterfacePackedInt32ArrayOperatorIndexConst gdextension_interface_packed_int32_array_operator_index_const = nullptr;
  141. GDExtensionInterfacePackedInt64ArrayOperatorIndex gdextension_interface_packed_int64_array_operator_index = nullptr;
  142. GDExtensionInterfacePackedInt64ArrayOperatorIndexConst gdextension_interface_packed_int64_array_operator_index_const = nullptr;
  143. GDExtensionInterfacePackedStringArrayOperatorIndex gdextension_interface_packed_string_array_operator_index = nullptr;
  144. GDExtensionInterfacePackedStringArrayOperatorIndexConst gdextension_interface_packed_string_array_operator_index_const = nullptr;
  145. GDExtensionInterfacePackedVector2ArrayOperatorIndex gdextension_interface_packed_vector2_array_operator_index = nullptr;
  146. GDExtensionInterfacePackedVector2ArrayOperatorIndexConst gdextension_interface_packed_vector2_array_operator_index_const = nullptr;
  147. GDExtensionInterfacePackedVector3ArrayOperatorIndex gdextension_interface_packed_vector3_array_operator_index = nullptr;
  148. GDExtensionInterfacePackedVector3ArrayOperatorIndexConst gdextension_interface_packed_vector3_array_operator_index_const = nullptr;
  149. GDExtensionInterfaceArrayOperatorIndex gdextension_interface_array_operator_index = nullptr;
  150. GDExtensionInterfaceArrayOperatorIndexConst gdextension_interface_array_operator_index_const = nullptr;
  151. GDExtensionInterfaceArrayRef gdextension_interface_array_ref = nullptr;
  152. GDExtensionInterfaceArraySetTyped gdextension_interface_array_set_typed = nullptr;
  153. GDExtensionInterfaceDictionaryOperatorIndex gdextension_interface_dictionary_operator_index = nullptr;
  154. GDExtensionInterfaceDictionaryOperatorIndexConst gdextension_interface_dictionary_operator_index_const = nullptr;
  155. GDExtensionInterfaceObjectMethodBindCall gdextension_interface_object_method_bind_call = nullptr;
  156. GDExtensionInterfaceObjectMethodBindPtrcall gdextension_interface_object_method_bind_ptrcall = nullptr;
  157. GDExtensionInterfaceObjectDestroy gdextension_interface_object_destroy = nullptr;
  158. GDExtensionInterfaceGlobalGetSingleton gdextension_interface_global_get_singleton = nullptr;
  159. GDExtensionInterfaceObjectGetInstanceBinding gdextension_interface_object_get_instance_binding = nullptr;
  160. GDExtensionInterfaceObjectSetInstanceBinding gdextension_interface_object_set_instance_binding = nullptr;
  161. GDExtensionInterfaceObjectSetInstance gdextension_interface_object_set_instance = nullptr;
  162. GDExtensionInterfaceObjectGetClassName gdextension_interface_object_get_class_name = nullptr;
  163. GDExtensionInterfaceObjectCastTo gdextension_interface_object_cast_to = nullptr;
  164. GDExtensionInterfaceObjectGetInstanceFromId gdextension_interface_object_get_instance_from_id = nullptr;
  165. GDExtensionInterfaceObjectGetInstanceId gdextension_interface_object_get_instance_id = nullptr;
  166. GDExtensionInterfaceObjectHasScriptMethod gdextension_interface_object_has_script_method = nullptr;
  167. GDExtensionInterfaceObjectCallScriptMethod gdextension_interface_object_call_script_method = nullptr;
  168. GDExtensionInterfaceCallableCustomCreate gdextension_interface_callable_custom_create = nullptr;
  169. GDExtensionInterfaceCallableCustomGetUserData gdextension_interface_callable_custom_get_userdata = nullptr;
  170. GDExtensionInterfaceRefGetObject gdextension_interface_ref_get_object = nullptr;
  171. GDExtensionInterfaceRefSetObject gdextension_interface_ref_set_object = nullptr;
  172. GDExtensionInterfaceScriptInstanceCreate2 gdextension_interface_script_instance_create2 = nullptr;
  173. GDExtensionInterfacePlaceHolderScriptInstanceCreate gdextension_interface_placeholder_script_instance_create = nullptr;
  174. GDExtensionInterfacePlaceHolderScriptInstanceUpdate gdextension_interface_placeholder_script_instance_update = nullptr;
  175. GDExtensionInterfaceClassdbConstructObject gdextension_interface_classdb_construct_object = nullptr;
  176. GDExtensionInterfaceClassdbGetMethodBind gdextension_interface_classdb_get_method_bind = nullptr;
  177. GDExtensionInterfaceClassdbGetClassTag gdextension_interface_classdb_get_class_tag = nullptr;
  178. GDExtensionInterfaceClassdbRegisterExtensionClass2 gdextension_interface_classdb_register_extension_class2 = nullptr;
  179. GDExtensionInterfaceClassdbRegisterExtensionClassMethod gdextension_interface_classdb_register_extension_class_method = nullptr;
  180. GDExtensionInterfaceClassdbRegisterExtensionClassVirtualMethod gdextension_interface_classdb_register_extension_class_virtual_method = nullptr;
  181. GDExtensionInterfaceClassdbRegisterExtensionClassIntegerConstant gdextension_interface_classdb_register_extension_class_integer_constant = nullptr;
  182. GDExtensionInterfaceClassdbRegisterExtensionClassProperty gdextension_interface_classdb_register_extension_class_property = nullptr;
  183. GDExtensionInterfaceClassdbRegisterExtensionClassPropertyIndexed gdextension_interface_classdb_register_extension_class_property_indexed = nullptr;
  184. GDExtensionInterfaceClassdbRegisterExtensionClassPropertyGroup gdextension_interface_classdb_register_extension_class_property_group = nullptr;
  185. GDExtensionInterfaceClassdbRegisterExtensionClassPropertySubgroup gdextension_interface_classdb_register_extension_class_property_subgroup = nullptr;
  186. GDExtensionInterfaceClassdbRegisterExtensionClassSignal gdextension_interface_classdb_register_extension_class_signal = nullptr;
  187. GDExtensionInterfaceClassdbUnregisterExtensionClass gdextension_interface_classdb_unregister_extension_class = nullptr;
  188. GDExtensionInterfaceGetLibraryPath gdextension_interface_get_library_path = nullptr;
  189. GDExtensionInterfaceEditorAddPlugin gdextension_interface_editor_add_plugin = nullptr;
  190. GDExtensionInterfaceEditorRemovePlugin gdextension_interface_editor_remove_plugin = nullptr;
  191. } // namespace internal
  192. bool GDExtensionBinding::api_initialized = false;
  193. int GDExtensionBinding::level_initialized[MODULE_INITIALIZATION_LEVEL_MAX] = { 0 };
  194. GDExtensionBinding::InitDataList GDExtensionBinding::initdata;
  195. #define ERR_PRINT_EARLY(m_msg) \
  196. internal::gdextension_interface_print_error(m_msg, FUNCTION_STR, __FILE__, __LINE__, false)
  197. #define LOAD_PROC_ADDRESS(m_name, m_type) \
  198. internal::gdextension_interface_##m_name = (m_type)p_get_proc_address(#m_name); \
  199. if (!internal::gdextension_interface_##m_name) { \
  200. ERR_PRINT_EARLY("Unable to load GDExtension interface function " #m_name "()"); \
  201. return false; \
  202. }
  203. // Partial definition of the legacy interface so we can detect it and show an error.
  204. typedef struct {
  205. uint32_t version_major;
  206. uint32_t version_minor;
  207. uint32_t version_patch;
  208. const char *version_string;
  209. GDExtensionInterfaceFunctionPtr unused1;
  210. GDExtensionInterfaceFunctionPtr unused2;
  211. GDExtensionInterfaceFunctionPtr unused3;
  212. GDExtensionInterfacePrintError print_error;
  213. GDExtensionInterfacePrintErrorWithMessage print_error_with_message;
  214. } LegacyGDExtensionInterface;
  215. GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, InitData *p_init_data, GDExtensionInitialization *r_initialization) {
  216. if (!p_init_data || !p_init_data->init_callback) {
  217. ERR_FAIL_V_MSG(false, "Initialization callback must be defined.");
  218. }
  219. if (api_initialized) {
  220. r_initialization->initialize = initialize_level;
  221. r_initialization->deinitialize = deinitialize_level;
  222. r_initialization->userdata = p_init_data;
  223. r_initialization->minimum_initialization_level = p_init_data->minimum_initialization_level;
  224. return true;
  225. }
  226. // Make sure we weren't passed the legacy struct.
  227. uint32_t *raw_interface = (uint32_t *)(void *)p_get_proc_address;
  228. if (raw_interface[0] == 4 && raw_interface[1] == 0) {
  229. // Use the legacy interface only to give a nice error.
  230. LegacyGDExtensionInterface *legacy_interface = (LegacyGDExtensionInterface *)p_get_proc_address;
  231. internal::gdextension_interface_print_error = (GDExtensionInterfacePrintError)legacy_interface->print_error;
  232. ERR_PRINT_EARLY("Cannot load a GDExtension built for Godot 4.1+ in Godot 4.0.");
  233. return false;
  234. }
  235. // Load the "print_error" function first (needed by the ERR_PRINT_EARLY() macro).
  236. internal::gdextension_interface_print_error = (GDExtensionInterfacePrintError)p_get_proc_address("print_error");
  237. if (!internal::gdextension_interface_print_error) {
  238. printf("ERROR: Unable to load GDExtension interface function print_error().\n");
  239. return false;
  240. }
  241. internal::gdextension_interface_get_proc_address = p_get_proc_address;
  242. internal::library = p_library;
  243. internal::token = p_library;
  244. LOAD_PROC_ADDRESS(get_godot_version, GDExtensionInterfaceGetGodotVersion);
  245. internal::gdextension_interface_get_godot_version(&internal::godot_version);
  246. // Check that godot-cpp was compiled using an extension_api.json older or at the
  247. // same version as the Godot that is loading it.
  248. bool compatible;
  249. if (internal::godot_version.major != GODOT_VERSION_MAJOR) {
  250. compatible = internal::godot_version.major > GODOT_VERSION_MAJOR;
  251. } else if (internal::godot_version.minor != GODOT_VERSION_MINOR) {
  252. compatible = internal::godot_version.minor > GODOT_VERSION_MINOR;
  253. } else {
  254. #if GODOT_VERSION_PATCH > 0
  255. compatible = internal::godot_version.patch >= GODOT_VERSION_PATCH;
  256. #else
  257. // Prevent -Wtype-limits warning due to unsigned comparison.
  258. compatible = true;
  259. #endif
  260. }
  261. if (!compatible) {
  262. // We need to use snprintf() here because vformat() uses Variant, and we haven't loaded
  263. // the GDExtension interface far enough to use Variants yet.
  264. char msg[128];
  265. snprintf(msg, 128, "Cannot load a GDExtension built for Godot %d.%d.%d using an older version of Godot (%d.%d.%d).",
  266. GODOT_VERSION_MAJOR, GODOT_VERSION_MINOR, GODOT_VERSION_PATCH,
  267. internal::godot_version.major, internal::godot_version.minor, internal::godot_version.patch);
  268. ERR_PRINT_EARLY(msg);
  269. return false;
  270. }
  271. LOAD_PROC_ADDRESS(mem_alloc, GDExtensionInterfaceMemAlloc);
  272. LOAD_PROC_ADDRESS(mem_realloc, GDExtensionInterfaceMemRealloc);
  273. LOAD_PROC_ADDRESS(mem_free, GDExtensionInterfaceMemFree);
  274. LOAD_PROC_ADDRESS(print_error_with_message, GDExtensionInterfacePrintErrorWithMessage);
  275. LOAD_PROC_ADDRESS(print_warning, GDExtensionInterfacePrintWarning);
  276. LOAD_PROC_ADDRESS(print_warning_with_message, GDExtensionInterfacePrintWarningWithMessage);
  277. LOAD_PROC_ADDRESS(print_script_error, GDExtensionInterfacePrintScriptError);
  278. LOAD_PROC_ADDRESS(print_script_error_with_message, GDExtensionInterfacePrintScriptErrorWithMessage);
  279. LOAD_PROC_ADDRESS(get_native_struct_size, GDExtensionInterfaceGetNativeStructSize);
  280. LOAD_PROC_ADDRESS(variant_new_copy, GDExtensionInterfaceVariantNewCopy);
  281. LOAD_PROC_ADDRESS(variant_new_nil, GDExtensionInterfaceVariantNewNil);
  282. LOAD_PROC_ADDRESS(variant_destroy, GDExtensionInterfaceVariantDestroy);
  283. LOAD_PROC_ADDRESS(variant_call, GDExtensionInterfaceVariantCall);
  284. LOAD_PROC_ADDRESS(variant_call_static, GDExtensionInterfaceVariantCallStatic);
  285. LOAD_PROC_ADDRESS(variant_evaluate, GDExtensionInterfaceVariantEvaluate);
  286. LOAD_PROC_ADDRESS(variant_set, GDExtensionInterfaceVariantSet);
  287. LOAD_PROC_ADDRESS(variant_set_named, GDExtensionInterfaceVariantSetNamed);
  288. LOAD_PROC_ADDRESS(variant_set_keyed, GDExtensionInterfaceVariantSetKeyed);
  289. LOAD_PROC_ADDRESS(variant_set_indexed, GDExtensionInterfaceVariantSetIndexed);
  290. LOAD_PROC_ADDRESS(variant_get, GDExtensionInterfaceVariantGet);
  291. LOAD_PROC_ADDRESS(variant_get_named, GDExtensionInterfaceVariantGetNamed);
  292. LOAD_PROC_ADDRESS(variant_get_keyed, GDExtensionInterfaceVariantGetKeyed);
  293. LOAD_PROC_ADDRESS(variant_get_indexed, GDExtensionInterfaceVariantGetIndexed);
  294. LOAD_PROC_ADDRESS(variant_iter_init, GDExtensionInterfaceVariantIterInit);
  295. LOAD_PROC_ADDRESS(variant_iter_next, GDExtensionInterfaceVariantIterNext);
  296. LOAD_PROC_ADDRESS(variant_iter_get, GDExtensionInterfaceVariantIterGet);
  297. LOAD_PROC_ADDRESS(variant_hash, GDExtensionInterfaceVariantHash);
  298. LOAD_PROC_ADDRESS(variant_recursive_hash, GDExtensionInterfaceVariantRecursiveHash);
  299. LOAD_PROC_ADDRESS(variant_hash_compare, GDExtensionInterfaceVariantHashCompare);
  300. LOAD_PROC_ADDRESS(variant_booleanize, GDExtensionInterfaceVariantBooleanize);
  301. LOAD_PROC_ADDRESS(variant_duplicate, GDExtensionInterfaceVariantDuplicate);
  302. LOAD_PROC_ADDRESS(variant_stringify, GDExtensionInterfaceVariantStringify);
  303. LOAD_PROC_ADDRESS(variant_get_type, GDExtensionInterfaceVariantGetType);
  304. LOAD_PROC_ADDRESS(variant_has_method, GDExtensionInterfaceVariantHasMethod);
  305. LOAD_PROC_ADDRESS(variant_has_member, GDExtensionInterfaceVariantHasMember);
  306. LOAD_PROC_ADDRESS(variant_has_key, GDExtensionInterfaceVariantHasKey);
  307. LOAD_PROC_ADDRESS(variant_get_type_name, GDExtensionInterfaceVariantGetTypeName);
  308. LOAD_PROC_ADDRESS(variant_can_convert, GDExtensionInterfaceVariantCanConvert);
  309. LOAD_PROC_ADDRESS(variant_can_convert_strict, GDExtensionInterfaceVariantCanConvertStrict);
  310. LOAD_PROC_ADDRESS(get_variant_from_type_constructor, GDExtensionInterfaceGetVariantFromTypeConstructor);
  311. LOAD_PROC_ADDRESS(get_variant_to_type_constructor, GDExtensionInterfaceGetVariantToTypeConstructor);
  312. LOAD_PROC_ADDRESS(variant_get_ptr_operator_evaluator, GDExtensionInterfaceVariantGetPtrOperatorEvaluator);
  313. LOAD_PROC_ADDRESS(variant_get_ptr_builtin_method, GDExtensionInterfaceVariantGetPtrBuiltinMethod);
  314. LOAD_PROC_ADDRESS(variant_get_ptr_constructor, GDExtensionInterfaceVariantGetPtrConstructor);
  315. LOAD_PROC_ADDRESS(variant_get_ptr_destructor, GDExtensionInterfaceVariantGetPtrDestructor);
  316. LOAD_PROC_ADDRESS(variant_construct, GDExtensionInterfaceVariantConstruct);
  317. LOAD_PROC_ADDRESS(variant_get_ptr_setter, GDExtensionInterfaceVariantGetPtrSetter);
  318. LOAD_PROC_ADDRESS(variant_get_ptr_getter, GDExtensionInterfaceVariantGetPtrGetter);
  319. LOAD_PROC_ADDRESS(variant_get_ptr_indexed_setter, GDExtensionInterfaceVariantGetPtrIndexedSetter);
  320. LOAD_PROC_ADDRESS(variant_get_ptr_indexed_getter, GDExtensionInterfaceVariantGetPtrIndexedGetter);
  321. LOAD_PROC_ADDRESS(variant_get_ptr_keyed_setter, GDExtensionInterfaceVariantGetPtrKeyedSetter);
  322. LOAD_PROC_ADDRESS(variant_get_ptr_keyed_getter, GDExtensionInterfaceVariantGetPtrKeyedGetter);
  323. LOAD_PROC_ADDRESS(variant_get_ptr_keyed_checker, GDExtensionInterfaceVariantGetPtrKeyedChecker);
  324. LOAD_PROC_ADDRESS(variant_get_constant_value, GDExtensionInterfaceVariantGetConstantValue);
  325. LOAD_PROC_ADDRESS(variant_get_ptr_utility_function, GDExtensionInterfaceVariantGetPtrUtilityFunction);
  326. LOAD_PROC_ADDRESS(string_new_with_latin1_chars, GDExtensionInterfaceStringNewWithLatin1Chars);
  327. LOAD_PROC_ADDRESS(string_new_with_utf8_chars, GDExtensionInterfaceStringNewWithUtf8Chars);
  328. LOAD_PROC_ADDRESS(string_new_with_utf16_chars, GDExtensionInterfaceStringNewWithUtf16Chars);
  329. LOAD_PROC_ADDRESS(string_new_with_utf32_chars, GDExtensionInterfaceStringNewWithUtf32Chars);
  330. LOAD_PROC_ADDRESS(string_new_with_wide_chars, GDExtensionInterfaceStringNewWithWideChars);
  331. LOAD_PROC_ADDRESS(string_new_with_latin1_chars_and_len, GDExtensionInterfaceStringNewWithLatin1CharsAndLen);
  332. LOAD_PROC_ADDRESS(string_new_with_utf8_chars_and_len, GDExtensionInterfaceStringNewWithUtf8CharsAndLen);
  333. LOAD_PROC_ADDRESS(string_new_with_utf16_chars_and_len, GDExtensionInterfaceStringNewWithUtf16CharsAndLen);
  334. LOAD_PROC_ADDRESS(string_new_with_utf32_chars_and_len, GDExtensionInterfaceStringNewWithUtf32CharsAndLen);
  335. LOAD_PROC_ADDRESS(string_new_with_wide_chars_and_len, GDExtensionInterfaceStringNewWithWideCharsAndLen);
  336. LOAD_PROC_ADDRESS(string_to_latin1_chars, GDExtensionInterfaceStringToLatin1Chars);
  337. LOAD_PROC_ADDRESS(string_to_utf8_chars, GDExtensionInterfaceStringToUtf8Chars);
  338. LOAD_PROC_ADDRESS(string_to_utf16_chars, GDExtensionInterfaceStringToUtf16Chars);
  339. LOAD_PROC_ADDRESS(string_to_utf32_chars, GDExtensionInterfaceStringToUtf32Chars);
  340. LOAD_PROC_ADDRESS(string_to_wide_chars, GDExtensionInterfaceStringToWideChars);
  341. LOAD_PROC_ADDRESS(string_operator_index, GDExtensionInterfaceStringOperatorIndex);
  342. LOAD_PROC_ADDRESS(string_operator_index_const, GDExtensionInterfaceStringOperatorIndexConst);
  343. LOAD_PROC_ADDRESS(string_operator_plus_eq_string, GDExtensionInterfaceStringOperatorPlusEqString);
  344. LOAD_PROC_ADDRESS(string_operator_plus_eq_char, GDExtensionInterfaceStringOperatorPlusEqChar);
  345. LOAD_PROC_ADDRESS(string_operator_plus_eq_cstr, GDExtensionInterfaceStringOperatorPlusEqCstr);
  346. LOAD_PROC_ADDRESS(string_operator_plus_eq_wcstr, GDExtensionInterfaceStringOperatorPlusEqWcstr);
  347. LOAD_PROC_ADDRESS(string_operator_plus_eq_c32str, GDExtensionInterfaceStringOperatorPlusEqC32str);
  348. LOAD_PROC_ADDRESS(string_resize, GDExtensionInterfaceStringResize);
  349. LOAD_PROC_ADDRESS(string_name_new_with_latin1_chars, GDExtensionInterfaceStringNameNewWithLatin1Chars);
  350. LOAD_PROC_ADDRESS(xml_parser_open_buffer, GDExtensionInterfaceXmlParserOpenBuffer);
  351. LOAD_PROC_ADDRESS(file_access_store_buffer, GDExtensionInterfaceFileAccessStoreBuffer);
  352. LOAD_PROC_ADDRESS(file_access_get_buffer, GDExtensionInterfaceFileAccessGetBuffer);
  353. LOAD_PROC_ADDRESS(worker_thread_pool_add_native_group_task, GDExtensionInterfaceWorkerThreadPoolAddNativeGroupTask);
  354. LOAD_PROC_ADDRESS(worker_thread_pool_add_native_task, GDExtensionInterfaceWorkerThreadPoolAddNativeTask);
  355. LOAD_PROC_ADDRESS(packed_byte_array_operator_index, GDExtensionInterfacePackedByteArrayOperatorIndex);
  356. LOAD_PROC_ADDRESS(packed_byte_array_operator_index_const, GDExtensionInterfacePackedByteArrayOperatorIndexConst);
  357. LOAD_PROC_ADDRESS(packed_color_array_operator_index, GDExtensionInterfacePackedColorArrayOperatorIndex);
  358. LOAD_PROC_ADDRESS(packed_color_array_operator_index_const, GDExtensionInterfacePackedColorArrayOperatorIndexConst);
  359. LOAD_PROC_ADDRESS(packed_float32_array_operator_index, GDExtensionInterfacePackedFloat32ArrayOperatorIndex);
  360. LOAD_PROC_ADDRESS(packed_float32_array_operator_index_const, GDExtensionInterfacePackedFloat32ArrayOperatorIndexConst);
  361. LOAD_PROC_ADDRESS(packed_float64_array_operator_index, GDExtensionInterfacePackedFloat64ArrayOperatorIndex);
  362. LOAD_PROC_ADDRESS(packed_float64_array_operator_index_const, GDExtensionInterfacePackedFloat64ArrayOperatorIndexConst);
  363. LOAD_PROC_ADDRESS(packed_int32_array_operator_index, GDExtensionInterfacePackedInt32ArrayOperatorIndex);
  364. LOAD_PROC_ADDRESS(packed_int32_array_operator_index_const, GDExtensionInterfacePackedInt32ArrayOperatorIndexConst);
  365. LOAD_PROC_ADDRESS(packed_int64_array_operator_index, GDExtensionInterfacePackedInt64ArrayOperatorIndex);
  366. LOAD_PROC_ADDRESS(packed_int64_array_operator_index_const, GDExtensionInterfacePackedInt64ArrayOperatorIndexConst);
  367. LOAD_PROC_ADDRESS(packed_string_array_operator_index, GDExtensionInterfacePackedStringArrayOperatorIndex);
  368. LOAD_PROC_ADDRESS(packed_string_array_operator_index_const, GDExtensionInterfacePackedStringArrayOperatorIndexConst);
  369. LOAD_PROC_ADDRESS(packed_vector2_array_operator_index, GDExtensionInterfacePackedVector2ArrayOperatorIndex);
  370. LOAD_PROC_ADDRESS(packed_vector2_array_operator_index_const, GDExtensionInterfacePackedVector2ArrayOperatorIndexConst);
  371. LOAD_PROC_ADDRESS(packed_vector3_array_operator_index, GDExtensionInterfacePackedVector3ArrayOperatorIndex);
  372. LOAD_PROC_ADDRESS(packed_vector3_array_operator_index_const, GDExtensionInterfacePackedVector3ArrayOperatorIndexConst);
  373. LOAD_PROC_ADDRESS(array_operator_index, GDExtensionInterfaceArrayOperatorIndex);
  374. LOAD_PROC_ADDRESS(array_operator_index_const, GDExtensionInterfaceArrayOperatorIndexConst);
  375. LOAD_PROC_ADDRESS(array_ref, GDExtensionInterfaceArrayRef);
  376. LOAD_PROC_ADDRESS(array_set_typed, GDExtensionInterfaceArraySetTyped);
  377. LOAD_PROC_ADDRESS(dictionary_operator_index, GDExtensionInterfaceDictionaryOperatorIndex);
  378. LOAD_PROC_ADDRESS(dictionary_operator_index_const, GDExtensionInterfaceDictionaryOperatorIndexConst);
  379. LOAD_PROC_ADDRESS(object_method_bind_call, GDExtensionInterfaceObjectMethodBindCall);
  380. LOAD_PROC_ADDRESS(object_method_bind_ptrcall, GDExtensionInterfaceObjectMethodBindPtrcall);
  381. LOAD_PROC_ADDRESS(object_destroy, GDExtensionInterfaceObjectDestroy);
  382. LOAD_PROC_ADDRESS(global_get_singleton, GDExtensionInterfaceGlobalGetSingleton);
  383. LOAD_PROC_ADDRESS(object_get_instance_binding, GDExtensionInterfaceObjectGetInstanceBinding);
  384. LOAD_PROC_ADDRESS(object_set_instance_binding, GDExtensionInterfaceObjectSetInstanceBinding);
  385. LOAD_PROC_ADDRESS(object_set_instance, GDExtensionInterfaceObjectSetInstance);
  386. LOAD_PROC_ADDRESS(object_get_class_name, GDExtensionInterfaceObjectGetClassName);
  387. LOAD_PROC_ADDRESS(object_cast_to, GDExtensionInterfaceObjectCastTo);
  388. LOAD_PROC_ADDRESS(object_get_instance_from_id, GDExtensionInterfaceObjectGetInstanceFromId);
  389. LOAD_PROC_ADDRESS(object_get_instance_id, GDExtensionInterfaceObjectGetInstanceId);
  390. LOAD_PROC_ADDRESS(object_has_script_method, GDExtensionInterfaceObjectHasScriptMethod);
  391. LOAD_PROC_ADDRESS(object_call_script_method, GDExtensionInterfaceObjectCallScriptMethod);
  392. LOAD_PROC_ADDRESS(callable_custom_create, GDExtensionInterfaceCallableCustomCreate);
  393. LOAD_PROC_ADDRESS(callable_custom_get_userdata, GDExtensionInterfaceCallableCustomGetUserData);
  394. LOAD_PROC_ADDRESS(ref_get_object, GDExtensionInterfaceRefGetObject);
  395. LOAD_PROC_ADDRESS(ref_set_object, GDExtensionInterfaceRefSetObject);
  396. LOAD_PROC_ADDRESS(script_instance_create2, GDExtensionInterfaceScriptInstanceCreate2);
  397. LOAD_PROC_ADDRESS(placeholder_script_instance_create, GDExtensionInterfacePlaceHolderScriptInstanceCreate);
  398. LOAD_PROC_ADDRESS(placeholder_script_instance_update, GDExtensionInterfacePlaceHolderScriptInstanceUpdate);
  399. LOAD_PROC_ADDRESS(classdb_construct_object, GDExtensionInterfaceClassdbConstructObject);
  400. LOAD_PROC_ADDRESS(classdb_get_method_bind, GDExtensionInterfaceClassdbGetMethodBind);
  401. LOAD_PROC_ADDRESS(classdb_get_class_tag, GDExtensionInterfaceClassdbGetClassTag);
  402. LOAD_PROC_ADDRESS(classdb_register_extension_class2, GDExtensionInterfaceClassdbRegisterExtensionClass2);
  403. LOAD_PROC_ADDRESS(classdb_register_extension_class_method, GDExtensionInterfaceClassdbRegisterExtensionClassMethod);
  404. LOAD_PROC_ADDRESS(classdb_register_extension_class_virtual_method, GDExtensionInterfaceClassdbRegisterExtensionClassVirtualMethod);
  405. LOAD_PROC_ADDRESS(classdb_register_extension_class_integer_constant, GDExtensionInterfaceClassdbRegisterExtensionClassIntegerConstant);
  406. LOAD_PROC_ADDRESS(classdb_register_extension_class_property, GDExtensionInterfaceClassdbRegisterExtensionClassProperty);
  407. LOAD_PROC_ADDRESS(classdb_register_extension_class_property_indexed, GDExtensionInterfaceClassdbRegisterExtensionClassPropertyIndexed);
  408. LOAD_PROC_ADDRESS(classdb_register_extension_class_property_group, GDExtensionInterfaceClassdbRegisterExtensionClassPropertyGroup);
  409. LOAD_PROC_ADDRESS(classdb_register_extension_class_property_subgroup, GDExtensionInterfaceClassdbRegisterExtensionClassPropertySubgroup);
  410. LOAD_PROC_ADDRESS(classdb_register_extension_class_signal, GDExtensionInterfaceClassdbRegisterExtensionClassSignal);
  411. LOAD_PROC_ADDRESS(classdb_unregister_extension_class, GDExtensionInterfaceClassdbUnregisterExtensionClass);
  412. LOAD_PROC_ADDRESS(get_library_path, GDExtensionInterfaceGetLibraryPath);
  413. LOAD_PROC_ADDRESS(editor_add_plugin, GDExtensionInterfaceEditorAddPlugin);
  414. LOAD_PROC_ADDRESS(editor_remove_plugin, GDExtensionInterfaceEditorRemovePlugin);
  415. r_initialization->initialize = initialize_level;
  416. r_initialization->deinitialize = deinitialize_level;
  417. r_initialization->userdata = p_init_data;
  418. r_initialization->minimum_initialization_level = p_init_data->minimum_initialization_level;
  419. Variant::init_bindings();
  420. godot::internal::register_engine_classes();
  421. api_initialized = true;
  422. return true;
  423. }
  424. #undef LOAD_PROC_ADDRESS
  425. #undef ERR_PRINT_EARLY
  426. void GDExtensionBinding::initialize_level(void *p_userdata, GDExtensionInitializationLevel p_level) {
  427. ERR_FAIL_COND(static_cast<ModuleInitializationLevel>(p_level) >= MODULE_INITIALIZATION_LEVEL_MAX);
  428. ClassDB::current_level = p_level;
  429. InitData *init_data = static_cast<InitData *>(p_userdata);
  430. if (init_data && init_data->init_callback) {
  431. init_data->init_callback(static_cast<ModuleInitializationLevel>(p_level));
  432. }
  433. if (level_initialized[p_level] == 0) {
  434. ClassDB::initialize(p_level);
  435. }
  436. level_initialized[p_level]++;
  437. }
  438. void GDExtensionBinding::deinitialize_level(void *p_userdata, GDExtensionInitializationLevel p_level) {
  439. ERR_FAIL_COND(static_cast<ModuleInitializationLevel>(p_level) >= MODULE_INITIALIZATION_LEVEL_MAX);
  440. ClassDB::current_level = p_level;
  441. InitData *init_data = static_cast<InitData *>(p_userdata);
  442. if (init_data && init_data->terminate_callback) {
  443. init_data->terminate_callback(static_cast<ModuleInitializationLevel>(p_level));
  444. }
  445. level_initialized[p_level]--;
  446. if (level_initialized[p_level] == 0) {
  447. EditorPlugins::deinitialize(p_level);
  448. ClassDB::deinitialize(p_level);
  449. }
  450. }
  451. void GDExtensionBinding::InitDataList::add(InitData *p_data) {
  452. if (data_count == data_capacity) {
  453. void *new_ptr = realloc(data, sizeof(InitData *) * (data_capacity + 32));
  454. if (new_ptr) {
  455. data = (InitData **)(new_ptr);
  456. data_capacity += 32;
  457. } else {
  458. ERR_FAIL_MSG("Unable to allocate memory for extension callbacks.");
  459. }
  460. }
  461. data[data_count++] = p_data;
  462. }
  463. GDExtensionBinding::InitDataList::~InitDataList() {
  464. for (int i = 0; i < data_count; i++) {
  465. if (data[i]) {
  466. delete data[i];
  467. }
  468. }
  469. if (data) {
  470. free(data);
  471. }
  472. }
  473. GDExtensionBinding::InitObject::InitObject(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
  474. get_proc_address = p_get_proc_address;
  475. library = p_library;
  476. initialization = r_initialization;
  477. init_data = new InitData();
  478. GDExtensionBinding::initdata.add(init_data);
  479. }
  480. void GDExtensionBinding::InitObject::register_initializer(Callback p_init) const {
  481. init_data->init_callback = p_init;
  482. }
  483. void GDExtensionBinding::InitObject::register_terminator(Callback p_terminate) const {
  484. init_data->terminate_callback = p_terminate;
  485. }
  486. void GDExtensionBinding::InitObject::set_minimum_library_initialization_level(ModuleInitializationLevel p_level) const {
  487. init_data->minimum_initialization_level = static_cast<GDExtensionInitializationLevel>(p_level);
  488. }
  489. GDExtensionBool GDExtensionBinding::InitObject::init() const {
  490. return GDExtensionBinding::init(get_proc_address, library, init_data, initialization);
  491. }
  492. } // namespace godot