Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/core/extension/gdextension_interface.h
9898 views
1
/**************************************************************************/
2
/* gdextension_interface.h */
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
31
#pragma once
32
33
/* This is a C class header, you can copy it and use it directly in your own binders.
34
* Together with the JSON file, you should be able to generate any binder.
35
*/
36
37
#ifndef __cplusplus
38
#include <stddef.h>
39
#include <stdint.h>
40
41
typedef uint32_t char32_t;
42
typedef uint16_t char16_t;
43
#else
44
#include <cstddef>
45
#include <cstdint>
46
47
extern "C" {
48
#endif
49
50
/* VARIANT TYPES */
51
52
typedef enum {
53
GDEXTENSION_VARIANT_TYPE_NIL,
54
55
/* atomic types */
56
GDEXTENSION_VARIANT_TYPE_BOOL,
57
GDEXTENSION_VARIANT_TYPE_INT,
58
GDEXTENSION_VARIANT_TYPE_FLOAT,
59
GDEXTENSION_VARIANT_TYPE_STRING,
60
61
/* math types */
62
GDEXTENSION_VARIANT_TYPE_VECTOR2,
63
GDEXTENSION_VARIANT_TYPE_VECTOR2I,
64
GDEXTENSION_VARIANT_TYPE_RECT2,
65
GDEXTENSION_VARIANT_TYPE_RECT2I,
66
GDEXTENSION_VARIANT_TYPE_VECTOR3,
67
GDEXTENSION_VARIANT_TYPE_VECTOR3I,
68
GDEXTENSION_VARIANT_TYPE_TRANSFORM2D,
69
GDEXTENSION_VARIANT_TYPE_VECTOR4,
70
GDEXTENSION_VARIANT_TYPE_VECTOR4I,
71
GDEXTENSION_VARIANT_TYPE_PLANE,
72
GDEXTENSION_VARIANT_TYPE_QUATERNION,
73
GDEXTENSION_VARIANT_TYPE_AABB,
74
GDEXTENSION_VARIANT_TYPE_BASIS,
75
GDEXTENSION_VARIANT_TYPE_TRANSFORM3D,
76
GDEXTENSION_VARIANT_TYPE_PROJECTION,
77
78
/* misc types */
79
GDEXTENSION_VARIANT_TYPE_COLOR,
80
GDEXTENSION_VARIANT_TYPE_STRING_NAME,
81
GDEXTENSION_VARIANT_TYPE_NODE_PATH,
82
GDEXTENSION_VARIANT_TYPE_RID,
83
GDEXTENSION_VARIANT_TYPE_OBJECT,
84
GDEXTENSION_VARIANT_TYPE_CALLABLE,
85
GDEXTENSION_VARIANT_TYPE_SIGNAL,
86
GDEXTENSION_VARIANT_TYPE_DICTIONARY,
87
GDEXTENSION_VARIANT_TYPE_ARRAY,
88
89
/* typed arrays */
90
GDEXTENSION_VARIANT_TYPE_PACKED_BYTE_ARRAY,
91
GDEXTENSION_VARIANT_TYPE_PACKED_INT32_ARRAY,
92
GDEXTENSION_VARIANT_TYPE_PACKED_INT64_ARRAY,
93
GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT32_ARRAY,
94
GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT64_ARRAY,
95
GDEXTENSION_VARIANT_TYPE_PACKED_STRING_ARRAY,
96
GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR2_ARRAY,
97
GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR3_ARRAY,
98
GDEXTENSION_VARIANT_TYPE_PACKED_COLOR_ARRAY,
99
GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR4_ARRAY,
100
101
GDEXTENSION_VARIANT_TYPE_VARIANT_MAX
102
} GDExtensionVariantType;
103
104
typedef enum {
105
/* comparison */
106
GDEXTENSION_VARIANT_OP_EQUAL,
107
GDEXTENSION_VARIANT_OP_NOT_EQUAL,
108
GDEXTENSION_VARIANT_OP_LESS,
109
GDEXTENSION_VARIANT_OP_LESS_EQUAL,
110
GDEXTENSION_VARIANT_OP_GREATER,
111
GDEXTENSION_VARIANT_OP_GREATER_EQUAL,
112
113
/* mathematic */
114
GDEXTENSION_VARIANT_OP_ADD,
115
GDEXTENSION_VARIANT_OP_SUBTRACT,
116
GDEXTENSION_VARIANT_OP_MULTIPLY,
117
GDEXTENSION_VARIANT_OP_DIVIDE,
118
GDEXTENSION_VARIANT_OP_NEGATE,
119
GDEXTENSION_VARIANT_OP_POSITIVE,
120
GDEXTENSION_VARIANT_OP_MODULE,
121
GDEXTENSION_VARIANT_OP_POWER,
122
123
/* bitwise */
124
GDEXTENSION_VARIANT_OP_SHIFT_LEFT,
125
GDEXTENSION_VARIANT_OP_SHIFT_RIGHT,
126
GDEXTENSION_VARIANT_OP_BIT_AND,
127
GDEXTENSION_VARIANT_OP_BIT_OR,
128
GDEXTENSION_VARIANT_OP_BIT_XOR,
129
GDEXTENSION_VARIANT_OP_BIT_NEGATE,
130
131
/* logic */
132
GDEXTENSION_VARIANT_OP_AND,
133
GDEXTENSION_VARIANT_OP_OR,
134
GDEXTENSION_VARIANT_OP_XOR,
135
GDEXTENSION_VARIANT_OP_NOT,
136
137
/* containment */
138
GDEXTENSION_VARIANT_OP_IN,
139
GDEXTENSION_VARIANT_OP_MAX
140
141
} GDExtensionVariantOperator;
142
143
// In this API there are multiple functions which expect the caller to pass a pointer
144
// on return value as parameter.
145
// In order to make it clear if the caller should initialize the return value or not
146
// we have two flavor of types:
147
// - `GDExtensionXXXPtr` for pointer on an initialized value
148
// - `GDExtensionUninitializedXXXPtr` for pointer on uninitialized value
149
//
150
// Notes:
151
// - Not respecting those requirements can seems harmless, but will lead to unexpected
152
// segfault or memory leak (for instance with a specific compiler/OS, or when two
153
// native extensions start doing ptrcall on each other).
154
// - Initialization must be done with the function pointer returned by `variant_get_ptr_constructor`,
155
// zero-initializing the variable should not be considered a valid initialization method here !
156
// - Some types have no destructor (see `extension_api.json`'s `has_destructor` field), for
157
// them it is always safe to skip the constructor for the return value if you are in a hurry ;-)
158
159
typedef void *GDExtensionVariantPtr;
160
typedef const void *GDExtensionConstVariantPtr;
161
typedef void *GDExtensionUninitializedVariantPtr;
162
typedef void *GDExtensionStringNamePtr;
163
typedef const void *GDExtensionConstStringNamePtr;
164
typedef void *GDExtensionUninitializedStringNamePtr;
165
typedef void *GDExtensionStringPtr;
166
typedef const void *GDExtensionConstStringPtr;
167
typedef void *GDExtensionUninitializedStringPtr;
168
typedef void *GDExtensionObjectPtr;
169
typedef const void *GDExtensionConstObjectPtr;
170
typedef void *GDExtensionUninitializedObjectPtr;
171
typedef void *GDExtensionTypePtr;
172
typedef const void *GDExtensionConstTypePtr;
173
typedef void *GDExtensionUninitializedTypePtr;
174
typedef const void *GDExtensionMethodBindPtr;
175
typedef int64_t GDExtensionInt;
176
typedef uint8_t GDExtensionBool;
177
typedef uint64_t GDObjectInstanceID;
178
typedef void *GDExtensionRefPtr;
179
typedef const void *GDExtensionConstRefPtr;
180
181
/* VARIANT DATA I/O */
182
183
typedef enum {
184
GDEXTENSION_CALL_OK,
185
GDEXTENSION_CALL_ERROR_INVALID_METHOD,
186
GDEXTENSION_CALL_ERROR_INVALID_ARGUMENT, // Expected a different variant type.
187
GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS, // Expected lower number of arguments.
188
GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS, // Expected higher number of arguments.
189
GDEXTENSION_CALL_ERROR_INSTANCE_IS_NULL,
190
GDEXTENSION_CALL_ERROR_METHOD_NOT_CONST, // Used for const call.
191
} GDExtensionCallErrorType;
192
193
typedef struct {
194
GDExtensionCallErrorType error;
195
int32_t argument;
196
int32_t expected;
197
} GDExtensionCallError;
198
199
typedef void (*GDExtensionVariantFromTypeConstructorFunc)(GDExtensionUninitializedVariantPtr, GDExtensionTypePtr);
200
typedef void (*GDExtensionTypeFromVariantConstructorFunc)(GDExtensionUninitializedTypePtr, GDExtensionVariantPtr);
201
typedef void *(*GDExtensionVariantGetInternalPtrFunc)(GDExtensionVariantPtr);
202
typedef void (*GDExtensionPtrOperatorEvaluator)(GDExtensionConstTypePtr p_left, GDExtensionConstTypePtr p_right, GDExtensionTypePtr r_result);
203
typedef void (*GDExtensionPtrBuiltInMethod)(GDExtensionTypePtr p_base, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_return, int p_argument_count);
204
typedef void (*GDExtensionPtrConstructor)(GDExtensionUninitializedTypePtr p_base, const GDExtensionConstTypePtr *p_args);
205
typedef void (*GDExtensionPtrDestructor)(GDExtensionTypePtr p_base);
206
typedef void (*GDExtensionPtrSetter)(GDExtensionTypePtr p_base, GDExtensionConstTypePtr p_value);
207
typedef void (*GDExtensionPtrGetter)(GDExtensionConstTypePtr p_base, GDExtensionTypePtr r_value);
208
typedef void (*GDExtensionPtrIndexedSetter)(GDExtensionTypePtr p_base, GDExtensionInt p_index, GDExtensionConstTypePtr p_value);
209
typedef void (*GDExtensionPtrIndexedGetter)(GDExtensionConstTypePtr p_base, GDExtensionInt p_index, GDExtensionTypePtr r_value);
210
typedef void (*GDExtensionPtrKeyedSetter)(GDExtensionTypePtr p_base, GDExtensionConstTypePtr p_key, GDExtensionConstTypePtr p_value);
211
typedef void (*GDExtensionPtrKeyedGetter)(GDExtensionConstTypePtr p_base, GDExtensionConstTypePtr p_key, GDExtensionTypePtr r_value);
212
typedef uint32_t (*GDExtensionPtrKeyedChecker)(GDExtensionConstVariantPtr p_base, GDExtensionConstVariantPtr p_key);
213
typedef void (*GDExtensionPtrUtilityFunction)(GDExtensionTypePtr r_return, const GDExtensionConstTypePtr *p_args, int p_argument_count);
214
215
typedef GDExtensionObjectPtr (*GDExtensionClassConstructor)();
216
217
typedef void *(*GDExtensionInstanceBindingCreateCallback)(void *p_token, void *p_instance);
218
typedef void (*GDExtensionInstanceBindingFreeCallback)(void *p_token, void *p_instance, void *p_binding);
219
typedef GDExtensionBool (*GDExtensionInstanceBindingReferenceCallback)(void *p_token, void *p_binding, GDExtensionBool p_reference);
220
221
typedef struct {
222
GDExtensionInstanceBindingCreateCallback create_callback;
223
GDExtensionInstanceBindingFreeCallback free_callback;
224
GDExtensionInstanceBindingReferenceCallback reference_callback;
225
} GDExtensionInstanceBindingCallbacks;
226
227
/* EXTENSION CLASSES */
228
229
typedef void *GDExtensionClassInstancePtr;
230
231
typedef GDExtensionBool (*GDExtensionClassSet)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value);
232
typedef GDExtensionBool (*GDExtensionClassGet)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
233
typedef uint64_t (*GDExtensionClassGetRID)(GDExtensionClassInstancePtr p_instance);
234
235
typedef struct {
236
GDExtensionVariantType type;
237
GDExtensionStringNamePtr name;
238
GDExtensionStringNamePtr class_name;
239
uint32_t hint; // Bitfield of `PropertyHint` (defined in `extension_api.json`).
240
GDExtensionStringPtr hint_string;
241
uint32_t usage; // Bitfield of `PropertyUsageFlags` (defined in `extension_api.json`).
242
} GDExtensionPropertyInfo;
243
244
typedef struct {
245
GDExtensionStringNamePtr name;
246
GDExtensionPropertyInfo return_value;
247
uint32_t flags; // Bitfield of `GDExtensionClassMethodFlags`.
248
int32_t id;
249
250
/* Arguments: `default_arguments` is an array of size `argument_count`. */
251
uint32_t argument_count;
252
GDExtensionPropertyInfo *arguments;
253
254
/* Default arguments: `default_arguments` is an array of size `default_argument_count`. */
255
uint32_t default_argument_count;
256
GDExtensionVariantPtr *default_arguments;
257
} GDExtensionMethodInfo;
258
259
typedef const GDExtensionPropertyInfo *(*GDExtensionClassGetPropertyList)(GDExtensionClassInstancePtr p_instance, uint32_t *r_count);
260
typedef void (*GDExtensionClassFreePropertyList)(GDExtensionClassInstancePtr p_instance, const GDExtensionPropertyInfo *p_list);
261
typedef void (*GDExtensionClassFreePropertyList2)(GDExtensionClassInstancePtr p_instance, const GDExtensionPropertyInfo *p_list, uint32_t p_count);
262
typedef GDExtensionBool (*GDExtensionClassPropertyCanRevert)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name);
263
typedef GDExtensionBool (*GDExtensionClassPropertyGetRevert)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
264
typedef GDExtensionBool (*GDExtensionClassValidateProperty)(GDExtensionClassInstancePtr p_instance, GDExtensionPropertyInfo *p_property);
265
typedef void (*GDExtensionClassNotification)(GDExtensionClassInstancePtr p_instance, int32_t p_what); // Deprecated. Use GDExtensionClassNotification2 instead.
266
typedef void (*GDExtensionClassNotification2)(GDExtensionClassInstancePtr p_instance, int32_t p_what, GDExtensionBool p_reversed);
267
typedef void (*GDExtensionClassToString)(GDExtensionClassInstancePtr p_instance, GDExtensionBool *r_is_valid, GDExtensionStringPtr p_out);
268
typedef void (*GDExtensionClassReference)(GDExtensionClassInstancePtr p_instance);
269
typedef void (*GDExtensionClassUnreference)(GDExtensionClassInstancePtr p_instance);
270
typedef void (*GDExtensionClassCallVirtual)(GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
271
typedef GDExtensionObjectPtr (*GDExtensionClassCreateInstance)(void *p_class_userdata);
272
typedef GDExtensionObjectPtr (*GDExtensionClassCreateInstance2)(void *p_class_userdata, GDExtensionBool p_notify_postinitialize);
273
typedef void (*GDExtensionClassFreeInstance)(void *p_class_userdata, GDExtensionClassInstancePtr p_instance);
274
typedef GDExtensionClassInstancePtr (*GDExtensionClassRecreateInstance)(void *p_class_userdata, GDExtensionObjectPtr p_object);
275
typedef GDExtensionClassCallVirtual (*GDExtensionClassGetVirtual)(void *p_class_userdata, GDExtensionConstStringNamePtr p_name);
276
typedef GDExtensionClassCallVirtual (*GDExtensionClassGetVirtual2)(void *p_class_userdata, GDExtensionConstStringNamePtr p_name, uint32_t p_hash);
277
typedef void *(*GDExtensionClassGetVirtualCallData)(void *p_class_userdata, GDExtensionConstStringNamePtr p_name);
278
typedef void *(*GDExtensionClassGetVirtualCallData2)(void *p_class_userdata, GDExtensionConstStringNamePtr p_name, uint32_t p_hash);
279
typedef void (*GDExtensionClassCallVirtualWithData)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, void *p_virtual_call_userdata, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
280
281
typedef struct {
282
GDExtensionBool is_virtual;
283
GDExtensionBool is_abstract;
284
GDExtensionClassSet set_func;
285
GDExtensionClassGet get_func;
286
GDExtensionClassGetPropertyList get_property_list_func;
287
GDExtensionClassFreePropertyList free_property_list_func;
288
GDExtensionClassPropertyCanRevert property_can_revert_func;
289
GDExtensionClassPropertyGetRevert property_get_revert_func;
290
GDExtensionClassNotification notification_func;
291
GDExtensionClassToString to_string_func;
292
GDExtensionClassReference reference_func;
293
GDExtensionClassUnreference unreference_func;
294
GDExtensionClassCreateInstance create_instance_func; // (Default) constructor; mandatory. If the class is not instantiable, consider making it virtual or abstract.
295
GDExtensionClassFreeInstance free_instance_func; // Destructor; mandatory.
296
GDExtensionClassGetVirtual get_virtual_func; // Queries a virtual function by name and returns a callback to invoke the requested virtual function.
297
GDExtensionClassGetRID get_rid_func;
298
void *class_userdata; // Per-class user data, later accessible in instance bindings.
299
} GDExtensionClassCreationInfo; // Deprecated. Use GDExtensionClassCreationInfo4 instead.
300
301
typedef struct {
302
GDExtensionBool is_virtual;
303
GDExtensionBool is_abstract;
304
GDExtensionBool is_exposed;
305
GDExtensionClassSet set_func;
306
GDExtensionClassGet get_func;
307
GDExtensionClassGetPropertyList get_property_list_func;
308
GDExtensionClassFreePropertyList free_property_list_func;
309
GDExtensionClassPropertyCanRevert property_can_revert_func;
310
GDExtensionClassPropertyGetRevert property_get_revert_func;
311
GDExtensionClassValidateProperty validate_property_func;
312
GDExtensionClassNotification2 notification_func;
313
GDExtensionClassToString to_string_func;
314
GDExtensionClassReference reference_func;
315
GDExtensionClassUnreference unreference_func;
316
GDExtensionClassCreateInstance create_instance_func; // (Default) constructor; mandatory. If the class is not instantiable, consider making it virtual or abstract.
317
GDExtensionClassFreeInstance free_instance_func; // Destructor; mandatory.
318
GDExtensionClassRecreateInstance recreate_instance_func;
319
// Queries a virtual function by name and returns a callback to invoke the requested virtual function.
320
GDExtensionClassGetVirtual get_virtual_func;
321
// Paired with `call_virtual_with_data_func`, this is an alternative to `get_virtual_func` for extensions that
322
// need or benefit from extra data when calling virtual functions.
323
// Returns user data that will be passed to `call_virtual_with_data_func`.
324
// Returning `NULL` from this function signals to Godot that the virtual function is not overridden.
325
// Data returned from this function should be managed by the extension and must be valid until the extension is deinitialized.
326
// You should supply either `get_virtual_func`, or `get_virtual_call_data_func` with `call_virtual_with_data_func`.
327
GDExtensionClassGetVirtualCallData get_virtual_call_data_func;
328
// Used to call virtual functions when `get_virtual_call_data_func` is not null.
329
GDExtensionClassCallVirtualWithData call_virtual_with_data_func;
330
GDExtensionClassGetRID get_rid_func;
331
void *class_userdata; // Per-class user data, later accessible in instance bindings.
332
} GDExtensionClassCreationInfo2; // Deprecated. Use GDExtensionClassCreationInfo4 instead.
333
334
typedef struct {
335
GDExtensionBool is_virtual;
336
GDExtensionBool is_abstract;
337
GDExtensionBool is_exposed;
338
GDExtensionBool is_runtime;
339
GDExtensionClassSet set_func;
340
GDExtensionClassGet get_func;
341
GDExtensionClassGetPropertyList get_property_list_func;
342
GDExtensionClassFreePropertyList2 free_property_list_func;
343
GDExtensionClassPropertyCanRevert property_can_revert_func;
344
GDExtensionClassPropertyGetRevert property_get_revert_func;
345
GDExtensionClassValidateProperty validate_property_func;
346
GDExtensionClassNotification2 notification_func;
347
GDExtensionClassToString to_string_func;
348
GDExtensionClassReference reference_func;
349
GDExtensionClassUnreference unreference_func;
350
GDExtensionClassCreateInstance create_instance_func; // (Default) constructor; mandatory. If the class is not instantiable, consider making it virtual or abstract.
351
GDExtensionClassFreeInstance free_instance_func; // Destructor; mandatory.
352
GDExtensionClassRecreateInstance recreate_instance_func;
353
// Queries a virtual function by name and returns a callback to invoke the requested virtual function.
354
GDExtensionClassGetVirtual get_virtual_func;
355
// Paired with `call_virtual_with_data_func`, this is an alternative to `get_virtual_func` for extensions that
356
// need or benefit from extra data when calling virtual functions.
357
// Returns user data that will be passed to `call_virtual_with_data_func`.
358
// Returning `NULL` from this function signals to Godot that the virtual function is not overridden.
359
// Data returned from this function should be managed by the extension and must be valid until the extension is deinitialized.
360
// You should supply either `get_virtual_func`, or `get_virtual_call_data_func` with `call_virtual_with_data_func`.
361
GDExtensionClassGetVirtualCallData get_virtual_call_data_func;
362
// Used to call virtual functions when `get_virtual_call_data_func` is not null.
363
GDExtensionClassCallVirtualWithData call_virtual_with_data_func;
364
GDExtensionClassGetRID get_rid_func;
365
void *class_userdata; // Per-class user data, later accessible in instance bindings.
366
} GDExtensionClassCreationInfo3; // Deprecated. Use GDExtensionClassCreationInfo4 instead.
367
368
typedef struct {
369
GDExtensionBool is_virtual;
370
GDExtensionBool is_abstract;
371
GDExtensionBool is_exposed;
372
GDExtensionBool is_runtime;
373
GDExtensionConstStringPtr icon_path;
374
GDExtensionClassSet set_func;
375
GDExtensionClassGet get_func;
376
GDExtensionClassGetPropertyList get_property_list_func;
377
GDExtensionClassFreePropertyList2 free_property_list_func;
378
GDExtensionClassPropertyCanRevert property_can_revert_func;
379
GDExtensionClassPropertyGetRevert property_get_revert_func;
380
GDExtensionClassValidateProperty validate_property_func;
381
GDExtensionClassNotification2 notification_func;
382
GDExtensionClassToString to_string_func;
383
GDExtensionClassReference reference_func;
384
GDExtensionClassUnreference unreference_func;
385
GDExtensionClassCreateInstance2 create_instance_func; // (Default) constructor; mandatory. If the class is not instantiable, consider making it virtual or abstract.
386
GDExtensionClassFreeInstance free_instance_func; // Destructor; mandatory.
387
GDExtensionClassRecreateInstance recreate_instance_func;
388
// Queries a virtual function by name and returns a callback to invoke the requested virtual function.
389
GDExtensionClassGetVirtual2 get_virtual_func;
390
// Paired with `call_virtual_with_data_func`, this is an alternative to `get_virtual_func` for extensions that
391
// need or benefit from extra data when calling virtual functions.
392
// Returns user data that will be passed to `call_virtual_with_data_func`.
393
// Returning `NULL` from this function signals to Godot that the virtual function is not overridden.
394
// Data returned from this function should be managed by the extension and must be valid until the extension is deinitialized.
395
// You should supply either `get_virtual_func`, or `get_virtual_call_data_func` with `call_virtual_with_data_func`.
396
GDExtensionClassGetVirtualCallData2 get_virtual_call_data_func;
397
// Used to call virtual functions when `get_virtual_call_data_func` is not null.
398
GDExtensionClassCallVirtualWithData call_virtual_with_data_func;
399
void *class_userdata; // Per-class user data, later accessible in instance bindings.
400
} GDExtensionClassCreationInfo4;
401
402
typedef GDExtensionClassCreationInfo4 GDExtensionClassCreationInfo5;
403
404
typedef void *GDExtensionClassLibraryPtr;
405
406
/* Passed a pointer to a PackedStringArray that should be filled with the classes that may be used by the GDExtension. */
407
typedef void (*GDExtensionEditorGetClassesUsedCallback)(GDExtensionTypePtr p_packed_string_array);
408
409
/* Method */
410
411
typedef enum {
412
GDEXTENSION_METHOD_FLAG_NORMAL = 1,
413
GDEXTENSION_METHOD_FLAG_EDITOR = 2,
414
GDEXTENSION_METHOD_FLAG_CONST = 4,
415
GDEXTENSION_METHOD_FLAG_VIRTUAL = 8,
416
GDEXTENSION_METHOD_FLAG_VARARG = 16,
417
GDEXTENSION_METHOD_FLAG_STATIC = 32,
418
GDEXTENSION_METHOD_FLAGS_DEFAULT = GDEXTENSION_METHOD_FLAG_NORMAL,
419
} GDExtensionClassMethodFlags;
420
421
typedef enum {
422
GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE,
423
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT8,
424
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT16,
425
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT32,
426
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT64,
427
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT8,
428
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT16,
429
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT32,
430
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT64,
431
GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_FLOAT,
432
GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_DOUBLE,
433
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_CHAR16,
434
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_CHAR32,
435
} GDExtensionClassMethodArgumentMetadata;
436
437
typedef void (*GDExtensionClassMethodCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
438
typedef void (*GDExtensionClassMethodValidatedCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionVariantPtr r_return);
439
typedef void (*GDExtensionClassMethodPtrCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
440
441
typedef struct {
442
GDExtensionStringNamePtr name;
443
void *method_userdata;
444
GDExtensionClassMethodCall call_func;
445
GDExtensionClassMethodPtrCall ptrcall_func;
446
uint32_t method_flags; // Bitfield of `GDExtensionClassMethodFlags`.
447
448
/* If `has_return_value` is false, `return_value_info` and `return_value_metadata` are ignored.
449
*
450
* @todo Consider dropping `has_return_value` and making the other two properties match `GDExtensionMethodInfo` and `GDExtensionClassVirtualMethod` for consistency in future version of this struct.
451
*/
452
GDExtensionBool has_return_value;
453
GDExtensionPropertyInfo *return_value_info;
454
GDExtensionClassMethodArgumentMetadata return_value_metadata;
455
456
/* Arguments: `arguments_info` and `arguments_metadata` are array of size `argument_count`.
457
* Name and hint information for the argument can be omitted in release builds. Class name should always be present if it applies.
458
*
459
* @todo Consider renaming `arguments_info` to `arguments` for consistency in future version of this struct.
460
*/
461
uint32_t argument_count;
462
GDExtensionPropertyInfo *arguments_info;
463
GDExtensionClassMethodArgumentMetadata *arguments_metadata;
464
465
/* Default arguments: `default_arguments` is an array of size `default_argument_count`. */
466
uint32_t default_argument_count;
467
GDExtensionVariantPtr *default_arguments;
468
} GDExtensionClassMethodInfo;
469
470
typedef struct {
471
GDExtensionStringNamePtr name;
472
uint32_t method_flags; // Bitfield of `GDExtensionClassMethodFlags`.
473
474
GDExtensionPropertyInfo return_value;
475
GDExtensionClassMethodArgumentMetadata return_value_metadata;
476
477
uint32_t argument_count;
478
GDExtensionPropertyInfo *arguments;
479
GDExtensionClassMethodArgumentMetadata *arguments_metadata;
480
} GDExtensionClassVirtualMethodInfo;
481
482
typedef void (*GDExtensionCallableCustomCall)(void *callable_userdata, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
483
typedef GDExtensionBool (*GDExtensionCallableCustomIsValid)(void *callable_userdata);
484
typedef void (*GDExtensionCallableCustomFree)(void *callable_userdata);
485
486
typedef uint32_t (*GDExtensionCallableCustomHash)(void *callable_userdata);
487
typedef GDExtensionBool (*GDExtensionCallableCustomEqual)(void *callable_userdata_a, void *callable_userdata_b);
488
typedef GDExtensionBool (*GDExtensionCallableCustomLessThan)(void *callable_userdata_a, void *callable_userdata_b);
489
490
typedef void (*GDExtensionCallableCustomToString)(void *callable_userdata, GDExtensionBool *r_is_valid, GDExtensionStringPtr r_out);
491
492
typedef GDExtensionInt (*GDExtensionCallableCustomGetArgumentCount)(void *callable_userdata, GDExtensionBool *r_is_valid);
493
494
typedef struct {
495
/* Only `call_func` and `token` are strictly required, however, `object_id` should be passed if its not a static method.
496
*
497
* `token` should point to an address that uniquely identifies the GDExtension (for example, the
498
* `GDExtensionClassLibraryPtr` passed to the entry symbol function.
499
*
500
* `hash_func`, `equal_func`, and `less_than_func` are optional. If not provided both `call_func` and
501
* `callable_userdata` together are used as the identity of the callable for hashing and comparison purposes.
502
*
503
* The hash returned by `hash_func` is cached, `hash_func` will not be called more than once per callable.
504
*
505
* `is_valid_func` is necessary if the validity of the callable can change before destruction.
506
*
507
* `free_func` is necessary if `callable_userdata` needs to be cleaned up when the callable is freed.
508
*/
509
void *callable_userdata;
510
void *token;
511
512
GDObjectInstanceID object_id;
513
514
GDExtensionCallableCustomCall call_func;
515
GDExtensionCallableCustomIsValid is_valid_func;
516
GDExtensionCallableCustomFree free_func;
517
518
GDExtensionCallableCustomHash hash_func;
519
GDExtensionCallableCustomEqual equal_func;
520
GDExtensionCallableCustomLessThan less_than_func;
521
522
GDExtensionCallableCustomToString to_string_func;
523
} GDExtensionCallableCustomInfo; // Deprecated. Use GDExtensionCallableCustomInfo2 instead.
524
525
typedef struct {
526
/* Only `call_func` and `token` are strictly required, however, `object_id` should be passed if its not a static method.
527
*
528
* `token` should point to an address that uniquely identifies the GDExtension (for example, the
529
* `GDExtensionClassLibraryPtr` passed to the entry symbol function.
530
*
531
* `hash_func`, `equal_func`, and `less_than_func` are optional. If not provided both `call_func` and
532
* `callable_userdata` together are used as the identity of the callable for hashing and comparison purposes.
533
*
534
* The hash returned by `hash_func` is cached, `hash_func` will not be called more than once per callable.
535
*
536
* `is_valid_func` is necessary if the validity of the callable can change before destruction.
537
*
538
* `free_func` is necessary if `callable_userdata` needs to be cleaned up when the callable is freed.
539
*/
540
void *callable_userdata;
541
void *token;
542
543
GDObjectInstanceID object_id;
544
545
GDExtensionCallableCustomCall call_func;
546
GDExtensionCallableCustomIsValid is_valid_func;
547
GDExtensionCallableCustomFree free_func;
548
549
GDExtensionCallableCustomHash hash_func;
550
GDExtensionCallableCustomEqual equal_func;
551
GDExtensionCallableCustomLessThan less_than_func;
552
553
GDExtensionCallableCustomToString to_string_func;
554
555
GDExtensionCallableCustomGetArgumentCount get_argument_count_func;
556
} GDExtensionCallableCustomInfo2;
557
558
/* SCRIPT INSTANCE EXTENSION */
559
560
typedef void *GDExtensionScriptInstanceDataPtr; // Pointer to custom ScriptInstance native implementation.
561
562
typedef GDExtensionBool (*GDExtensionScriptInstanceSet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value);
563
typedef GDExtensionBool (*GDExtensionScriptInstanceGet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
564
typedef const GDExtensionPropertyInfo *(*GDExtensionScriptInstanceGetPropertyList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count);
565
typedef void (*GDExtensionScriptInstanceFreePropertyList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionPropertyInfo *p_list); // Deprecated. Use GDExtensionScriptInstanceFreePropertyList2 instead.
566
typedef void (*GDExtensionScriptInstanceFreePropertyList2)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionPropertyInfo *p_list, uint32_t p_count);
567
typedef GDExtensionBool (*GDExtensionScriptInstanceGetClassCategory)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionPropertyInfo *p_class_category);
568
569
typedef GDExtensionVariantType (*GDExtensionScriptInstanceGetPropertyType)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionBool *r_is_valid);
570
typedef GDExtensionBool (*GDExtensionScriptInstanceValidateProperty)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionPropertyInfo *p_property);
571
572
typedef GDExtensionBool (*GDExtensionScriptInstancePropertyCanRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name);
573
typedef GDExtensionBool (*GDExtensionScriptInstancePropertyGetRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
574
575
typedef GDExtensionObjectPtr (*GDExtensionScriptInstanceGetOwner)(GDExtensionScriptInstanceDataPtr p_instance);
576
typedef void (*GDExtensionScriptInstancePropertyStateAdd)(GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value, void *p_userdata);
577
typedef void (*GDExtensionScriptInstanceGetPropertyState)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionScriptInstancePropertyStateAdd p_add_func, void *p_userdata);
578
579
typedef const GDExtensionMethodInfo *(*GDExtensionScriptInstanceGetMethodList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count);
580
typedef void (*GDExtensionScriptInstanceFreeMethodList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionMethodInfo *p_list); // Deprecated. Use GDExtensionScriptInstanceFreeMethodList2 instead.
581
typedef void (*GDExtensionScriptInstanceFreeMethodList2)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionMethodInfo *p_list, uint32_t p_count);
582
583
typedef GDExtensionBool (*GDExtensionScriptInstanceHasMethod)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name);
584
585
typedef GDExtensionInt (*GDExtensionScriptInstanceGetMethodArgumentCount)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionBool *r_is_valid);
586
587
typedef void (*GDExtensionScriptInstanceCall)(GDExtensionScriptInstanceDataPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
588
typedef void (*GDExtensionScriptInstanceNotification)(GDExtensionScriptInstanceDataPtr p_instance, int32_t p_what); // Deprecated. Use GDExtensionScriptInstanceNotification2 instead.
589
typedef void (*GDExtensionScriptInstanceNotification2)(GDExtensionScriptInstanceDataPtr p_instance, int32_t p_what, GDExtensionBool p_reversed);
590
typedef void (*GDExtensionScriptInstanceToString)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionBool *r_is_valid, GDExtensionStringPtr r_out);
591
592
typedef void (*GDExtensionScriptInstanceRefCountIncremented)(GDExtensionScriptInstanceDataPtr p_instance);
593
typedef GDExtensionBool (*GDExtensionScriptInstanceRefCountDecremented)(GDExtensionScriptInstanceDataPtr p_instance);
594
595
typedef GDExtensionObjectPtr (*GDExtensionScriptInstanceGetScript)(GDExtensionScriptInstanceDataPtr p_instance);
596
typedef GDExtensionBool (*GDExtensionScriptInstanceIsPlaceholder)(GDExtensionScriptInstanceDataPtr p_instance);
597
598
typedef void *GDExtensionScriptLanguagePtr;
599
600
typedef GDExtensionScriptLanguagePtr (*GDExtensionScriptInstanceGetLanguage)(GDExtensionScriptInstanceDataPtr p_instance);
601
602
typedef void (*GDExtensionScriptInstanceFree)(GDExtensionScriptInstanceDataPtr p_instance);
603
604
typedef void *GDExtensionScriptInstancePtr; // Pointer to ScriptInstance.
605
606
typedef struct {
607
GDExtensionScriptInstanceSet set_func;
608
GDExtensionScriptInstanceGet get_func;
609
GDExtensionScriptInstanceGetPropertyList get_property_list_func;
610
GDExtensionScriptInstanceFreePropertyList free_property_list_func;
611
612
GDExtensionScriptInstancePropertyCanRevert property_can_revert_func;
613
GDExtensionScriptInstancePropertyGetRevert property_get_revert_func;
614
615
GDExtensionScriptInstanceGetOwner get_owner_func;
616
GDExtensionScriptInstanceGetPropertyState get_property_state_func;
617
618
GDExtensionScriptInstanceGetMethodList get_method_list_func;
619
GDExtensionScriptInstanceFreeMethodList free_method_list_func;
620
GDExtensionScriptInstanceGetPropertyType get_property_type_func;
621
622
GDExtensionScriptInstanceHasMethod has_method_func;
623
624
GDExtensionScriptInstanceCall call_func;
625
GDExtensionScriptInstanceNotification notification_func;
626
627
GDExtensionScriptInstanceToString to_string_func;
628
629
GDExtensionScriptInstanceRefCountIncremented refcount_incremented_func;
630
GDExtensionScriptInstanceRefCountDecremented refcount_decremented_func;
631
632
GDExtensionScriptInstanceGetScript get_script_func;
633
634
GDExtensionScriptInstanceIsPlaceholder is_placeholder_func;
635
636
GDExtensionScriptInstanceSet set_fallback_func;
637
GDExtensionScriptInstanceGet get_fallback_func;
638
639
GDExtensionScriptInstanceGetLanguage get_language_func;
640
641
GDExtensionScriptInstanceFree free_func;
642
643
} GDExtensionScriptInstanceInfo; // Deprecated. Use GDExtensionScriptInstanceInfo3 instead.
644
645
typedef struct {
646
GDExtensionScriptInstanceSet set_func;
647
GDExtensionScriptInstanceGet get_func;
648
GDExtensionScriptInstanceGetPropertyList get_property_list_func;
649
GDExtensionScriptInstanceFreePropertyList free_property_list_func;
650
GDExtensionScriptInstanceGetClassCategory get_class_category_func; // Optional. Set to NULL for the default behavior.
651
652
GDExtensionScriptInstancePropertyCanRevert property_can_revert_func;
653
GDExtensionScriptInstancePropertyGetRevert property_get_revert_func;
654
655
GDExtensionScriptInstanceGetOwner get_owner_func;
656
GDExtensionScriptInstanceGetPropertyState get_property_state_func;
657
658
GDExtensionScriptInstanceGetMethodList get_method_list_func;
659
GDExtensionScriptInstanceFreeMethodList free_method_list_func;
660
GDExtensionScriptInstanceGetPropertyType get_property_type_func;
661
GDExtensionScriptInstanceValidateProperty validate_property_func;
662
663
GDExtensionScriptInstanceHasMethod has_method_func;
664
665
GDExtensionScriptInstanceCall call_func;
666
GDExtensionScriptInstanceNotification2 notification_func;
667
668
GDExtensionScriptInstanceToString to_string_func;
669
670
GDExtensionScriptInstanceRefCountIncremented refcount_incremented_func;
671
GDExtensionScriptInstanceRefCountDecremented refcount_decremented_func;
672
673
GDExtensionScriptInstanceGetScript get_script_func;
674
675
GDExtensionScriptInstanceIsPlaceholder is_placeholder_func;
676
677
GDExtensionScriptInstanceSet set_fallback_func;
678
GDExtensionScriptInstanceGet get_fallback_func;
679
680
GDExtensionScriptInstanceGetLanguage get_language_func;
681
682
GDExtensionScriptInstanceFree free_func;
683
684
} GDExtensionScriptInstanceInfo2; // Deprecated. Use GDExtensionScriptInstanceInfo3 instead.
685
686
typedef struct {
687
GDExtensionScriptInstanceSet set_func;
688
GDExtensionScriptInstanceGet get_func;
689
GDExtensionScriptInstanceGetPropertyList get_property_list_func;
690
GDExtensionScriptInstanceFreePropertyList2 free_property_list_func;
691
GDExtensionScriptInstanceGetClassCategory get_class_category_func; // Optional. Set to NULL for the default behavior.
692
693
GDExtensionScriptInstancePropertyCanRevert property_can_revert_func;
694
GDExtensionScriptInstancePropertyGetRevert property_get_revert_func;
695
696
GDExtensionScriptInstanceGetOwner get_owner_func;
697
GDExtensionScriptInstanceGetPropertyState get_property_state_func;
698
699
GDExtensionScriptInstanceGetMethodList get_method_list_func;
700
GDExtensionScriptInstanceFreeMethodList2 free_method_list_func;
701
GDExtensionScriptInstanceGetPropertyType get_property_type_func;
702
GDExtensionScriptInstanceValidateProperty validate_property_func;
703
704
GDExtensionScriptInstanceHasMethod has_method_func;
705
706
GDExtensionScriptInstanceGetMethodArgumentCount get_method_argument_count_func;
707
708
GDExtensionScriptInstanceCall call_func;
709
GDExtensionScriptInstanceNotification2 notification_func;
710
711
GDExtensionScriptInstanceToString to_string_func;
712
713
GDExtensionScriptInstanceRefCountIncremented refcount_incremented_func;
714
GDExtensionScriptInstanceRefCountDecremented refcount_decremented_func;
715
716
GDExtensionScriptInstanceGetScript get_script_func;
717
718
GDExtensionScriptInstanceIsPlaceholder is_placeholder_func;
719
720
GDExtensionScriptInstanceSet set_fallback_func;
721
GDExtensionScriptInstanceGet get_fallback_func;
722
723
GDExtensionScriptInstanceGetLanguage get_language_func;
724
725
GDExtensionScriptInstanceFree free_func;
726
727
} GDExtensionScriptInstanceInfo3;
728
729
typedef void (*GDExtensionWorkerThreadPoolGroupTask)(void *, uint32_t);
730
typedef void (*GDExtensionWorkerThreadPoolTask)(void *);
731
732
/* INITIALIZATION */
733
734
typedef enum {
735
GDEXTENSION_INITIALIZATION_CORE,
736
GDEXTENSION_INITIALIZATION_SERVERS,
737
GDEXTENSION_INITIALIZATION_SCENE,
738
GDEXTENSION_INITIALIZATION_EDITOR,
739
GDEXTENSION_MAX_INITIALIZATION_LEVEL,
740
} GDExtensionInitializationLevel;
741
742
typedef void (*GDExtensionInitializeCallback)(void *p_userdata, GDExtensionInitializationLevel p_level);
743
typedef void (*GDExtensionDeinitializeCallback)(void *p_userdata, GDExtensionInitializationLevel p_level);
744
745
typedef struct {
746
/* Minimum initialization level required.
747
* If Core or Servers, the extension needs editor or game restart to take effect */
748
GDExtensionInitializationLevel minimum_initialization_level;
749
/* Up to the user to supply when initializing */
750
void *userdata;
751
/* This function will be called multiple times for each initialization level. */
752
GDExtensionInitializeCallback initialize;
753
GDExtensionDeinitializeCallback deinitialize;
754
} GDExtensionInitialization;
755
756
typedef void (*GDExtensionInterfaceFunctionPtr)();
757
typedef GDExtensionInterfaceFunctionPtr (*GDExtensionInterfaceGetProcAddress)(const char *p_function_name);
758
759
/*
760
* Each GDExtension should define a C function that matches the signature of GDExtensionInitializationFunction,
761
* and export it so that it can be loaded via dlopen() or equivalent for the given platform.
762
*
763
* For example:
764
*
765
* GDExtensionBool my_extension_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization);
766
*
767
* This function's name must be specified as the 'entry_symbol' in the .gdextension file.
768
*
769
* This makes it the entry point of the GDExtension and will be called on initialization.
770
*
771
* The GDExtension can then modify the r_initialization structure, setting the minimum initialization level,
772
* and providing pointers to functions that will be called at various stages of initialization/shutdown.
773
*
774
* The rest of the GDExtension's interface to Godot consists of function pointers that can be loaded
775
* by calling p_get_proc_address("...") with the name of the function.
776
*
777
* For example:
778
*
779
* GDExtensionInterfaceGetGodotVersion get_godot_version = (GDExtensionInterfaceGetGodotVersion)p_get_proc_address("get_godot_version");
780
*
781
* (Note that snippet may cause "cast between incompatible function types" on some compilers, you can
782
* silence this by adding an intermediary `void*` cast.)
783
*
784
* You can then call it like a normal function:
785
*
786
* GDExtensionGodotVersion godot_version;
787
* get_godot_version(&godot_version);
788
* printf("Godot v%d.%d.%d\n", godot_version.major, godot_version.minor, godot_version.patch);
789
*
790
* All of these interface functions are described below, together with the name that's used to load it,
791
* and the function pointer typedef that shows its signature.
792
*/
793
typedef GDExtensionBool (*GDExtensionInitializationFunction)(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization);
794
795
/* INTERFACE */
796
797
typedef struct {
798
uint32_t major;
799
uint32_t minor;
800
uint32_t patch;
801
const char *string;
802
} GDExtensionGodotVersion;
803
804
typedef struct {
805
uint32_t major;
806
uint32_t minor;
807
uint32_t patch;
808
uint32_t hex; // Full version encoded as hexadecimal with one byte (2 hex digits) per number (e.g. for "3.1.12" it would be 0x03010C)
809
const char *status; // (e.g. "stable", "beta", "rc1", "rc2")
810
const char *build; // (e.g. "custom_build")
811
const char *hash; // Full Git commit hash.
812
uint64_t timestamp; // Git commit date UNIX timestamp in seconds, or 0 if unavailable.
813
const char *string; // (e.g. "Godot v3.1.4.stable.official.mono")
814
} GDExtensionGodotVersion2;
815
816
/* Called when starting the main loop. */
817
typedef void (*GDExtensionMainLoopStartupCallback)();
818
819
/* Called when shutting down the main loop. */
820
typedef void (*GDExtensionMainLoopShutdownCallback)();
821
822
/* Called for every frame iteration of the main loop. */
823
typedef void (*GDExtensionMainLoopFrameCallback)();
824
825
typedef struct {
826
// Will be called after Godot is started and is fully initialized.
827
GDExtensionMainLoopStartupCallback startup_func;
828
// Will be called before Godot is shutdown when it is still fully initialized.
829
GDExtensionMainLoopShutdownCallback shutdown_func;
830
// Will be called for each process frame. This will run after all `_process()` methods on Node, and before `ScriptServer::frame()`.
831
// This is intended to be the equivalent of `ScriptLanguage::frame()` for GDExtension language bindings that don't use the script API.
832
GDExtensionMainLoopFrameCallback frame_func;
833
} GDExtensionMainLoopCallbacks;
834
835
/**
836
* @name get_godot_version
837
* @since 4.1
838
* @deprecated in Godot 4.5. Use `get_godot_version2` instead.
839
*
840
* Gets the Godot version that the GDExtension was loaded into.
841
*
842
* @param r_godot_version A pointer to the structure to write the version information into.
843
*/
844
typedef void (*GDExtensionInterfaceGetGodotVersion)(GDExtensionGodotVersion *r_godot_version);
845
846
/**
847
* @name get_godot_version2
848
* @since 4.5
849
*
850
* Gets the Godot version that the GDExtension was loaded into.
851
*
852
* @param r_godot_version A pointer to the structure to write the version information into.
853
*/
854
typedef void (*GDExtensionInterfaceGetGodotVersion2)(GDExtensionGodotVersion2 *r_godot_version);
855
856
/* INTERFACE: Memory */
857
858
/**
859
* @name mem_alloc
860
* @since 4.1
861
*
862
* Allocates memory.
863
*
864
* @param p_bytes The amount of memory to allocate in bytes.
865
*
866
* @return A pointer to the allocated memory, or NULL if unsuccessful.
867
*/
868
typedef void *(*GDExtensionInterfaceMemAlloc)(size_t p_bytes);
869
870
/**
871
* @name mem_realloc
872
* @since 4.1
873
*
874
* Reallocates memory.
875
*
876
* @param p_ptr A pointer to the previously allocated memory.
877
* @param p_bytes The number of bytes to resize the memory block to.
878
*
879
* @return A pointer to the allocated memory, or NULL if unsuccessful.
880
*/
881
typedef void *(*GDExtensionInterfaceMemRealloc)(void *p_ptr, size_t p_bytes);
882
883
/**
884
* @name mem_free
885
* @since 4.1
886
*
887
* Frees memory.
888
*
889
* @param p_ptr A pointer to the previously allocated memory.
890
*/
891
typedef void (*GDExtensionInterfaceMemFree)(void *p_ptr);
892
893
/* INTERFACE: Godot Core */
894
895
/**
896
* @name print_error
897
* @since 4.1
898
*
899
* Logs an error to Godot's built-in debugger and to the OS terminal.
900
*
901
* @param p_description The code triggering the error.
902
* @param p_function The function name where the error occurred.
903
* @param p_file The file where the error occurred.
904
* @param p_line The line where the error occurred.
905
* @param p_editor_notify Whether or not to notify the editor.
906
*/
907
typedef void (*GDExtensionInterfacePrintError)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
908
909
/**
910
* @name print_error_with_message
911
* @since 4.1
912
*
913
* Logs an error with a message to Godot's built-in debugger and to the OS terminal.
914
*
915
* @param p_description The code triggering the error.
916
* @param p_message The message to show along with the error.
917
* @param p_function The function name where the error occurred.
918
* @param p_file The file where the error occurred.
919
* @param p_line The line where the error occurred.
920
* @param p_editor_notify Whether or not to notify the editor.
921
*/
922
typedef void (*GDExtensionInterfacePrintErrorWithMessage)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
923
924
/**
925
* @name print_warning
926
* @since 4.1
927
*
928
* Logs a warning to Godot's built-in debugger and to the OS terminal.
929
*
930
* @param p_description The code triggering the warning.
931
* @param p_function The function name where the warning occurred.
932
* @param p_file The file where the warning occurred.
933
* @param p_line The line where the warning occurred.
934
* @param p_editor_notify Whether or not to notify the editor.
935
*/
936
typedef void (*GDExtensionInterfacePrintWarning)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
937
938
/**
939
* @name print_warning_with_message
940
* @since 4.1
941
*
942
* Logs a warning with a message to Godot's built-in debugger and to the OS terminal.
943
*
944
* @param p_description The code triggering the warning.
945
* @param p_message The message to show along with the warning.
946
* @param p_function The function name where the warning occurred.
947
* @param p_file The file where the warning occurred.
948
* @param p_line The line where the warning occurred.
949
* @param p_editor_notify Whether or not to notify the editor.
950
*/
951
typedef void (*GDExtensionInterfacePrintWarningWithMessage)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
952
953
/**
954
* @name print_script_error
955
* @since 4.1
956
*
957
* Logs a script error to Godot's built-in debugger and to the OS terminal.
958
*
959
* @param p_description The code triggering the error.
960
* @param p_function The function name where the error occurred.
961
* @param p_file The file where the error occurred.
962
* @param p_line The line where the error occurred.
963
* @param p_editor_notify Whether or not to notify the editor.
964
*/
965
typedef void (*GDExtensionInterfacePrintScriptError)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
966
967
/**
968
* @name print_script_error_with_message
969
* @since 4.1
970
*
971
* Logs a script error with a message to Godot's built-in debugger and to the OS terminal.
972
*
973
* @param p_description The code triggering the error.
974
* @param p_message The message to show along with the error.
975
* @param p_function The function name where the error occurred.
976
* @param p_file The file where the error occurred.
977
* @param p_line The line where the error occurred.
978
* @param p_editor_notify Whether or not to notify the editor.
979
*/
980
typedef void (*GDExtensionInterfacePrintScriptErrorWithMessage)(const char *p_description, const char *p_message, const char *p_function, const char *p_file, int32_t p_line, GDExtensionBool p_editor_notify);
981
982
/**
983
* @name get_native_struct_size
984
* @since 4.1
985
*
986
* Gets the size of a native struct (ex. ObjectID) in bytes.
987
*
988
* @param p_name A pointer to a StringName identifying the struct name.
989
*
990
* @return The size in bytes.
991
*/
992
typedef uint64_t (*GDExtensionInterfaceGetNativeStructSize)(GDExtensionConstStringNamePtr p_name);
993
994
/* INTERFACE: Variant */
995
996
/**
997
* @name variant_new_copy
998
* @since 4.1
999
*
1000
* Copies one Variant into a another.
1001
*
1002
* @param r_dest A pointer to the destination Variant.
1003
* @param p_src A pointer to the source Variant.
1004
*/
1005
typedef void (*GDExtensionInterfaceVariantNewCopy)(GDExtensionUninitializedVariantPtr r_dest, GDExtensionConstVariantPtr p_src);
1006
1007
/**
1008
* @name variant_new_nil
1009
* @since 4.1
1010
*
1011
* Creates a new Variant containing nil.
1012
*
1013
* @param r_dest A pointer to the destination Variant.
1014
*/
1015
typedef void (*GDExtensionInterfaceVariantNewNil)(GDExtensionUninitializedVariantPtr r_dest);
1016
1017
/**
1018
* @name variant_destroy
1019
* @since 4.1
1020
*
1021
* Destroys a Variant.
1022
*
1023
* @param p_self A pointer to the Variant to destroy.
1024
*/
1025
typedef void (*GDExtensionInterfaceVariantDestroy)(GDExtensionVariantPtr p_self);
1026
1027
/**
1028
* @name variant_call
1029
* @since 4.1
1030
*
1031
* Calls a method on a Variant.
1032
*
1033
* @param p_self A pointer to the Variant.
1034
* @param p_method A pointer to a StringName identifying the method.
1035
* @param p_args A pointer to a C array of Variant.
1036
* @param p_argument_count The number of arguments.
1037
* @param r_return A pointer a Variant which will be assigned the return value.
1038
* @param r_error A pointer the structure which will hold error information.
1039
*
1040
* @see Variant::callp()
1041
*/
1042
typedef void (*GDExtensionInterfaceVariantCall)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error);
1043
1044
/**
1045
* @name variant_call_static
1046
* @since 4.1
1047
*
1048
* Calls a static method on a Variant.
1049
*
1050
* @param p_type The variant type.
1051
* @param p_method A pointer to a StringName identifying the method.
1052
* @param p_args A pointer to a C array of Variant.
1053
* @param p_argument_count The number of arguments.
1054
* @param r_return A pointer a Variant which will be assigned the return value.
1055
* @param r_error A pointer the structure which will be updated with error information.
1056
*
1057
* @see Variant::call_static()
1058
*/
1059
typedef void (*GDExtensionInterfaceVariantCallStatic)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error);
1060
1061
/**
1062
* @name variant_evaluate
1063
* @since 4.1
1064
*
1065
* Evaluate an operator on two Variants.
1066
*
1067
* @param p_op The operator to evaluate.
1068
* @param p_a The first Variant.
1069
* @param p_b The second Variant.
1070
* @param r_return A pointer a Variant which will be assigned the return value.
1071
* @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
1072
*
1073
* @see Variant::evaluate()
1074
*/
1075
typedef void (*GDExtensionInterfaceVariantEvaluate)(GDExtensionVariantOperator p_op, GDExtensionConstVariantPtr p_a, GDExtensionConstVariantPtr p_b, GDExtensionUninitializedVariantPtr r_return, GDExtensionBool *r_valid);
1076
1077
/**
1078
* @name variant_set
1079
* @since 4.1
1080
*
1081
* Sets a key on a Variant to a value.
1082
*
1083
* @param p_self A pointer to the Variant.
1084
* @param p_key A pointer to a Variant representing the key.
1085
* @param p_value A pointer to a Variant representing the value.
1086
* @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
1087
*
1088
* @see Variant::set()
1089
*/
1090
typedef void (*GDExtensionInterfaceVariantSet)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
1091
1092
/**
1093
* @name variant_set_named
1094
* @since 4.1
1095
*
1096
* Sets a named key on a Variant to a value.
1097
*
1098
* @param p_self A pointer to the Variant.
1099
* @param p_key A pointer to a StringName representing the key.
1100
* @param p_value A pointer to a Variant representing the value.
1101
* @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
1102
*
1103
* @see Variant::set_named()
1104
*/
1105
typedef void (*GDExtensionInterfaceVariantSetNamed)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
1106
1107
/**
1108
* @name variant_set_keyed
1109
* @since 4.1
1110
*
1111
* Sets a keyed property on a Variant to a value.
1112
*
1113
* @param p_self A pointer to the Variant.
1114
* @param p_key A pointer to a Variant representing the key.
1115
* @param p_value A pointer to a Variant representing the value.
1116
* @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
1117
*
1118
* @see Variant::set_keyed()
1119
*/
1120
typedef void (*GDExtensionInterfaceVariantSetKeyed)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
1121
1122
/**
1123
* @name variant_set_indexed
1124
* @since 4.1
1125
*
1126
* Sets an index on a Variant to a value.
1127
*
1128
* @param p_self A pointer to the Variant.
1129
* @param p_index The index.
1130
* @param p_value A pointer to a Variant representing the value.
1131
* @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
1132
* @param r_oob A pointer to a boolean which will be set to true if the index is out of bounds.
1133
*/
1134
typedef void (*GDExtensionInterfaceVariantSetIndexed)(GDExtensionVariantPtr p_self, GDExtensionInt p_index, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid, GDExtensionBool *r_oob);
1135
1136
/**
1137
* @name variant_get
1138
* @since 4.1
1139
*
1140
* Gets the value of a key from a Variant.
1141
*
1142
* @param p_self A pointer to the Variant.
1143
* @param p_key A pointer to a Variant representing the key.
1144
* @param r_ret A pointer to a Variant which will be assigned the value.
1145
* @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
1146
*/
1147
typedef void (*GDExtensionInterfaceVariantGet)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid);
1148
1149
/**
1150
* @name variant_get_named
1151
* @since 4.1
1152
*
1153
* Gets the value of a named key from a Variant.
1154
*
1155
* @param p_self A pointer to the Variant.
1156
* @param p_key A pointer to a StringName representing the key.
1157
* @param r_ret A pointer to a Variant which will be assigned the value.
1158
* @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
1159
*/
1160
typedef void (*GDExtensionInterfaceVariantGetNamed)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid);
1161
1162
/**
1163
* @name variant_get_keyed
1164
* @since 4.1
1165
*
1166
* Gets the value of a keyed property from a Variant.
1167
*
1168
* @param p_self A pointer to the Variant.
1169
* @param p_key A pointer to a Variant representing the key.
1170
* @param r_ret A pointer to a Variant which will be assigned the value.
1171
* @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
1172
*/
1173
typedef void (*GDExtensionInterfaceVariantGetKeyed)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid);
1174
1175
/**
1176
* @name variant_get_indexed
1177
* @since 4.1
1178
*
1179
* Gets the value of an index from a Variant.
1180
*
1181
* @param p_self A pointer to the Variant.
1182
* @param p_index The index.
1183
* @param r_ret A pointer to a Variant which will be assigned the value.
1184
* @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
1185
* @param r_oob A pointer to a boolean which will be set to true if the index is out of bounds.
1186
*/
1187
typedef void (*GDExtensionInterfaceVariantGetIndexed)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_index, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid, GDExtensionBool *r_oob);
1188
1189
/**
1190
* @name variant_iter_init
1191
* @since 4.1
1192
*
1193
* Initializes an iterator over a Variant.
1194
*
1195
* @param p_self A pointer to the Variant.
1196
* @param r_iter A pointer to a Variant which will be assigned the iterator.
1197
* @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
1198
*
1199
* @return true if the operation is valid; otherwise false.
1200
*
1201
* @see Variant::iter_init()
1202
*/
1203
typedef GDExtensionBool (*GDExtensionInterfaceVariantIterInit)(GDExtensionConstVariantPtr p_self, GDExtensionUninitializedVariantPtr r_iter, GDExtensionBool *r_valid);
1204
1205
/**
1206
* @name variant_iter_next
1207
* @since 4.1
1208
*
1209
* Gets the next value for an iterator over a Variant.
1210
*
1211
* @param p_self A pointer to the Variant.
1212
* @param r_iter A pointer to a Variant which will be assigned the iterator.
1213
* @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
1214
*
1215
* @return true if the operation is valid; otherwise false.
1216
*
1217
* @see Variant::iter_next()
1218
*/
1219
typedef GDExtensionBool (*GDExtensionInterfaceVariantIterNext)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionBool *r_valid);
1220
1221
/**
1222
* @name variant_iter_get
1223
* @since 4.1
1224
*
1225
* Gets the next value for an iterator over a Variant.
1226
*
1227
* @param p_self A pointer to the Variant.
1228
* @param r_iter A pointer to a Variant which will be assigned the iterator.
1229
* @param r_ret A pointer to a Variant which will be assigned false if the operation is invalid.
1230
* @param r_valid A pointer to a boolean which will be set to false if the operation is invalid.
1231
*
1232
* @see Variant::iter_get()
1233
*/
1234
typedef void (*GDExtensionInterfaceVariantIterGet)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionUninitializedVariantPtr r_ret, GDExtensionBool *r_valid);
1235
1236
/**
1237
* @name variant_hash
1238
* @since 4.1
1239
*
1240
* Gets the hash of a Variant.
1241
*
1242
* @param p_self A pointer to the Variant.
1243
*
1244
* @return The hash value.
1245
*
1246
* @see Variant::hash()
1247
*/
1248
typedef GDExtensionInt (*GDExtensionInterfaceVariantHash)(GDExtensionConstVariantPtr p_self);
1249
1250
/**
1251
* @name variant_recursive_hash
1252
* @since 4.1
1253
*
1254
* Gets the recursive hash of a Variant.
1255
*
1256
* @param p_self A pointer to the Variant.
1257
* @param p_recursion_count The number of recursive loops so far.
1258
*
1259
* @return The hash value.
1260
*
1261
* @see Variant::recursive_hash()
1262
*/
1263
typedef GDExtensionInt (*GDExtensionInterfaceVariantRecursiveHash)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_recursion_count);
1264
1265
/**
1266
* @name variant_hash_compare
1267
* @since 4.1
1268
*
1269
* Compares two Variants by their hash.
1270
*
1271
* @param p_self A pointer to the Variant.
1272
* @param p_other A pointer to the other Variant to compare it to.
1273
*
1274
* @return The hash value.
1275
*
1276
* @see Variant::hash_compare()
1277
*/
1278
typedef GDExtensionBool (*GDExtensionInterfaceVariantHashCompare)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_other);
1279
1280
/**
1281
* @name variant_booleanize
1282
* @since 4.1
1283
*
1284
* Converts a Variant to a boolean.
1285
*
1286
* @param p_self A pointer to the Variant.
1287
*
1288
* @return The boolean value of the Variant.
1289
*/
1290
typedef GDExtensionBool (*GDExtensionInterfaceVariantBooleanize)(GDExtensionConstVariantPtr p_self);
1291
1292
/**
1293
* @name variant_duplicate
1294
* @since 4.1
1295
*
1296
* Duplicates a Variant.
1297
*
1298
* @param p_self A pointer to the Variant.
1299
* @param r_ret A pointer to a Variant to store the duplicated value.
1300
* @param p_deep Whether or not to duplicate deeply (when supported by the Variant type).
1301
*/
1302
typedef void (*GDExtensionInterfaceVariantDuplicate)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_ret, GDExtensionBool p_deep);
1303
1304
/**
1305
* @name variant_stringify
1306
* @since 4.1
1307
*
1308
* Converts a Variant to a string.
1309
*
1310
* @param p_self A pointer to the Variant.
1311
* @param r_ret A pointer to a String to store the resulting value.
1312
*/
1313
typedef void (*GDExtensionInterfaceVariantStringify)(GDExtensionConstVariantPtr p_self, GDExtensionStringPtr r_ret);
1314
1315
/**
1316
* @name variant_get_type
1317
* @since 4.1
1318
*
1319
* Gets the type of a Variant.
1320
*
1321
* @param p_self A pointer to the Variant.
1322
*
1323
* @return The variant type.
1324
*/
1325
typedef GDExtensionVariantType (*GDExtensionInterfaceVariantGetType)(GDExtensionConstVariantPtr p_self);
1326
1327
/**
1328
* @name variant_has_method
1329
* @since 4.1
1330
*
1331
* Checks if a Variant has the given method.
1332
*
1333
* @param p_self A pointer to the Variant.
1334
* @param p_method A pointer to a StringName with the method name.
1335
*
1336
* @return true if the variant has the given method; otherwise false.
1337
*/
1338
typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMethod)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_method);
1339
1340
/**
1341
* @name variant_has_member
1342
* @since 4.1
1343
*
1344
* Checks if a type of Variant has the given member.
1345
*
1346
* @param p_type The Variant type.
1347
* @param p_member A pointer to a StringName with the member name.
1348
*
1349
* @return true if the variant has the given method; otherwise false.
1350
*/
1351
typedef GDExtensionBool (*GDExtensionInterfaceVariantHasMember)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
1352
1353
/**
1354
* @name variant_has_key
1355
* @since 4.1
1356
*
1357
* Checks if a Variant has a key.
1358
*
1359
* @param p_self A pointer to the Variant.
1360
* @param p_key A pointer to a Variant representing the key.
1361
* @param r_valid A pointer to a boolean which will be set to false if the key doesn't exist.
1362
*
1363
* @return true if the key exists; otherwise false.
1364
*/
1365
typedef GDExtensionBool (*GDExtensionInterfaceVariantHasKey)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionBool *r_valid);
1366
1367
/**
1368
* @name variant_get_object_instance_id
1369
* @since 4.4
1370
*
1371
* Gets the object instance ID from a variant of type GDEXTENSION_VARIANT_TYPE_OBJECT.
1372
*
1373
* If the variant isn't of type GDEXTENSION_VARIANT_TYPE_OBJECT, then zero will be returned.
1374
* The instance ID will be returned even if the object is no longer valid - use `object_get_instance_by_id()` to check if the object is still valid.
1375
*
1376
* @param p_self A pointer to the Variant.
1377
*
1378
* @return The instance ID for the contained object.
1379
*/
1380
typedef GDObjectInstanceID (*GDExtensionInterfaceVariantGetObjectInstanceId)(GDExtensionConstVariantPtr p_self);
1381
1382
/**
1383
* @name variant_get_type_name
1384
* @since 4.1
1385
*
1386
* Gets the name of a Variant type.
1387
*
1388
* @param p_type The Variant type.
1389
* @param r_name A pointer to a String to store the Variant type name.
1390
*/
1391
typedef void (*GDExtensionInterfaceVariantGetTypeName)(GDExtensionVariantType p_type, GDExtensionUninitializedStringPtr r_name);
1392
1393
/**
1394
* @name variant_can_convert
1395
* @since 4.1
1396
*
1397
* Checks if Variants can be converted from one type to another.
1398
*
1399
* @param p_from The Variant type to convert from.
1400
* @param p_to The Variant type to convert to.
1401
*
1402
* @return true if the conversion is possible; otherwise false.
1403
*/
1404
typedef GDExtensionBool (*GDExtensionInterfaceVariantCanConvert)(GDExtensionVariantType p_from, GDExtensionVariantType p_to);
1405
1406
/**
1407
* @name variant_can_convert_strict
1408
* @since 4.1
1409
*
1410
* Checks if Variant can be converted from one type to another using stricter rules.
1411
*
1412
* @param p_from The Variant type to convert from.
1413
* @param p_to The Variant type to convert to.
1414
*
1415
* @return true if the conversion is possible; otherwise false.
1416
*/
1417
typedef GDExtensionBool (*GDExtensionInterfaceVariantCanConvertStrict)(GDExtensionVariantType p_from, GDExtensionVariantType p_to);
1418
1419
/**
1420
* @name get_variant_from_type_constructor
1421
* @since 4.1
1422
*
1423
* Gets a pointer to a function that can create a Variant of the given type from a raw value.
1424
*
1425
* @param p_type The Variant type.
1426
*
1427
* @return A pointer to a function that can create a Variant of the given type from a raw value.
1428
*/
1429
typedef GDExtensionVariantFromTypeConstructorFunc (*GDExtensionInterfaceGetVariantFromTypeConstructor)(GDExtensionVariantType p_type);
1430
1431
/**
1432
* @name get_variant_to_type_constructor
1433
* @since 4.1
1434
*
1435
* Gets a pointer to a function that can get the raw value from a Variant of the given type.
1436
*
1437
* @param p_type The Variant type.
1438
*
1439
* @return A pointer to a function that can get the raw value from a Variant of the given type.
1440
*/
1441
typedef GDExtensionTypeFromVariantConstructorFunc (*GDExtensionInterfaceGetVariantToTypeConstructor)(GDExtensionVariantType p_type);
1442
1443
/**
1444
* @name variant_get_ptr_internal_getter
1445
* @since 4.4
1446
*
1447
* Provides a function pointer for retrieving a pointer to a variant's internal value.
1448
* Access to a variant's internal value can be used to modify it in-place, or to retrieve its value without the overhead of variant conversion functions.
1449
* It is recommended to cache the getter for all variant types in a function table to avoid retrieval overhead upon use.
1450
*
1451
* @note Each function assumes the variant's type has already been determined and matches the function.
1452
* Invoking the function with a variant of a mismatched type has undefined behavior, and may lead to a segmentation fault.
1453
*
1454
* @param p_type The Variant type.
1455
*
1456
* @return A pointer to a type-specific function that returns a pointer to the internal value of a variant. Check the implementation of this function (gdextension_variant_get_ptr_internal_getter) for pointee type info of each variant type.
1457
*/
1458
typedef GDExtensionVariantGetInternalPtrFunc (*GDExtensionInterfaceGetVariantGetInternalPtrFunc)(GDExtensionVariantType p_type);
1459
1460
/**
1461
* @name variant_get_ptr_operator_evaluator
1462
* @since 4.1
1463
*
1464
* Gets a pointer to a function that can evaluate the given Variant operator on the given Variant types.
1465
*
1466
* @param p_operator The variant operator.
1467
* @param p_type_a The type of the first Variant.
1468
* @param p_type_b The type of the second Variant.
1469
*
1470
* @return A pointer to a function that can evaluate the given Variant operator on the given Variant types.
1471
*/
1472
typedef GDExtensionPtrOperatorEvaluator (*GDExtensionInterfaceVariantGetPtrOperatorEvaluator)(GDExtensionVariantOperator p_operator, GDExtensionVariantType p_type_a, GDExtensionVariantType p_type_b);
1473
1474
/**
1475
* @name variant_get_ptr_builtin_method
1476
* @since 4.1
1477
*
1478
* Gets a pointer to a function that can call a builtin method on a type of Variant.
1479
*
1480
* @param p_type The Variant type.
1481
* @param p_method A pointer to a StringName with the method name.
1482
* @param p_hash A hash representing the method signature.
1483
*
1484
* @return A pointer to a function that can call a builtin method on a type of Variant.
1485
*/
1486
typedef GDExtensionPtrBuiltInMethod (*GDExtensionInterfaceVariantGetPtrBuiltinMethod)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, GDExtensionInt p_hash);
1487
1488
/**
1489
* @name variant_get_ptr_constructor
1490
* @since 4.1
1491
*
1492
* Gets a pointer to a function that can call one of the constructors for a type of Variant.
1493
*
1494
* @param p_type The Variant type.
1495
* @param p_constructor The index of the constructor.
1496
*
1497
* @return A pointer to a function that can call one of the constructors for a type of Variant.
1498
*/
1499
typedef GDExtensionPtrConstructor (*GDExtensionInterfaceVariantGetPtrConstructor)(GDExtensionVariantType p_type, int32_t p_constructor);
1500
1501
/**
1502
* @name variant_get_ptr_destructor
1503
* @since 4.1
1504
*
1505
* Gets a pointer to a function than can call the destructor for a type of Variant.
1506
*
1507
* @param p_type The Variant type.
1508
*
1509
* @return A pointer to a function than can call the destructor for a type of Variant.
1510
*/
1511
typedef GDExtensionPtrDestructor (*GDExtensionInterfaceVariantGetPtrDestructor)(GDExtensionVariantType p_type);
1512
1513
/**
1514
* @name variant_construct
1515
* @since 4.1
1516
*
1517
* Constructs a Variant of the given type, using the first constructor that matches the given arguments.
1518
*
1519
* @param p_type The Variant type.
1520
* @param r_base A pointer to a Variant to store the constructed value.
1521
* @param p_args A pointer to a C array of Variant pointers representing the arguments for the constructor.
1522
* @param p_argument_count The number of arguments to pass to the constructor.
1523
* @param r_error A pointer the structure which will be updated with error information.
1524
*/
1525
typedef void (*GDExtensionInterfaceVariantConstruct)(GDExtensionVariantType p_type, GDExtensionUninitializedVariantPtr r_base, const GDExtensionConstVariantPtr *p_args, int32_t p_argument_count, GDExtensionCallError *r_error);
1526
1527
/**
1528
* @name variant_get_ptr_setter
1529
* @since 4.1
1530
*
1531
* Gets a pointer to a function that can call a member's setter on the given Variant type.
1532
*
1533
* @param p_type The Variant type.
1534
* @param p_member A pointer to a StringName with the member name.
1535
*
1536
* @return A pointer to a function that can call a member's setter on the given Variant type.
1537
*/
1538
typedef GDExtensionPtrSetter (*GDExtensionInterfaceVariantGetPtrSetter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
1539
1540
/**
1541
* @name variant_get_ptr_getter
1542
* @since 4.1
1543
*
1544
* Gets a pointer to a function that can call a member's getter on the given Variant type.
1545
*
1546
* @param p_type The Variant type.
1547
* @param p_member A pointer to a StringName with the member name.
1548
*
1549
* @return A pointer to a function that can call a member's getter on the given Variant type.
1550
*/
1551
typedef GDExtensionPtrGetter (*GDExtensionInterfaceVariantGetPtrGetter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
1552
1553
/**
1554
* @name variant_get_ptr_indexed_setter
1555
* @since 4.1
1556
*
1557
* Gets a pointer to a function that can set an index on the given Variant type.
1558
*
1559
* @param p_type The Variant type.
1560
*
1561
* @return A pointer to a function that can set an index on the given Variant type.
1562
*/
1563
typedef GDExtensionPtrIndexedSetter (*GDExtensionInterfaceVariantGetPtrIndexedSetter)(GDExtensionVariantType p_type);
1564
1565
/**
1566
* @name variant_get_ptr_indexed_getter
1567
* @since 4.1
1568
*
1569
* Gets a pointer to a function that can get an index on the given Variant type.
1570
*
1571
* @param p_type The Variant type.
1572
*
1573
* @return A pointer to a function that can get an index on the given Variant type.
1574
*/
1575
typedef GDExtensionPtrIndexedGetter (*GDExtensionInterfaceVariantGetPtrIndexedGetter)(GDExtensionVariantType p_type);
1576
1577
/**
1578
* @name variant_get_ptr_keyed_setter
1579
* @since 4.1
1580
*
1581
* Gets a pointer to a function that can set a key on the given Variant type.
1582
*
1583
* @param p_type The Variant type.
1584
*
1585
* @return A pointer to a function that can set a key on the given Variant type.
1586
*/
1587
typedef GDExtensionPtrKeyedSetter (*GDExtensionInterfaceVariantGetPtrKeyedSetter)(GDExtensionVariantType p_type);
1588
1589
/**
1590
* @name variant_get_ptr_keyed_getter
1591
* @since 4.1
1592
*
1593
* Gets a pointer to a function that can get a key on the given Variant type.
1594
*
1595
* @param p_type The Variant type.
1596
*
1597
* @return A pointer to a function that can get a key on the given Variant type.
1598
*/
1599
typedef GDExtensionPtrKeyedGetter (*GDExtensionInterfaceVariantGetPtrKeyedGetter)(GDExtensionVariantType p_type);
1600
1601
/**
1602
* @name variant_get_ptr_keyed_checker
1603
* @since 4.1
1604
*
1605
* Gets a pointer to a function that can check a key on the given Variant type.
1606
*
1607
* @param p_type The Variant type.
1608
*
1609
* @return A pointer to a function that can check a key on the given Variant type.
1610
*/
1611
typedef GDExtensionPtrKeyedChecker (*GDExtensionInterfaceVariantGetPtrKeyedChecker)(GDExtensionVariantType p_type);
1612
1613
/**
1614
* @name variant_get_constant_value
1615
* @since 4.1
1616
*
1617
* Gets the value of a constant from the given Variant type.
1618
*
1619
* @param p_type The Variant type.
1620
* @param p_constant A pointer to a StringName with the constant name.
1621
* @param r_ret A pointer to a Variant to store the value.
1622
*/
1623
typedef void (*GDExtensionInterfaceVariantGetConstantValue)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_constant, GDExtensionUninitializedVariantPtr r_ret);
1624
1625
/**
1626
* @name variant_get_ptr_utility_function
1627
* @since 4.1
1628
*
1629
* Gets a pointer to a function that can call a Variant utility function.
1630
*
1631
* @param p_function A pointer to a StringName with the function name.
1632
* @param p_hash A hash representing the function signature.
1633
*
1634
* @return A pointer to a function that can call a Variant utility function.
1635
*/
1636
typedef GDExtensionPtrUtilityFunction (*GDExtensionInterfaceVariantGetPtrUtilityFunction)(GDExtensionConstStringNamePtr p_function, GDExtensionInt p_hash);
1637
1638
/* INTERFACE: String Utilities */
1639
1640
/**
1641
* @name string_new_with_latin1_chars
1642
* @since 4.1
1643
*
1644
* Creates a String from a Latin-1 encoded C string.
1645
*
1646
* @param r_dest A pointer to a Variant to hold the newly created String.
1647
* @param p_contents A pointer to a Latin-1 encoded C string (null terminated).
1648
*/
1649
typedef void (*GDExtensionInterfaceStringNewWithLatin1Chars)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents);
1650
1651
/**
1652
* @name string_new_with_utf8_chars
1653
* @since 4.1
1654
*
1655
* Creates a String from a UTF-8 encoded C string.
1656
*
1657
* @param r_dest A pointer to a Variant to hold the newly created String.
1658
* @param p_contents A pointer to a UTF-8 encoded C string (null terminated).
1659
*/
1660
typedef void (*GDExtensionInterfaceStringNewWithUtf8Chars)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents);
1661
1662
/**
1663
* @name string_new_with_utf16_chars
1664
* @since 4.1
1665
*
1666
* Creates a String from a UTF-16 encoded C string.
1667
*
1668
* @param r_dest A pointer to a Variant to hold the newly created String.
1669
* @param p_contents A pointer to a UTF-16 encoded C string (null terminated).
1670
*/
1671
typedef void (*GDExtensionInterfaceStringNewWithUtf16Chars)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents);
1672
1673
/**
1674
* @name string_new_with_utf32_chars
1675
* @since 4.1
1676
*
1677
* Creates a String from a UTF-32 encoded C string.
1678
*
1679
* @param r_dest A pointer to a Variant to hold the newly created String.
1680
* @param p_contents A pointer to a UTF-32 encoded C string (null terminated).
1681
*/
1682
typedef void (*GDExtensionInterfaceStringNewWithUtf32Chars)(GDExtensionUninitializedStringPtr r_dest, const char32_t *p_contents);
1683
1684
/**
1685
* @name string_new_with_wide_chars
1686
* @since 4.1
1687
*
1688
* Creates a String from a wide C string.
1689
*
1690
* @param r_dest A pointer to a Variant to hold the newly created String.
1691
* @param p_contents A pointer to a wide C string (null terminated).
1692
*/
1693
typedef void (*GDExtensionInterfaceStringNewWithWideChars)(GDExtensionUninitializedStringPtr r_dest, const wchar_t *p_contents);
1694
1695
/**
1696
* @name string_new_with_latin1_chars_and_len
1697
* @since 4.1
1698
*
1699
* Creates a String from a Latin-1 encoded C string with the given length.
1700
*
1701
* @param r_dest A pointer to a Variant to hold the newly created String.
1702
* @param p_contents A pointer to a Latin-1 encoded C string.
1703
* @param p_size The number of characters (= number of bytes).
1704
*/
1705
typedef void (*GDExtensionInterfaceStringNewWithLatin1CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
1706
1707
/**
1708
* @name string_new_with_utf8_chars_and_len
1709
* @since 4.1
1710
* @deprecated in Godot 4.3. Use `string_new_with_utf8_chars_and_len2` instead.
1711
*
1712
* Creates a String from a UTF-8 encoded C string with the given length.
1713
*
1714
* @param r_dest A pointer to a Variant to hold the newly created String.
1715
* @param p_contents A pointer to a UTF-8 encoded C string.
1716
* @param p_size The number of bytes (not code units).
1717
*/
1718
typedef void (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
1719
1720
/**
1721
* @name string_new_with_utf8_chars_and_len2
1722
* @since 4.3
1723
*
1724
* Creates a String from a UTF-8 encoded C string with the given length.
1725
*
1726
* @param r_dest A pointer to a Variant to hold the newly created String.
1727
* @param p_contents A pointer to a UTF-8 encoded C string.
1728
* @param p_size The number of bytes (not code units).
1729
*
1730
* @return Error code signifying if the operation successful.
1731
*/
1732
typedef GDExtensionInt (*GDExtensionInterfaceStringNewWithUtf8CharsAndLen2)(GDExtensionUninitializedStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
1733
1734
/**
1735
* @name string_new_with_utf16_chars_and_len
1736
* @since 4.1
1737
* @deprecated in Godot 4.3. Use `string_new_with_utf16_chars_and_len2` instead.
1738
*
1739
* Creates a String from a UTF-16 encoded C string with the given length.
1740
*
1741
* @param r_dest A pointer to a Variant to hold the newly created String.
1742
* @param p_contents A pointer to a UTF-16 encoded C string.
1743
* @param p_char_count The number of characters (not bytes).
1744
*/
1745
typedef void (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_char_count);
1746
1747
/**
1748
* @name string_new_with_utf16_chars_and_len2
1749
* @since 4.3
1750
*
1751
* Creates a String from a UTF-16 encoded C string with the given length.
1752
*
1753
* @param r_dest A pointer to a Variant to hold the newly created String.
1754
* @param p_contents A pointer to a UTF-16 encoded C string.
1755
* @param p_char_count The number of characters (not bytes).
1756
* @param p_default_little_endian If true, UTF-16 use little endian.
1757
*
1758
* @return Error code signifying if the operation successful.
1759
*/
1760
typedef GDExtensionInt (*GDExtensionInterfaceStringNewWithUtf16CharsAndLen2)(GDExtensionUninitializedStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_char_count, GDExtensionBool p_default_little_endian);
1761
1762
/**
1763
* @name string_new_with_utf32_chars_and_len
1764
* @since 4.1
1765
*
1766
* Creates a String from a UTF-32 encoded C string with the given length.
1767
*
1768
* @param r_dest A pointer to a Variant to hold the newly created String.
1769
* @param p_contents A pointer to a UTF-32 encoded C string.
1770
* @param p_char_count The number of characters (not bytes).
1771
*/
1772
typedef void (*GDExtensionInterfaceStringNewWithUtf32CharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const char32_t *p_contents, GDExtensionInt p_char_count);
1773
1774
/**
1775
* @name string_new_with_wide_chars_and_len
1776
* @since 4.1
1777
*
1778
* Creates a String from a wide C string with the given length.
1779
*
1780
* @param r_dest A pointer to a Variant to hold the newly created String.
1781
* @param p_contents A pointer to a wide C string.
1782
* @param p_char_count The number of characters (not bytes).
1783
*/
1784
typedef void (*GDExtensionInterfaceStringNewWithWideCharsAndLen)(GDExtensionUninitializedStringPtr r_dest, const wchar_t *p_contents, GDExtensionInt p_char_count);
1785
1786
/**
1787
* @name string_to_latin1_chars
1788
* @since 4.1
1789
*
1790
* Converts a String to a Latin-1 encoded C string.
1791
*
1792
* It doesn't write a null terminator.
1793
*
1794
* @param p_self A pointer to the String.
1795
* @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
1796
* @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value.
1797
*
1798
* @return The resulting encoded string length in characters (not bytes), not including a null terminator.
1799
*/
1800
typedef GDExtensionInt (*GDExtensionInterfaceStringToLatin1Chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length);
1801
1802
/**
1803
* @name string_to_utf8_chars
1804
* @since 4.1
1805
*
1806
* Converts a String to a UTF-8 encoded C string.
1807
*
1808
* It doesn't write a null terminator.
1809
*
1810
* @param p_self A pointer to the String.
1811
* @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
1812
* @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value.
1813
*
1814
* @return The resulting encoded string length in characters (not bytes), not including a null terminator.
1815
*/
1816
typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf8Chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length);
1817
1818
/**
1819
* @name string_to_utf16_chars
1820
* @since 4.1
1821
*
1822
* Converts a String to a UTF-16 encoded C string.
1823
*
1824
* It doesn't write a null terminator.
1825
*
1826
* @param p_self A pointer to the String.
1827
* @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
1828
* @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value.
1829
*
1830
* @return The resulting encoded string length in characters (not bytes), not including a null terminator.
1831
*/
1832
typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf16Chars)(GDExtensionConstStringPtr p_self, char16_t *r_text, GDExtensionInt p_max_write_length);
1833
1834
/**
1835
* @name string_to_utf32_chars
1836
* @since 4.1
1837
*
1838
* Converts a String to a UTF-32 encoded C string.
1839
*
1840
* It doesn't write a null terminator.
1841
*
1842
* @param p_self A pointer to the String.
1843
* @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
1844
* @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value.
1845
*
1846
* @return The resulting encoded string length in characters (not bytes), not including a null terminator.
1847
*/
1848
typedef GDExtensionInt (*GDExtensionInterfaceStringToUtf32Chars)(GDExtensionConstStringPtr p_self, char32_t *r_text, GDExtensionInt p_max_write_length);
1849
1850
/**
1851
* @name string_to_wide_chars
1852
* @since 4.1
1853
*
1854
* Converts a String to a wide C string.
1855
*
1856
* It doesn't write a null terminator.
1857
*
1858
* @param p_self A pointer to the String.
1859
* @param r_text A pointer to the buffer to hold the resulting data. If NULL is passed in, only the length will be computed.
1860
* @param p_max_write_length The maximum number of characters that can be written to r_text. It has no affect on the return value.
1861
*
1862
* @return The resulting encoded string length in characters (not bytes), not including a null terminator.
1863
*/
1864
typedef GDExtensionInt (*GDExtensionInterfaceStringToWideChars)(GDExtensionConstStringPtr p_self, wchar_t *r_text, GDExtensionInt p_max_write_length);
1865
1866
/**
1867
* @name string_operator_index
1868
* @since 4.1
1869
*
1870
* Gets a pointer to the character at the given index from a String.
1871
*
1872
* @param p_self A pointer to the String.
1873
* @param p_index The index.
1874
*
1875
* @return A pointer to the requested character.
1876
*/
1877
typedef char32_t *(*GDExtensionInterfaceStringOperatorIndex)(GDExtensionStringPtr p_self, GDExtensionInt p_index);
1878
1879
/**
1880
* @name string_operator_index_const
1881
* @since 4.1
1882
*
1883
* Gets a const pointer to the character at the given index from a String.
1884
*
1885
* @param p_self A pointer to the String.
1886
* @param p_index The index.
1887
*
1888
* @return A const pointer to the requested character.
1889
*/
1890
typedef const char32_t *(*GDExtensionInterfaceStringOperatorIndexConst)(GDExtensionConstStringPtr p_self, GDExtensionInt p_index);
1891
1892
/**
1893
* @name string_operator_plus_eq_string
1894
* @since 4.1
1895
*
1896
* Appends another String to a String.
1897
*
1898
* @param p_self A pointer to the String.
1899
* @param p_b A pointer to the other String to append.
1900
*/
1901
typedef void (*GDExtensionInterfaceStringOperatorPlusEqString)(GDExtensionStringPtr p_self, GDExtensionConstStringPtr p_b);
1902
1903
/**
1904
* @name string_operator_plus_eq_char
1905
* @since 4.1
1906
*
1907
* Appends a character to a String.
1908
*
1909
* @param p_self A pointer to the String.
1910
* @param p_b A pointer to the character to append.
1911
*/
1912
typedef void (*GDExtensionInterfaceStringOperatorPlusEqChar)(GDExtensionStringPtr p_self, char32_t p_b);
1913
1914
/**
1915
* @name string_operator_plus_eq_cstr
1916
* @since 4.1
1917
*
1918
* Appends a Latin-1 encoded C string to a String.
1919
*
1920
* @param p_self A pointer to the String.
1921
* @param p_b A pointer to a Latin-1 encoded C string (null terminated).
1922
*/
1923
typedef void (*GDExtensionInterfaceStringOperatorPlusEqCstr)(GDExtensionStringPtr p_self, const char *p_b);
1924
1925
/**
1926
* @name string_operator_plus_eq_wcstr
1927
* @since 4.1
1928
*
1929
* Appends a wide C string to a String.
1930
*
1931
* @param p_self A pointer to the String.
1932
* @param p_b A pointer to a wide C string (null terminated).
1933
*/
1934
typedef void (*GDExtensionInterfaceStringOperatorPlusEqWcstr)(GDExtensionStringPtr p_self, const wchar_t *p_b);
1935
1936
/**
1937
* @name string_operator_plus_eq_c32str
1938
* @since 4.1
1939
*
1940
* Appends a UTF-32 encoded C string to a String.
1941
*
1942
* @param p_self A pointer to the String.
1943
* @param p_b A pointer to a UTF-32 encoded C string (null terminated).
1944
*/
1945
typedef void (*GDExtensionInterfaceStringOperatorPlusEqC32str)(GDExtensionStringPtr p_self, const char32_t *p_b);
1946
1947
/**
1948
* @name string_resize
1949
* @since 4.2
1950
*
1951
* Resizes the underlying string data to the given number of characters.
1952
*
1953
* Space needs to be allocated for the null terminating character ('\0') which
1954
* also must be added manually, in order for all string functions to work correctly.
1955
*
1956
* Warning: This is an error-prone operation - only use it if there's no other
1957
* efficient way to accomplish your goal.
1958
*
1959
* @param p_self A pointer to the String.
1960
* @param p_resize The new length for the String.
1961
*
1962
* @return Error code signifying if the operation successful.
1963
*/
1964
typedef GDExtensionInt (*GDExtensionInterfaceStringResize)(GDExtensionStringPtr p_self, GDExtensionInt p_resize);
1965
1966
/* INTERFACE: StringName Utilities */
1967
1968
/**
1969
* @name string_name_new_with_latin1_chars
1970
* @since 4.2
1971
*
1972
* Creates a StringName from a Latin-1 encoded C string.
1973
*
1974
* If `p_is_static` is true, then:
1975
* - The StringName will reuse the `p_contents` buffer instead of copying it.
1976
* You must guarantee that the buffer remains valid for the duration of the application (e.g. string literal).
1977
* - You must not call a destructor for this StringName. Incrementing the initial reference once should achieve this.
1978
*
1979
* `p_is_static` is purely an optimization and can easily introduce undefined behavior if used wrong. In case of doubt, set it to false.
1980
*
1981
* @param r_dest A pointer to uninitialized storage, into which the newly created StringName is constructed.
1982
* @param p_contents A pointer to a C string (null terminated and Latin-1 or ASCII encoded).
1983
* @param p_is_static Whether the StringName reuses the buffer directly (see above).
1984
*/
1985
typedef void (*GDExtensionInterfaceStringNameNewWithLatin1Chars)(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents, GDExtensionBool p_is_static);
1986
1987
/**
1988
* @name string_name_new_with_utf8_chars
1989
* @since 4.2
1990
*
1991
* Creates a StringName from a UTF-8 encoded C string.
1992
*
1993
* @param r_dest A pointer to uninitialized storage, into which the newly created StringName is constructed.
1994
* @param p_contents A pointer to a C string (null terminated and UTF-8 encoded).
1995
*/
1996
typedef void (*GDExtensionInterfaceStringNameNewWithUtf8Chars)(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents);
1997
1998
/**
1999
* @name string_name_new_with_utf8_chars_and_len
2000
* @since 4.2
2001
*
2002
* Creates a StringName from a UTF-8 encoded string with a given number of characters.
2003
*
2004
* @param r_dest A pointer to uninitialized storage, into which the newly created StringName is constructed.
2005
* @param p_contents A pointer to a C string (null terminated and UTF-8 encoded).
2006
* @param p_size The number of bytes (not UTF-8 code points).
2007
*/
2008
typedef void (*GDExtensionInterfaceStringNameNewWithUtf8CharsAndLen)(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents, GDExtensionInt p_size);
2009
2010
/* INTERFACE: XMLParser Utilities */
2011
2012
/**
2013
* @name xml_parser_open_buffer
2014
* @since 4.1
2015
*
2016
* Opens a raw XML buffer on an XMLParser instance.
2017
*
2018
* @param p_instance A pointer to an XMLParser object.
2019
* @param p_buffer A pointer to the buffer.
2020
* @param p_size The size of the buffer.
2021
*
2022
* @return A Godot error code (ex. OK, ERR_INVALID_DATA, etc).
2023
*
2024
* @see XMLParser::open_buffer()
2025
*/
2026
typedef GDExtensionInt (*GDExtensionInterfaceXmlParserOpenBuffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_buffer, size_t p_size);
2027
2028
/* INTERFACE: FileAccess Utilities */
2029
2030
/**
2031
* @name file_access_store_buffer
2032
* @since 4.1
2033
*
2034
* Stores the given buffer using an instance of FileAccess.
2035
*
2036
* @param p_instance A pointer to a FileAccess object.
2037
* @param p_src A pointer to the buffer.
2038
* @param p_length The size of the buffer.
2039
*
2040
* @see FileAccess::store_buffer()
2041
*/
2042
typedef void (*GDExtensionInterfaceFileAccessStoreBuffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_src, uint64_t p_length);
2043
2044
/**
2045
* @name file_access_get_buffer
2046
* @since 4.1
2047
*
2048
* Reads the next p_length bytes into the given buffer using an instance of FileAccess.
2049
*
2050
* @param p_instance A pointer to a FileAccess object.
2051
* @param p_dst A pointer to the buffer to store the data.
2052
* @param p_length The requested number of bytes to read.
2053
*
2054
* @return The actual number of bytes read (may be less than requested).
2055
*/
2056
typedef uint64_t (*GDExtensionInterfaceFileAccessGetBuffer)(GDExtensionConstObjectPtr p_instance, uint8_t *p_dst, uint64_t p_length);
2057
2058
/* INTERFACE: Image Utilities */
2059
2060
/**
2061
* @name image_ptrw
2062
* @since 4.3
2063
*
2064
* Returns writable pointer to internal Image buffer.
2065
*
2066
* @param p_instance A pointer to a Image object.
2067
*
2068
* @return Pointer to internal Image buffer.
2069
*
2070
* @see Image::ptrw()
2071
*/
2072
typedef uint8_t *(*GDExtensionInterfaceImagePtrw)(GDExtensionObjectPtr p_instance);
2073
2074
/**
2075
* @name image_ptr
2076
* @since 4.3
2077
*
2078
* Returns read only pointer to internal Image buffer.
2079
*
2080
* @param p_instance A pointer to a Image object.
2081
*
2082
* @return Pointer to internal Image buffer.
2083
*
2084
* @see Image::ptr()
2085
*/
2086
typedef const uint8_t *(*GDExtensionInterfaceImagePtr)(GDExtensionObjectPtr p_instance);
2087
2088
/* INTERFACE: WorkerThreadPool Utilities */
2089
2090
/**
2091
* @name worker_thread_pool_add_native_group_task
2092
* @since 4.1
2093
*
2094
* Adds a group task to an instance of WorkerThreadPool.
2095
*
2096
* @param p_instance A pointer to a WorkerThreadPool object.
2097
* @param p_func A pointer to a function to run in the thread pool.
2098
* @param p_userdata A pointer to arbitrary data which will be passed to p_func.
2099
* @param p_elements The number of element needed in the group.
2100
* @param p_tasks The number of tasks needed in the group.
2101
* @param p_high_priority Whether or not this is a high priority task.
2102
* @param p_description A pointer to a String with the task description.
2103
*
2104
* @return The task group ID.
2105
*
2106
* @see WorkerThreadPool::add_group_task()
2107
*/
2108
typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeGroupTask)(GDExtensionObjectPtr p_instance, GDExtensionWorkerThreadPoolGroupTask p_func, void *p_userdata, int p_elements, int p_tasks, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
2109
2110
/**
2111
* @name worker_thread_pool_add_native_task
2112
* @since 4.1
2113
*
2114
* Adds a task to an instance of WorkerThreadPool.
2115
*
2116
* @param p_instance A pointer to a WorkerThreadPool object.
2117
* @param p_func A pointer to a function to run in the thread pool.
2118
* @param p_userdata A pointer to arbitrary data which will be passed to p_func.
2119
* @param p_high_priority Whether or not this is a high priority task.
2120
* @param p_description A pointer to a String with the task description.
2121
*
2122
* @return The task ID.
2123
*/
2124
typedef int64_t (*GDExtensionInterfaceWorkerThreadPoolAddNativeTask)(GDExtensionObjectPtr p_instance, GDExtensionWorkerThreadPoolTask p_func, void *p_userdata, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
2125
2126
/* INTERFACE: Packed Array */
2127
2128
/**
2129
* @name packed_byte_array_operator_index
2130
* @since 4.1
2131
*
2132
* Gets a pointer to a byte in a PackedByteArray.
2133
*
2134
* @param p_self A pointer to a PackedByteArray object.
2135
* @param p_index The index of the byte to get.
2136
*
2137
* @return A pointer to the requested byte.
2138
*/
2139
typedef uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
2140
2141
/**
2142
* @name packed_byte_array_operator_index_const
2143
* @since 4.1
2144
*
2145
* Gets a const pointer to a byte in a PackedByteArray.
2146
*
2147
* @param p_self A const pointer to a PackedByteArray object.
2148
* @param p_index The index of the byte to get.
2149
*
2150
* @return A const pointer to the requested byte.
2151
*/
2152
typedef const uint8_t *(*GDExtensionInterfacePackedByteArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
2153
2154
/**
2155
* @name packed_float32_array_operator_index
2156
* @since 4.1
2157
*
2158
* Gets a pointer to a 32-bit float in a PackedFloat32Array.
2159
*
2160
* @param p_self A pointer to a PackedFloat32Array object.
2161
* @param p_index The index of the float to get.
2162
*
2163
* @return A pointer to the requested 32-bit float.
2164
*/
2165
typedef float *(*GDExtensionInterfacePackedFloat32ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
2166
2167
/**
2168
* @name packed_float32_array_operator_index_const
2169
* @since 4.1
2170
*
2171
* Gets a const pointer to a 32-bit float in a PackedFloat32Array.
2172
*
2173
* @param p_self A const pointer to a PackedFloat32Array object.
2174
* @param p_index The index of the float to get.
2175
*
2176
* @return A const pointer to the requested 32-bit float.
2177
*/
2178
typedef const float *(*GDExtensionInterfacePackedFloat32ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
2179
2180
/**
2181
* @name packed_float64_array_operator_index
2182
* @since 4.1
2183
*
2184
* Gets a pointer to a 64-bit float in a PackedFloat64Array.
2185
*
2186
* @param p_self A pointer to a PackedFloat64Array object.
2187
* @param p_index The index of the float to get.
2188
*
2189
* @return A pointer to the requested 64-bit float.
2190
*/
2191
typedef double *(*GDExtensionInterfacePackedFloat64ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
2192
2193
/**
2194
* @name packed_float64_array_operator_index_const
2195
* @since 4.1
2196
*
2197
* Gets a const pointer to a 64-bit float in a PackedFloat64Array.
2198
*
2199
* @param p_self A const pointer to a PackedFloat64Array object.
2200
* @param p_index The index of the float to get.
2201
*
2202
* @return A const pointer to the requested 64-bit float.
2203
*/
2204
typedef const double *(*GDExtensionInterfacePackedFloat64ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
2205
2206
/**
2207
* @name packed_int32_array_operator_index
2208
* @since 4.1
2209
*
2210
* Gets a pointer to a 32-bit integer in a PackedInt32Array.
2211
*
2212
* @param p_self A pointer to a PackedInt32Array object.
2213
* @param p_index The index of the integer to get.
2214
*
2215
* @return A pointer to the requested 32-bit integer.
2216
*/
2217
typedef int32_t *(*GDExtensionInterfacePackedInt32ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
2218
2219
/**
2220
* @name packed_int32_array_operator_index_const
2221
* @since 4.1
2222
*
2223
* Gets a const pointer to a 32-bit integer in a PackedInt32Array.
2224
*
2225
* @param p_self A const pointer to a PackedInt32Array object.
2226
* @param p_index The index of the integer to get.
2227
*
2228
* @return A const pointer to the requested 32-bit integer.
2229
*/
2230
typedef const int32_t *(*GDExtensionInterfacePackedInt32ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
2231
2232
/**
2233
* @name packed_int64_array_operator_index
2234
* @since 4.1
2235
*
2236
* Gets a pointer to a 64-bit integer in a PackedInt64Array.
2237
*
2238
* @param p_self A pointer to a PackedInt64Array object.
2239
* @param p_index The index of the integer to get.
2240
*
2241
* @return A pointer to the requested 64-bit integer.
2242
*/
2243
typedef int64_t *(*GDExtensionInterfacePackedInt64ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
2244
2245
/**
2246
* @name packed_int64_array_operator_index_const
2247
* @since 4.1
2248
*
2249
* Gets a const pointer to a 64-bit integer in a PackedInt64Array.
2250
*
2251
* @param p_self A const pointer to a PackedInt64Array object.
2252
* @param p_index The index of the integer to get.
2253
*
2254
* @return A const pointer to the requested 64-bit integer.
2255
*/
2256
typedef const int64_t *(*GDExtensionInterfacePackedInt64ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
2257
2258
/**
2259
* @name packed_string_array_operator_index
2260
* @since 4.1
2261
*
2262
* Gets a pointer to a string in a PackedStringArray.
2263
*
2264
* @param p_self A pointer to a PackedStringArray object.
2265
* @param p_index The index of the String to get.
2266
*
2267
* @return A pointer to the requested String.
2268
*/
2269
typedef GDExtensionStringPtr (*GDExtensionInterfacePackedStringArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
2270
2271
/**
2272
* @name packed_string_array_operator_index_const
2273
* @since 4.1
2274
*
2275
* Gets a const pointer to a string in a PackedStringArray.
2276
*
2277
* @param p_self A const pointer to a PackedStringArray object.
2278
* @param p_index The index of the String to get.
2279
*
2280
* @return A const pointer to the requested String.
2281
*/
2282
typedef GDExtensionStringPtr (*GDExtensionInterfacePackedStringArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
2283
2284
/**
2285
* @name packed_vector2_array_operator_index
2286
* @since 4.1
2287
*
2288
* Gets a pointer to a Vector2 in a PackedVector2Array.
2289
*
2290
* @param p_self A pointer to a PackedVector2Array object.
2291
* @param p_index The index of the Vector2 to get.
2292
*
2293
* @return A pointer to the requested Vector2.
2294
*/
2295
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector2ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
2296
2297
/**
2298
* @name packed_vector2_array_operator_index_const
2299
* @since 4.1
2300
*
2301
* Gets a const pointer to a Vector2 in a PackedVector2Array.
2302
*
2303
* @param p_self A const pointer to a PackedVector2Array object.
2304
* @param p_index The index of the Vector2 to get.
2305
*
2306
* @return A const pointer to the requested Vector2.
2307
*/
2308
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector2ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
2309
2310
/**
2311
* @name packed_vector3_array_operator_index
2312
* @since 4.1
2313
*
2314
* Gets a pointer to a Vector3 in a PackedVector3Array.
2315
*
2316
* @param p_self A pointer to a PackedVector3Array object.
2317
* @param p_index The index of the Vector3 to get.
2318
*
2319
* @return A pointer to the requested Vector3.
2320
*/
2321
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
2322
2323
/**
2324
* @name packed_vector3_array_operator_index_const
2325
* @since 4.1
2326
*
2327
* Gets a const pointer to a Vector3 in a PackedVector3Array.
2328
*
2329
* @param p_self A const pointer to a PackedVector3Array object.
2330
* @param p_index The index of the Vector3 to get.
2331
*
2332
* @return A const pointer to the requested Vector3.
2333
*/
2334
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector3ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
2335
2336
/**
2337
* @name packed_vector4_array_operator_index
2338
* @since 4.3
2339
*
2340
* Gets a pointer to a Vector4 in a PackedVector4Array.
2341
*
2342
* @param p_self A pointer to a PackedVector4Array object.
2343
* @param p_index The index of the Vector4 to get.
2344
*
2345
* @return A pointer to the requested Vector4.
2346
*/
2347
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector4ArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
2348
2349
/**
2350
* @name packed_vector4_array_operator_index_const
2351
* @since 4.3
2352
*
2353
* Gets a const pointer to a Vector4 in a PackedVector4Array.
2354
*
2355
* @param p_self A const pointer to a PackedVector4Array object.
2356
* @param p_index The index of the Vector4 to get.
2357
*
2358
* @return A const pointer to the requested Vector4.
2359
*/
2360
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedVector4ArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
2361
2362
/**
2363
* @name packed_color_array_operator_index
2364
* @since 4.1
2365
*
2366
* Gets a pointer to a color in a PackedColorArray.
2367
*
2368
* @param p_self A pointer to a PackedColorArray object.
2369
* @param p_index The index of the Color to get.
2370
*
2371
* @return A pointer to the requested Color.
2372
*/
2373
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
2374
2375
/**
2376
* @name packed_color_array_operator_index_const
2377
* @since 4.1
2378
*
2379
* Gets a const pointer to a color in a PackedColorArray.
2380
*
2381
* @param p_self A const pointer to a PackedColorArray object.
2382
* @param p_index The index of the Color to get.
2383
*
2384
* @return A const pointer to the requested Color.
2385
*/
2386
typedef GDExtensionTypePtr (*GDExtensionInterfacePackedColorArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
2387
2388
/**
2389
* @name array_operator_index
2390
* @since 4.1
2391
*
2392
* Gets a pointer to a Variant in an Array.
2393
*
2394
* @param p_self A pointer to an Array object.
2395
* @param p_index The index of the Variant to get.
2396
*
2397
* @return A pointer to the requested Variant.
2398
*/
2399
typedef GDExtensionVariantPtr (*GDExtensionInterfaceArrayOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionInt p_index);
2400
2401
/**
2402
* @name array_operator_index_const
2403
* @since 4.1
2404
*
2405
* Gets a const pointer to a Variant in an Array.
2406
*
2407
* @param p_self A const pointer to an Array object.
2408
* @param p_index The index of the Variant to get.
2409
*
2410
* @return A const pointer to the requested Variant.
2411
*/
2412
typedef GDExtensionVariantPtr (*GDExtensionInterfaceArrayOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index);
2413
2414
/**
2415
* @name array_ref
2416
* @since 4.1
2417
* @deprecated in Godot 4.5. use `Array::operator=` instead.
2418
*
2419
* Sets an Array to be a reference to another Array object.
2420
*
2421
* @param p_self A pointer to the Array object to update.
2422
* @param p_from A pointer to the Array object to reference.
2423
*/
2424
typedef void (*GDExtensionInterfaceArrayRef)(GDExtensionTypePtr p_self, GDExtensionConstTypePtr p_from);
2425
2426
/**
2427
* @name array_set_typed
2428
* @since 4.1
2429
*
2430
* Makes an Array into a typed Array.
2431
*
2432
* @param p_self A pointer to the Array.
2433
* @param p_type The type of Variant the Array will store.
2434
* @param p_class_name A pointer to a StringName with the name of the object (if p_type is GDEXTENSION_VARIANT_TYPE_OBJECT).
2435
* @param p_script A pointer to a Script object (if p_type is GDEXTENSION_VARIANT_TYPE_OBJECT and the base class is extended by a script).
2436
*/
2437
typedef void (*GDExtensionInterfaceArraySetTyped)(GDExtensionTypePtr p_self, GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstVariantPtr p_script);
2438
2439
/* INTERFACE: Dictionary */
2440
2441
/**
2442
* @name dictionary_operator_index
2443
* @since 4.1
2444
*
2445
* Gets a pointer to a Variant in a Dictionary with the given key.
2446
*
2447
* @param p_self A pointer to a Dictionary object.
2448
* @param p_key A pointer to a Variant representing the key.
2449
*
2450
* @return A pointer to a Variant representing the value at the given key.
2451
*/
2452
typedef GDExtensionVariantPtr (*GDExtensionInterfaceDictionaryOperatorIndex)(GDExtensionTypePtr p_self, GDExtensionConstVariantPtr p_key);
2453
2454
/**
2455
* @name dictionary_operator_index_const
2456
* @since 4.1
2457
*
2458
* Gets a const pointer to a Variant in a Dictionary with the given key.
2459
*
2460
* @param p_self A const pointer to a Dictionary object.
2461
* @param p_key A pointer to a Variant representing the key.
2462
*
2463
* @return A const pointer to a Variant representing the value at the given key.
2464
*/
2465
typedef GDExtensionVariantPtr (*GDExtensionInterfaceDictionaryOperatorIndexConst)(GDExtensionConstTypePtr p_self, GDExtensionConstVariantPtr p_key);
2466
2467
/**
2468
* @name dictionary_set_typed
2469
* @since 4.4
2470
*
2471
* Makes a Dictionary into a typed Dictionary.
2472
*
2473
* @param p_self A pointer to the Dictionary.
2474
* @param p_key_type The type of Variant the Dictionary key will store.
2475
* @param p_key_class_name A pointer to a StringName with the name of the object (if p_key_type is GDEXTENSION_VARIANT_TYPE_OBJECT).
2476
* @param p_key_script A pointer to a Script object (if p_key_type is GDEXTENSION_VARIANT_TYPE_OBJECT and the base class is extended by a script).
2477
* @param p_value_type The type of Variant the Dictionary value will store.
2478
* @param p_value_class_name A pointer to a StringName with the name of the object (if p_value_type is GDEXTENSION_VARIANT_TYPE_OBJECT).
2479
* @param p_value_script A pointer to a Script object (if p_value_type is GDEXTENSION_VARIANT_TYPE_OBJECT and the base class is extended by a script).
2480
*/
2481
typedef void (*GDExtensionInterfaceDictionarySetTyped)(GDExtensionTypePtr p_self, 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);
2482
2483
/* INTERFACE: Object */
2484
2485
/**
2486
* @name object_method_bind_call
2487
* @since 4.1
2488
*
2489
* Calls a method on an Object.
2490
*
2491
* @param p_method_bind A pointer to the MethodBind representing the method on the Object's class.
2492
* @param p_instance A pointer to the Object.
2493
* @param p_args A pointer to a C array of Variants representing the arguments.
2494
* @param p_arg_count The number of arguments.
2495
* @param r_ret A pointer to Variant which will receive the return value.
2496
* @param r_error A pointer to a GDExtensionCallError struct that will receive error information.
2497
*/
2498
typedef void (*GDExtensionInterfaceObjectMethodBindCall)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_arg_count, GDExtensionUninitializedVariantPtr r_ret, GDExtensionCallError *r_error);
2499
2500
/**
2501
* @name object_method_bind_ptrcall
2502
* @since 4.1
2503
*
2504
* Calls a method on an Object (using a "ptrcall").
2505
*
2506
* @param p_method_bind A pointer to the MethodBind representing the method on the Object's class.
2507
* @param p_instance A pointer to the Object.
2508
* @param p_args A pointer to a C array representing the arguments.
2509
* @param r_ret A pointer to the Object that will receive the return value.
2510
*/
2511
typedef void (*GDExtensionInterfaceObjectMethodBindPtrcall)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
2512
2513
/**
2514
* @name object_destroy
2515
* @since 4.1
2516
*
2517
* Destroys an Object.
2518
*
2519
* @param p_o A pointer to the Object.
2520
*/
2521
typedef void (*GDExtensionInterfaceObjectDestroy)(GDExtensionObjectPtr p_o);
2522
2523
/**
2524
* @name global_get_singleton
2525
* @since 4.1
2526
*
2527
* Gets a global singleton by name.
2528
*
2529
* @param p_name A pointer to a StringName with the singleton name.
2530
*
2531
* @return A pointer to the singleton Object.
2532
*/
2533
typedef GDExtensionObjectPtr (*GDExtensionInterfaceGlobalGetSingleton)(GDExtensionConstStringNamePtr p_name);
2534
2535
/**
2536
* @name object_get_instance_binding
2537
* @since 4.1
2538
*
2539
* Gets a pointer representing an Object's instance binding.
2540
*
2541
* @param p_o A pointer to the Object.
2542
* @param p_token A token the library received by the GDExtension's entry point function.
2543
* @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct.
2544
*
2545
* @return A pointer to the instance binding.
2546
*/
2547
typedef void *(*GDExtensionInterfaceObjectGetInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token, const GDExtensionInstanceBindingCallbacks *p_callbacks);
2548
2549
/**
2550
* @name object_set_instance_binding
2551
* @since 4.1
2552
*
2553
* Sets an Object's instance binding.
2554
*
2555
* @param p_o A pointer to the Object.
2556
* @param p_token A token the library received by the GDExtension's entry point function.
2557
* @param p_binding A pointer to the instance binding.
2558
* @param p_callbacks A pointer to a GDExtensionInstanceBindingCallbacks struct.
2559
*/
2560
typedef void (*GDExtensionInterfaceObjectSetInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token, void *p_binding, const GDExtensionInstanceBindingCallbacks *p_callbacks);
2561
2562
/**
2563
* @name object_free_instance_binding
2564
* @since 4.2
2565
*
2566
* Free an Object's instance binding.
2567
*
2568
* @param p_o A pointer to the Object.
2569
* @param p_token A token the library received by the GDExtension's entry point function.
2570
*/
2571
typedef void (*GDExtensionInterfaceObjectFreeInstanceBinding)(GDExtensionObjectPtr p_o, void *p_token);
2572
2573
/**
2574
* @name object_set_instance
2575
* @since 4.1
2576
*
2577
* Sets an extension class instance on a Object.
2578
*
2579
* `p_classname` should be a registered extension class and should extend the `p_o` Object's class.
2580
*
2581
* @param p_o A pointer to the Object.
2582
* @param p_classname A pointer to a StringName with the registered extension class's name.
2583
* @param p_instance A pointer to the extension class instance.
2584
*/
2585
typedef void (*GDExtensionInterfaceObjectSetInstance)(GDExtensionObjectPtr p_o, GDExtensionConstStringNamePtr p_classname, GDExtensionClassInstancePtr p_instance);
2586
2587
/**
2588
* @name object_get_class_name
2589
* @since 4.1
2590
*
2591
* Gets the class name of an Object.
2592
*
2593
* If the GDExtension wraps the Godot object in an abstraction specific to its class, this is the
2594
* function that should be used to determine which wrapper to use.
2595
*
2596
* @param p_object A pointer to the Object.
2597
* @param p_library A pointer the library received by the GDExtension's entry point function.
2598
* @param r_class_name A pointer to a String to receive the class name.
2599
*
2600
* @return true if successful in getting the class name; otherwise false.
2601
*/
2602
typedef GDExtensionBool (*GDExtensionInterfaceObjectGetClassName)(GDExtensionConstObjectPtr p_object, GDExtensionClassLibraryPtr p_library, GDExtensionUninitializedStringNamePtr r_class_name);
2603
2604
/**
2605
* @name object_cast_to
2606
* @since 4.1
2607
*
2608
* Casts an Object to a different type.
2609
*
2610
* @param p_object A pointer to the Object.
2611
* @param p_class_tag A pointer uniquely identifying a built-in class in the ClassDB.
2612
*
2613
* @return Returns a pointer to the Object, or NULL if it can't be cast to the requested type.
2614
*/
2615
typedef GDExtensionObjectPtr (*GDExtensionInterfaceObjectCastTo)(GDExtensionConstObjectPtr p_object, void *p_class_tag);
2616
2617
/**
2618
* @name object_get_instance_from_id
2619
* @since 4.1
2620
*
2621
* Gets an Object by its instance ID.
2622
*
2623
* @param p_instance_id The instance ID.
2624
*
2625
* @return A pointer to the Object.
2626
*/
2627
typedef GDExtensionObjectPtr (*GDExtensionInterfaceObjectGetInstanceFromId)(GDObjectInstanceID p_instance_id);
2628
2629
/**
2630
* @name object_get_instance_id
2631
* @since 4.1
2632
*
2633
* Gets the instance ID from an Object.
2634
*
2635
* @param p_object A pointer to the Object.
2636
*
2637
* @return The instance ID.
2638
*/
2639
typedef GDObjectInstanceID (*GDExtensionInterfaceObjectGetInstanceId)(GDExtensionConstObjectPtr p_object);
2640
2641
/**
2642
* @name object_has_script_method
2643
* @since 4.3
2644
*
2645
* Checks if this object has a script with the given method.
2646
*
2647
* @param p_object A pointer to the Object.
2648
* @param p_method A pointer to a StringName identifying the method.
2649
*
2650
* @return true if the object has a script and that script has a method with the given name. Returns false if the object has no script.
2651
*/
2652
typedef GDExtensionBool (*GDExtensionInterfaceObjectHasScriptMethod)(GDExtensionConstObjectPtr p_object, GDExtensionConstStringNamePtr p_method);
2653
2654
/**
2655
* @name object_call_script_method
2656
* @since 4.3
2657
*
2658
* Call the given script method on this object.
2659
*
2660
* @param p_object A pointer to the Object.
2661
* @param p_method A pointer to a StringName identifying the method.
2662
* @param p_args A pointer to a C array of Variant.
2663
* @param p_argument_count The number of arguments.
2664
* @param r_return A pointer a Variant which will be assigned the return value.
2665
* @param r_error A pointer the structure which will hold error information.
2666
*/
2667
typedef void (*GDExtensionInterfaceObjectCallScriptMethod)(GDExtensionObjectPtr p_object, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionUninitializedVariantPtr r_return, GDExtensionCallError *r_error);
2668
2669
/* INTERFACE: Reference */
2670
2671
/**
2672
* @name ref_get_object
2673
* @since 4.1
2674
*
2675
* Gets the Object from a reference.
2676
*
2677
* @param p_ref A pointer to the reference.
2678
*
2679
* @return A pointer to the Object from the reference or NULL.
2680
*/
2681
typedef GDExtensionObjectPtr (*GDExtensionInterfaceRefGetObject)(GDExtensionConstRefPtr p_ref);
2682
2683
/**
2684
* @name ref_set_object
2685
* @since 4.1
2686
*
2687
* Sets the Object referred to by a reference.
2688
*
2689
* @param p_ref A pointer to the reference.
2690
* @param p_object A pointer to the Object to refer to.
2691
*/
2692
typedef void (*GDExtensionInterfaceRefSetObject)(GDExtensionRefPtr p_ref, GDExtensionObjectPtr p_object);
2693
2694
/* INTERFACE: Script Instance */
2695
2696
/**
2697
* @name script_instance_create
2698
* @since 4.1
2699
* @deprecated in Godot 4.2. Use `script_instance_create3` instead.
2700
*
2701
* Creates a script instance that contains the given info and instance data.
2702
*
2703
* @param p_info A pointer to a GDExtensionScriptInstanceInfo struct.
2704
* @param p_instance_data A pointer to a data representing the script instance in the GDExtension. This will be passed to all the function pointers on p_info.
2705
*
2706
* @return A pointer to a ScriptInstanceExtension object.
2707
*/
2708
typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate)(const GDExtensionScriptInstanceInfo *p_info, GDExtensionScriptInstanceDataPtr p_instance_data);
2709
2710
/**
2711
* @name script_instance_create2
2712
* @since 4.2
2713
* @deprecated in Godot 4.3. Use `script_instance_create3` instead.
2714
*
2715
* Creates a script instance that contains the given info and instance data.
2716
*
2717
* @param p_info A pointer to a GDExtensionScriptInstanceInfo2 struct.
2718
* @param p_instance_data A pointer to a data representing the script instance in the GDExtension. This will be passed to all the function pointers on p_info.
2719
*
2720
* @return A pointer to a ScriptInstanceExtension object.
2721
*/
2722
typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate2)(const GDExtensionScriptInstanceInfo2 *p_info, GDExtensionScriptInstanceDataPtr p_instance_data);
2723
2724
/**
2725
* @name script_instance_create3
2726
* @since 4.3
2727
*
2728
* Creates a script instance that contains the given info and instance data.
2729
*
2730
* @param p_info A pointer to a GDExtensionScriptInstanceInfo3 struct.
2731
* @param p_instance_data A pointer to a data representing the script instance in the GDExtension. This will be passed to all the function pointers on p_info.
2732
*
2733
* @return A pointer to a ScriptInstanceExtension object.
2734
*/
2735
typedef GDExtensionScriptInstancePtr (*GDExtensionInterfaceScriptInstanceCreate3)(const GDExtensionScriptInstanceInfo3 *p_info, GDExtensionScriptInstanceDataPtr p_instance_data);
2736
2737
/**
2738
* @name placeholder_script_instance_create
2739
* @since 4.2
2740
*
2741
* Creates a placeholder script instance for a given script and instance.
2742
*
2743
* This interface is optional as a custom placeholder could also be created with script_instance_create().
2744
*
2745
* @param p_language A pointer to a ScriptLanguage.
2746
* @param p_script A pointer to a Script.
2747
* @param p_owner A pointer to an Object.
2748
*
2749
* @return A pointer to a PlaceHolderScriptInstance object.
2750
*/
2751
typedef GDExtensionScriptInstancePtr (*GDExtensionInterfacePlaceHolderScriptInstanceCreate)(GDExtensionObjectPtr p_language, GDExtensionObjectPtr p_script, GDExtensionObjectPtr p_owner);
2752
2753
/**
2754
* @name placeholder_script_instance_update
2755
* @since 4.2
2756
*
2757
* Updates a placeholder script instance with the given properties and values.
2758
*
2759
* The passed in placeholder must be an instance of PlaceHolderScriptInstance
2760
* such as the one returned by placeholder_script_instance_create().
2761
*
2762
* @param p_placeholder A pointer to a PlaceHolderScriptInstance.
2763
* @param p_properties A pointer to an Array of Dictionary representing PropertyInfo.
2764
* @param p_values A pointer to a Dictionary mapping StringName to Variant values.
2765
*/
2766
typedef void (*GDExtensionInterfacePlaceHolderScriptInstanceUpdate)(GDExtensionScriptInstancePtr p_placeholder, GDExtensionConstTypePtr p_properties, GDExtensionConstTypePtr p_values);
2767
2768
/**
2769
* @name object_get_script_instance
2770
* @since 4.2
2771
*
2772
* Get the script instance data attached to this object.
2773
*
2774
* @param p_object A pointer to the Object.
2775
* @param p_language A pointer to the language expected for this script instance.
2776
*
2777
* @return A GDExtensionScriptInstanceDataPtr that was attached to this object as part of script_instance_create.
2778
*/
2779
typedef GDExtensionScriptInstanceDataPtr (*GDExtensionInterfaceObjectGetScriptInstance)(GDExtensionConstObjectPtr p_object, GDExtensionObjectPtr p_language);
2780
2781
/**
2782
* @name object_set_script_instance
2783
* @since 4.5
2784
*
2785
* Set the script instance data attached to this object.
2786
*
2787
* @param p_object A pointer to the Object.
2788
* @param p_script_instance A pointer to the script instance data to attach to this object.
2789
*/
2790
typedef void (*GDExtensionInterfaceObjectSetScriptInstance)(GDExtensionObjectPtr p_object, GDExtensionScriptInstanceDataPtr p_script_instance);
2791
2792
/* INTERFACE: Callable */
2793
2794
/**
2795
* @name callable_custom_create
2796
* @since 4.2
2797
* @deprecated in Godot 4.3. Use `callable_custom_create2` instead.
2798
*
2799
* Creates a custom Callable object from a function pointer.
2800
*
2801
* Provided struct can be safely freed once the function returns.
2802
*
2803
* @param r_callable A pointer that will receive the new Callable.
2804
* @param p_callable_custom_info The info required to construct a Callable.
2805
*/
2806
typedef void (*GDExtensionInterfaceCallableCustomCreate)(GDExtensionUninitializedTypePtr r_callable, GDExtensionCallableCustomInfo *p_callable_custom_info);
2807
2808
/**
2809
* @name callable_custom_create2
2810
* @since 4.3
2811
*
2812
* Creates a custom Callable object from a function pointer.
2813
*
2814
* Provided struct can be safely freed once the function returns.
2815
*
2816
* @param r_callable A pointer that will receive the new Callable.
2817
* @param p_callable_custom_info The info required to construct a Callable.
2818
*/
2819
typedef void (*GDExtensionInterfaceCallableCustomCreate2)(GDExtensionUninitializedTypePtr r_callable, GDExtensionCallableCustomInfo2 *p_callable_custom_info);
2820
2821
/**
2822
* @name callable_custom_get_userdata
2823
* @since 4.2
2824
*
2825
* Retrieves the userdata pointer from a custom Callable.
2826
*
2827
* If the Callable is not a custom Callable or the token does not match the one provided to callable_custom_create() via GDExtensionCallableCustomInfo then NULL will be returned.
2828
*
2829
* @param p_callable A pointer to a Callable.
2830
* @param p_token A pointer to an address that uniquely identifies the GDExtension.
2831
*
2832
* @return The userdata pointer given when creating this custom Callable.
2833
*/
2834
typedef void *(*GDExtensionInterfaceCallableCustomGetUserData)(GDExtensionConstTypePtr p_callable, void *p_token);
2835
2836
/* INTERFACE: ClassDB */
2837
2838
/**
2839
* @name classdb_construct_object
2840
* @since 4.1
2841
* @deprecated in Godot 4.4. Use `classdb_construct_object2` instead.
2842
*
2843
* Constructs an Object of the requested class.
2844
*
2845
* The passed class must be a built-in godot class, or an already-registered extension class. In both cases, object_set_instance() should be called to fully initialize the object.
2846
*
2847
* @param p_classname A pointer to a StringName with the class name.
2848
*
2849
* @return A pointer to the newly created Object.
2850
*/
2851
typedef GDExtensionObjectPtr (*GDExtensionInterfaceClassdbConstructObject)(GDExtensionConstStringNamePtr p_classname);
2852
2853
/**
2854
* @name classdb_construct_object2
2855
* @since 4.4
2856
*
2857
* Constructs an Object of the requested class.
2858
*
2859
* The passed class must be a built-in godot class, or an already-registered extension class. In both cases, object_set_instance() should be called to fully initialize the object.
2860
*
2861
* "NOTIFICATION_POSTINITIALIZE" must be sent after construction.
2862
*
2863
* @param p_classname A pointer to a StringName with the class name.
2864
*
2865
* @return A pointer to the newly created Object.
2866
*/
2867
typedef GDExtensionObjectPtr (*GDExtensionInterfaceClassdbConstructObject2)(GDExtensionConstStringNamePtr p_classname);
2868
2869
/**
2870
* @name classdb_get_method_bind
2871
* @since 4.1
2872
*
2873
* Gets a pointer to the MethodBind in ClassDB for the given class, method and hash.
2874
*
2875
* @param p_classname A pointer to a StringName with the class name.
2876
* @param p_methodname A pointer to a StringName with the method name.
2877
* @param p_hash A hash representing the function signature.
2878
*
2879
* @return A pointer to the MethodBind from ClassDB.
2880
*/
2881
typedef GDExtensionMethodBindPtr (*GDExtensionInterfaceClassdbGetMethodBind)(GDExtensionConstStringNamePtr p_classname, GDExtensionConstStringNamePtr p_methodname, GDExtensionInt p_hash);
2882
2883
/**
2884
* @name classdb_get_class_tag
2885
* @since 4.1
2886
*
2887
* Gets a pointer uniquely identifying the given built-in class in the ClassDB.
2888
*
2889
* @param p_classname A pointer to a StringName with the class name.
2890
*
2891
* @return A pointer uniquely identifying the built-in class in the ClassDB.
2892
*/
2893
typedef void *(*GDExtensionInterfaceClassdbGetClassTag)(GDExtensionConstStringNamePtr p_classname);
2894
2895
/* INTERFACE: ClassDB Extension */
2896
2897
/**
2898
* @name classdb_register_extension_class
2899
* @since 4.1
2900
* @deprecated in Godot 4.2. Use `classdb_register_extension_class4` instead.
2901
*
2902
* Registers an extension class in the ClassDB.
2903
*
2904
* Provided struct can be safely freed once the function returns.
2905
*
2906
* @param p_library A pointer the library received by the GDExtension's entry point function.
2907
* @param p_class_name A pointer to a StringName with the class name.
2908
* @param p_parent_class_name A pointer to a StringName with the parent class name.
2909
* @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo struct.
2910
*/
2911
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo *p_extension_funcs);
2912
2913
/**
2914
* @name classdb_register_extension_class2
2915
* @since 4.2
2916
* @deprecated in Godot 4.3. Use `classdb_register_extension_class4` instead.
2917
*
2918
* Registers an extension class in the ClassDB.
2919
*
2920
* Provided struct can be safely freed once the function returns.
2921
*
2922
* @param p_library A pointer the library received by the GDExtension's entry point function.
2923
* @param p_class_name A pointer to a StringName with the class name.
2924
* @param p_parent_class_name A pointer to a StringName with the parent class name.
2925
* @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo2 struct.
2926
*/
2927
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass2)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo2 *p_extension_funcs);
2928
2929
/**
2930
* @name classdb_register_extension_class3
2931
* @since 4.3
2932
* @deprecated in Godot 4.4. Use `classdb_register_extension_class4` instead.
2933
*
2934
* Registers an extension class in the ClassDB.
2935
*
2936
* Provided struct can be safely freed once the function returns.
2937
*
2938
* @param p_library A pointer the library received by the GDExtension's entry point function.
2939
* @param p_class_name A pointer to a StringName with the class name.
2940
* @param p_parent_class_name A pointer to a StringName with the parent class name.
2941
* @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo3 struct.
2942
*/
2943
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass3)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo3 *p_extension_funcs);
2944
2945
/**
2946
* @name classdb_register_extension_class4
2947
* @since 4.4
2948
* @deprecated in Godot 4.5. Use `classdb_register_extension_class5` instead.
2949
*
2950
* Registers an extension class in the ClassDB.
2951
*
2952
* Provided struct can be safely freed once the function returns.
2953
*
2954
* @param p_library A pointer the library received by the GDExtension's entry point function.
2955
* @param p_class_name A pointer to a StringName with the class name.
2956
* @param p_parent_class_name A pointer to a StringName with the parent class name.
2957
* @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo4 struct.
2958
*/
2959
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass4)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo4 *p_extension_funcs);
2960
2961
/**
2962
* @name classdb_register_extension_class5
2963
* @since 4.5
2964
*
2965
* Registers an extension class in the ClassDB.
2966
*
2967
* Provided struct can be safely freed once the function returns.
2968
*
2969
* @param p_library A pointer the library received by the GDExtension's entry point function.
2970
* @param p_class_name A pointer to a StringName with the class name.
2971
* @param p_parent_class_name A pointer to a StringName with the parent class name.
2972
* @param p_extension_funcs A pointer to a GDExtensionClassCreationInfo5 struct.
2973
*/
2974
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClass5)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo5 *p_extension_funcs);
2975
2976
/**
2977
* @name classdb_register_extension_class_method
2978
* @since 4.1
2979
*
2980
* Registers a method on an extension class in the ClassDB.
2981
*
2982
* Provided struct can be safely freed once the function returns.
2983
*
2984
* @param p_library A pointer the library received by the GDExtension's entry point function.
2985
* @param p_class_name A pointer to a StringName with the class name.
2986
* @param p_method_info A pointer to a GDExtensionClassMethodInfo struct.
2987
*/
2988
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassMethod)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassMethodInfo *p_method_info);
2989
2990
/**
2991
* @name classdb_register_extension_class_virtual_method
2992
* @since 4.3
2993
*
2994
* Registers a virtual method on an extension class in ClassDB, that can be implemented by scripts or other extensions.
2995
*
2996
* Provided struct can be safely freed once the function returns.
2997
*
2998
* @param p_library A pointer the library received by the GDExtension's entry point function.
2999
* @param p_class_name A pointer to a StringName with the class name.
3000
* @param p_method_info A pointer to a GDExtensionClassMethodInfo struct.
3001
*/
3002
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassVirtualMethod)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassVirtualMethodInfo *p_method_info);
3003
3004
/**
3005
* @name classdb_register_extension_class_integer_constant
3006
* @since 4.1
3007
*
3008
* Registers an integer constant on an extension class in the ClassDB.
3009
*
3010
* Note about registering bitfield values (if p_is_bitfield is true): even though p_constant_value is signed, language bindings are
3011
* advised to treat bitfields as uint64_t, since this is generally clearer and can prevent mistakes like using -1 for setting all bits.
3012
* Language APIs should thus provide an abstraction that registers bitfields (uint64_t) separately from regular constants (int64_t).
3013
*
3014
* @param p_library A pointer the library received by the GDExtension's entry point function.
3015
* @param p_class_name A pointer to a StringName with the class name.
3016
* @param p_enum_name A pointer to a StringName with the enum name.
3017
* @param p_constant_name A pointer to a StringName with the constant name.
3018
* @param p_constant_value The constant value.
3019
* @param p_is_bitfield Whether or not this constant is part of a bitfield.
3020
*/
3021
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassIntegerConstant)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_enum_name, GDExtensionConstStringNamePtr p_constant_name, GDExtensionInt p_constant_value, GDExtensionBool p_is_bitfield);
3022
3023
/**
3024
* @name classdb_register_extension_class_property
3025
* @since 4.1
3026
*
3027
* Registers a property on an extension class in the ClassDB.
3028
*
3029
* Provided struct can be safely freed once the function returns.
3030
*
3031
* @param p_library A pointer the library received by the GDExtension's entry point function.
3032
* @param p_class_name A pointer to a StringName with the class name.
3033
* @param p_info A pointer to a GDExtensionPropertyInfo struct.
3034
* @param p_setter A pointer to a StringName with the name of the setter method.
3035
* @param p_getter A pointer to a StringName with the name of the getter method.
3036
*/
3037
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassProperty)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionPropertyInfo *p_info, GDExtensionConstStringNamePtr p_setter, GDExtensionConstStringNamePtr p_getter);
3038
3039
/**
3040
* @name classdb_register_extension_class_property_indexed
3041
* @since 4.2
3042
*
3043
* Registers an indexed property on an extension class in the ClassDB.
3044
*
3045
* Provided struct can be safely freed once the function returns.
3046
*
3047
* @param p_library A pointer the library received by the GDExtension's entry point function.
3048
* @param p_class_name A pointer to a StringName with the class name.
3049
* @param p_info A pointer to a GDExtensionPropertyInfo struct.
3050
* @param p_setter A pointer to a StringName with the name of the setter method.
3051
* @param p_getter A pointer to a StringName with the name of the getter method.
3052
* @param p_index The index to pass as the first argument to the getter and setter methods.
3053
*/
3054
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertyIndexed)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionPropertyInfo *p_info, GDExtensionConstStringNamePtr p_setter, GDExtensionConstStringNamePtr p_getter, GDExtensionInt p_index);
3055
3056
/**
3057
* @name classdb_register_extension_class_property_group
3058
* @since 4.1
3059
*
3060
* Registers a property group on an extension class in the ClassDB.
3061
*
3062
* @param p_library A pointer the library received by the GDExtension's entry point function.
3063
* @param p_class_name A pointer to a StringName with the class name.
3064
* @param p_group_name A pointer to a String with the group name.
3065
* @param p_prefix A pointer to a String with the prefix used by properties in this group.
3066
*/
3067
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertyGroup)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_group_name, GDExtensionConstStringPtr p_prefix);
3068
3069
/**
3070
* @name classdb_register_extension_class_property_subgroup
3071
* @since 4.1
3072
*
3073
* Registers a property subgroup on an extension class in the ClassDB.
3074
*
3075
* @param p_library A pointer the library received by the GDExtension's entry point function.
3076
* @param p_class_name A pointer to a StringName with the class name.
3077
* @param p_subgroup_name A pointer to a String with the subgroup name.
3078
* @param p_prefix A pointer to a String with the prefix used by properties in this subgroup.
3079
*/
3080
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassPropertySubgroup)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_subgroup_name, GDExtensionConstStringPtr p_prefix);
3081
3082
/**
3083
* @name classdb_register_extension_class_signal
3084
* @since 4.1
3085
*
3086
* Registers a signal on an extension class in the ClassDB.
3087
*
3088
* Provided structs can be safely freed once the function returns.
3089
*
3090
* @param p_library A pointer the library received by the GDExtension's entry point function.
3091
* @param p_class_name A pointer to a StringName with the class name.
3092
* @param p_signal_name A pointer to a StringName with the signal name.
3093
* @param p_argument_info A pointer to a GDExtensionPropertyInfo struct.
3094
* @param p_argument_count The number of arguments the signal receives.
3095
*/
3096
typedef void (*GDExtensionInterfaceClassdbRegisterExtensionClassSignal)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_signal_name, const GDExtensionPropertyInfo *p_argument_info, GDExtensionInt p_argument_count);
3097
3098
/**
3099
* @name classdb_unregister_extension_class
3100
* @since 4.1
3101
*
3102
* Unregisters an extension class in the ClassDB.
3103
*
3104
* Unregistering a parent class before a class that inherits it will result in failure. Inheritors must be unregistered first.
3105
*
3106
* @param p_library A pointer the library received by the GDExtension's entry point function.
3107
* @param p_class_name A pointer to a StringName with the class name.
3108
*/
3109
typedef void (*GDExtensionInterfaceClassdbUnregisterExtensionClass)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name);
3110
3111
/**
3112
* @name get_library_path
3113
* @since 4.1
3114
*
3115
* Gets the path to the current GDExtension library.
3116
*
3117
* @param p_library A pointer the library received by the GDExtension's entry point function.
3118
* @param r_path A pointer to a String which will receive the path.
3119
*/
3120
typedef void (*GDExtensionInterfaceGetLibraryPath)(GDExtensionClassLibraryPtr p_library, GDExtensionUninitializedStringPtr r_path);
3121
3122
/**
3123
* @name editor_add_plugin
3124
* @since 4.1
3125
*
3126
* Adds an editor plugin.
3127
*
3128
* It's safe to call during initialization.
3129
*
3130
* @param p_class_name A pointer to a StringName with the name of a class (descending from EditorPlugin) which is already registered with ClassDB.
3131
*/
3132
typedef void (*GDExtensionInterfaceEditorAddPlugin)(GDExtensionConstStringNamePtr p_class_name);
3133
3134
/**
3135
* @name editor_remove_plugin
3136
* @since 4.1
3137
*
3138
* Removes an editor plugin.
3139
*
3140
* @param p_class_name A pointer to a StringName with the name of a class that was previously added as an editor plugin.
3141
*/
3142
typedef void (*GDExtensionInterfaceEditorRemovePlugin)(GDExtensionConstStringNamePtr p_class_name);
3143
3144
/**
3145
* @name editor_help_load_xml_from_utf8_chars
3146
* @since 4.3
3147
*
3148
* Loads new XML-formatted documentation data in the editor.
3149
*
3150
* The provided pointer can be immediately freed once the function returns.
3151
*
3152
* @param p_data A pointer to a UTF-8 encoded C string (null terminated).
3153
*/
3154
typedef void (*GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8Chars)(const char *p_data);
3155
3156
/**
3157
* @name editor_help_load_xml_from_utf8_chars_and_len
3158
* @since 4.3
3159
*
3160
* Loads new XML-formatted documentation data in the editor.
3161
*
3162
* The provided pointer can be immediately freed once the function returns.
3163
*
3164
* @param p_data A pointer to a UTF-8 encoded C string.
3165
* @param p_size The number of bytes (not code units).
3166
*/
3167
typedef void (*GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8CharsAndLen)(const char *p_data, GDExtensionInt p_size);
3168
3169
/**
3170
* @name editor_register_get_classes_used_callback
3171
* @since 4.5
3172
*
3173
* Registers a callback that Godot can call to get the list of all classes (from ClassDB) that may be used by the calling GDExtension.
3174
*
3175
* This is used by the editor to generate a build profile (in "Tools" > "Engine Compilation Configuration Editor..." > "Detect from project"),
3176
* in order to recompile Godot with only the classes used.
3177
* In the provided callback, the GDExtension should provide the list of classes that _may_ be used statically, thus the time of invocation shouldn't matter.
3178
* If a GDExtension doesn't register a callback, Godot will assume that it could be using any classes.
3179
*
3180
* @param p_library A pointer the library received by the GDExtension's entry point function.
3181
* @param p_callback The callback to retrieve the list of classes used.
3182
*/
3183
typedef void (*GDExtensionInterfaceEditorRegisterGetClassesUsedCallback)(GDExtensionClassLibraryPtr p_library, GDExtensionEditorGetClassesUsedCallback p_callback);
3184
3185
/**
3186
* @name register_main_loop_callbacks
3187
* @since 4.5
3188
*
3189
* Registers callbacks to be called at different phases of the main loop.
3190
*
3191
* @param p_library A pointer the library received by the GDExtension's entry point function.
3192
* @param p_callbacks A pointer to the structure that contains the callbacks.
3193
*/
3194
typedef void (*GDExtensionInterfaceRegisterMainLoopCallbacks)(GDExtensionClassLibraryPtr p_library, const GDExtensionMainLoopCallbacks *p_callbacks);
3195
3196
#ifdef __cplusplus
3197
}
3198
#endif
3199
3200