1 module godot.abi.types; 2 3 //import godot.abi.api; 4 import godot.api.types; 5 // import core.stdc.stddef : wchar_t; 6 7 @nogc nothrow: 8 extern (C): 9 10 ////// Error 11 12 enum godot_error { 13 GODOT_OK, 14 GODOT_FAILED, ///< Generic fail error 15 GODOT_ERR_UNAVAILABLE, ///< What is requested is unsupported/unavailable 16 GODOT_ERR_UNCONFIGURED, ///< The object being used hasnt been properly set up yet 17 GODOT_ERR_UNAUTHORIZED, ///< Missing credentials for requested resource 18 GODOT_ERR_PARAMETER_RANGE_ERROR, ///< Parameter given out of range (5) 19 GODOT_ERR_OUT_OF_MEMORY, ///< Out of memory 20 GODOT_ERR_FILE_NOT_FOUND, 21 GODOT_ERR_FILE_BAD_DRIVE, 22 GODOT_ERR_FILE_BAD_PATH, 23 GODOT_ERR_FILE_NO_PERMISSION, // (10) 24 GODOT_ERR_FILE_ALREADY_IN_USE, 25 GODOT_ERR_FILE_CANT_OPEN, 26 GODOT_ERR_FILE_CANT_WRITE, 27 GODOT_ERR_FILE_CANT_READ, 28 GODOT_ERR_FILE_UNRECOGNIZED, // (15) 29 GODOT_ERR_FILE_CORRUPT, 30 GODOT_ERR_FILE_MISSING_DEPENDENCIES, 31 GODOT_ERR_FILE_EOF, 32 GODOT_ERR_CANT_OPEN, ///< Can't open a resource/socket/file 33 GODOT_ERR_CANT_CREATE, // (20) 34 GODOT_ERR_QUERY_FAILED, 35 GODOT_ERR_ALREADY_IN_USE, 36 GODOT_ERR_LOCKED, ///< resource is locked 37 GODOT_ERR_TIMEOUT, 38 GODOT_ERR_CANT_CONNECT, // (25) 39 GODOT_ERR_CANT_RESOLVE, 40 GODOT_ERR_CONNECTION_ERROR, 41 GODOT_ERR_CANT_ACQUIRE_RESOURCE, 42 GODOT_ERR_CANT_FORK, 43 GODOT_ERR_INVALID_DATA, ///< Data passed is invalid (30) 44 GODOT_ERR_INVALID_PARAMETER, ///< Parameter passed is invalid 45 GODOT_ERR_ALREADY_EXISTS, ///< When adding, item already exists 46 GODOT_ERR_DOES_NOT_EXIST, ///< When retrieving/erasing, it item does not exist 47 GODOT_ERR_DATABASE_CANT_READ, ///< database is full 48 GODOT_ERR_DATABASE_CANT_WRITE, ///< database is full (35) 49 GODOT_ERR_COMPILATION_FAILED, 50 GODOT_ERR_METHOD_NOT_FOUND, 51 GODOT_ERR_LINK_FAILED, 52 GODOT_ERR_SCRIPT_FAILED, 53 GODOT_ERR_CYCLIC_LINK, // (40) 54 GODOT_ERR_INVALID_DECLARATION, 55 GODOT_ERR_DUPLICATE_SYMBOL, 56 GODOT_ERR_PARSE_ERROR, 57 GODOT_ERR_BUSY, 58 GODOT_ERR_SKIP, // (45) 59 GODOT_ERR_HELP, ///< user requested help!! 60 GODOT_ERR_BUG, ///< a bug in the software certainly happened, due to a double check failing or unexpected behavior. 61 GODOT_ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames 62 GODOT_ERR_OMFG_THIS_IS_VERY_VERY_BAD, ///< shit happens, has never been used, though 63 GODOT_ERR_WTF = GODOT_ERR_OMFG_THIS_IS_VERY_VERY_BAD ///< short version of the above 64 } 65 66 ////// bool 67 68 alias godot_bool = bool; 69 70 enum GODOT_TRUE = 1; 71 enum GODOT_FALSE = 0; 72 73 /////// int 74 75 alias godot_int = int; 76 77 /////// real 78 // note that this one is used in math structs types such as Vector2 or Plane 79 // also see godot.api.types.real_t 80 version (GODOT_REAL_T_DOUBLE) 81 alias godot_real_t = double; 82 else 83 alias godot_real_t = float; 84 85 // TODO: use proper config for GODOT_USE_DOUBLE 86 /// Regular Godot floating point, used in methods such as `_process(float delta)` 87 alias godot_float = double; 88 89 alias uint64 = ulong; 90 alias uint64_t = uint64; 91 alias int64 = long; 92 alias int64_t = int64; 93 alias uint32 = uint; 94 alias uint32_t = uint32; 95 alias int32 = int; 96 alias int32_t = int32; 97 alias uint16 = ushort; 98 alias uint16_t = uint16; 99 alias int16 = short; 100 alias int16_t = int16; 101 alias uint8 = ubyte; 102 alias uint8_t = uint8; 103 alias int8 = byte; 104 alias int8_t = int8; 105 106 // This is for struct types only, not to be confused with plain floating point variables 107 alias real_t = godot.api.types.real_t; 108 109 // internal godot id 110 struct ObjectID { 111 uint64_t id; 112 } 113 114 alias char16_t = ushort; 115 alias char32_t = uint; 116 117 /////// Object reference (type-safe void pointer) 118 struct godot_object { 119 package(godot) void* ptr; 120 } 121 122 // core types 123 // NOTE: quite a few of these have sizes that cause D to generate incorrect 124 // calling convention for SysV ABI (bugs 5570 & 13207). Partial workaround is 125 // using larger integers instead of byte arrays. Needs fixing eventually... 126 127 struct godot_array { 128 size_t _opaque; 129 } 130 131 struct godot_basis { 132 uint[9] _opaque; 133 } 134 135 struct godot_color { 136 ulong[2] _opaque; 137 } 138 139 struct godot_dictionary { 140 size_t _opaque; 141 } 142 143 struct godot_node_path { 144 ubyte[8] _opaque; 145 } 146 147 struct godot_plane { 148 ubyte[4 * godot_real_t.sizeof] _opaque; 149 } 150 151 mixin template PackedArray(Type, string name) { 152 mixin("struct godot_packed_" ~ name ~ "_array { size_t _opaque; }"); 153 //mixin("struct godot_packed_"~name~"_array_read_access { ubyte _opaque; }"); 154 //mixin("struct godot_packed_"~name~"_array_write_access { ubyte _opaque; }"); 155 } 156 157 mixin PackedArray!(ubyte, "byte"); 158 mixin PackedArray!(int, "int32"); 159 mixin PackedArray!(long, "int64"); 160 mixin PackedArray!(float, "float32"); 161 mixin PackedArray!(double, "float64"); 162 mixin PackedArray!(godot_string, "string"); 163 mixin PackedArray!(godot_vector2, "vector2"); 164 mixin PackedArray!(godot_vector3, "vector3"); 165 mixin PackedArray!(godot_color, "color"); 166 167 // Alignment hardcoded in `core/variant/callable.h`. 168 enum GODOT_CALLABLE_SIZE = 16; 169 170 struct godot_callable { 171 ubyte[GODOT_CALLABLE_SIZE] _opaque; 172 } 173 174 struct godot_quaternion { 175 ubyte[4 * godot_real_t.sizeof] _opaque; 176 } 177 178 struct godot_rect2 { 179 ubyte[4 * godot_real_t.sizeof] _opaque; 180 } 181 182 struct godot_rect2i { 183 ubyte[4 * int.sizeof] _opaque; 184 } 185 186 struct godot_aabb { 187 ubyte[6 * godot_real_t.sizeof] _opaque; 188 } 189 190 struct godot_rid { 191 ulong _opaque; 192 } 193 194 struct godot_string { 195 size_t _opaque; 196 } 197 198 struct godot_char_string { 199 size_t _opaque; 200 } 201 202 struct godot_transform3d { 203 ubyte[12 * godot_real_t.sizeof] _opaque; 204 } 205 206 struct godot_transform2d { 207 ubyte[6 * godot_real_t.sizeof] _opaque; 208 } 209 210 struct godot_variant { 211 ubyte[24] _opaque; 212 } 213 214 enum godot_variant_type { 215 GODOT_VARIANT_TYPE_NIL, 216 217 // atomic types 218 GODOT_VARIANT_TYPE_BOOL, 219 GODOT_VARIANT_TYPE_INT, 220 GODOT_VARIANT_TYPE_FLOAT, 221 GODOT_VARIANT_TYPE_STRING, 222 223 // math types 224 225 GODOT_VARIANT_TYPE_VECTOR2, // 5 226 GODOT_VARIANT_TYPE_VECTOR2I, 227 GODOT_VARIANT_TYPE_RECT2, 228 GODOT_VARIANT_TYPE_RECT2I, 229 GODOT_VARIANT_TYPE_VECTOR3, 230 GODOT_VARIANT_TYPE_VECTOR3I, // 10 231 GODOT_VARIANT_TYPE_TRANSFORM2D, 232 GODOT_VARIANT_TYPE_VECTOR4, 233 GODOT_VARIANT_TYPE_VECTOR4I, // 10 234 GODOT_VARIANT_TYPE_PLANE, 235 GODOT_VARIANT_TYPE_QUATERNION, 236 GODOT_VARIANT_TYPE_AABB, 237 GODOT_VARIANT_TYPE_BASIS, // 15 238 GODOT_VARIANT_TYPE_TRANSFORM3D, 239 GODOT_VARIANT_TYPE_PROJECTION, 240 241 // misc types 242 GODOT_VARIANT_TYPE_COLOR, 243 GODOT_VARIANT_TYPE_STRING_NAME, 244 GODOT_VARIANT_TYPE_NODE_PATH, 245 GODOT_VARIANT_TYPE_RID, // 20 246 GODOT_VARIANT_TYPE_OBJECT, 247 GODOT_VARIANT_TYPE_CALLABLE, 248 GODOT_VARIANT_TYPE_SIGNAL, 249 GODOT_VARIANT_TYPE_DICTIONARY, 250 GODOT_VARIANT_TYPE_ARRAY, // 25 251 252 // arrays 253 GODOT_VARIANT_TYPE_PACKED_BYTE_ARRAY, 254 GODOT_VARIANT_TYPE_PACKED_INT32_ARRAY, 255 GODOT_VARIANT_TYPE_PACKED_INT64_ARRAY, 256 GODOT_VARIANT_TYPE_PACKED_FLOAT32_ARRAY, 257 GODOT_VARIANT_TYPE_PACKED_FLOAT64_ARRAY, // 30 258 GODOT_VARIANT_TYPE_PACKED_STRING_ARRAY, 259 GODOT_VARIANT_TYPE_PACKED_VECTOR2_ARRAY, 260 GODOT_VARIANT_TYPE_PACKED_VECTOR3_ARRAY, 261 GODOT_VARIANT_TYPE_PACKED_COLOR_ARRAY, 262 } 263 264 enum godot_variant_call_error_error { 265 GODOT_CALL_ERROR_CALL_OK, 266 GODOT_CALL_ERROR_CALL_ERROR_INVALID_METHOD, 267 GODOT_CALL_ERROR_CALL_ERROR_INVALID_ARGUMENT, 268 GODOT_CALL_ERROR_CALL_ERROR_TOO_MANY_ARGUMENTS, 269 GODOT_CALL_ERROR_CALL_ERROR_TOO_FEW_ARGUMENTS, 270 GODOT_CALL_ERROR_CALL_ERROR_INSTANCE_IS_NULL, 271 } 272 273 struct godot_variant_call_error { 274 godot_variant_call_error_error error; 275 int argument; 276 godot_variant_type expected; 277 } 278 279 enum godot_variant_operator { 280 // comparison 281 GODOT_VARIANT_OP_EQUAL, 282 GODOT_VARIANT_OP_NOT_EQUAL, 283 GODOT_VARIANT_OP_LESS, 284 GODOT_VARIANT_OP_LESS_EQUAL, 285 GODOT_VARIANT_OP_GREATER, 286 GODOT_VARIANT_OP_GREATER_EQUAL, 287 288 // mathematic 289 GODOT_VARIANT_OP_ADD, 290 GODOT_VARIANT_OP_SUBTRACT, 291 GODOT_VARIANT_OP_MULTIPLY, 292 GODOT_VARIANT_OP_DIVIDE, 293 GODOT_VARIANT_OP_NEGATE, 294 GODOT_VARIANT_OP_POSITIVE, 295 GODOT_VARIANT_OP_MODULE, 296 //GODOT_VARIANT_OP_STRING_CONCAT, 297 298 // bitwise 299 GODOT_VARIANT_OP_SHIFT_LEFT, 300 GODOT_VARIANT_OP_SHIFT_RIGHT, 301 GODOT_VARIANT_OP_BIT_AND, 302 GODOT_VARIANT_OP_BIT_OR, 303 GODOT_VARIANT_OP_BIT_XOR, 304 GODOT_VARIANT_OP_BIT_NEGATE, 305 306 // logic 307 GODOT_VARIANT_OP_AND, 308 GODOT_VARIANT_OP_OR, 309 GODOT_VARIANT_OP_XOR, 310 GODOT_VARIANT_OP_NOT, 311 312 // containment 313 GODOT_VARIANT_OP_IN, 314 315 GODOT_VARIANT_OP_MAX, 316 } 317 318 enum godot_variant_utility_function_type { 319 GODOT_UTILITY_FUNC_TYPE_MATH, 320 GODOT_UTILITY_FUNC_TYPE_RANDOM, 321 GODOT_UTILITY_FUNC_TYPE_GENERAL 322 } 323 324 struct godot_vector2 { 325 ubyte[2 * godot_real_t.sizeof] _opaque; 326 } 327 328 struct godot_vector2i { 329 uint[2] _opaque; 330 } 331 332 struct godot_vector3 { 333 ubyte[3 * godot_real_t.sizeof] _opaque; 334 } 335 336 struct godot_vector3i { 337 uint[3] _opaque; 338 } 339 340 struct godot_vector4 { 341 ubyte[4 * godot_real_t.sizeof] _opaque; 342 } 343 344 struct godot_vector4i { 345 uint[4] _opaque; 346 } 347 348 struct godot_projection { 349 godot_vector4[4] _opaque; 350 } 351 352 enum godot_vector3_axis { 353 GODOT_VECTOR3_AXIS_X, 354 GODOT_VECTOR3_AXIS_Y, 355 GODOT_VECTOR3_AXIS_Z, 356 } 357 358 // Packed arrays 359 struct godot_packed_byte_array { 360 size_t[2] _opaque; 361 } 362 363 struct godot_packed_int32_array { 364 size_t[2] _opaque; 365 } 366 367 struct godot_packed_int64_array { 368 size_t[2] _opaque; 369 } 370 371 struct godot_packed_float32_array { 372 size_t[2] _opaque; 373 } 374 375 struct godot_packed_float64_array { 376 size_t[2] _opaque; 377 } 378 379 struct godot_packed_string_array { 380 size_t[2] _opaque; 381 } 382 383 struct godot_packed_vector2_array { 384 size_t[2] _opaque; 385 } 386 387 struct godot_packed_vector2i_array { 388 size_t[2] _opaque; 389 } 390 391 struct godot_packed_vector3_array { 392 size_t[2] _opaque; 393 } 394 395 struct godot_packed_vector3i_array { 396 size_t[2] _opaque; 397 } 398 399 struct godot_packed_color_array { 400 size_t[2] _opaque; 401 }