Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/core/extension/extension_api_dump.cpp
9903 views
1
/**************************************************************************/
2
/* extension_api_dump.cpp */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#include "extension_api_dump.h"
32
33
#include "core/config/engine.h"
34
#include "core/core_constants.h"
35
#include "core/extension/gdextension_special_compat_hashes.h"
36
#include "core/io/file_access.h"
37
#include "core/io/json.h"
38
#include "core/templates/pair.h"
39
#include "core/version.h"
40
41
#ifdef TOOLS_ENABLED
42
#include "editor/doc/editor_help.h"
43
44
static String get_builtin_or_variant_type_name(const Variant::Type p_type) {
45
if (p_type == Variant::NIL) {
46
return "Variant";
47
} else {
48
return Variant::get_type_name(p_type);
49
}
50
}
51
52
static String get_property_info_type_name(const PropertyInfo &p_info) {
53
if (p_info.type == Variant::INT && (p_info.hint == PROPERTY_HINT_INT_IS_POINTER)) {
54
if (p_info.hint_string.is_empty()) {
55
return "void*";
56
} else {
57
return p_info.hint_string + "*";
58
}
59
}
60
if (p_info.type == Variant::ARRAY && (p_info.hint == PROPERTY_HINT_ARRAY_TYPE)) {
61
return String("typedarray::") + p_info.hint_string;
62
}
63
if (p_info.type == Variant::DICTIONARY && (p_info.hint == PROPERTY_HINT_DICTIONARY_TYPE)) {
64
return String("typeddictionary::") + p_info.hint_string;
65
}
66
if (p_info.type == Variant::INT && (p_info.usage & (PROPERTY_USAGE_CLASS_IS_ENUM))) {
67
return String("enum::") + String(p_info.class_name);
68
}
69
if (p_info.type == Variant::INT && (p_info.usage & (PROPERTY_USAGE_CLASS_IS_BITFIELD))) {
70
return String("bitfield::") + String(p_info.class_name);
71
}
72
if (p_info.type == Variant::INT && (p_info.usage & PROPERTY_USAGE_ARRAY)) {
73
return "int";
74
}
75
if (p_info.class_name != StringName()) {
76
return p_info.class_name;
77
}
78
if (p_info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
79
return p_info.hint_string;
80
}
81
if (p_info.type == Variant::NIL && (p_info.usage & PROPERTY_USAGE_NIL_IS_VARIANT)) {
82
return "Variant";
83
}
84
if (p_info.type == Variant::NIL) {
85
return "void";
86
}
87
return get_builtin_or_variant_type_name(p_info.type);
88
}
89
90
static String get_type_meta_name(const GodotTypeInfo::Metadata metadata) {
91
static const char *argmeta[13] = { "none", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64", "float", "double", "char16", "char32" };
92
return argmeta[metadata];
93
}
94
95
static String fix_doc_description(const String &p_bbcode) {
96
// Based on what EditorHelp does.
97
98
return p_bbcode.dedent()
99
.remove_chars("\t\r")
100
.strip_edges();
101
}
102
103
Dictionary GDExtensionAPIDump::generate_extension_api(bool p_include_docs) {
104
Dictionary api_dump;
105
106
{
107
//header
108
Dictionary header;
109
header["version_major"] = GODOT_VERSION_MAJOR;
110
header["version_minor"] = GODOT_VERSION_MINOR;
111
#if GODOT_VERSION_PATCH
112
header["version_patch"] = GODOT_VERSION_PATCH;
113
#else
114
header["version_patch"] = 0;
115
#endif
116
header["version_status"] = GODOT_VERSION_STATUS;
117
header["version_build"] = GODOT_VERSION_BUILD;
118
header["version_full_name"] = GODOT_VERSION_FULL_NAME;
119
120
#if REAL_T_IS_DOUBLE
121
header["precision"] = "double";
122
#else
123
header["precision"] = "single";
124
#endif
125
126
api_dump["header"] = header;
127
}
128
129
const uint32_t vec3_elems = 3;
130
const uint32_t vec4_elems = 4;
131
const uint32_t ptrsize_32 = 4;
132
const uint32_t ptrsize_64 = 8;
133
static const char *build_config_name[4] = { "float_32", "float_64", "double_32", "double_64" };
134
135
{
136
//type sizes
137
constexpr struct {
138
Variant::Type type;
139
uint32_t size_32_bits_real_float;
140
uint32_t size_64_bits_real_float;
141
uint32_t size_32_bits_real_double;
142
uint32_t size_64_bits_real_double;
143
144
// For compile-time size check.
145
constexpr uint32_t operator[](int index) const {
146
switch (index) {
147
#ifndef REAL_T_IS_DOUBLE
148
case sizeof(uint32_t):
149
return size_32_bits_real_float;
150
case sizeof(uint64_t):
151
return size_64_bits_real_float;
152
#else // REAL_T_IS_DOUBLE
153
case sizeof(uint32_t):
154
return size_32_bits_real_double;
155
case sizeof(uint64_t):
156
return size_64_bits_real_double;
157
#endif
158
}
159
return -1;
160
}
161
} type_size_array[Variant::VARIANT_MAX + 1] = {
162
{ Variant::NIL, 0, 0, 0, 0 },
163
{ Variant::BOOL, sizeof(uint8_t), sizeof(uint8_t), sizeof(uint8_t), sizeof(uint8_t) },
164
{ Variant::INT, sizeof(int64_t), sizeof(int64_t), sizeof(int64_t), sizeof(int64_t) },
165
{ Variant::FLOAT, sizeof(double), sizeof(double), sizeof(double), sizeof(double) },
166
{ Variant::STRING, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
167
{ Variant::VECTOR2, 2 * sizeof(float), 2 * sizeof(float), 2 * sizeof(double), 2 * sizeof(double) },
168
{ Variant::VECTOR2I, 2 * sizeof(int32_t), 2 * sizeof(int32_t), 2 * sizeof(int32_t), 2 * sizeof(int32_t) },
169
{ Variant::RECT2, 4 * sizeof(float), 4 * sizeof(float), 4 * sizeof(double), 4 * sizeof(double) },
170
{ Variant::RECT2I, 4 * sizeof(int32_t), 4 * sizeof(int32_t), 4 * sizeof(int32_t), 4 * sizeof(int32_t) },
171
{ Variant::VECTOR3, vec3_elems * sizeof(float), vec3_elems * sizeof(float), vec3_elems * sizeof(double), vec3_elems * sizeof(double) },
172
{ Variant::VECTOR3I, 3 * sizeof(int32_t), 3 * sizeof(int32_t), 3 * sizeof(int32_t), 3 * sizeof(int32_t) },
173
{ Variant::TRANSFORM2D, 6 * sizeof(float), 6 * sizeof(float), 6 * sizeof(double), 6 * sizeof(double) },
174
{ Variant::VECTOR4, 4 * sizeof(float), 4 * sizeof(float), 4 * sizeof(double), 4 * sizeof(double) },
175
{ Variant::VECTOR4I, 4 * sizeof(int32_t), 4 * sizeof(int32_t), 4 * sizeof(int32_t), 4 * sizeof(int32_t) },
176
{ Variant::PLANE, (vec3_elems + 1) * sizeof(float), (vec3_elems + 1) * sizeof(float), (vec3_elems + 1) * sizeof(double), (vec3_elems + 1) * sizeof(double) },
177
{ Variant::QUATERNION, 4 * sizeof(float), 4 * sizeof(float), 4 * sizeof(double), 4 * sizeof(double) },
178
{ Variant::AABB, (vec3_elems * 2) * sizeof(float), (vec3_elems * 2) * sizeof(float), (vec3_elems * 2) * sizeof(double), (vec3_elems * 2) * sizeof(double) },
179
{ Variant::BASIS, (vec3_elems * 3) * sizeof(float), (vec3_elems * 3) * sizeof(float), (vec3_elems * 3) * sizeof(double), (vec3_elems * 3) * sizeof(double) },
180
{ Variant::TRANSFORM3D, (vec3_elems * 4) * sizeof(float), (vec3_elems * 4) * sizeof(float), (vec3_elems * 4) * sizeof(double), (vec3_elems * 4) * sizeof(double) },
181
{ Variant::PROJECTION, (vec4_elems * 4) * sizeof(float), (vec4_elems * 4) * sizeof(float), (vec4_elems * 4) * sizeof(double), (vec4_elems * 4) * sizeof(double) },
182
{ Variant::COLOR, 4 * sizeof(float), 4 * sizeof(float), 4 * sizeof(float), 4 * sizeof(float) },
183
{ Variant::STRING_NAME, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
184
{ Variant::NODE_PATH, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
185
{ Variant::RID, sizeof(uint64_t), sizeof(uint64_t), sizeof(uint64_t), sizeof(uint64_t) },
186
{ Variant::OBJECT, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
187
{ Variant::CALLABLE, sizeof(Callable), sizeof(Callable), sizeof(Callable), sizeof(Callable) }, // Hardcoded align.
188
{ Variant::SIGNAL, sizeof(Signal), sizeof(Signal), sizeof(Signal), sizeof(Signal) }, // Hardcoded align.
189
{ Variant::DICTIONARY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
190
{ Variant::ARRAY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
191
{ Variant::PACKED_BYTE_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
192
{ Variant::PACKED_INT32_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
193
{ Variant::PACKED_INT64_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
194
{ Variant::PACKED_FLOAT32_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
195
{ Variant::PACKED_FLOAT64_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
196
{ Variant::PACKED_STRING_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
197
{ Variant::PACKED_VECTOR2_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
198
{ Variant::PACKED_VECTOR3_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
199
{ Variant::PACKED_COLOR_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
200
{ Variant::PACKED_VECTOR4_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
201
{ Variant::VARIANT_MAX, sizeof(uint64_t) + sizeof(float) * 4, sizeof(uint64_t) + sizeof(float) * 4, sizeof(uint64_t) + sizeof(double) * 4, sizeof(uint64_t) + sizeof(double) * 4 },
202
};
203
204
// Validate sizes at compile time for the current build configuration.
205
static_assert(type_size_array[Variant::BOOL][sizeof(void *)] == sizeof(GDExtensionBool), "Size of bool mismatch");
206
static_assert(type_size_array[Variant::INT][sizeof(void *)] == sizeof(GDExtensionInt), "Size of int mismatch");
207
static_assert(type_size_array[Variant::FLOAT][sizeof(void *)] == sizeof(double), "Size of float mismatch");
208
static_assert(type_size_array[Variant::STRING][sizeof(void *)] == sizeof(String), "Size of String mismatch");
209
static_assert(type_size_array[Variant::VECTOR2][sizeof(void *)] == sizeof(Vector2), "Size of Vector2 mismatch");
210
static_assert(type_size_array[Variant::VECTOR2I][sizeof(void *)] == sizeof(Vector2i), "Size of Vector2i mismatch");
211
static_assert(type_size_array[Variant::RECT2][sizeof(void *)] == sizeof(Rect2), "Size of Rect2 mismatch");
212
static_assert(type_size_array[Variant::RECT2I][sizeof(void *)] == sizeof(Rect2i), "Size of Rect2i mismatch");
213
static_assert(type_size_array[Variant::VECTOR3][sizeof(void *)] == sizeof(Vector3), "Size of Vector3 mismatch");
214
static_assert(type_size_array[Variant::VECTOR3I][sizeof(void *)] == sizeof(Vector3i), "Size of Vector3i mismatch");
215
static_assert(type_size_array[Variant::TRANSFORM2D][sizeof(void *)] == sizeof(Transform2D), "Size of Transform2D mismatch");
216
static_assert(type_size_array[Variant::VECTOR4][sizeof(void *)] == sizeof(Vector4), "Size of Vector4 mismatch");
217
static_assert(type_size_array[Variant::VECTOR4I][sizeof(void *)] == sizeof(Vector4i), "Size of Vector4i mismatch");
218
static_assert(type_size_array[Variant::PLANE][sizeof(void *)] == sizeof(Plane), "Size of Plane mismatch");
219
static_assert(type_size_array[Variant::QUATERNION][sizeof(void *)] == sizeof(Quaternion), "Size of Quaternion mismatch");
220
static_assert(type_size_array[Variant::AABB][sizeof(void *)] == sizeof(AABB), "Size of AABB mismatch");
221
static_assert(type_size_array[Variant::BASIS][sizeof(void *)] == sizeof(Basis), "Size of Basis mismatch");
222
static_assert(type_size_array[Variant::TRANSFORM3D][sizeof(void *)] == sizeof(Transform3D), "Size of Transform3D mismatch");
223
static_assert(type_size_array[Variant::PROJECTION][sizeof(void *)] == sizeof(Projection), "Size of Projection mismatch");
224
static_assert(type_size_array[Variant::COLOR][sizeof(void *)] == sizeof(Color), "Size of Color mismatch");
225
static_assert(type_size_array[Variant::STRING_NAME][sizeof(void *)] == sizeof(StringName), "Size of StringName mismatch");
226
static_assert(type_size_array[Variant::NODE_PATH][sizeof(void *)] == sizeof(NodePath), "Size of NodePath mismatch");
227
static_assert(type_size_array[Variant::RID][sizeof(void *)] == sizeof(RID), "Size of RID mismatch");
228
static_assert(type_size_array[Variant::OBJECT][sizeof(void *)] == sizeof(Object *), "Size of Object mismatch");
229
static_assert(type_size_array[Variant::CALLABLE][sizeof(void *)] == sizeof(Callable), "Size of Callable mismatch");
230
static_assert(type_size_array[Variant::SIGNAL][sizeof(void *)] == sizeof(Signal), "Size of Signal mismatch");
231
static_assert(type_size_array[Variant::DICTIONARY][sizeof(void *)] == sizeof(Dictionary), "Size of Dictionary mismatch");
232
static_assert(type_size_array[Variant::ARRAY][sizeof(void *)] == sizeof(Array), "Size of Array mismatch");
233
static_assert(type_size_array[Variant::PACKED_BYTE_ARRAY][sizeof(void *)] == sizeof(PackedByteArray), "Size of PackedByteArray mismatch");
234
static_assert(type_size_array[Variant::PACKED_INT32_ARRAY][sizeof(void *)] == sizeof(PackedInt32Array), "Size of PackedInt32Array mismatch");
235
static_assert(type_size_array[Variant::PACKED_INT64_ARRAY][sizeof(void *)] == sizeof(PackedInt64Array), "Size of PackedInt64Array mismatch");
236
static_assert(type_size_array[Variant::PACKED_FLOAT32_ARRAY][sizeof(void *)] == sizeof(PackedFloat32Array), "Size of PackedFloat32Array mismatch");
237
static_assert(type_size_array[Variant::PACKED_FLOAT64_ARRAY][sizeof(void *)] == sizeof(PackedFloat64Array), "Size of PackedFloat64Array mismatch");
238
static_assert(type_size_array[Variant::PACKED_STRING_ARRAY][sizeof(void *)] == sizeof(PackedStringArray), "Size of PackedStringArray mismatch");
239
static_assert(type_size_array[Variant::PACKED_VECTOR2_ARRAY][sizeof(void *)] == sizeof(PackedVector2Array), "Size of PackedVector2Array mismatch");
240
static_assert(type_size_array[Variant::PACKED_VECTOR3_ARRAY][sizeof(void *)] == sizeof(PackedVector3Array), "Size of PackedVector3Array mismatch");
241
static_assert(type_size_array[Variant::PACKED_COLOR_ARRAY][sizeof(void *)] == sizeof(PackedColorArray), "Size of PackedColorArray mismatch");
242
static_assert(type_size_array[Variant::PACKED_VECTOR4_ARRAY][sizeof(void *)] == sizeof(PackedVector4Array), "Size of PackedVector4Array mismatch");
243
static_assert(type_size_array[Variant::VARIANT_MAX][sizeof(void *)] == sizeof(Variant), "Size of Variant mismatch");
244
245
Array core_type_sizes;
246
247
for (int i = 0; i < 4; i++) {
248
Dictionary d;
249
d["build_configuration"] = build_config_name[i];
250
Array sizes;
251
for (int j = 0; j <= Variant::VARIANT_MAX; j++) {
252
Variant::Type t = type_size_array[j].type;
253
String name = t == Variant::VARIANT_MAX ? String("Variant") : Variant::get_type_name(t);
254
Dictionary d2;
255
d2["name"] = name;
256
uint32_t size = 0;
257
switch (i) {
258
case 0:
259
size = type_size_array[j].size_32_bits_real_float;
260
break;
261
case 1:
262
size = type_size_array[j].size_64_bits_real_float;
263
break;
264
case 2:
265
size = type_size_array[j].size_32_bits_real_double;
266
break;
267
case 3:
268
size = type_size_array[j].size_64_bits_real_double;
269
break;
270
}
271
d2["size"] = size;
272
sizes.push_back(d2);
273
}
274
d["sizes"] = sizes;
275
core_type_sizes.push_back(d);
276
}
277
api_dump["builtin_class_sizes"] = core_type_sizes;
278
}
279
280
{
281
// Member offsets, meta types and sizes.
282
283
#define REAL_MEMBER_OFFSET(type, member) \
284
{ \
285
type, \
286
member, \
287
"float", \
288
sizeof(float), \
289
"float", \
290
sizeof(float), \
291
"double", \
292
sizeof(double), \
293
"double", \
294
sizeof(double), \
295
}
296
297
#define INT32_MEMBER_OFFSET(type, member) \
298
{ \
299
type, \
300
member, \
301
"int32", \
302
sizeof(int32_t), \
303
"int32", \
304
sizeof(int32_t), \
305
"int32", \
306
sizeof(int32_t), \
307
"int32", \
308
sizeof(int32_t), \
309
}
310
311
#define INT32_BASED_BUILTIN_MEMBER_OFFSET(type, member, member_type, member_elems) \
312
{ \
313
type, \
314
member, \
315
member_type, \
316
sizeof(int32_t) * member_elems, \
317
member_type, \
318
sizeof(int32_t) * member_elems, \
319
member_type, \
320
sizeof(int32_t) * member_elems, \
321
member_type, \
322
sizeof(int32_t) * member_elems, \
323
}
324
325
#define REAL_BASED_BUILTIN_MEMBER_OFFSET(type, member, member_type, member_elems) \
326
{ \
327
type, \
328
member, \
329
member_type, \
330
sizeof(float) * member_elems, \
331
member_type, \
332
sizeof(float) * member_elems, \
333
member_type, \
334
sizeof(double) * member_elems, \
335
member_type, \
336
sizeof(double) * member_elems, \
337
}
338
339
struct {
340
Variant::Type type;
341
const char *member;
342
const char *member_meta_32_bits_real_float;
343
const uint32_t member_size_32_bits_real_float;
344
const char *member_meta_64_bits_real_float;
345
const uint32_t member_size_64_bits_real_float;
346
const char *member_meta_32_bits_real_double;
347
const uint32_t member_size_32_bits_real_double;
348
const char *member_meta_64_bits_real_double;
349
const uint32_t member_size_64_bits_real_double;
350
} member_offset_array[] = {
351
// Vector2
352
REAL_MEMBER_OFFSET(Variant::VECTOR2, "x"),
353
REAL_MEMBER_OFFSET(Variant::VECTOR2, "y"),
354
// Vector2i
355
INT32_MEMBER_OFFSET(Variant::VECTOR2I, "x"),
356
INT32_MEMBER_OFFSET(Variant::VECTOR2I, "y"),
357
// Rect2
358
REAL_BASED_BUILTIN_MEMBER_OFFSET(Variant::RECT2, "position", "Vector2", 2),
359
REAL_BASED_BUILTIN_MEMBER_OFFSET(Variant::RECT2, "size", "Vector2", 2),
360
// Rect2i
361
INT32_BASED_BUILTIN_MEMBER_OFFSET(Variant::RECT2I, "position", "Vector2i", 2),
362
INT32_BASED_BUILTIN_MEMBER_OFFSET(Variant::RECT2I, "size", "Vector2i", 2),
363
// Vector3
364
REAL_MEMBER_OFFSET(Variant::VECTOR3, "x"),
365
REAL_MEMBER_OFFSET(Variant::VECTOR3, "y"),
366
REAL_MEMBER_OFFSET(Variant::VECTOR3, "z"),
367
// Vector3i
368
INT32_MEMBER_OFFSET(Variant::VECTOR3I, "x"),
369
INT32_MEMBER_OFFSET(Variant::VECTOR3I, "y"),
370
INT32_MEMBER_OFFSET(Variant::VECTOR3I, "z"),
371
// Transform2D
372
REAL_BASED_BUILTIN_MEMBER_OFFSET(Variant::TRANSFORM2D, "x", "Vector2", 2),
373
REAL_BASED_BUILTIN_MEMBER_OFFSET(Variant::TRANSFORM2D, "y", "Vector2", 2),
374
REAL_BASED_BUILTIN_MEMBER_OFFSET(Variant::TRANSFORM2D, "origin", "Vector2", 2),
375
// Vector4
376
REAL_MEMBER_OFFSET(Variant::VECTOR4, "x"),
377
REAL_MEMBER_OFFSET(Variant::VECTOR4, "y"),
378
REAL_MEMBER_OFFSET(Variant::VECTOR4, "z"),
379
REAL_MEMBER_OFFSET(Variant::VECTOR4, "w"),
380
// Vector4i
381
INT32_MEMBER_OFFSET(Variant::VECTOR4I, "x"),
382
INT32_MEMBER_OFFSET(Variant::VECTOR4I, "y"),
383
INT32_MEMBER_OFFSET(Variant::VECTOR4I, "z"),
384
INT32_MEMBER_OFFSET(Variant::VECTOR4I, "w"),
385
// Plane
386
REAL_BASED_BUILTIN_MEMBER_OFFSET(Variant::PLANE, "normal", "Vector3", vec3_elems),
387
REAL_MEMBER_OFFSET(Variant::PLANE, "d"),
388
// Quaternion
389
REAL_MEMBER_OFFSET(Variant::QUATERNION, "x"),
390
REAL_MEMBER_OFFSET(Variant::QUATERNION, "y"),
391
REAL_MEMBER_OFFSET(Variant::QUATERNION, "z"),
392
REAL_MEMBER_OFFSET(Variant::QUATERNION, "w"),
393
// AABB
394
REAL_BASED_BUILTIN_MEMBER_OFFSET(Variant::AABB, "position", "Vector3", vec3_elems),
395
REAL_BASED_BUILTIN_MEMBER_OFFSET(Variant::AABB, "size", "Vector3", vec3_elems),
396
// Basis (remember that basis vectors are flipped!)
397
REAL_BASED_BUILTIN_MEMBER_OFFSET(Variant::BASIS, "x", "Vector3", vec3_elems),
398
REAL_BASED_BUILTIN_MEMBER_OFFSET(Variant::BASIS, "y", "Vector3", vec3_elems),
399
REAL_BASED_BUILTIN_MEMBER_OFFSET(Variant::BASIS, "z", "Vector3", vec3_elems),
400
// Transform3D
401
REAL_BASED_BUILTIN_MEMBER_OFFSET(Variant::TRANSFORM3D, "basis", "Basis", vec3_elems * 3),
402
REAL_BASED_BUILTIN_MEMBER_OFFSET(Variant::TRANSFORM3D, "origin", "Vector3", vec3_elems),
403
// Projection
404
REAL_BASED_BUILTIN_MEMBER_OFFSET(Variant::PROJECTION, "x", "Vector4", vec4_elems),
405
REAL_BASED_BUILTIN_MEMBER_OFFSET(Variant::PROJECTION, "y", "Vector4", vec4_elems),
406
REAL_BASED_BUILTIN_MEMBER_OFFSET(Variant::PROJECTION, "z", "Vector4", vec4_elems),
407
REAL_BASED_BUILTIN_MEMBER_OFFSET(Variant::PROJECTION, "w", "Vector4", vec4_elems),
408
// Color (always composed of 4bytes floats)
409
{ Variant::COLOR, "r", "float", sizeof(float), "float", sizeof(float), "float", sizeof(float), "float", sizeof(float) },
410
{ Variant::COLOR, "g", "float", sizeof(float), "float", sizeof(float), "float", sizeof(float), "float", sizeof(float) },
411
{ Variant::COLOR, "b", "float", sizeof(float), "float", sizeof(float), "float", sizeof(float), "float", sizeof(float) },
412
{ Variant::COLOR, "a", "float", sizeof(float), "float", sizeof(float), "float", sizeof(float), "float", sizeof(float) },
413
// End marker, must stay last
414
{ Variant::NIL, nullptr, nullptr, 0, nullptr, 0, nullptr, 0, nullptr, 0 },
415
};
416
417
Array core_type_member_offsets;
418
419
for (int i = 0; i < 4; i++) {
420
Dictionary d;
421
d["build_configuration"] = build_config_name[i];
422
Array type_offsets;
423
uint32_t idx = 0;
424
425
Variant::Type previous_type = Variant::NIL;
426
427
Dictionary d2;
428
Array members;
429
uint32_t offset = 0;
430
431
while (true) {
432
Variant::Type t = member_offset_array[idx].type;
433
if (t != previous_type) {
434
if (previous_type != Variant::NIL) {
435
d2["members"] = members;
436
type_offsets.push_back(d2);
437
}
438
if (t == Variant::NIL) {
439
break;
440
}
441
442
String name = t == Variant::VARIANT_MAX ? String("Variant") : Variant::get_type_name(t);
443
d2 = Dictionary();
444
members = Array();
445
offset = 0;
446
d2["name"] = name;
447
previous_type = t;
448
}
449
Dictionary d3;
450
const char *member_meta = nullptr;
451
uint32_t member_size = 0;
452
switch (i) {
453
case 0:
454
member_meta = member_offset_array[idx].member_meta_32_bits_real_float;
455
member_size = member_offset_array[idx].member_size_32_bits_real_float;
456
break;
457
case 1:
458
member_meta = member_offset_array[idx].member_meta_64_bits_real_float;
459
member_size = member_offset_array[idx].member_size_64_bits_real_float;
460
break;
461
case 2:
462
member_meta = member_offset_array[idx].member_meta_32_bits_real_double;
463
member_size = member_offset_array[idx].member_size_32_bits_real_double;
464
break;
465
case 3:
466
member_meta = member_offset_array[idx].member_meta_64_bits_real_double;
467
member_size = member_offset_array[idx].member_size_64_bits_real_double;
468
break;
469
}
470
d3["member"] = member_offset_array[idx].member;
471
d3["offset"] = offset;
472
d3["meta"] = member_meta;
473
offset += member_size;
474
members.push_back(d3);
475
idx++;
476
}
477
d["classes"] = type_offsets;
478
core_type_member_offsets.push_back(d);
479
}
480
api_dump["builtin_class_member_offsets"] = core_type_member_offsets;
481
}
482
483
if (p_include_docs) {
484
EditorHelp::generate_doc(false);
485
}
486
487
{
488
// Global enums and constants.
489
Array constants;
490
HashMap<String, List<Pair<String, int64_t>>> enum_list;
491
HashMap<String, bool> enum_is_bitfield;
492
493
const DocData::ClassDoc *global_scope_doc = nullptr;
494
if (p_include_docs) {
495
global_scope_doc = EditorHelp::get_doc_data()->class_list.getptr("@GlobalScope");
496
CRASH_COND_MSG(!global_scope_doc, "Could not find '@GlobalScope' in DocData.");
497
}
498
499
for (int i = 0; i < CoreConstants::get_global_constant_count(); i++) {
500
int64_t value = CoreConstants::get_global_constant_value(i);
501
String enum_name = CoreConstants::get_global_constant_enum(i);
502
String name = CoreConstants::get_global_constant_name(i);
503
bool bitfield = CoreConstants::is_global_constant_bitfield(i);
504
if (!enum_name.is_empty()) {
505
enum_list[enum_name].push_back(Pair<String, int64_t>(name, value));
506
enum_is_bitfield[enum_name] = bitfield;
507
} else {
508
Dictionary d;
509
d["name"] = name;
510
d["value"] = value;
511
d["is_bitfield"] = bitfield;
512
if (p_include_docs) {
513
for (const DocData::ConstantDoc &constant_doc : global_scope_doc->constants) {
514
if (constant_doc.name == name) {
515
d["description"] = fix_doc_description(constant_doc.description);
516
break;
517
}
518
}
519
}
520
constants.push_back(d);
521
}
522
}
523
524
api_dump["global_constants"] = constants;
525
526
Array enums;
527
for (const KeyValue<String, List<Pair<String, int64_t>>> &E : enum_list) {
528
Dictionary d1;
529
d1["name"] = E.key;
530
d1["is_bitfield"] = enum_is_bitfield[E.key];
531
if (p_include_docs) {
532
const DocData::EnumDoc *enum_doc = global_scope_doc->enums.getptr(E.key);
533
if (enum_doc) {
534
d1["description"] = fix_doc_description(enum_doc->description);
535
}
536
}
537
Array values;
538
for (const Pair<String, int64_t> &F : E.value) {
539
Dictionary d2;
540
d2["name"] = F.first;
541
d2["value"] = F.second;
542
if (p_include_docs) {
543
for (const DocData::ConstantDoc &constant_doc : global_scope_doc->constants) {
544
if (constant_doc.name == F.first) {
545
d2["description"] = fix_doc_description(constant_doc.description);
546
break;
547
}
548
}
549
}
550
values.push_back(d2);
551
}
552
d1["values"] = values;
553
enums.push_back(d1);
554
}
555
556
api_dump["global_enums"] = enums;
557
}
558
{
559
Array utility_funcs;
560
561
List<StringName> utility_func_names;
562
Variant::get_utility_function_list(&utility_func_names);
563
564
const DocData::ClassDoc *global_scope_doc = nullptr;
565
if (p_include_docs) {
566
global_scope_doc = EditorHelp::get_doc_data()->class_list.getptr("@GlobalScope");
567
CRASH_COND_MSG(!global_scope_doc, "Could not find '@GlobalScope' in DocData.");
568
}
569
570
for (const StringName &name : utility_func_names) {
571
Dictionary func;
572
func["name"] = String(name);
573
if (Variant::has_utility_function_return_value(name)) {
574
Variant::Type rt = Variant::get_utility_function_return_type(name);
575
func["return_type"] = rt == Variant::NIL ? String("Variant") : Variant::get_type_name(rt);
576
}
577
switch (Variant::get_utility_function_type(name)) {
578
case Variant::UTILITY_FUNC_TYPE_MATH:
579
func["category"] = "math";
580
break;
581
case Variant::UTILITY_FUNC_TYPE_RANDOM:
582
func["category"] = "random";
583
break;
584
case Variant::UTILITY_FUNC_TYPE_GENERAL:
585
func["category"] = "general";
586
break;
587
}
588
bool vararg = Variant::is_utility_function_vararg(name);
589
func["is_vararg"] = Variant::is_utility_function_vararg(name);
590
func["hash"] = Variant::get_utility_function_hash(name);
591
Array arguments;
592
int argcount = Variant::get_utility_function_argument_count(name);
593
for (int i = 0; i < argcount; i++) {
594
Dictionary arg;
595
String argname = vararg ? "arg" + itos(i + 1) : Variant::get_utility_function_argument_name(name, i);
596
arg["name"] = argname;
597
arg["type"] = get_builtin_or_variant_type_name(Variant::get_utility_function_argument_type(name, i));
598
//no default value support in utility functions
599
arguments.push_back(arg);
600
}
601
602
if (arguments.size()) {
603
func["arguments"] = arguments;
604
}
605
606
if (p_include_docs) {
607
for (const DocData::MethodDoc &method_doc : global_scope_doc->methods) {
608
if (method_doc.name == name) {
609
func["description"] = fix_doc_description(method_doc.description);
610
break;
611
}
612
}
613
}
614
615
utility_funcs.push_back(func);
616
}
617
618
api_dump["utility_functions"] = utility_funcs;
619
}
620
621
{
622
// builtin types
623
624
Array builtins;
625
626
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
627
if (i == Variant::OBJECT) {
628
continue;
629
}
630
631
Variant::Type type = Variant::Type(i);
632
633
Dictionary d;
634
d["name"] = Variant::get_type_name(type);
635
if (Variant::has_indexing(type)) {
636
d["indexing_return_type"] = get_builtin_or_variant_type_name(Variant::get_indexed_element_type(type));
637
}
638
639
d["is_keyed"] = Variant::is_keyed(type);
640
641
DocData::ClassDoc *builtin_doc = nullptr;
642
if (p_include_docs && d["name"] != "Nil") {
643
builtin_doc = EditorHelp::get_doc_data()->class_list.getptr(d["name"]);
644
CRASH_COND_MSG(!builtin_doc, vformat("Could not find '%s' in DocData.", d["name"]));
645
}
646
647
{
648
//members
649
Array members;
650
651
List<StringName> member_names;
652
Variant::get_member_list(type, &member_names);
653
for (const StringName &member_name : member_names) {
654
Dictionary d2;
655
d2["name"] = String(member_name);
656
d2["type"] = get_builtin_or_variant_type_name(Variant::get_member_type(type, member_name));
657
if (p_include_docs) {
658
for (const DocData::PropertyDoc &property_doc : builtin_doc->properties) {
659
if (property_doc.name == member_name) {
660
d2["description"] = fix_doc_description(property_doc.description);
661
break;
662
}
663
}
664
}
665
members.push_back(d2);
666
}
667
if (members.size()) {
668
d["members"] = members;
669
}
670
}
671
{
672
//constants
673
Array constants;
674
675
List<StringName> constant_names;
676
Variant::get_constants_for_type(type, &constant_names);
677
for (const StringName &constant_name : constant_names) {
678
Dictionary d2;
679
d2["name"] = String(constant_name);
680
Variant constant = Variant::get_constant_value(type, constant_name);
681
d2["type"] = get_builtin_or_variant_type_name(constant.get_type());
682
d2["value"] = constant.get_construct_string();
683
if (p_include_docs) {
684
for (const DocData::ConstantDoc &constant_doc : builtin_doc->constants) {
685
if (constant_doc.name == constant_name) {
686
d2["description"] = fix_doc_description(constant_doc.description);
687
break;
688
}
689
}
690
}
691
constants.push_back(d2);
692
}
693
if (constants.size()) {
694
d["constants"] = constants;
695
}
696
}
697
{
698
//enums
699
Array enums;
700
701
List<StringName> enum_names;
702
Variant::get_enums_for_type(type, &enum_names);
703
for (const StringName &enum_name : enum_names) {
704
Dictionary enum_dict;
705
enum_dict["name"] = String(enum_name);
706
707
List<StringName> enumeration_names;
708
Variant::get_enumerations_for_enum(type, enum_name, &enumeration_names);
709
710
Array values;
711
712
for (const StringName &enumeration : enumeration_names) {
713
Dictionary values_dict;
714
values_dict["name"] = String(enumeration);
715
values_dict["value"] = Variant::get_enum_value(type, enum_name, enumeration);
716
if (p_include_docs) {
717
for (const DocData::ConstantDoc &constant_doc : builtin_doc->constants) {
718
if (constant_doc.name == enumeration) {
719
values_dict["description"] = fix_doc_description(constant_doc.description);
720
break;
721
}
722
}
723
}
724
values.push_back(values_dict);
725
}
726
727
if (p_include_docs) {
728
const DocData::EnumDoc *enum_doc = builtin_doc->enums.getptr(enum_name);
729
if (enum_doc) {
730
enum_dict["description"] = fix_doc_description(enum_doc->description);
731
}
732
}
733
734
if (values.size()) {
735
enum_dict["values"] = values;
736
}
737
enums.push_back(enum_dict);
738
}
739
740
if (enums.size()) {
741
d["enums"] = enums;
742
}
743
}
744
{
745
//operators
746
Array operators;
747
748
for (int j = 0; j < Variant::VARIANT_MAX; j++) {
749
for (int k = 0; k < Variant::OP_MAX; k++) {
750
Variant::Type rt = Variant::get_operator_return_type(Variant::Operator(k), type, Variant::Type(j));
751
if (rt != Variant::NIL) {
752
Dictionary d2;
753
String operator_name = Variant::get_operator_name(Variant::Operator(k));
754
d2["name"] = operator_name;
755
756
String right_type_name = get_builtin_or_variant_type_name(Variant::Type(j));
757
bool is_unary = k == Variant::OP_NEGATE || k == Variant::OP_POSITIVE || k == Variant::OP_NOT || k == Variant::OP_BIT_NEGATE;
758
if (!is_unary) {
759
d2["right_type"] = right_type_name;
760
}
761
762
d2["return_type"] = get_builtin_or_variant_type_name(Variant::get_operator_return_type(Variant::Operator(k), type, Variant::Type(j)));
763
764
if (p_include_docs && builtin_doc != nullptr) {
765
for (const DocData::MethodDoc &operator_doc : builtin_doc->operators) {
766
if (operator_doc.name == "operator " + operator_name &&
767
(is_unary || operator_doc.arguments[0].type == right_type_name)) {
768
d2["description"] = fix_doc_description(operator_doc.description);
769
break;
770
}
771
}
772
}
773
774
operators.push_back(d2);
775
}
776
}
777
}
778
if (operators.size()) {
779
d["operators"] = operators;
780
}
781
}
782
{
783
//methods
784
Array methods;
785
786
List<StringName> method_names;
787
Variant::get_builtin_method_list(type, &method_names);
788
for (const StringName &method_name : method_names) {
789
Dictionary d2;
790
d2["name"] = String(method_name);
791
if (Variant::has_builtin_method_return_value(type, method_name)) {
792
Variant::Type ret_type = Variant::get_builtin_method_return_type(type, method_name);
793
d2["return_type"] = ret_type == Variant::NIL ? String("Variant") : Variant::get_type_name(ret_type);
794
}
795
d2["is_vararg"] = Variant::is_builtin_method_vararg(type, method_name);
796
d2["is_const"] = Variant::is_builtin_method_const(type, method_name);
797
d2["is_static"] = Variant::is_builtin_method_static(type, method_name);
798
d2["hash"] = Variant::get_builtin_method_hash(type, method_name);
799
800
Vector<Variant> default_args = Variant::get_builtin_method_default_arguments(type, method_name);
801
802
Array arguments;
803
int argcount = Variant::get_builtin_method_argument_count(type, method_name);
804
for (int j = 0; j < argcount; j++) {
805
Dictionary d3;
806
d3["name"] = Variant::get_builtin_method_argument_name(type, method_name, j);
807
d3["type"] = get_builtin_or_variant_type_name(Variant::get_builtin_method_argument_type(type, method_name, j));
808
809
if (j >= (argcount - default_args.size())) {
810
int dargidx = j - (argcount - default_args.size());
811
d3["default_value"] = default_args[dargidx].get_construct_string();
812
}
813
arguments.push_back(d3);
814
}
815
816
if (arguments.size()) {
817
d2["arguments"] = arguments;
818
}
819
820
if (p_include_docs) {
821
for (const DocData::MethodDoc &method_doc : builtin_doc->methods) {
822
if (method_doc.name == method_name) {
823
d2["description"] = fix_doc_description(method_doc.description);
824
break;
825
}
826
}
827
}
828
829
methods.push_back(d2);
830
}
831
if (methods.size()) {
832
d["methods"] = methods;
833
}
834
}
835
{
836
//constructors
837
Array constructors;
838
839
for (int j = 0; j < Variant::get_constructor_count(type); j++) {
840
Dictionary d2;
841
d2["index"] = j;
842
843
Array arguments;
844
int argcount = Variant::get_constructor_argument_count(type, j);
845
for (int k = 0; k < argcount; k++) {
846
Dictionary d3;
847
d3["name"] = Variant::get_constructor_argument_name(type, j, k);
848
d3["type"] = get_builtin_or_variant_type_name(Variant::get_constructor_argument_type(type, j, k));
849
arguments.push_back(d3);
850
}
851
if (arguments.size()) {
852
d2["arguments"] = arguments;
853
}
854
855
if (p_include_docs && builtin_doc) {
856
for (const DocData::MethodDoc &constructor_doc : builtin_doc->constructors) {
857
if (constructor_doc.arguments.size() != argcount) {
858
continue;
859
}
860
bool constructor_found = true;
861
for (int k = 0; k < argcount; k++) {
862
const DocData::ArgumentDoc &argument_doc = constructor_doc.arguments[k];
863
const Dictionary &argument_dict = arguments[k];
864
const String &argument_string = argument_dict["type"];
865
if (argument_doc.type != argument_string) {
866
constructor_found = false;
867
break;
868
}
869
}
870
if (constructor_found) {
871
d2["description"] = fix_doc_description(constructor_doc.description);
872
}
873
}
874
}
875
876
constructors.push_back(d2);
877
}
878
879
if (constructors.size()) {
880
d["constructors"] = constructors;
881
}
882
}
883
{
884
//destructor
885
d["has_destructor"] = Variant::has_destructor(type);
886
}
887
888
if (p_include_docs && builtin_doc != nullptr) {
889
d["brief_description"] = fix_doc_description(builtin_doc->brief_description);
890
d["description"] = fix_doc_description(builtin_doc->description);
891
}
892
893
builtins.push_back(d);
894
}
895
896
api_dump["builtin_classes"] = builtins;
897
}
898
899
{
900
// classes
901
Array classes;
902
903
List<StringName> class_list;
904
905
ClassDB::get_class_list(&class_list);
906
907
class_list.sort_custom<StringName::AlphCompare>();
908
909
for (const StringName &class_name : class_list) {
910
if (!ClassDB::is_class_exposed(class_name)) {
911
continue;
912
}
913
Dictionary d;
914
d["name"] = String(class_name);
915
d["is_refcounted"] = ClassDB::is_parent_class(class_name, "RefCounted");
916
d["is_instantiable"] = ClassDB::can_instantiate(class_name);
917
StringName parent_class = ClassDB::get_parent_class(class_name);
918
if (parent_class != StringName()) {
919
d["inherits"] = String(parent_class);
920
}
921
922
DocData::ClassDoc *class_doc = nullptr;
923
if (p_include_docs) {
924
class_doc = EditorHelp::get_doc_data()->class_list.getptr(class_name);
925
CRASH_COND_MSG(!class_doc, vformat("Could not find '%s' in DocData.", class_name));
926
}
927
928
{
929
ClassDB::APIType api = ClassDB::get_api_type(class_name);
930
static const char *api_type[5] = { "core", "editor", "extension", "editor_extension" };
931
d["api_type"] = api_type[api];
932
}
933
934
{
935
//constants
936
Array constants;
937
List<String> constant_list;
938
ClassDB::get_integer_constant_list(class_name, &constant_list, true);
939
for (const String &F : constant_list) {
940
StringName enum_name = ClassDB::get_integer_constant_enum(class_name, F);
941
if (enum_name != StringName()) {
942
continue; //enums will be handled on their own
943
}
944
945
Dictionary d2;
946
d2["name"] = String(F);
947
d2["value"] = ClassDB::get_integer_constant(class_name, F);
948
949
if (p_include_docs) {
950
for (const DocData::ConstantDoc &constant_doc : class_doc->constants) {
951
if (constant_doc.name == F) {
952
d2["description"] = fix_doc_description(constant_doc.description);
953
break;
954
}
955
}
956
}
957
958
constants.push_back(d2);
959
}
960
961
if (constants.size()) {
962
d["constants"] = constants;
963
}
964
}
965
{
966
//enum
967
Array enums;
968
List<StringName> enum_list;
969
ClassDB::get_enum_list(class_name, &enum_list, true);
970
for (const StringName &F : enum_list) {
971
Dictionary d2;
972
d2["name"] = String(F);
973
d2["is_bitfield"] = ClassDB::is_enum_bitfield(class_name, F);
974
975
Array values;
976
List<StringName> enum_constant_list;
977
ClassDB::get_enum_constants(class_name, F, &enum_constant_list, true);
978
for (const StringName &enum_constant : enum_constant_list) {
979
Dictionary d3;
980
d3["name"] = String(enum_constant);
981
d3["value"] = ClassDB::get_integer_constant(class_name, enum_constant);
982
983
if (p_include_docs) {
984
for (const DocData::ConstantDoc &constant_doc : class_doc->constants) {
985
if (constant_doc.name == enum_constant) {
986
d3["description"] = fix_doc_description(constant_doc.description);
987
break;
988
}
989
}
990
}
991
992
values.push_back(d3);
993
}
994
995
d2["values"] = values;
996
997
if (p_include_docs) {
998
const DocData::EnumDoc *enum_doc = class_doc->enums.getptr(F);
999
if (enum_doc) {
1000
d2["description"] = fix_doc_description(enum_doc->description);
1001
}
1002
}
1003
1004
enums.push_back(d2);
1005
}
1006
1007
if (enums.size()) {
1008
d["enums"] = enums;
1009
}
1010
}
1011
{
1012
//methods
1013
Array methods;
1014
List<MethodInfo> method_list;
1015
ClassDB::get_method_list(class_name, &method_list, true);
1016
for (const MethodInfo &F : method_list) {
1017
StringName method_name = F.name;
1018
if ((F.flags & METHOD_FLAG_VIRTUAL) && !(F.flags & METHOD_FLAG_OBJECT_CORE)) {
1019
//virtual method
1020
const MethodInfo &mi = F;
1021
Dictionary d2;
1022
d2["name"] = String(method_name);
1023
d2["is_const"] = (F.flags & METHOD_FLAG_CONST) ? true : false;
1024
d2["is_static"] = (F.flags & METHOD_FLAG_STATIC) ? true : false;
1025
d2["is_required"] = (F.flags & METHOD_FLAG_VIRTUAL_REQUIRED) ? true : false;
1026
d2["is_vararg"] = false;
1027
d2["is_virtual"] = true;
1028
d2["hash"] = mi.get_compatibility_hash();
1029
1030
Vector<uint32_t> compat_hashes = ClassDB::get_virtual_method_compatibility_hashes(class_name, method_name);
1031
Array compatibility;
1032
if (compat_hashes.size()) {
1033
for (int i = 0; i < compat_hashes.size(); i++) {
1034
compatibility.push_back(compat_hashes[i]);
1035
}
1036
}
1037
if (compatibility.size() > 0) {
1038
d2["hash_compatibility"] = compatibility;
1039
}
1040
1041
bool has_return = mi.return_val.type != Variant::NIL || (mi.return_val.usage & PROPERTY_USAGE_NIL_IS_VARIANT);
1042
if (has_return) {
1043
PropertyInfo pinfo = mi.return_val;
1044
Dictionary d3;
1045
1046
d3["type"] = get_property_info_type_name(pinfo);
1047
1048
if (mi.get_argument_meta(-1) > 0) {
1049
d3["meta"] = get_type_meta_name((GodotTypeInfo::Metadata)mi.get_argument_meta(-1));
1050
}
1051
1052
d2["return_value"] = d3;
1053
}
1054
1055
Array arguments;
1056
for (int64_t i = 0; i < mi.arguments.size(); ++i) {
1057
const PropertyInfo &pinfo = mi.arguments[i];
1058
Dictionary d3;
1059
1060
d3["name"] = pinfo.name;
1061
1062
d3["type"] = get_property_info_type_name(pinfo);
1063
1064
if (mi.get_argument_meta(i) > 0) {
1065
d3["meta"] = get_type_meta_name((GodotTypeInfo::Metadata)mi.get_argument_meta(i));
1066
}
1067
1068
arguments.push_back(d3);
1069
}
1070
1071
if (arguments.size()) {
1072
d2["arguments"] = arguments;
1073
}
1074
1075
if (p_include_docs) {
1076
for (const DocData::MethodDoc &method_doc : class_doc->methods) {
1077
if (method_doc.name == method_name) {
1078
d2["description"] = fix_doc_description(method_doc.description);
1079
break;
1080
}
1081
}
1082
}
1083
1084
methods.push_back(d2);
1085
1086
} else if (F.name.begins_with("_")) {
1087
//hidden method, ignore
1088
1089
} else {
1090
Dictionary d2;
1091
d2["name"] = String(method_name);
1092
1093
MethodBind *method = ClassDB::get_method(class_name, method_name);
1094
if (!method) {
1095
continue;
1096
}
1097
1098
d2["is_const"] = method->is_const();
1099
d2["is_vararg"] = method->is_vararg();
1100
d2["is_static"] = method->is_static();
1101
d2["is_virtual"] = false;
1102
d2["hash"] = method->get_hash();
1103
1104
Vector<uint32_t> compat_hashes = ClassDB::get_method_compatibility_hashes(class_name, method_name);
1105
Array compatibility;
1106
if (compat_hashes.size()) {
1107
for (int i = 0; i < compat_hashes.size(); i++) {
1108
compatibility.push_back(compat_hashes[i]);
1109
}
1110
}
1111
1112
#ifndef DISABLE_DEPRECATED
1113
GDExtensionSpecialCompatHashes::get_legacy_hashes(class_name, method_name, compatibility);
1114
#endif
1115
1116
if (compatibility.size() > 0) {
1117
d2["hash_compatibility"] = compatibility;
1118
}
1119
1120
Vector<Variant> default_args = method->get_default_arguments();
1121
1122
Array arguments;
1123
for (int i = (method->has_return() ? -1 : 0); i < method->get_argument_count(); i++) {
1124
PropertyInfo pinfo = i == -1 ? method->get_return_info() : method->get_argument_info(i);
1125
Dictionary d3;
1126
1127
if (i >= 0) {
1128
d3["name"] = pinfo.name;
1129
}
1130
d3["type"] = get_property_info_type_name(pinfo);
1131
1132
if (method->get_argument_meta(i) > 0) {
1133
d3["meta"] = get_type_meta_name(method->get_argument_meta(i));
1134
}
1135
1136
if (i >= 0 && i >= (method->get_argument_count() - default_args.size())) {
1137
int dargidx = i - (method->get_argument_count() - default_args.size());
1138
d3["default_value"] = default_args[dargidx].get_construct_string();
1139
}
1140
1141
if (i == -1) {
1142
d2["return_value"] = d3;
1143
} else {
1144
arguments.push_back(d3);
1145
}
1146
}
1147
1148
if (arguments.size()) {
1149
d2["arguments"] = arguments;
1150
}
1151
1152
if (p_include_docs) {
1153
for (const DocData::MethodDoc &method_doc : class_doc->methods) {
1154
if (method_doc.name == method_name) {
1155
d2["description"] = fix_doc_description(method_doc.description);
1156
break;
1157
}
1158
}
1159
}
1160
1161
methods.push_back(d2);
1162
}
1163
}
1164
1165
if (methods.size()) {
1166
d["methods"] = methods;
1167
}
1168
}
1169
1170
{
1171
//signals
1172
Array signals;
1173
List<MethodInfo> signal_list;
1174
ClassDB::get_signal_list(class_name, &signal_list, true);
1175
for (const MethodInfo &F : signal_list) {
1176
StringName signal_name = F.name;
1177
Dictionary d2;
1178
d2["name"] = String(signal_name);
1179
1180
Array arguments;
1181
1182
for (int64_t i = 0; i < F.arguments.size(); ++i) {
1183
Dictionary d3;
1184
d3["name"] = F.arguments[i].name;
1185
d3["type"] = get_property_info_type_name(F.arguments[i]);
1186
if (F.get_argument_meta(i) > 0) {
1187
d3["meta"] = get_type_meta_name((GodotTypeInfo::Metadata)F.get_argument_meta(i));
1188
}
1189
arguments.push_back(d3);
1190
}
1191
if (arguments.size()) {
1192
d2["arguments"] = arguments;
1193
}
1194
1195
if (p_include_docs) {
1196
for (const DocData::MethodDoc &signal_doc : class_doc->signals) {
1197
if (signal_doc.name == signal_name) {
1198
d2["description"] = fix_doc_description(signal_doc.description);
1199
break;
1200
}
1201
}
1202
}
1203
1204
signals.push_back(d2);
1205
}
1206
1207
if (signals.size()) {
1208
d["signals"] = signals;
1209
}
1210
}
1211
{
1212
//properties
1213
Array properties;
1214
List<PropertyInfo> property_list;
1215
ClassDB::get_property_list(class_name, &property_list, true);
1216
for (const PropertyInfo &F : property_list) {
1217
if (F.usage & PROPERTY_USAGE_CATEGORY || F.usage & PROPERTY_USAGE_GROUP || F.usage & PROPERTY_USAGE_SUBGROUP || (F.type == Variant::NIL && F.usage & PROPERTY_USAGE_ARRAY)) {
1218
continue; //not real properties
1219
}
1220
if (F.name.begins_with("_")) {
1221
continue; //hidden property
1222
}
1223
if (F.name.contains_char('/')) {
1224
// Ignore properties with '/' (slash) in the name. These are only meant for use in the inspector.
1225
continue;
1226
}
1227
StringName property_name = F.name;
1228
Dictionary d2;
1229
d2["type"] = get_property_info_type_name(F);
1230
d2["name"] = String(property_name);
1231
StringName setter = ClassDB::get_property_setter(class_name, F.name);
1232
if (!(setter == "")) {
1233
d2["setter"] = setter;
1234
}
1235
StringName getter = ClassDB::get_property_getter(class_name, F.name);
1236
if (!(getter == "")) {
1237
d2["getter"] = getter;
1238
}
1239
int index = ClassDB::get_property_index(class_name, F.name);
1240
if (index != -1) {
1241
d2["index"] = index;
1242
}
1243
1244
if (p_include_docs) {
1245
for (const DocData::PropertyDoc &property_doc : class_doc->properties) {
1246
if (property_doc.name == property_name) {
1247
d2["description"] = fix_doc_description(property_doc.description);
1248
break;
1249
}
1250
}
1251
}
1252
1253
properties.push_back(d2);
1254
}
1255
1256
if (properties.size()) {
1257
d["properties"] = properties;
1258
}
1259
}
1260
1261
if (p_include_docs && class_doc != nullptr) {
1262
d["brief_description"] = fix_doc_description(class_doc->brief_description);
1263
d["description"] = fix_doc_description(class_doc->description);
1264
}
1265
1266
classes.push_back(d);
1267
}
1268
1269
api_dump["classes"] = classes;
1270
}
1271
1272
{
1273
// singletons
1274
1275
Array singletons;
1276
List<Engine::Singleton> singleton_list;
1277
Engine::get_singleton()->get_singletons(&singleton_list);
1278
1279
for (const Engine::Singleton &s : singleton_list) {
1280
Dictionary d;
1281
d["name"] = s.name;
1282
if (s.class_name != StringName()) {
1283
d["type"] = String(s.class_name);
1284
} else {
1285
d["type"] = String(s.ptr->get_class());
1286
}
1287
singletons.push_back(d);
1288
}
1289
1290
if (singletons.size()) {
1291
api_dump["singletons"] = singletons;
1292
}
1293
}
1294
1295
{
1296
Array native_structures;
1297
1298
List<StringName> native_structs;
1299
ClassDB::get_native_struct_list(&native_structs);
1300
native_structs.sort_custom<StringName::AlphCompare>();
1301
1302
for (const StringName &E : native_structs) {
1303
String code = ClassDB::get_native_struct_code(E);
1304
1305
Dictionary d;
1306
d["name"] = String(E);
1307
d["format"] = code;
1308
1309
native_structures.push_back(d);
1310
}
1311
1312
api_dump["native_structures"] = native_structures;
1313
}
1314
1315
return api_dump;
1316
}
1317
1318
void GDExtensionAPIDump::generate_extension_json_file(const String &p_path, bool p_include_docs) {
1319
Dictionary api = generate_extension_api(p_include_docs);
1320
Ref<JSON> json;
1321
json.instantiate();
1322
1323
String text = json->stringify(api, "\t", false) + "\n";
1324
Ref<FileAccess> fa = FileAccess::open(p_path, FileAccess::WRITE);
1325
ERR_FAIL_COND_MSG(fa.is_null(), vformat("Cannot open file '%s' for writing.", p_path));
1326
fa->store_string(text);
1327
}
1328
1329
static bool compare_value(const String &p_path, const String &p_field, const Variant &p_old_value, const Variant &p_new_value, bool p_allow_name_change) {
1330
bool failed = false;
1331
String path = p_path + "/" + p_field;
1332
if (p_old_value.get_type() == Variant::ARRAY && p_new_value.get_type() == Variant::ARRAY) {
1333
Array old_array = p_old_value;
1334
Array new_array = p_new_value;
1335
if (!compare_value(path, "size", old_array.size(), new_array.size(), p_allow_name_change)) {
1336
failed = true;
1337
}
1338
for (int i = 0; i < old_array.size() && i < new_array.size(); i++) {
1339
if (!compare_value(path, itos(i), old_array[i], new_array[i], p_allow_name_change)) {
1340
failed = true;
1341
}
1342
}
1343
} else if (p_old_value.get_type() == Variant::DICTIONARY && p_new_value.get_type() == Variant::DICTIONARY) {
1344
Dictionary old_dict = p_old_value;
1345
Dictionary new_dict = p_new_value;
1346
for (const KeyValue<Variant, Variant> &kv : old_dict) {
1347
if (!new_dict.has(kv.key)) {
1348
failed = true;
1349
print_error(vformat("Validate extension JSON: Error: Field '%s': %s was removed.", p_path, kv.key));
1350
continue;
1351
}
1352
if (p_allow_name_change && kv.key == "name") {
1353
continue;
1354
}
1355
if (!compare_value(path, kv.key, kv.value, new_dict[kv.key], p_allow_name_change)) {
1356
failed = true;
1357
}
1358
}
1359
for (const Variant &key : old_dict.keys()) {
1360
if (!old_dict.has(key)) {
1361
failed = true;
1362
print_error(vformat("Validate extension JSON: Error: Field '%s': %s was added with value %s.", p_path, key, new_dict[key]));
1363
}
1364
}
1365
} else {
1366
bool equal = Variant::evaluate(Variant::OP_EQUAL, p_old_value, p_new_value);
1367
if (!equal) {
1368
print_error(vformat("Validate extension JSON: Error: Field '%s': %s changed value in new API, from %s to %s.", p_path, p_field, p_old_value.get_construct_string(), p_new_value.get_construct_string()));
1369
return false;
1370
}
1371
}
1372
return !failed;
1373
}
1374
1375
static bool compare_dict_array(const Dictionary &p_old_api, const Dictionary &p_new_api, const String &p_base_array, const String &p_name_field, const Vector<String> &p_fields_to_compare, bool p_compare_hashes, const String &p_outer_class = String(), bool p_compare_operators = false, bool p_compare_enum_value = false) {
1376
String base_array = p_outer_class + p_base_array;
1377
if (!p_old_api.has(p_base_array)) {
1378
return true; // May just not have this array and its still good. Probably added recently.
1379
}
1380
bool failed = false;
1381
ERR_FAIL_COND_V_MSG(!p_new_api.has(p_base_array), false, vformat("New API lacks base array: %s", p_base_array));
1382
Array new_api = p_new_api[p_base_array];
1383
HashMap<String, Dictionary> new_api_assoc;
1384
1385
for (const Variant &var : new_api) {
1386
Dictionary elem = var;
1387
ERR_FAIL_COND_V_MSG(!elem.has(p_name_field), false, vformat("Validate extension JSON: Element of base_array '%s' is missing field '%s'. This is a bug.", base_array, p_name_field));
1388
String name = elem[p_name_field];
1389
if (name.is_valid_float()) {
1390
name = name.trim_suffix(".0"); // Make "integers" stringified as integers.
1391
}
1392
if (p_compare_operators && elem.has("right_type")) {
1393
name += " " + String(elem["right_type"]);
1394
}
1395
new_api_assoc.insert(name, elem);
1396
}
1397
1398
Array old_api = p_old_api[p_base_array];
1399
for (const Variant &var : old_api) {
1400
Dictionary old_elem = var;
1401
if (!old_elem.has(p_name_field)) {
1402
failed = true;
1403
print_error(vformat("Validate extension JSON: JSON file: element of base array '%s' is missing the field: '%s'.", base_array, p_name_field));
1404
continue;
1405
}
1406
String name = old_elem[p_name_field];
1407
if (name.is_valid_float()) {
1408
name = name.trim_suffix(".0"); // Make "integers" stringified as integers.
1409
}
1410
if (p_compare_operators && old_elem.has("right_type")) {
1411
name += " " + String(old_elem["right_type"]);
1412
}
1413
if (!new_api_assoc.has(name)) {
1414
failed = true;
1415
print_error(vformat("Validate extension JSON: API was removed: %s/%s", base_array, name));
1416
continue;
1417
}
1418
1419
Dictionary new_elem = new_api_assoc[name];
1420
1421
for (int j = 0; j < p_fields_to_compare.size(); j++) {
1422
String field = p_fields_to_compare[j];
1423
bool optional = field.begins_with("*");
1424
if (optional) {
1425
// This is an optional field, but if exists it has to exist in both.
1426
field = field.substr(1);
1427
}
1428
1429
bool added = field.begins_with("+");
1430
if (added) {
1431
// Meaning this field must either exist or contents may not exist.
1432
field = field.substr(1);
1433
}
1434
1435
bool enum_values = field.begins_with("$");
1436
if (enum_values) {
1437
// Meaning this field is a list of enum values.
1438
field = field.substr(1);
1439
}
1440
1441
bool allow_name_change = field.begins_with("@");
1442
if (allow_name_change) {
1443
// Meaning that when structurally comparing the old and new value, the dictionary entry 'name' may change.
1444
field = field.substr(1);
1445
}
1446
1447
Variant old_value;
1448
1449
if (!old_elem.has(field)) {
1450
if (optional) {
1451
if (new_elem.has(field)) {
1452
failed = true;
1453
print_error(vformat("Validate extension JSON: JSON file: Field was added in a way that breaks compatibility '%s/%s': %s", base_array, name, field));
1454
}
1455
} else if (added && new_elem.has(field)) {
1456
// Should be ok, field now exists, should not be verified in prior versions where it does not.
1457
} else {
1458
failed = true;
1459
print_error(vformat("Validate extension JSON: JSON file: Missing field in '%s/%s': %s", base_array, name, field));
1460
}
1461
continue;
1462
} else {
1463
old_value = old_elem[field];
1464
}
1465
1466
if (!new_elem.has(field)) {
1467
failed = true;
1468
ERR_PRINT(vformat("Validate extension JSON: Missing field in current API '%s/%s': %s. This is a bug.", base_array, name, field));
1469
continue;
1470
}
1471
1472
Variant new_value = new_elem[field];
1473
1474
if (p_compare_enum_value && name.ends_with("_MAX")) {
1475
if (static_cast<int64_t>(new_value) > static_cast<int64_t>(old_value)) {
1476
// Ignore the _MAX value of an enum increasing.
1477
continue;
1478
}
1479
}
1480
if (enum_values) {
1481
if (!compare_dict_array(old_elem, new_elem, field, "name", { "value" }, false, base_array + "/" + name + "/", false, true)) {
1482
failed = true;
1483
}
1484
} else if (!compare_value(base_array + "/" + name, field, old_value, new_value, allow_name_change)) {
1485
failed = true;
1486
}
1487
}
1488
1489
if (p_compare_hashes) {
1490
if (!old_elem.has("hash")) {
1491
if (old_elem.has("is_virtual") && bool(old_elem["is_virtual"]) && !old_elem.has("hash")) {
1492
continue; // Virtual methods didn't use to have hashes, so skip check if it's missing in the old file.
1493
}
1494
1495
failed = true;
1496
print_error(vformat("Validate extension JSON: JSON file: element of base array '%s' is missing the field: 'hash'.", base_array));
1497
continue;
1498
}
1499
1500
uint64_t old_hash = old_elem["hash"];
1501
1502
if (!new_elem.has("hash")) {
1503
failed = true;
1504
print_error(vformat("Validate extension JSON: Error: Field '%s' is missing the field: 'hash'.", base_array));
1505
continue;
1506
}
1507
1508
uint64_t new_hash = new_elem["hash"];
1509
bool hash_found = false;
1510
if (old_hash == new_hash) {
1511
hash_found = true;
1512
} else if (new_elem.has("hash_compatibility")) {
1513
Array compatibility = new_elem["hash_compatibility"];
1514
for (int j = 0; j < compatibility.size(); j++) {
1515
new_hash = compatibility[j];
1516
if (new_hash == old_hash) {
1517
hash_found = true;
1518
break;
1519
}
1520
}
1521
}
1522
1523
if (!hash_found) {
1524
failed = true;
1525
print_error(vformat("Validate extension JSON: Error: Hash changed for '%s/%s', from %08X to %08X. This means that the function has changed and no compatibility function was provided.", base_array, name, old_hash, new_hash));
1526
continue;
1527
}
1528
}
1529
}
1530
1531
return !failed;
1532
}
1533
1534
static bool compare_sub_dict_array(HashSet<String> &r_removed_classes_registered, const String &p_outer, const String &p_outer_name, const Dictionary &p_old_api, const Dictionary &p_new_api, const String &p_base_array, const String &p_name_field, const Vector<String> &p_fields_to_compare, bool p_compare_hashes, bool p_compare_operators = false) {
1535
if (!p_old_api.has(p_outer)) {
1536
return true; // May just not have this array and its still good. Probably added recently or optional.
1537
}
1538
bool failed = false;
1539
ERR_FAIL_COND_V_MSG(!p_new_api.has(p_outer), false, vformat("New API lacks base array: %s", p_outer));
1540
Array new_api = p_new_api[p_outer];
1541
HashMap<String, Dictionary> new_api_assoc;
1542
1543
for (const Variant &var : new_api) {
1544
Dictionary elem = var;
1545
ERR_FAIL_COND_V_MSG(!elem.has(p_outer_name), false, vformat("Validate extension JSON: Element of base_array '%s' is missing field '%s'. This is a bug.", p_outer, p_outer_name));
1546
new_api_assoc.insert(elem[p_outer_name], elem);
1547
}
1548
1549
Array old_api = p_old_api[p_outer];
1550
1551
for (const Variant &var : old_api) {
1552
Dictionary old_elem = var;
1553
if (!old_elem.has(p_outer_name)) {
1554
failed = true;
1555
print_error(vformat("Validate extension JSON: JSON file: element of base array '%s' is missing the field: '%s'.", p_outer, p_outer_name));
1556
continue;
1557
}
1558
String name = old_elem[p_outer_name];
1559
if (!new_api_assoc.has(name)) {
1560
failed = true;
1561
if (!r_removed_classes_registered.has(name)) {
1562
print_error(vformat("Validate extension JSON: API was removed: %s/%s", p_outer, name));
1563
r_removed_classes_registered.insert(name);
1564
}
1565
continue;
1566
}
1567
1568
Dictionary new_elem = new_api_assoc[name];
1569
1570
if (!compare_dict_array(old_elem, new_elem, p_base_array, p_name_field, p_fields_to_compare, p_compare_hashes, p_outer + "/" + name + "/", p_compare_operators)) {
1571
failed = true;
1572
}
1573
}
1574
1575
return !failed;
1576
}
1577
1578
Error GDExtensionAPIDump::validate_extension_json_file(const String &p_path) {
1579
Error error;
1580
String text = FileAccess::get_file_as_string(p_path, &error);
1581
if (error != OK) {
1582
ERR_PRINT(vformat("Validate extension JSON: Could not open file '%s'.", p_path));
1583
return error;
1584
}
1585
1586
Ref<JSON> json;
1587
json.instantiate();
1588
error = json->parse(text);
1589
if (error != OK) {
1590
ERR_PRINT(vformat("Validate extension JSON: Error parsing '%s' at line %d: %s", p_path, json->get_error_line(), json->get_error_message()));
1591
return error;
1592
}
1593
1594
Dictionary old_api = json->get_data();
1595
Dictionary new_api = generate_extension_api();
1596
1597
{ // Validate header:
1598
Dictionary header = old_api["header"];
1599
ERR_FAIL_COND_V(!header.has("version_major"), ERR_INVALID_DATA);
1600
ERR_FAIL_COND_V(!header.has("version_minor"), ERR_INVALID_DATA);
1601
int major = header["version_major"];
1602
int minor = header["version_minor"];
1603
1604
ERR_FAIL_COND_V_MSG(major != GODOT_VERSION_MAJOR, ERR_INVALID_DATA, vformat("JSON API dump is for a different engine version (%d) than this one (%d)", major, GODOT_VERSION_MAJOR));
1605
ERR_FAIL_COND_V_MSG(minor > GODOT_VERSION_MINOR, ERR_INVALID_DATA, vformat("JSON API dump is for a newer version of the engine: %d.%d", major, minor));
1606
}
1607
1608
bool failed = false;
1609
1610
HashSet<String> removed_classes_registered;
1611
1612
if (!compare_dict_array(old_api, new_api, "global_constants", "name", Vector<String>({ "value", "is_bitfield" }), false)) {
1613
failed = true;
1614
}
1615
1616
if (!compare_dict_array(old_api, new_api, "global_enums", "name", Vector<String>({ "$values", "is_bitfield" }), false)) {
1617
failed = true;
1618
}
1619
1620
if (!compare_dict_array(old_api, new_api, "utility_functions", "name", Vector<String>({ "category", "is_vararg", "*return_type", "*@arguments" }), true)) {
1621
failed = true;
1622
}
1623
1624
if (!compare_sub_dict_array(removed_classes_registered, "builtin_classes", "name", old_api, new_api, "members", "name", { "type" }, false)) {
1625
failed = true;
1626
}
1627
1628
if (!compare_sub_dict_array(removed_classes_registered, "builtin_classes", "name", old_api, new_api, "constants", "name", { "type", "value" }, false)) {
1629
failed = true;
1630
}
1631
1632
if (!compare_sub_dict_array(removed_classes_registered, "builtin_classes", "name", old_api, new_api, "operators", "name", { "return_type" }, false, true)) {
1633
failed = true;
1634
}
1635
1636
if (!compare_sub_dict_array(removed_classes_registered, "builtin_classes", "name", old_api, new_api, "methods", "name", { "is_vararg", "is_static", "is_const", "*return_type", "*@arguments" }, true)) {
1637
failed = true;
1638
}
1639
1640
if (!compare_sub_dict_array(removed_classes_registered, "builtin_classes", "name", old_api, new_api, "constructors", "index", { "*@arguments" }, false)) {
1641
failed = true;
1642
}
1643
1644
if (!compare_sub_dict_array(removed_classes_registered, "classes", "name", old_api, new_api, "constants", "name", { "value" }, false)) {
1645
failed = true;
1646
}
1647
1648
if (!compare_sub_dict_array(removed_classes_registered, "classes", "name", old_api, new_api, "enums", "name", { "is_bitfield", "$values" }, false)) {
1649
failed = true;
1650
}
1651
1652
if (!compare_sub_dict_array(removed_classes_registered, "classes", "name", old_api, new_api, "methods", "name", { "is_virtual", "is_vararg", "is_static", "is_const", "*return_value", "*@arguments" }, true)) {
1653
failed = true;
1654
}
1655
1656
if (!compare_sub_dict_array(removed_classes_registered, "classes", "name", old_api, new_api, "signals", "name", { "*@arguments" }, false)) {
1657
failed = true;
1658
}
1659
1660
if (!compare_sub_dict_array(removed_classes_registered, "classes", "name", old_api, new_api, "properties", "name", { "type", "*setter", "*getter", "*index" }, false)) {
1661
failed = true;
1662
}
1663
1664
if (!compare_dict_array(old_api, new_api, "singletons", "name", Vector<String>({ "type" }), false)) {
1665
failed = true;
1666
}
1667
1668
if (!compare_dict_array(old_api, new_api, "native_structures", "name", Vector<String>({ "format" }), false)) {
1669
failed = true;
1670
}
1671
1672
if (failed) {
1673
return ERR_INVALID_DATA;
1674
} else {
1675
return OK;
1676
}
1677
}
1678
1679
#endif // TOOLS_ENABLED
1680
1681