1 /*************************************************************************/ 2 /* gdnative_interface.h */ 3 /*************************************************************************/ 4 /* This file is part of: */ 5 /* GODOT ENGINE */ 6 /* https://godotengine.org */ 7 /*************************************************************************/ 8 /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ 9 /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ 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 31 /* This is a C class header, you can copy it and use it directly in your own binders. 32 * Together with the JSON file, you should be able to generate any binder. 33 */ 34 35 module godot.abi.gdextension; 36 37 import godot.abi.types; 38 import core.stdc.config; 39 // import core.stdc.stddef : wchar_t; 40 41 extern (C): 42 //@nogc nothrow: 43 44 /* VARIANT TYPES */ 45 46 alias GDNativeVariantType = int; 47 enum : GDNativeVariantType { 48 GDNATIVE_VARIANT_TYPE_NIL, 49 50 /* atomic types */ 51 GDNATIVE_VARIANT_TYPE_BOOL, 52 GDNATIVE_VARIANT_TYPE_INT, 53 GDNATIVE_VARIANT_TYPE_FLOAT, 54 GDNATIVE_VARIANT_TYPE_STRING, 55 56 /* math types */ 57 GDNATIVE_VARIANT_TYPE_VECTOR2, 58 GDNATIVE_VARIANT_TYPE_VECTOR2I, 59 GDNATIVE_VARIANT_TYPE_RECT2, 60 GDNATIVE_VARIANT_TYPE_RECT2I, 61 GDNATIVE_VARIANT_TYPE_VECTOR3, 62 GDNATIVE_VARIANT_TYPE_VECTOR3I, 63 GDNATIVE_VARIANT_TYPE_TRANSFORM2D, 64 GDNATIVE_VARIANT_TYPE_VECTOR4, 65 GDNATIVE_VARIANT_TYPE_VECTOR4I, 66 GDNATIVE_VARIANT_TYPE_PLANE, 67 GDNATIVE_VARIANT_TYPE_QUATERNION, 68 GDNATIVE_VARIANT_TYPE_AABB, 69 GDNATIVE_VARIANT_TYPE_BASIS, 70 GDNATIVE_VARIANT_TYPE_TRANSFORM3D, 71 GDNATIVE_VARIANT_TYPE_PROJECTION, 72 73 /* misc types */ 74 GDNATIVE_VARIANT_TYPE_COLOR, 75 GDNATIVE_VARIANT_TYPE_STRING_NAME, 76 GDNATIVE_VARIANT_TYPE_NODE_PATH, 77 GDNATIVE_VARIANT_TYPE_RID, 78 GDNATIVE_VARIANT_TYPE_OBJECT, 79 GDNATIVE_VARIANT_TYPE_CALLABLE, 80 GDNATIVE_VARIANT_TYPE_SIGNAL, 81 GDNATIVE_VARIANT_TYPE_DICTIONARY, 82 GDNATIVE_VARIANT_TYPE_ARRAY, 83 84 /* typed arrays */ 85 GDNATIVE_VARIANT_TYPE_PACKED_BYTE_ARRAY, 86 GDNATIVE_VARIANT_TYPE_PACKED_INT32_ARRAY, 87 GDNATIVE_VARIANT_TYPE_PACKED_INT64_ARRAY, 88 GDNATIVE_VARIANT_TYPE_PACKED_FLOAT32_ARRAY, 89 GDNATIVE_VARIANT_TYPE_PACKED_FLOAT64_ARRAY, 90 GDNATIVE_VARIANT_TYPE_PACKED_STRING_ARRAY, 91 GDNATIVE_VARIANT_TYPE_PACKED_VECTOR2_ARRAY, 92 GDNATIVE_VARIANT_TYPE_PACKED_VECTOR3_ARRAY, 93 GDNATIVE_VARIANT_TYPE_PACKED_COLOR_ARRAY, 94 95 GDNATIVE_VARIANT_TYPE_VARIANT_MAX 96 } 97 98 alias GDNativeVariantOperator = int; 99 enum : GDNativeVariantOperator { 100 /* comparison */ 101 GDNATIVE_VARIANT_OP_EQUAL, 102 GDNATIVE_VARIANT_OP_NOT_EQUAL, 103 GDNATIVE_VARIANT_OP_LESS, 104 GDNATIVE_VARIANT_OP_LESS_EQUAL, 105 GDNATIVE_VARIANT_OP_GREATER, 106 GDNATIVE_VARIANT_OP_GREATER_EQUAL, 107 /* mathematic */ 108 GDNATIVE_VARIANT_OP_ADD, 109 GDNATIVE_VARIANT_OP_SUBTRACT, 110 GDNATIVE_VARIANT_OP_MULTIPLY, 111 GDNATIVE_VARIANT_OP_DIVIDE, 112 GDNATIVE_VARIANT_OP_NEGATE, 113 GDNATIVE_VARIANT_OP_POSITIVE, 114 GDNATIVE_VARIANT_OP_MODULE, 115 GDNATIVE_VARIANT_OP_POWER, 116 /* bitwise */ 117 GDNATIVE_VARIANT_OP_SHIFT_LEFT, 118 GDNATIVE_VARIANT_OP_SHIFT_RIGHT, 119 GDNATIVE_VARIANT_OP_BIT_AND, 120 GDNATIVE_VARIANT_OP_BIT_OR, 121 GDNATIVE_VARIANT_OP_BIT_XOR, 122 GDNATIVE_VARIANT_OP_BIT_NEGATE, 123 /* logic */ 124 GDNATIVE_VARIANT_OP_AND, 125 GDNATIVE_VARIANT_OP_OR, 126 GDNATIVE_VARIANT_OP_XOR, 127 GDNATIVE_VARIANT_OP_NOT, 128 /* containment */ 129 GDNATIVE_VARIANT_OP_IN, 130 GDNATIVE_VARIANT_OP_MAX 131 132 } 133 134 alias GDNativeVariantPtr = void*; 135 alias GDNativeStringNamePtr = void*; 136 alias GDNativeStringPtr = void*; 137 alias GDNativeObjectPtr = void*; 138 alias GDNativeTypePtr = void*; 139 alias GDNativeExtensionPtr = void*; 140 alias GDNativeMethodBindPtr = void*; 141 alias GDNativeInt = int64_t; 142 alias GDNativeBool = uint8_t; 143 alias GDObjectInstanceID = uint64_t; 144 145 /* VARIANT DATA I/O */ 146 147 alias GDNativeCallErrorType = int; 148 enum : GDNativeCallErrorType { 149 GDNATIVE_CALL_OK, 150 GDNATIVE_CALL_ERROR_INVALID_METHOD, 151 GDNATIVE_CALL_ERROR_INVALID_ARGUMENT, /* expected is variant type */ 152 GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS, /* expected is number of arguments */ 153 GDNATIVE_CALL_ERROR_TOO_FEW_ARGUMENTS, /* expected is number of arguments */ 154 GDNATIVE_CALL_ERROR_INSTANCE_IS_NULL, 155 GDNATIVE_CALL_ERROR_METHOD_NOT_CONST, /* used for const call */ 156 157 } 158 159 struct GDNativeCallError { 160 //@nogc nothrow: 161 GDNativeCallErrorType error; 162 int32_t argument; 163 int32_t expected; 164 } 165 166 alias GDNativeVariantFromTypeConstructorFunc = void function(GDNativeVariantPtr, GDNativeTypePtr); 167 alias GDNativeTypeFromVariantConstructorFunc = void function(GDNativeTypePtr, GDNativeVariantPtr); 168 alias GDNativePtrOperatorEvaluator = void function(const GDNativeTypePtr p_left, const GDNativeTypePtr p_right, GDNativeTypePtr r_result); 169 alias GDNativePtrBuiltInMethod = void function(GDNativeTypePtr p_base, const GDNativeTypePtr* p_args, GDNativeTypePtr r_return, int p_argument_count); 170 alias GDNativePtrConstructor = void function(GDNativeTypePtr p_base, const GDNativeTypePtr* p_args); 171 alias GDNativePtrDestructor = void function(GDNativeTypePtr p_base); 172 alias GDNativePtrSetter = void function(GDNativeTypePtr p_base, const GDNativeTypePtr p_value); 173 alias GDNativePtrGetter = void function(const GDNativeTypePtr p_base, GDNativeTypePtr r_value); 174 alias GDNativePtrIndexedSetter = void function(GDNativeTypePtr p_base, GDNativeInt p_index, const GDNativeTypePtr p_value); 175 alias GDNativePtrIndexedGetter = void function(const GDNativeTypePtr p_base, GDNativeInt p_index, GDNativeTypePtr r_value); 176 alias GDNativePtrKeyedSetter = void function(GDNativeTypePtr p_base, const GDNativeTypePtr p_key, const GDNativeTypePtr p_value); 177 alias GDNativePtrKeyedGetter = void function(const GDNativeTypePtr p_base, const GDNativeTypePtr p_key, GDNativeTypePtr r_value); 178 alias GDNativePtrKeyedChecker = uint32_t function(const GDNativeVariantPtr p_base, const GDNativeVariantPtr p_key); 179 alias GDNativePtrUtilityFunction = void function(GDNativeTypePtr r_return, const GDNativeTypePtr* p_arguments, int p_argument_count); 180 181 alias GDNativeClassConstructor = GDNativeObjectPtr function(); 182 183 alias GDNativeInstanceBindingCreateCallback = void* function(void* p_token, void* p_instance); 184 alias GDNativeInstanceBindingFreeCallback = void function(void* p_token, void* p_instance, void* p_binding); 185 alias GDNativeInstanceBindingReferenceCallback = GDNativeBool function( 186 void* p_token, void* p_binding, GDNativeBool p_reference); 187 188 struct GDNativeInstanceBindingCallbacks { 189 //@nogc nothrow: 190 GDNativeInstanceBindingCreateCallback create_callback; 191 GDNativeInstanceBindingFreeCallback free_callback; 192 GDNativeInstanceBindingReferenceCallback reference_callback; 193 } 194 195 /* EXTENSION CLASSES */ 196 197 alias GDExtensionClassInstancePtr = void*; 198 199 alias GDNativeExtensionClassSet = GDNativeBool function(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value); 200 alias GDNativeExtensionClassGet = GDNativeBool function(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret); 201 alias GDNativeExtensionClassGetRID = uint64_t function(GDExtensionClassInstancePtr p_instance); 202 203 struct GDNativePropertyInfo { 204 //@nogc nothrow: 205 GDNativeVariantType type; 206 const(char)* name; 207 const(char)* class_name; 208 uint32_t hint; // Bitfield of `PropertyHint` (defined in `extension_api.json`) 209 const(char)* hint_string; 210 uint32_t usage; // Bitfield of `PropertyUsageFlags` (defined in `extension_api.json`) 211 } 212 213 struct GDNativeMethodInfo { 214 //@nogc nothrow: 215 const(char)* name; 216 GDNativePropertyInfo return_value; 217 uint32_t flags; // Bitfield of `GDNativeExtensionClassMethodFlags` 218 int32_t id; 219 GDNativePropertyInfo* arguments; 220 uint32_t argument_count; 221 GDNativeVariantPtr default_arguments; 222 uint32_t default_argument_count; 223 } 224 225 alias GDNativeExtensionClassGetPropertyList = const GDNativePropertyInfo* function( 226 GDExtensionClassInstancePtr p_instance, uint32_t* r_count); 227 alias GDNativeExtensionClassFreePropertyList = void function( 228 GDExtensionClassInstancePtr p_instance, const GDNativePropertyInfo* p_list); 229 alias GDNativeExtensionClassPropertyCanRevert = GDNativeBool function( 230 GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name); 231 alias GDNativeExtensionClassPropertyGetRevert = GDNativeBool function( 232 GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret); 233 alias GDNativeExtensionClassNotification = void function( 234 GDExtensionClassInstancePtr p_instance, int32_t p_what); 235 alias GDNativeExtensionClassToString = void function( 236 GDExtensionClassInstancePtr p_instance, GDNativeStringPtr p_out); 237 alias GDNativeExtensionClassReference = void function(GDExtensionClassInstancePtr p_instance); 238 alias GDNativeExtensionClassUnreference = void function(GDExtensionClassInstancePtr p_instance); 239 alias GDNativeExtensionClassCallVirtual = void function(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr* p_args, GDNativeTypePtr r_ret); 240 alias GDNativeExtensionClassCreateInstance = GDNativeObjectPtr function(void* p_userdata); 241 alias GDNativeExtensionClassFreeInstance = void function(void* p_userdata, GDExtensionClassInstancePtr p_instance); 242 alias GDNativeExtensionClassGetVirtual = GDNativeExtensionClassCallVirtual function( 243 void* p_userdata, const char* p_name); 244 245 struct GDNativeExtensionClassCreationInfo { 246 //@nogc nothrow: 247 GDNativeBool is_virtual; 248 GDNativeBool is_abstract; 249 GDNativeExtensionClassSet set_func; 250 GDNativeExtensionClassGet get_func; 251 GDNativeExtensionClassGetPropertyList get_property_list_func; 252 GDNativeExtensionClassFreePropertyList free_property_list_func; 253 GDNativeExtensionClassPropertyCanRevert property_can_revert_func; 254 GDNativeExtensionClassPropertyGetRevert property_get_revert_func; 255 GDNativeExtensionClassNotification notification_func; 256 GDNativeExtensionClassToString to_string_func; 257 GDNativeExtensionClassReference reference_func; 258 GDNativeExtensionClassUnreference unreference_func; 259 GDNativeExtensionClassCreateInstance create_instance_func; /* this one is mandatory */ 260 GDNativeExtensionClassFreeInstance free_instance_func; /* this one is mandatory */ 261 GDNativeExtensionClassGetVirtual get_virtual_func; 262 GDNativeExtensionClassGetRID get_rid_func; 263 void* class_userdata; 264 } 265 266 alias GDNativeExtensionClassLibraryPtr = void*; 267 268 /* Method */ 269 270 alias GDNativeExtensionClassMethodFlags = int; 271 enum : GDNativeExtensionClassMethodFlags { 272 GDNATIVE_EXTENSION_METHOD_FLAG_NORMAL = 1, 273 GDNATIVE_EXTENSION_METHOD_FLAG_EDITOR = 2, 274 GDNATIVE_EXTENSION_METHOD_FLAG_CONST = 4, 275 GDNATIVE_EXTENSION_METHOD_FLAG_VIRTUAL = 8, 276 GDNATIVE_EXTENSION_METHOD_FLAG_VARARG = 16, 277 GDNATIVE_EXTENSION_METHOD_FLAG_STATIC = 32, 278 GDNATIVE_EXTENSION_METHOD_FLAGS_DEFAULT = GDNATIVE_EXTENSION_METHOD_FLAG_NORMAL, 279 } 280 281 alias GDNativeExtensionClassMethodArgumentMetadata = int; 282 enum : GDNativeExtensionClassMethodArgumentMetadata { 283 GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_NONE, 284 GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT8, 285 GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT16, 286 GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT32, 287 GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT64, 288 GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT8, 289 GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT16, 290 GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT32, 291 GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT64, 292 GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_FLOAT, 293 GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_DOUBLE 294 } 295 296 alias GDNativeExtensionClassMethodCall = void function(void* method_userdata, GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr* p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError* r_error); 297 alias GDNativeExtensionClassMethodPtrCall = void function(void* method_userdata, GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr* p_args, GDNativeTypePtr r_ret); 298 299 /* passing -1 as argument in the following functions refers to the return type */ 300 alias GDNativeExtensionClassMethodGetArgumentType = GDNativeVariantType function( 301 void* p_method_userdata, int32_t p_argument); 302 alias GDNativeExtensionClassMethodGetArgumentInfo = void function( 303 void* p_method_userdata, int32_t p_argument, GDNativePropertyInfo* r_info); 304 alias GDNativeExtensionClassMethodGetArgumentMetadata = GDNativeExtensionClassMethodArgumentMetadata function( 305 void* p_method_userdata, int32_t p_argument); 306 307 struct GDNativeExtensionClassMethodInfo { 308 //@nogc nothrow: 309 const char* name; 310 void* method_userdata; 311 GDNativeExtensionClassMethodCall call_func; 312 GDNativeExtensionClassMethodPtrCall ptrcall_func; 313 uint32_t method_flags; // Bitfield of `GDNativeExtensionClassMethodFlags` 314 uint32_t argument_count; 315 GDNativeBool has_return_value; 316 GDNativeExtensionClassMethodGetArgumentType get_argument_type_func; 317 GDNativeExtensionClassMethodGetArgumentInfo get_argument_info_func; /* name and hint information for the argument can be omitted in release builds. Class name should always be present if it applies. */ 318 GDNativeExtensionClassMethodGetArgumentMetadata get_argument_metadata_func; 319 uint32_t default_argument_count; 320 GDNativeVariantPtr* default_arguments; 321 } 322 323 /* SCRIPT INSTANCE EXTENSION */ 324 325 alias GDNativeExtensionScriptInstanceDataPtr = void*; // Pointer to custom ScriptInstance native implementation 326 327 alias GDNativeExtensionScriptInstanceSet = GDNativeBool function(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value); 328 alias GDNativeExtensionScriptInstanceGet = GDNativeBool function(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret); 329 alias GDNativeExtensionScriptInstanceGetPropertyList = const GDNativePropertyInfo function( 330 GDNativeExtensionScriptInstanceDataPtr p_instance, uint32_t* r_count); 331 alias GDNativeExtensionScriptInstanceFreePropertyList = void function( 332 GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativePropertyInfo* p_list); 333 alias GDNativeExtensionScriptInstanceGetPropertyType = GDNativeVariantType function( 334 GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name, GDNativeBool* r_is_valid); 335 336 alias GDNativeExtensionScriptInstancePropertyCanRevert = GDNativeBool function( 337 GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name); 338 alias GDNativeExtensionScriptInstancePropertyGetRevert = GDNativeBool function( 339 GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret); 340 341 alias GDNativeExtensionScriptInstanceGetOwner = GDNativeObjectPtr function( 342 GDNativeExtensionScriptInstanceDataPtr p_instance); 343 alias GDNativeExtensionScriptInstancePropertyStateAdd = void function( 344 const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value, void* p_userdata); 345 alias GDNativeExtensionScriptInstanceGetPropertyState = void function(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeExtensionScriptInstancePropertyStateAdd p_add_func, void* p_userdata); 346 347 alias GDNativeExtensionScriptInstanceGetMethodList = const GDNativeMethodInfo function( 348 GDNativeExtensionScriptInstanceDataPtr p_instance, uint32_t* r_count); 349 alias GDNativeExtensionScriptInstanceFreeMethodList = void function( 350 GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeMethodInfo* p_list); 351 352 alias GDNativeExtensionScriptInstanceHasMethod = GDNativeBool function( 353 GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name); 354 355 alias GDNativeExtensionScriptInstanceCall = void function( 356 GDNativeExtensionScriptInstanceDataPtr p_self, const GDNativeStringNamePtr p_method, const GDNativeVariantPtr* p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError* r_error); 357 alias GDNativeExtensionScriptInstanceNotification = void function( 358 GDNativeExtensionScriptInstanceDataPtr p_instance, int32_t p_what); 359 alias GDNativeExtensionScriptInstanceToString = const char* function( 360 GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeBool* r_is_valid); 361 362 alias GDNativeExtensionScriptInstanceRefCountIncremented = void function( 363 GDNativeExtensionScriptInstanceDataPtr p_instance); 364 alias GDNativeExtensionScriptInstanceRefCountDecremented = GDNativeBool function( 365 GDNativeExtensionScriptInstanceDataPtr p_instance); 366 367 alias GDNativeExtensionScriptInstanceGetScript = GDNativeObjectPtr function( 368 GDNativeExtensionScriptInstanceDataPtr p_instance); 369 alias GDNativeExtensionScriptInstanceIsPlaceholder = GDNativeBool function( 370 GDNativeExtensionScriptInstanceDataPtr p_instance); 371 372 alias GDNativeExtensionScriptLanguagePtr = void*; 373 374 alias GDNativeExtensionScriptInstanceGetLanguage = GDNativeExtensionScriptLanguagePtr function( 375 GDNativeExtensionScriptInstanceDataPtr p_instance); 376 377 alias GDNativeExtensionScriptInstanceFree = void function( 378 GDNativeExtensionScriptInstanceDataPtr p_instance); 379 380 alias GDNativeScriptInstancePtr = void*; // Pointer to ScriptInstance. 381 382 struct GDNativeExtensionScriptInstanceInfo { 383 //@nogc nothrow: 384 GDNativeExtensionScriptInstanceSet set_func; 385 GDNativeExtensionScriptInstanceGet get_func; 386 GDNativeExtensionScriptInstanceGetPropertyList get_property_list_func; 387 GDNativeExtensionScriptInstanceFreePropertyList free_property_list_func; 388 GDNativeExtensionScriptInstanceGetPropertyType get_property_type_func; 389 390 GDNativeExtensionScriptInstancePropertyCanRevert property_can_revert_func; 391 GDNativeExtensionScriptInstancePropertyGetRevert property_get_revert_func; 392 393 GDNativeExtensionScriptInstanceGetOwner get_owner_func; 394 GDNativeExtensionScriptInstanceGetPropertyState get_property_state_func; 395 396 GDNativeExtensionScriptInstanceGetMethodList get_method_list_func; 397 GDNativeExtensionScriptInstanceFreeMethodList free_method_list_func; 398 399 GDNativeExtensionScriptInstanceHasMethod has_method_func; 400 401 GDNativeExtensionScriptInstanceCall call_func; 402 GDNativeExtensionScriptInstanceNotification notification_func; 403 404 GDNativeExtensionScriptInstanceToString to_string_func; 405 406 GDNativeExtensionScriptInstanceRefCountIncremented refcount_incremented_func; 407 GDNativeExtensionScriptInstanceRefCountDecremented refcount_decremented_func; 408 409 GDNativeExtensionScriptInstanceGetScript get_script_func; 410 411 GDNativeExtensionScriptInstanceIsPlaceholder is_placeholder_func; 412 413 GDNativeExtensionScriptInstanceSet set_fallback_func; 414 GDNativeExtensionScriptInstanceGet get_fallback_func; 415 416 GDNativeExtensionScriptInstanceGetLanguage get_language_func; 417 418 GDNativeExtensionScriptInstanceFree free_func; 419 } 420 421 /* INTERFACE */ 422 423 struct GDNativeInterface { 424 //@nogc nothrow: 425 uint32_t version_major; 426 uint32_t version_minor; 427 uint32_t version_patch; 428 const(char)* version_string; 429 430 /* GODOT CORE */ 431 void* function(size_t p_bytes) mem_alloc; 432 void* function(void* p_ptr, size_t p_bytes) mem_realloc; 433 void function(void* p_ptr) mem_free; 434 435 nothrow void function(const(char)* p_description, const(char)* p_function, const(char)* p_file, int32_t p_line) print_error; 436 nothrow void function(const(char)* p_description, const(char)* p_function, const(char)* p_file, int32_t p_line) print_warning; 437 nothrow void function(const(char)* p_description, const(char)* p_function, const(char)* p_file, int32_t p_line) print_script_error; 438 439 uint64_t function(const(char)* p_name) get_native_struct_size; 440 441 /* GODOT VARIANT */ 442 443 /* variant general */ 444 void function(GDNativeVariantPtr r_dest, const GDNativeVariantPtr p_src) variant_new_copy; 445 void function(GDNativeVariantPtr r_dest) variant_new_nil; 446 void function(GDNativeVariantPtr p_self) variant_destroy; 447 448 /* variant type */ 449 void function(GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_method, const GDNativeVariantPtr* p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError* r_error) variant_call; 450 void function(GDNativeVariantType p_type, const GDNativeStringNamePtr p_method, const GDNativeVariantPtr* p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError* r_error) variant_call_static; 451 void function(GDNativeVariantOperator p_op, const GDNativeVariantPtr p_a, const GDNativeVariantPtr p_b, GDNativeVariantPtr r_return, GDNativeBool* r_valid) variant_evaluate; 452 void function(GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, const GDNativeVariantPtr p_value, GDNativeBool* r_valid) variant_set; 453 void function(GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_key, const GDNativeVariantPtr p_value, GDNativeBool* r_valid) variant_set_named; 454 void function(GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, const GDNativeVariantPtr p_value, GDNativeBool* r_valid) variant_set_keyed; 455 void function(GDNativeVariantPtr p_self, GDNativeInt p_index, const GDNativeVariantPtr p_value, GDNativeBool* r_valid, GDNativeBool* r_oob) variant_set_indexed; 456 void function(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, GDNativeVariantPtr r_ret, GDNativeBool* r_valid) variant_get; 457 void function(const GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_key, GDNativeVariantPtr r_ret, GDNativeBool* r_valid) variant_get_named; 458 void function(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, GDNativeVariantPtr r_ret, GDNativeBool* r_valid) variant_get_keyed; 459 void function(const GDNativeVariantPtr p_self, GDNativeInt p_index, GDNativeVariantPtr r_ret, GDNativeBool* r_valid, GDNativeBool* r_oob) variant_get_indexed; 460 GDNativeBool function(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeBool* r_valid) variant_iter_init; 461 GDNativeBool function(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeBool* r_valid) variant_iter_next; 462 void function(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeVariantPtr r_ret, GDNativeBool* r_valid) variant_iter_get; 463 GDNativeInt function(const GDNativeVariantPtr p_self) variant_hash; 464 GDNativeInt function(const GDNativeVariantPtr p_self, GDNativeInt p_recursion_count) variant_recursive_hash; 465 GDNativeBool function(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_other) variant_hash_compare; 466 GDNativeBool function(const GDNativeVariantPtr p_self) variant_booleanize; 467 void function(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_ret, GDNativeBool p_deep) variant_duplicate; 468 void function(const GDNativeVariantPtr p_self, GDNativeStringPtr r_ret) variant_stringify; 469 470 GDNativeVariantType function(const GDNativeVariantPtr p_self) variant_get_type; 471 GDNativeBool function(const GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_method) variant_has_method; 472 GDNativeBool function(GDNativeVariantType p_type, const GDNativeStringNamePtr p_member) variant_has_member; 473 GDNativeBool function(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, GDNativeBool* r_valid) variant_has_key; 474 void function(GDNativeVariantType p_type, GDNativeStringPtr r_name) variant_get_type_name; 475 GDNativeBool function(GDNativeVariantType p_from, GDNativeVariantType p_to) variant_can_convert; 476 GDNativeBool function(GDNativeVariantType p_from, GDNativeVariantType p_to) variant_can_convert_strict; 477 478 /* ptrcalls */ 479 GDNativeVariantFromTypeConstructorFunc function(GDNativeVariantType p_type) get_variant_from_type_constructor; 480 GDNativeTypeFromVariantConstructorFunc function(GDNativeVariantType p_type) get_variant_to_type_constructor; 481 GDNativePtrOperatorEvaluator function(GDNativeVariantOperator p_operator, GDNativeVariantType p_type_a, GDNativeVariantType p_type_b) variant_get_ptr_operator_evaluator; 482 GDNativePtrBuiltInMethod function(GDNativeVariantType p_type, const(char)* p_method, GDNativeInt p_hash) variant_get_ptr_builtin_method; 483 GDNativePtrConstructor function(GDNativeVariantType p_type, int32_t p_constructor) variant_get_ptr_constructor; 484 GDNativePtrDestructor function(GDNativeVariantType p_type) variant_get_ptr_destructor; 485 void function(GDNativeVariantType p_type, GDNativeVariantPtr p_base, const(GDNativeVariantPtr)* p_args, int32_t p_argument_count, GDNativeCallError* r_error) variant_construct; 486 GDNativePtrSetter function(GDNativeVariantType p_type, const(char)* p_member) variant_get_ptr_setter; 487 GDNativePtrGetter function(GDNativeVariantType p_type, const(char)* p_member) variant_get_ptr_getter; 488 GDNativePtrIndexedSetter function(GDNativeVariantType p_type) variant_get_ptr_indexed_setter; 489 GDNativePtrIndexedGetter function(GDNativeVariantType p_type) variant_get_ptr_indexed_getter; 490 GDNativePtrKeyedSetter function(GDNativeVariantType p_type) variant_get_ptr_keyed_setter; 491 GDNativePtrKeyedGetter function(GDNativeVariantType p_type) variant_get_ptr_keyed_getter; 492 GDNativePtrKeyedChecker function(GDNativeVariantType p_type) variant_get_ptr_keyed_checker; 493 void function(GDNativeVariantType p_type, const(char)* p_constant, GDNativeVariantPtr r_ret) variant_get_constant_value; 494 GDNativePtrUtilityFunction function(const(char)* p_function, GDNativeInt p_hash) variant_get_ptr_utility_function; 495 496 /* extra utilities */ 497 498 void function(GDNativeStringPtr r_dest, const(char)* p_contents) string_new_with_latin1_chars; 499 void function(GDNativeStringPtr r_dest, const(char)* p_contents) string_new_with_utf8_chars; 500 void function(GDNativeStringPtr r_dest, const(char16_t)* p_contents) string_new_with_utf16_chars; 501 void function(GDNativeStringPtr r_dest, const(char32_t)* p_contents) string_new_with_utf32_chars; 502 void function(GDNativeStringPtr r_dest, const(wchar_t)* p_contents) string_new_with_wide_chars; 503 void function(GDNativeStringPtr r_dest, const(char)* p_contents, const GDNativeInt p_size) string_new_with_latin1_chars_and_len; 504 void function(GDNativeStringPtr r_dest, const(char)* p_contents, const GDNativeInt p_size) string_new_with_utf8_chars_and_len; 505 void function(GDNativeStringPtr r_dest, const(char16_t)* p_contents, const GDNativeInt p_size) string_new_with_utf16_chars_and_len; 506 void function(GDNativeStringPtr r_dest, const(char32_t)* p_contents, const GDNativeInt p_size) string_new_with_utf32_chars_and_len; 507 void function(GDNativeStringPtr r_dest, const(wchar_t)* p_contents, const GDNativeInt p_size) string_new_with_wide_chars_and_len; 508 /* Information about the following functions: 509 * - The return value is the resulting encoded string length. 510 * - The length returned is in characters, not in bytes. It also does not include a trailing zero. 511 * - These functions also do not write trailing zero, If you need it, write it yourself at the position indicated by the length (and make sure to allocate it). 512 * - Passing NULL in r_text means only the length is computed (again, without including trailing zero). 513 * - p_max_write_length argument is in characters, not bytes. It will be ignored if r_text is NULL. 514 * - p_max_write_length argument does not affect the return value, it's only to cap write length. 515 */ 516 GDNativeInt function(const GDNativeStringPtr p_self, char* r_text, GDNativeInt p_max_write_length) string_to_latin1_chars; 517 GDNativeInt function(const GDNativeStringPtr p_self, char* r_text, GDNativeInt p_max_write_length) string_to_utf8_chars; 518 GDNativeInt function(const GDNativeStringPtr p_self, char16_t* r_text, GDNativeInt p_max_write_length) string_to_utf16_chars; 519 GDNativeInt function(const GDNativeStringPtr p_self, char32_t* r_text, GDNativeInt p_max_write_length) string_to_utf32_chars; 520 GDNativeInt function(const GDNativeStringPtr p_self, wchar_t* r_text, GDNativeInt p_max_write_length) string_to_wide_chars; 521 char32_t* function(GDNativeStringPtr p_self, GDNativeInt p_index) string_operator_index; 522 const(char32_t)* function(const GDNativeStringPtr p_self, GDNativeInt p_index) string_operator_index_const; 523 524 /* Packed array functions */ 525 526 uint8_t* function(GDNativeTypePtr p_self, GDNativeInt p_index) packed_byte_array_operator_index; // p_self should be a PackedByteArray 527 const(uint8_t)* function(const GDNativeTypePtr p_self, GDNativeInt p_index) packed_byte_array_operator_index_const; // p_self should be a PackedByteArray 528 529 GDNativeTypePtr function(GDNativeTypePtr p_self, GDNativeInt p_index) packed_color_array_operator_index; // p_self should be a PackedColorArray, returns Color ptr 530 GDNativeTypePtr function(const GDNativeTypePtr p_self, GDNativeInt p_index) packed_color_array_operator_index_const; // p_self should be a PackedColorArray, returns Color ptr 531 532 float* function(GDNativeTypePtr p_self, GDNativeInt p_index) packed_float32_array_operator_index; // p_self should be a PackedFloat32Array 533 const(float)* function(const GDNativeTypePtr p_self, GDNativeInt p_index) packed_float32_array_operator_index_const; // p_self should be a PackedFloat32Array 534 double* function(GDNativeTypePtr p_self, GDNativeInt p_index) packed_float64_array_operator_index; // p_self should be a PackedFloat64Array 535 const(double)* function(const GDNativeTypePtr p_self, GDNativeInt p_index) packed_float64_array_operator_index_const; // p_self should be a PackedFloat64Array 536 537 int32_t* function(GDNativeTypePtr p_self, GDNativeInt p_index) packed_int32_array_operator_index; // p_self should be a PackedInt32Array 538 const(int32_t)* function(const GDNativeTypePtr p_self, GDNativeInt p_index) packed_int32_array_operator_index_const; // p_self should be a PackedInt32Array 539 int64_t* function(GDNativeTypePtr p_self, GDNativeInt p_index) packed_int64_array_operator_index; // p_self should be a PackedInt32Array 540 const(int64_t)* function(const GDNativeTypePtr p_self, GDNativeInt p_index) packed_int64_array_operator_index_const; // p_self should be a PackedInt32Array 541 542 GDNativeStringPtr function(GDNativeTypePtr p_self, GDNativeInt p_index) packed_string_array_operator_index; // p_self should be a PackedStringArray 543 GDNativeStringPtr function(const GDNativeTypePtr p_self, GDNativeInt p_index) packed_string_array_operator_index_const; // p_self should be a PackedStringArray 544 545 GDNativeTypePtr function(GDNativeTypePtr p_self, GDNativeInt p_index) packed_vector2_array_operator_index; // p_self should be a PackedVector2Array, returns Vector2 ptr 546 GDNativeTypePtr function(const GDNativeTypePtr p_self, GDNativeInt p_index) packed_vector2_array_operator_index_const; // p_self should be a PackedVector2Array, returns Vector2 ptr 547 GDNativeTypePtr function(GDNativeTypePtr p_self, GDNativeInt p_index) packed_vector3_array_operator_index; // p_self should be a PackedVector3Array, returns Vector3 ptr 548 GDNativeTypePtr function(const GDNativeTypePtr p_self, GDNativeInt p_index) packed_vector3_array_operator_index_const; // p_self should be a PackedVector3Array, returns Vector3 ptr 549 550 GDNativeVariantPtr function(GDNativeTypePtr p_self, GDNativeInt p_index) array_operator_index; // p_self should be an Array ptr 551 GDNativeVariantPtr function(const GDNativeTypePtr p_self, GDNativeInt p_index) array_operator_index_const; // p_self should be an Array ptr 552 553 /* Dictionary functions */ 554 555 GDNativeVariantPtr function(GDNativeTypePtr p_self, const GDNativeVariantPtr p_key) dictionary_operator_index; // p_self should be an Dictionary ptr 556 GDNativeVariantPtr function(const GDNativeTypePtr p_self, const GDNativeVariantPtr p_key) dictionary_operator_index_const; // p_self should be an Dictionary ptr 557 558 /* OBJECT */ 559 560 void function(const GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeVariantPtr* p_args, GDNativeInt p_arg_count, GDNativeVariantPtr r_ret, GDNativeCallError* r_error) object_method_bind_call; 561 void function(const GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeTypePtr* p_args, GDNativeTypePtr r_ret) object_method_bind_ptrcall; 562 void function(GDNativeObjectPtr p_o) object_destroy; 563 GDNativeObjectPtr function(const(char)* p_name) global_get_singleton; 564 565 void* function(GDNativeObjectPtr p_o, void* p_token, const GDNativeInstanceBindingCallbacks* p_callbacks) object_get_instance_binding; 566 void function(GDNativeObjectPtr p_o, void* p_token, void* p_binding, const GDNativeInstanceBindingCallbacks* p_callbacks) object_set_instance_binding; 567 568 void function(GDNativeObjectPtr p_o, const char* p_classname, GDExtensionClassInstancePtr p_instance) object_set_instance; /* p_classname should be a registered extension class and should extend the p_o object's class. */ 569 570 GDNativeObjectPtr function(const GDNativeObjectPtr p_object, void* p_class_tag) object_cast_to; 571 GDNativeObjectPtr function(GDObjectInstanceID p_instance_id) object_get_instance_from_id; 572 GDObjectInstanceID function(const GDNativeObjectPtr p_object) object_get_instance_id; 573 574 /* SCRIPT INSTANCE */ 575 576 GDNativeScriptInstancePtr function(const GDNativeExtensionScriptInstanceInfo* p_info, GDNativeExtensionScriptInstanceDataPtr p_instance_data) script_instance_create; 577 578 /* CLASSDB */ 579 GDNativeObjectPtr function(const char* p_classname) classdb_construct_object; /* The passed class must be a built-in godot class, or an already-registered extension class. In both case, object_set_instance should be called to fully initialize the object. */ 580 GDNativeMethodBindPtr function(const char* p_classname, const char* p_methodname, GDNativeInt p_hash) classdb_get_method_bind; 581 void* function(const char* p_classname) classdb_get_class_tag; 582 583 /* CLASSDB EXTENSION */ 584 585 void function(const GDNativeExtensionClassLibraryPtr p_library, const char* p_class_name, const char* p_parent_class_name, const GDNativeExtensionClassCreationInfo* p_extension_funcs) classdb_register_extension_class; 586 void function(const GDNativeExtensionClassLibraryPtr p_library, const char* p_class_name, const GDNativeExtensionClassMethodInfo* p_method_info) classdb_register_extension_class_method; 587 void function(const GDNativeExtensionClassLibraryPtr p_library, const char* p_class_name, const char* p_enum_name, const char* p_constant_name, GDNativeInt p_constant_value, bool p_is_bitfield) classdb_register_extension_class_integer_constant; 588 void function(const GDNativeExtensionClassLibraryPtr p_library, const char* p_class_name, const GDNativePropertyInfo* p_info, const char* p_setter, const char* p_getter) classdb_register_extension_class_property; 589 void function(const GDNativeExtensionClassLibraryPtr p_library, const char* p_class_name, const char* p_group_name, const char* p_prefix) classdb_register_extension_class_property_group; 590 void function(const GDNativeExtensionClassLibraryPtr p_library, const char* p_class_name, const char* p_subgroup_name, const char* p_prefix) classdb_register_extension_class_property_subgroup; 591 void function(const GDNativeExtensionClassLibraryPtr p_library, const char* p_class_name, const char* p_signal_name, const GDNativePropertyInfo* p_argument_info, GDNativeInt p_argument_count) classdb_register_extension_class_signal; 592 void function(const GDNativeExtensionClassLibraryPtr p_library, const char* p_class_name) classdb_unregister_extension_class; /* Unregistering a parent class before a class that inherits it will result in failure. Inheritors must be unregistered first. */ 593 594 void function(const GDNativeExtensionClassLibraryPtr p_library, GDNativeStringPtr r_path) get_library_path; 595 596 } 597 598 /* INITIALIZATION */ 599 alias GDNativeInitializationLevel = int; 600 enum : GDNativeInitializationLevel { 601 GDNATIVE_INITIALIZATION_CORE, 602 GDNATIVE_INITIALIZATION_SERVERS, 603 GDNATIVE_INITIALIZATION_SCENE, 604 GDNATIVE_INITIALIZATION_EDITOR, 605 GDNATIVE_MAX_INITIALIZATION_LEVEL, 606 } 607 608 struct GDNativeInitialization { 609 //@nogc nothrow: 610 /* Minimum initialization level required. 611 * If Core or Servers, the extension needs editor or game restart to take effect */ 612 GDNativeInitializationLevel minimum_initialization_level; 613 /* Up to the user to supply when initializing */ 614 void* userdata; 615 /* This function will be called multiple times for each initialization level. */ 616 void function(void* userdata, GDNativeInitializationLevel p_level) initialize; 617 void function(void* userdata, GDNativeInitializationLevel p_level) deinitialize; 618 } 619 620 /* Define a C function prototype that implements the function below and expose it to dlopen() (or similar). 621 * It will be called on initialization. The name must be an unique one specified in the .gdextension config file. 622 */ 623 624 alias GDNativeInitializationFunction = GDNativeBool function(const GDNativeInterface* p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization* r_initialization);