2
0

extension_api_dump.cpp 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941
  1. /*************************************************************************/
  2. /* extension_api_dump.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "extension_api_dump.h"
  31. #include "core/config/engine.h"
  32. #include "core/core_constants.h"
  33. #include "core/io/file_access.h"
  34. #include "core/io/json.h"
  35. #include "core/templates/pair.h"
  36. #include "core/version.h"
  37. #ifdef TOOLS_ENABLED
  38. static String get_type_name(const PropertyInfo &p_info) {
  39. if (p_info.type == Variant::INT && (p_info.hint == PROPERTY_HINT_INT_IS_POINTER)) {
  40. if (p_info.hint_string.is_empty()) {
  41. return "void*";
  42. } else {
  43. return p_info.hint_string + "*";
  44. }
  45. }
  46. if (p_info.type == Variant::ARRAY && (p_info.hint == PROPERTY_HINT_ARRAY_TYPE)) {
  47. return String("typedarray::") + p_info.hint_string;
  48. }
  49. if (p_info.type == Variant::INT && (p_info.usage & (PROPERTY_USAGE_CLASS_IS_ENUM))) {
  50. return String("enum::") + String(p_info.class_name);
  51. }
  52. if (p_info.type == Variant::INT && (p_info.usage & (PROPERTY_USAGE_CLASS_IS_BITFIELD))) {
  53. return String("bitfield::") + String(p_info.class_name);
  54. }
  55. if (p_info.type == Variant::INT && (p_info.usage & PROPERTY_USAGE_ARRAY)) {
  56. return "int";
  57. }
  58. if (p_info.class_name != StringName()) {
  59. return p_info.class_name;
  60. }
  61. if (p_info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
  62. return p_info.hint_string;
  63. }
  64. if (p_info.type == Variant::NIL && (p_info.usage & PROPERTY_USAGE_NIL_IS_VARIANT)) {
  65. return "Variant";
  66. }
  67. if (p_info.type == Variant::NIL) {
  68. return "void";
  69. }
  70. return Variant::get_type_name(p_info.type);
  71. }
  72. Dictionary NativeExtensionAPIDump::generate_extension_api() {
  73. Dictionary api_dump;
  74. {
  75. //header
  76. Dictionary header;
  77. header["version_major"] = VERSION_MAJOR;
  78. header["version_minor"] = VERSION_MINOR;
  79. #if VERSION_PATCH
  80. header["version_patch"] = VERSION_PATCH;
  81. #else
  82. header["version_patch"] = 0;
  83. #endif
  84. header["version_status"] = VERSION_STATUS;
  85. header["version_build"] = VERSION_BUILD;
  86. header["version_full_name"] = VERSION_FULL_NAME;
  87. api_dump["header"] = header;
  88. }
  89. const uint32_t vec3_elems = 3;
  90. const uint32_t vec4_elems = 4;
  91. const uint32_t ptrsize_32 = 4;
  92. const uint32_t ptrsize_64 = 8;
  93. static const char *build_config_name[4] = { "float_32", "float_64", "double_32", "double_64" };
  94. {
  95. //type sizes
  96. constexpr struct {
  97. Variant::Type type;
  98. uint32_t size_32_bits_real_float;
  99. uint32_t size_64_bits_real_float;
  100. uint32_t size_32_bits_real_double;
  101. uint32_t size_64_bits_real_double;
  102. // For compile-time size check.
  103. constexpr uint32_t operator[](int index) const {
  104. switch (index) {
  105. #ifndef REAL_T_IS_DOUBLE
  106. case sizeof(uint32_t):
  107. return size_32_bits_real_float;
  108. case sizeof(uint64_t):
  109. return size_64_bits_real_float;
  110. #else // REAL_T_IS_DOUBLE
  111. case sizeof(uint32_t):
  112. return size_32_bits_real_double;
  113. case sizeof(uint64_t):
  114. return size_64_bits_real_double;
  115. #endif
  116. }
  117. return -1;
  118. }
  119. } type_size_array[Variant::VARIANT_MAX + 1] = {
  120. { Variant::NIL, 0, 0, 0, 0 },
  121. { Variant::BOOL, sizeof(uint8_t), sizeof(uint8_t), sizeof(uint8_t), sizeof(uint8_t) },
  122. { Variant::INT, sizeof(int64_t), sizeof(int64_t), sizeof(int64_t), sizeof(int64_t) },
  123. { Variant::FLOAT, sizeof(double), sizeof(double), sizeof(double), sizeof(double) },
  124. { Variant::STRING, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
  125. { Variant::VECTOR2, 2 * sizeof(float), 2 * sizeof(float), 2 * sizeof(double), 2 * sizeof(double) },
  126. { Variant::VECTOR2I, 2 * sizeof(int32_t), 2 * sizeof(int32_t), 2 * sizeof(int32_t), 2 * sizeof(int32_t) },
  127. { Variant::RECT2, 4 * sizeof(float), 4 * sizeof(float), 4 * sizeof(double), 4 * sizeof(double) },
  128. { Variant::RECT2I, 4 * sizeof(int32_t), 4 * sizeof(int32_t), 4 * sizeof(int32_t), 4 * sizeof(int32_t) },
  129. { Variant::VECTOR3, vec3_elems * sizeof(float), vec3_elems * sizeof(float), vec3_elems * sizeof(double), vec3_elems * sizeof(double) },
  130. { Variant::VECTOR3I, 3 * sizeof(int32_t), 3 * sizeof(int32_t), 3 * sizeof(int32_t), 3 * sizeof(int32_t) },
  131. { Variant::TRANSFORM2D, 6 * sizeof(float), 6 * sizeof(float), 6 * sizeof(double), 6 * sizeof(double) },
  132. { Variant::VECTOR4, 4 * sizeof(float), 4 * sizeof(float), 4 * sizeof(double), 4 * sizeof(double) },
  133. { Variant::VECTOR4I, 4 * sizeof(int32_t), 4 * sizeof(int32_t), 4 * sizeof(int32_t), 4 * sizeof(int32_t) },
  134. { Variant::PLANE, (vec3_elems + 1) * sizeof(float), (vec3_elems + 1) * sizeof(float), (vec3_elems + 1) * sizeof(double), (vec3_elems + 1) * sizeof(double) },
  135. { Variant::QUATERNION, 4 * sizeof(float), 4 * sizeof(float), 4 * sizeof(double), 4 * sizeof(double) },
  136. { Variant::AABB, (vec3_elems * 2) * sizeof(float), (vec3_elems * 2) * sizeof(float), (vec3_elems * 2) * sizeof(double), (vec3_elems * 2) * sizeof(double) },
  137. { Variant::BASIS, (vec3_elems * 3) * sizeof(float), (vec3_elems * 3) * sizeof(float), (vec3_elems * 3) * sizeof(double), (vec3_elems * 3) * sizeof(double) },
  138. { Variant::TRANSFORM3D, (vec3_elems * 4) * sizeof(float), (vec3_elems * 4) * sizeof(float), (vec3_elems * 4) * sizeof(double), (vec3_elems * 4) * sizeof(double) },
  139. { Variant::PROJECTION, (vec4_elems * 4) * sizeof(float), (vec4_elems * 4) * sizeof(float), (vec4_elems * 4) * sizeof(double), (vec4_elems * 4) * sizeof(double) },
  140. { Variant::COLOR, 4 * sizeof(float), 4 * sizeof(float), 4 * sizeof(float), 4 * sizeof(float) },
  141. { Variant::STRING_NAME, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
  142. { Variant::NODE_PATH, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
  143. { Variant::RID, sizeof(uint64_t), sizeof(uint64_t), sizeof(uint64_t), sizeof(uint64_t) },
  144. { Variant::OBJECT, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
  145. { Variant::CALLABLE, sizeof(Callable), sizeof(Callable), sizeof(Callable), sizeof(Callable) }, // Hardcoded align.
  146. { Variant::SIGNAL, sizeof(Signal), sizeof(Signal), sizeof(Signal), sizeof(Signal) }, // Hardcoded align.
  147. { Variant::DICTIONARY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
  148. { Variant::ARRAY, ptrsize_32, ptrsize_64, ptrsize_32, ptrsize_64 },
  149. { Variant::PACKED_BYTE_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
  150. { Variant::PACKED_INT32_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
  151. { Variant::PACKED_INT64_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
  152. { Variant::PACKED_FLOAT32_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
  153. { Variant::PACKED_FLOAT64_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
  154. { Variant::PACKED_STRING_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
  155. { Variant::PACKED_VECTOR2_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
  156. { Variant::PACKED_VECTOR3_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
  157. { Variant::PACKED_COLOR_ARRAY, ptrsize_32 * 2, ptrsize_64 * 2, ptrsize_32 * 2, ptrsize_64 * 2 },
  158. { 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 },
  159. };
  160. // Validate sizes at compile time for the current build configuration.
  161. static_assert(type_size_array[Variant::BOOL][sizeof(void *)] == sizeof(GDNativeBool), "Size of bool mismatch");
  162. static_assert(type_size_array[Variant::INT][sizeof(void *)] == sizeof(GDNativeInt), "Size of int mismatch");
  163. static_assert(type_size_array[Variant::FLOAT][sizeof(void *)] == sizeof(double), "Size of float mismatch");
  164. static_assert(type_size_array[Variant::STRING][sizeof(void *)] == sizeof(String), "Size of String mismatch");
  165. static_assert(type_size_array[Variant::VECTOR2][sizeof(void *)] == sizeof(Vector2), "Size of Vector2 mismatch");
  166. static_assert(type_size_array[Variant::VECTOR2I][sizeof(void *)] == sizeof(Vector2i), "Size of Vector2i mismatch");
  167. static_assert(type_size_array[Variant::RECT2][sizeof(void *)] == sizeof(Rect2), "Size of Rect2 mismatch");
  168. static_assert(type_size_array[Variant::RECT2I][sizeof(void *)] == sizeof(Rect2i), "Size of Rect2i mismatch");
  169. static_assert(type_size_array[Variant::VECTOR3][sizeof(void *)] == sizeof(Vector3), "Size of Vector3 mismatch");
  170. static_assert(type_size_array[Variant::VECTOR3I][sizeof(void *)] == sizeof(Vector3i), "Size of Vector3i mismatch");
  171. static_assert(type_size_array[Variant::TRANSFORM2D][sizeof(void *)] == sizeof(Transform2D), "Size of Transform2D mismatch");
  172. static_assert(type_size_array[Variant::VECTOR4][sizeof(void *)] == sizeof(Vector4), "Size of Vector4 mismatch");
  173. static_assert(type_size_array[Variant::VECTOR4I][sizeof(void *)] == sizeof(Vector4i), "Size of Vector4i mismatch");
  174. static_assert(type_size_array[Variant::PLANE][sizeof(void *)] == sizeof(Plane), "Size of Plane mismatch");
  175. static_assert(type_size_array[Variant::QUATERNION][sizeof(void *)] == sizeof(Quaternion), "Size of Quaternion mismatch");
  176. static_assert(type_size_array[Variant::AABB][sizeof(void *)] == sizeof(AABB), "Size of AABB mismatch");
  177. static_assert(type_size_array[Variant::BASIS][sizeof(void *)] == sizeof(Basis), "Size of Basis mismatch");
  178. static_assert(type_size_array[Variant::TRANSFORM3D][sizeof(void *)] == sizeof(Transform3D), "Size of Transform3D mismatch");
  179. static_assert(type_size_array[Variant::PROJECTION][sizeof(void *)] == sizeof(Projection), "Size of Projection mismatch");
  180. static_assert(type_size_array[Variant::COLOR][sizeof(void *)] == sizeof(Color), "Size of Color mismatch");
  181. static_assert(type_size_array[Variant::STRING_NAME][sizeof(void *)] == sizeof(StringName), "Size of StringName mismatch");
  182. static_assert(type_size_array[Variant::NODE_PATH][sizeof(void *)] == sizeof(NodePath), "Size of NodePath mismatch");
  183. static_assert(type_size_array[Variant::RID][sizeof(void *)] == sizeof(RID), "Size of RID mismatch");
  184. static_assert(type_size_array[Variant::OBJECT][sizeof(void *)] == sizeof(Object *), "Size of Object mismatch");
  185. static_assert(type_size_array[Variant::CALLABLE][sizeof(void *)] == sizeof(Callable), "Size of Callable mismatch");
  186. static_assert(type_size_array[Variant::SIGNAL][sizeof(void *)] == sizeof(Signal), "Size of Signal mismatch");
  187. static_assert(type_size_array[Variant::DICTIONARY][sizeof(void *)] == sizeof(Dictionary), "Size of Dictionary mismatch");
  188. static_assert(type_size_array[Variant::ARRAY][sizeof(void *)] == sizeof(Array), "Size of Array mismatch");
  189. static_assert(type_size_array[Variant::PACKED_BYTE_ARRAY][sizeof(void *)] == sizeof(PackedByteArray), "Size of PackedByteArray mismatch");
  190. static_assert(type_size_array[Variant::PACKED_INT32_ARRAY][sizeof(void *)] == sizeof(PackedInt32Array), "Size of PackedInt32Array mismatch");
  191. static_assert(type_size_array[Variant::PACKED_INT64_ARRAY][sizeof(void *)] == sizeof(PackedInt64Array), "Size of PackedInt64Array mismatch");
  192. static_assert(type_size_array[Variant::PACKED_FLOAT32_ARRAY][sizeof(void *)] == sizeof(PackedFloat32Array), "Size of PackedFloat32Array mismatch");
  193. static_assert(type_size_array[Variant::PACKED_FLOAT64_ARRAY][sizeof(void *)] == sizeof(PackedFloat64Array), "Size of PackedFloat64Array mismatch");
  194. static_assert(type_size_array[Variant::PACKED_STRING_ARRAY][sizeof(void *)] == sizeof(PackedStringArray), "Size of PackedStringArray mismatch");
  195. static_assert(type_size_array[Variant::PACKED_VECTOR2_ARRAY][sizeof(void *)] == sizeof(PackedVector2Array), "Size of PackedVector2Array mismatch");
  196. static_assert(type_size_array[Variant::PACKED_VECTOR3_ARRAY][sizeof(void *)] == sizeof(PackedVector3Array), "Size of PackedVector3Array mismatch");
  197. static_assert(type_size_array[Variant::PACKED_COLOR_ARRAY][sizeof(void *)] == sizeof(PackedColorArray), "Size of PackedColorArray mismatch");
  198. static_assert(type_size_array[Variant::VARIANT_MAX][sizeof(void *)] == sizeof(Variant), "Size of Variant mismatch");
  199. Array core_type_sizes;
  200. for (int i = 0; i < 4; i++) {
  201. Dictionary d;
  202. d["build_configuration"] = build_config_name[i];
  203. Array sizes;
  204. for (int j = 0; j <= Variant::VARIANT_MAX; j++) {
  205. Variant::Type t = type_size_array[j].type;
  206. String name = t == Variant::VARIANT_MAX ? String("Variant") : Variant::get_type_name(t);
  207. Dictionary d2;
  208. d2["name"] = name;
  209. uint32_t size = 0;
  210. switch (i) {
  211. case 0:
  212. size = type_size_array[j].size_32_bits_real_float;
  213. break;
  214. case 1:
  215. size = type_size_array[j].size_64_bits_real_float;
  216. break;
  217. case 2:
  218. size = type_size_array[j].size_32_bits_real_double;
  219. break;
  220. case 3:
  221. size = type_size_array[j].size_64_bits_real_double;
  222. break;
  223. }
  224. d2["size"] = size;
  225. sizes.push_back(d2);
  226. }
  227. d["sizes"] = sizes;
  228. core_type_sizes.push_back(d);
  229. }
  230. api_dump["builtin_class_sizes"] = core_type_sizes;
  231. }
  232. {
  233. // Member offsets sizes.
  234. struct {
  235. Variant::Type type;
  236. const char *member;
  237. uint32_t offset_32_bits_real_float;
  238. uint32_t offset_64_bits_real_float;
  239. uint32_t offset_32_bits_real_double;
  240. uint32_t offset_64_bits_real_double;
  241. } member_offset_array[] = {
  242. { Variant::VECTOR2, "x", 0, 0, 0, 0 },
  243. { Variant::VECTOR2, "y", sizeof(float), sizeof(float), sizeof(double), sizeof(double) },
  244. { Variant::VECTOR2I, "x", 0, 0, 0, 0 },
  245. { Variant::VECTOR2I, "y", sizeof(int32_t), sizeof(int32_t), sizeof(int32_t), sizeof(int32_t) },
  246. { Variant::RECT2, "position", 0, 0, 0, 0 },
  247. { Variant::RECT2, "size", 2 * sizeof(Vector2), 2 * sizeof(float), 2 * sizeof(double), 2 * sizeof(double) },
  248. { Variant::RECT2I, "position", 0, 0, 0, 0 },
  249. { Variant::RECT2I, "size", 2 * sizeof(int32_t), 2 * sizeof(int32_t), 2 * sizeof(int32_t), 2 * sizeof(int32_t) },
  250. { Variant::VECTOR3, "x", 0, 0, 0, 0 },
  251. { Variant::VECTOR3, "y", sizeof(float), sizeof(float), sizeof(double), sizeof(double) },
  252. { Variant::VECTOR3, "z", 2 * sizeof(float), 2 * sizeof(float), 2 * sizeof(double), 2 * sizeof(double) },
  253. { Variant::VECTOR3I, "x", 0, 0, 0, 0 },
  254. { Variant::VECTOR3I, "y", sizeof(int32_t), sizeof(int32_t), sizeof(int32_t), sizeof(int32_t) },
  255. { Variant::VECTOR3I, "z", 2 * sizeof(int32_t), 2 * sizeof(int32_t), 2 * sizeof(int32_t), 2 * sizeof(int32_t) },
  256. { Variant::TRANSFORM2D, "x", 0, 0, 0, 0 },
  257. { Variant::TRANSFORM2D, "y", 2 * sizeof(float), 2 * sizeof(float), 2 * sizeof(double), 2 * sizeof(double) },
  258. { Variant::TRANSFORM2D, "origin", 4 * sizeof(float), 4 * sizeof(float), 4 * sizeof(double), 4 * sizeof(double) },
  259. { Variant::VECTOR4, "x", 0, 0, 0, 0 },
  260. { Variant::VECTOR4, "y", sizeof(float), sizeof(float), sizeof(double), sizeof(double) },
  261. { Variant::VECTOR4, "z", 2 * sizeof(float), 2 * sizeof(float), 2 * sizeof(double), 2 * sizeof(double) },
  262. { Variant::VECTOR4, "w", 3 * sizeof(float), 3 * sizeof(float), 3 * sizeof(double), 3 * sizeof(double) },
  263. { Variant::VECTOR4I, "x", 0, 0, 0, 0 },
  264. { Variant::VECTOR4I, "y", sizeof(int32_t), sizeof(int32_t), sizeof(int32_t), sizeof(int32_t) },
  265. { Variant::VECTOR4I, "z", 2 * sizeof(int32_t), 2 * sizeof(int32_t), 2 * sizeof(int32_t), 2 * sizeof(int32_t) },
  266. { Variant::VECTOR4I, "w", 3 * sizeof(int32_t), 3 * sizeof(int32_t), 3 * sizeof(int32_t), 3 * sizeof(int32_t) },
  267. { Variant::PLANE, "normal", 0, 0, 0, 0 },
  268. { Variant::PLANE, "d", vec3_elems * sizeof(float), vec3_elems * sizeof(float), vec3_elems * sizeof(double), vec3_elems * sizeof(double) },
  269. { Variant::QUATERNION, "x", 0, 0, 0, 0 },
  270. { Variant::QUATERNION, "y", sizeof(float), sizeof(float), sizeof(double), sizeof(double) },
  271. { Variant::QUATERNION, "z", 2 * sizeof(float), 2 * sizeof(float), 2 * sizeof(double), 2 * sizeof(double) },
  272. { Variant::QUATERNION, "w", 3 * sizeof(float), 3 * sizeof(float), 3 * sizeof(double), 3 * sizeof(double) },
  273. { Variant::AABB, "position", 0, 0, 0, 0 },
  274. { Variant::AABB, "size", vec3_elems * sizeof(float), vec3_elems * sizeof(float), vec3_elems * sizeof(double), vec3_elems * sizeof(double) },
  275. // Remember that basis vectors are flipped!
  276. { Variant::BASIS, "x", 0, 0, 0, 0 },
  277. { Variant::BASIS, "y", vec3_elems * sizeof(float), vec3_elems * sizeof(float), vec3_elems * sizeof(double), vec3_elems * sizeof(double) },
  278. { Variant::BASIS, "z", vec3_elems * 2 * sizeof(float), vec3_elems * 2 * sizeof(float), vec3_elems * 2 * sizeof(double), vec3_elems * 2 * sizeof(double) },
  279. { Variant::TRANSFORM3D, "basis", 0, 0, 0, 0 },
  280. { Variant::TRANSFORM3D, "origin", (vec3_elems * 3) * sizeof(float), (vec3_elems * 3) * sizeof(float), (vec3_elems * 3) * sizeof(double), (vec3_elems * 3) * sizeof(double) },
  281. { Variant::PROJECTION, "x", 0, 0, 0, 0 },
  282. { Variant::PROJECTION, "y", vec4_elems * sizeof(float), vec4_elems * sizeof(float), vec4_elems * sizeof(double), vec4_elems * sizeof(double) },
  283. { Variant::PROJECTION, "z", vec4_elems * 2 * sizeof(float), vec4_elems * 2 * sizeof(float), vec4_elems * 2 * sizeof(double), vec4_elems * 2 * sizeof(double) },
  284. { Variant::PROJECTION, "w", vec4_elems * 3 * sizeof(float), vec4_elems * 3 * sizeof(float), vec4_elems * 3 * sizeof(double), vec4_elems * 3 * sizeof(double) },
  285. { Variant::COLOR, "r", 0, 0, 0, 0 },
  286. { Variant::COLOR, "g", sizeof(float), sizeof(float), sizeof(float), sizeof(float) },
  287. { Variant::COLOR, "b", 2 * sizeof(float), 2 * sizeof(float), 2 * sizeof(float), 2 * sizeof(float) },
  288. { Variant::COLOR, "a", 3 * sizeof(float), 3 * sizeof(float), 3 * sizeof(float), 3 * sizeof(float) },
  289. { Variant::NIL, nullptr, 0, 0, 0, 0 },
  290. };
  291. Array core_type_member_offsets;
  292. for (int i = 0; i < 4; i++) {
  293. Dictionary d;
  294. d["build_configuration"] = build_config_name[i];
  295. Array type_offsets;
  296. uint32_t idx = 0;
  297. Variant::Type last_type = Variant::NIL;
  298. Dictionary d2;
  299. Array members;
  300. while (true) {
  301. Variant::Type t = member_offset_array[idx].type;
  302. if (t != last_type) {
  303. if (last_type != Variant::NIL) {
  304. d2["members"] = members;
  305. type_offsets.push_back(d2);
  306. }
  307. if (t == Variant::NIL) {
  308. break;
  309. }
  310. String name = t == Variant::VARIANT_MAX ? String("Variant") : Variant::get_type_name(t);
  311. d2 = Dictionary();
  312. members = Array();
  313. d2["name"] = name;
  314. last_type = t;
  315. }
  316. Dictionary d3;
  317. uint32_t offset = 0;
  318. switch (i) {
  319. case 0:
  320. offset = member_offset_array[idx].offset_32_bits_real_float;
  321. break;
  322. case 1:
  323. offset = member_offset_array[idx].offset_64_bits_real_float;
  324. break;
  325. case 2:
  326. offset = member_offset_array[idx].offset_32_bits_real_double;
  327. break;
  328. case 3:
  329. offset = member_offset_array[idx].offset_64_bits_real_double;
  330. break;
  331. }
  332. d3["member"] = member_offset_array[idx].member;
  333. d3["offset"] = offset;
  334. members.push_back(d3);
  335. idx++;
  336. }
  337. d["classes"] = type_offsets;
  338. core_type_member_offsets.push_back(d);
  339. }
  340. api_dump["builtin_class_member_offsets"] = core_type_member_offsets;
  341. }
  342. {
  343. // Global enums and constants.
  344. Array constants;
  345. HashMap<String, List<Pair<String, int64_t>>> enum_list;
  346. for (int i = 0; i < CoreConstants::get_global_constant_count(); i++) {
  347. int64_t value = CoreConstants::get_global_constant_value(i);
  348. String enum_name = CoreConstants::get_global_constant_enum(i);
  349. String name = CoreConstants::get_global_constant_name(i);
  350. if (!enum_name.is_empty()) {
  351. enum_list[enum_name].push_back(Pair<String, int64_t>(name, value));
  352. } else {
  353. Dictionary d;
  354. d["name"] = name;
  355. d["value"] = value;
  356. constants.push_back(d);
  357. }
  358. }
  359. api_dump["global_constants"] = constants;
  360. Array enums;
  361. for (const KeyValue<String, List<Pair<String, int64_t>>> &E : enum_list) {
  362. Dictionary d1;
  363. d1["name"] = E.key;
  364. Array values;
  365. for (const Pair<String, int64_t> &F : E.value) {
  366. Dictionary d2;
  367. d2["name"] = F.first;
  368. d2["value"] = F.second;
  369. values.push_back(d2);
  370. }
  371. d1["values"] = values;
  372. enums.push_back(d1);
  373. }
  374. api_dump["global_enums"] = enums;
  375. }
  376. {
  377. Array utility_funcs;
  378. List<StringName> utility_func_names;
  379. Variant::get_utility_function_list(&utility_func_names);
  380. for (const StringName &name : utility_func_names) {
  381. Dictionary func;
  382. func["name"] = String(name);
  383. if (Variant::has_utility_function_return_value(name)) {
  384. Variant::Type rt = Variant::get_utility_function_return_type(name);
  385. func["return_type"] = rt == Variant::NIL ? String("Variant") : Variant::get_type_name(rt);
  386. }
  387. switch (Variant::get_utility_function_type(name)) {
  388. case Variant::UTILITY_FUNC_TYPE_MATH:
  389. func["category"] = "math";
  390. break;
  391. case Variant::UTILITY_FUNC_TYPE_RANDOM:
  392. func["category"] = "random";
  393. break;
  394. case Variant::UTILITY_FUNC_TYPE_GENERAL:
  395. func["category"] = "general";
  396. break;
  397. }
  398. bool vararg = Variant::is_utility_function_vararg(name);
  399. func["is_vararg"] = Variant::is_utility_function_vararg(name);
  400. func["hash"] = Variant::get_utility_function_hash(name);
  401. Array arguments;
  402. int argcount = Variant::get_utility_function_argument_count(name);
  403. for (int i = 0; i < argcount; i++) {
  404. Dictionary arg;
  405. String argname = vararg ? "arg" + itos(i + 1) : Variant::get_utility_function_argument_name(name, i);
  406. arg["name"] = argname;
  407. Variant::Type argtype = Variant::get_utility_function_argument_type(name, i);
  408. arg["type"] = argtype == Variant::NIL ? String("Variant") : Variant::get_type_name(argtype);
  409. //no default value support in utility functions
  410. arguments.push_back(arg);
  411. }
  412. if (arguments.size()) {
  413. func["arguments"] = arguments;
  414. }
  415. utility_funcs.push_back(func);
  416. }
  417. api_dump["utility_functions"] = utility_funcs;
  418. }
  419. {
  420. // builtin types
  421. Array builtins;
  422. for (int i = 0; i < Variant::VARIANT_MAX; i++) {
  423. if (i == Variant::OBJECT) {
  424. continue;
  425. }
  426. Variant::Type type = Variant::Type(i);
  427. Dictionary d;
  428. d["name"] = Variant::get_type_name(type);
  429. if (Variant::has_indexing(type)) {
  430. Variant::Type index_type = Variant::get_indexed_element_type(type);
  431. d["indexing_return_type"] = index_type == Variant::NIL ? String("Variant") : Variant::get_type_name(index_type);
  432. }
  433. d["is_keyed"] = Variant::is_keyed(type);
  434. {
  435. //members
  436. Array members;
  437. List<StringName> member_names;
  438. Variant::get_member_list(type, &member_names);
  439. for (const StringName &member_name : member_names) {
  440. Dictionary d2;
  441. d2["name"] = String(member_name);
  442. d2["type"] = Variant::get_type_name(Variant::get_member_type(type, member_name));
  443. members.push_back(d2);
  444. }
  445. if (members.size()) {
  446. d["members"] = members;
  447. }
  448. }
  449. {
  450. //constants
  451. Array constants;
  452. List<StringName> constant_names;
  453. Variant::get_constants_for_type(type, &constant_names);
  454. for (const StringName &constant_name : constant_names) {
  455. Dictionary d2;
  456. d2["name"] = String(constant_name);
  457. Variant constant = Variant::get_constant_value(type, constant_name);
  458. d2["type"] = Variant::get_type_name(constant.get_type());
  459. d2["value"] = constant.get_construct_string();
  460. constants.push_back(d2);
  461. }
  462. if (constants.size()) {
  463. d["constants"] = constants;
  464. }
  465. }
  466. {
  467. //enums
  468. Array enums;
  469. List<StringName> enum_names;
  470. Variant::get_enums_for_type(type, &enum_names);
  471. for (const StringName &enum_name : enum_names) {
  472. Dictionary enum_dict;
  473. enum_dict["name"] = String(enum_name);
  474. List<StringName> enumeration_names;
  475. Variant::get_enumerations_for_enum(type, enum_name, &enumeration_names);
  476. Array values;
  477. for (const StringName &enumeration : enumeration_names) {
  478. Dictionary values_dict;
  479. values_dict["name"] = String(enumeration);
  480. values_dict["value"] = Variant::get_enum_value(type, enum_name, enumeration);
  481. values.push_back(values_dict);
  482. }
  483. if (values.size()) {
  484. enum_dict["values"] = values;
  485. }
  486. enums.push_back(enum_dict);
  487. }
  488. if (enums.size()) {
  489. d["enums"] = enums;
  490. }
  491. }
  492. {
  493. //operators
  494. Array operators;
  495. for (int j = 0; j < Variant::VARIANT_MAX; j++) {
  496. for (int k = 0; k < Variant::OP_MAX; k++) {
  497. Variant::Type rt = Variant::get_operator_return_type(Variant::Operator(k), type, Variant::Type(j));
  498. if (rt != Variant::NIL) {
  499. Dictionary d2;
  500. d2["name"] = Variant::get_operator_name(Variant::Operator(k));
  501. if (k != Variant::OP_NEGATE && k != Variant::OP_POSITIVE && k != Variant::OP_NOT && k != Variant::OP_BIT_NEGATE) {
  502. d2["right_type"] = Variant::get_type_name(Variant::Type(j));
  503. }
  504. d2["return_type"] = Variant::get_type_name(Variant::get_operator_return_type(Variant::Operator(k), type, Variant::Type(j)));
  505. operators.push_back(d2);
  506. }
  507. }
  508. }
  509. if (operators.size()) {
  510. d["operators"] = operators;
  511. }
  512. }
  513. {
  514. //methods
  515. Array methods;
  516. List<StringName> method_names;
  517. Variant::get_builtin_method_list(type, &method_names);
  518. for (const StringName &method_name : method_names) {
  519. Dictionary d2;
  520. d2["name"] = String(method_name);
  521. if (Variant::has_builtin_method_return_value(type, method_name)) {
  522. Variant::Type ret_type = Variant::get_builtin_method_return_type(type, method_name);
  523. d2["return_type"] = ret_type == Variant::NIL ? String("Variant") : Variant::get_type_name(ret_type);
  524. }
  525. d2["is_vararg"] = Variant::is_builtin_method_vararg(type, method_name);
  526. d2["is_const"] = Variant::is_builtin_method_const(type, method_name);
  527. d2["is_static"] = Variant::is_builtin_method_static(type, method_name);
  528. d2["hash"] = Variant::get_builtin_method_hash(type, method_name);
  529. Vector<Variant> default_args = Variant::get_builtin_method_default_arguments(type, method_name);
  530. Array arguments;
  531. int argcount = Variant::get_builtin_method_argument_count(type, method_name);
  532. for (int j = 0; j < argcount; j++) {
  533. Dictionary d3;
  534. d3["name"] = Variant::get_builtin_method_argument_name(type, method_name, j);
  535. Variant::Type argtype = Variant::get_builtin_method_argument_type(type, method_name, j);
  536. d3["type"] = argtype == Variant::NIL ? String("Variant") : Variant::get_type_name(argtype);
  537. if (j >= (argcount - default_args.size())) {
  538. int dargidx = j - (argcount - default_args.size());
  539. d3["default_value"] = default_args[dargidx].get_construct_string();
  540. }
  541. arguments.push_back(d3);
  542. }
  543. if (arguments.size()) {
  544. d2["arguments"] = arguments;
  545. }
  546. methods.push_back(d2);
  547. }
  548. if (methods.size()) {
  549. d["methods"] = methods;
  550. }
  551. }
  552. {
  553. //constructors
  554. Array constructors;
  555. for (int j = 0; j < Variant::get_constructor_count(type); j++) {
  556. Dictionary d2;
  557. d2["index"] = j;
  558. Array arguments;
  559. int argcount = Variant::get_constructor_argument_count(type, j);
  560. for (int k = 0; k < argcount; k++) {
  561. Dictionary d3;
  562. d3["name"] = Variant::get_constructor_argument_name(type, j, k);
  563. d3["type"] = Variant::get_type_name(Variant::get_constructor_argument_type(type, j, k));
  564. arguments.push_back(d3);
  565. }
  566. if (arguments.size()) {
  567. d2["arguments"] = arguments;
  568. }
  569. constructors.push_back(d2);
  570. }
  571. if (constructors.size()) {
  572. d["constructors"] = constructors;
  573. }
  574. }
  575. {
  576. //destructor
  577. d["has_destructor"] = Variant::has_destructor(type);
  578. }
  579. builtins.push_back(d);
  580. }
  581. api_dump["builtin_classes"] = builtins;
  582. }
  583. {
  584. // classes
  585. Array classes;
  586. List<StringName> class_list;
  587. ClassDB::get_class_list(&class_list);
  588. class_list.sort_custom<StringName::AlphCompare>();
  589. for (const StringName &class_name : class_list) {
  590. Dictionary d;
  591. d["name"] = String(class_name);
  592. d["is_refcounted"] = ClassDB::is_parent_class(class_name, "RefCounted");
  593. d["is_instantiable"] = ClassDB::can_instantiate(class_name);
  594. StringName parent_class = ClassDB::get_parent_class(class_name);
  595. if (parent_class != StringName()) {
  596. d["inherits"] = String(parent_class);
  597. }
  598. {
  599. ClassDB::APIType api = ClassDB::get_api_type(class_name);
  600. static const char *api_type[5] = { "core", "editor", "extension", "editor_extension" };
  601. d["api_type"] = api_type[api];
  602. }
  603. {
  604. //constants
  605. Array constants;
  606. List<String> constant_list;
  607. ClassDB::get_integer_constant_list(class_name, &constant_list, true);
  608. for (const String &F : constant_list) {
  609. StringName enum_name = ClassDB::get_integer_constant_enum(class_name, F);
  610. if (enum_name != StringName()) {
  611. continue; //enums will be handled on their own
  612. }
  613. Dictionary d2;
  614. d2["name"] = String(F);
  615. d2["value"] = ClassDB::get_integer_constant(class_name, F);
  616. constants.push_back(d2);
  617. }
  618. if (constants.size()) {
  619. d["constants"] = constants;
  620. }
  621. }
  622. {
  623. //enum
  624. Array enums;
  625. List<StringName> enum_list;
  626. ClassDB::get_enum_list(class_name, &enum_list, true);
  627. for (const StringName &F : enum_list) {
  628. Dictionary d2;
  629. d2["name"] = String(F);
  630. d2["is_bitfield"] = ClassDB::is_enum_bitfield(class_name, F);
  631. Array values;
  632. List<StringName> enum_constant_list;
  633. ClassDB::get_enum_constants(class_name, F, &enum_constant_list, true);
  634. for (List<StringName>::Element *G = enum_constant_list.front(); G; G = G->next()) {
  635. Dictionary d3;
  636. d3["name"] = String(G->get());
  637. d3["value"] = ClassDB::get_integer_constant(class_name, G->get());
  638. values.push_back(d3);
  639. }
  640. d2["values"] = values;
  641. enums.push_back(d2);
  642. }
  643. if (enums.size()) {
  644. d["enums"] = enums;
  645. }
  646. }
  647. {
  648. //methods
  649. Array methods;
  650. List<MethodInfo> method_list;
  651. ClassDB::get_method_list(class_name, &method_list, true);
  652. for (const MethodInfo &F : method_list) {
  653. StringName method_name = F.name;
  654. if ((F.flags & METHOD_FLAG_VIRTUAL) && !(F.flags & METHOD_FLAG_OBJECT_CORE)) {
  655. //virtual method
  656. const MethodInfo &mi = F;
  657. Dictionary d2;
  658. d2["name"] = String(method_name);
  659. d2["is_const"] = (F.flags & METHOD_FLAG_CONST) ? true : false;
  660. d2["is_static"] = (F.flags & METHOD_FLAG_STATIC) ? true : false;
  661. d2["is_vararg"] = false;
  662. d2["is_virtual"] = true;
  663. // virtual functions have no hash since no MethodBind is involved
  664. bool has_return = mi.return_val.type != Variant::NIL || (mi.return_val.usage & PROPERTY_USAGE_NIL_IS_VARIANT);
  665. Array arguments;
  666. for (int i = (has_return ? -1 : 0); i < mi.arguments.size(); i++) {
  667. PropertyInfo pinfo = i == -1 ? mi.return_val : mi.arguments[i];
  668. Dictionary d3;
  669. if (i >= 0) {
  670. d3["name"] = pinfo.name;
  671. }
  672. d3["type"] = get_type_name(pinfo);
  673. if (i == -1) {
  674. d2["return_value"] = d3;
  675. } else {
  676. arguments.push_back(d3);
  677. }
  678. }
  679. if (arguments.size()) {
  680. d2["arguments"] = arguments;
  681. }
  682. methods.push_back(d2);
  683. } else if (F.name.begins_with("_")) {
  684. //hidden method, ignore
  685. } else {
  686. Dictionary d2;
  687. d2["name"] = String(method_name);
  688. MethodBind *method = ClassDB::get_method(class_name, method_name);
  689. if (!method) {
  690. continue;
  691. }
  692. d2["is_const"] = method->is_const();
  693. d2["is_vararg"] = method->is_vararg();
  694. d2["is_static"] = method->is_static();
  695. d2["is_virtual"] = false;
  696. d2["hash"] = method->get_hash();
  697. Vector<Variant> default_args = method->get_default_arguments();
  698. Array arguments;
  699. for (int i = (method->has_return() ? -1 : 0); i < method->get_argument_count(); i++) {
  700. PropertyInfo pinfo = i == -1 ? method->get_return_info() : method->get_argument_info(i);
  701. Dictionary d3;
  702. if (i >= 0) {
  703. d3["name"] = pinfo.name;
  704. }
  705. d3["type"] = get_type_name(pinfo);
  706. if (method->get_argument_meta(i) > 0) {
  707. static const char *argmeta[11] = { "none", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64", "float", "double" };
  708. d3["meta"] = argmeta[method->get_argument_meta(i)];
  709. }
  710. if (i >= 0 && i >= (method->get_argument_count() - default_args.size())) {
  711. int dargidx = i - (method->get_argument_count() - default_args.size());
  712. d3["default_value"] = default_args[dargidx].get_construct_string();
  713. }
  714. if (i == -1) {
  715. d2["return_value"] = d3;
  716. } else {
  717. arguments.push_back(d3);
  718. }
  719. }
  720. if (arguments.size()) {
  721. d2["arguments"] = arguments;
  722. }
  723. methods.push_back(d2);
  724. }
  725. }
  726. if (methods.size()) {
  727. d["methods"] = methods;
  728. }
  729. }
  730. {
  731. //signals
  732. Array signals;
  733. List<MethodInfo> signal_list;
  734. ClassDB::get_signal_list(class_name, &signal_list, true);
  735. for (const MethodInfo &F : signal_list) {
  736. StringName signal_name = F.name;
  737. Dictionary d2;
  738. d2["name"] = String(signal_name);
  739. Array arguments;
  740. for (int i = 0; i < F.arguments.size(); i++) {
  741. Dictionary d3;
  742. d3["name"] = F.arguments[i].name;
  743. d3["type"] = get_type_name(F.arguments[i]);
  744. arguments.push_back(d3);
  745. }
  746. if (arguments.size()) {
  747. d2["arguments"] = arguments;
  748. }
  749. signals.push_back(d2);
  750. }
  751. if (signals.size()) {
  752. d["signals"] = signals;
  753. }
  754. }
  755. {
  756. //properties
  757. Array properties;
  758. List<PropertyInfo> property_list;
  759. ClassDB::get_property_list(class_name, &property_list, true);
  760. for (const PropertyInfo &F : property_list) {
  761. 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)) {
  762. continue; //not real properties
  763. }
  764. if (F.name.begins_with("_")) {
  765. continue; //hidden property
  766. }
  767. if (F.name.find("/") >= 0) {
  768. // Ignore properties with '/' (slash) in the name. These are only meant for use in the inspector.
  769. continue;
  770. }
  771. StringName property_name = F.name;
  772. Dictionary d2;
  773. d2["type"] = get_type_name(F);
  774. d2["name"] = String(property_name);
  775. d2["setter"] = ClassDB::get_property_setter(class_name, F.name);
  776. d2["getter"] = ClassDB::get_property_getter(class_name, F.name);
  777. d2["index"] = ClassDB::get_property_index(class_name, F.name);
  778. properties.push_back(d2);
  779. }
  780. if (properties.size()) {
  781. d["properties"] = properties;
  782. }
  783. }
  784. classes.push_back(d);
  785. }
  786. api_dump["classes"] = classes;
  787. }
  788. {
  789. // singletons
  790. Array singletons;
  791. List<Engine::Singleton> singleton_list;
  792. Engine::get_singleton()->get_singletons(&singleton_list);
  793. for (const Engine::Singleton &s : singleton_list) {
  794. Dictionary d;
  795. d["name"] = s.name;
  796. if (s.class_name != StringName()) {
  797. d["type"] = String(s.class_name);
  798. } else {
  799. d["type"] = String(s.ptr->get_class());
  800. }
  801. singletons.push_back(d);
  802. }
  803. if (singletons.size()) {
  804. api_dump["singletons"] = singletons;
  805. }
  806. }
  807. {
  808. Array native_structures;
  809. List<StringName> native_structs;
  810. ClassDB::get_native_struct_list(&native_structs);
  811. native_structs.sort_custom<StringName::AlphCompare>();
  812. for (const StringName &E : native_structs) {
  813. String code = ClassDB::get_native_struct_code(E);
  814. Dictionary d;
  815. d["name"] = String(E);
  816. d["format"] = code;
  817. native_structures.push_back(d);
  818. }
  819. api_dump["native_structures"] = native_structures;
  820. }
  821. return api_dump;
  822. }
  823. void NativeExtensionAPIDump::generate_extension_json_file(const String &p_path) {
  824. Dictionary api = generate_extension_api();
  825. Ref<JSON> json;
  826. json.instantiate();
  827. String text = json->stringify(api, "\t", false);
  828. Ref<FileAccess> fa = FileAccess::open(p_path, FileAccess::WRITE);
  829. CharString cs = text.ascii();
  830. fa->store_buffer((const uint8_t *)cs.ptr(), cs.length());
  831. }
  832. #endif