interop_types.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /**************************************************************************/
  2. /* interop_types.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef INTEROP_TYPES_H
  31. #define INTEROP_TYPES_H
  32. #include "core/math/math_defs.h"
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. #include <stdbool.h>
  37. #include <stdint.h>
  38. // This is taken from the old GDNative, which was removed.
  39. #define GODOT_VARIANT_SIZE (sizeof(real_t) * 4 + sizeof(int64_t))
  40. typedef struct {
  41. uint8_t _dont_touch_that[GODOT_VARIANT_SIZE];
  42. } godot_variant;
  43. #define GODOT_ARRAY_SIZE sizeof(void *)
  44. typedef struct {
  45. uint8_t _dont_touch_that[GODOT_ARRAY_SIZE];
  46. } godot_array;
  47. #define GODOT_DICTIONARY_SIZE sizeof(void *)
  48. typedef struct {
  49. uint8_t _dont_touch_that[GODOT_DICTIONARY_SIZE];
  50. } godot_dictionary;
  51. #define GODOT_STRING_SIZE sizeof(void *)
  52. typedef struct {
  53. uint8_t _dont_touch_that[GODOT_STRING_SIZE];
  54. } godot_string;
  55. #define GODOT_STRING_NAME_SIZE sizeof(void *)
  56. typedef struct {
  57. uint8_t _dont_touch_that[GODOT_STRING_NAME_SIZE];
  58. } godot_string_name;
  59. #define GODOT_PACKED_ARRAY_SIZE (2 * sizeof(void *))
  60. typedef struct {
  61. uint8_t _dont_touch_that[GODOT_PACKED_ARRAY_SIZE];
  62. } godot_packed_array;
  63. #define GODOT_VECTOR2_SIZE (sizeof(real_t) * 2)
  64. typedef struct {
  65. uint8_t _dont_touch_that[GODOT_VECTOR2_SIZE];
  66. } godot_vector2;
  67. #define GODOT_VECTOR2I_SIZE (sizeof(int32_t) * 2)
  68. typedef struct {
  69. uint8_t _dont_touch_that[GODOT_VECTOR2I_SIZE];
  70. } godot_vector2i;
  71. #define GODOT_RECT2_SIZE (sizeof(real_t) * 4)
  72. typedef struct godot_rect2 {
  73. uint8_t _dont_touch_that[GODOT_RECT2_SIZE];
  74. } godot_rect2;
  75. #define GODOT_RECT2I_SIZE (sizeof(int32_t) * 4)
  76. typedef struct godot_rect2i {
  77. uint8_t _dont_touch_that[GODOT_RECT2I_SIZE];
  78. } godot_rect2i;
  79. #define GODOT_VECTOR3_SIZE (sizeof(real_t) * 3)
  80. typedef struct {
  81. uint8_t _dont_touch_that[GODOT_VECTOR3_SIZE];
  82. } godot_vector3;
  83. #define GODOT_VECTOR3I_SIZE (sizeof(int32_t) * 3)
  84. typedef struct {
  85. uint8_t _dont_touch_that[GODOT_VECTOR3I_SIZE];
  86. } godot_vector3i;
  87. #define GODOT_TRANSFORM2D_SIZE (sizeof(real_t) * 6)
  88. typedef struct {
  89. uint8_t _dont_touch_that[GODOT_TRANSFORM2D_SIZE];
  90. } godot_transform2d;
  91. #define GODOT_VECTOR4_SIZE (sizeof(real_t) * 4)
  92. typedef struct {
  93. uint8_t _dont_touch_that[GODOT_VECTOR4_SIZE];
  94. } godot_vector4;
  95. #define GODOT_VECTOR4I_SIZE (sizeof(int32_t) * 4)
  96. typedef struct {
  97. uint8_t _dont_touch_that[GODOT_VECTOR4I_SIZE];
  98. } godot_vector4i;
  99. #define GODOT_PLANE_SIZE (sizeof(real_t) * 4)
  100. typedef struct {
  101. uint8_t _dont_touch_that[GODOT_PLANE_SIZE];
  102. } godot_plane;
  103. #define GODOT_QUATERNION_SIZE (sizeof(real_t) * 4)
  104. typedef struct {
  105. uint8_t _dont_touch_that[GODOT_QUATERNION_SIZE];
  106. } godot_quaternion;
  107. #define GODOT_AABB_SIZE (sizeof(real_t) * 6)
  108. typedef struct {
  109. uint8_t _dont_touch_that[GODOT_AABB_SIZE];
  110. } godot_aabb;
  111. #define GODOT_BASIS_SIZE (sizeof(real_t) * 9)
  112. typedef struct {
  113. uint8_t _dont_touch_that[GODOT_BASIS_SIZE];
  114. } godot_basis;
  115. #define GODOT_TRANSFORM3D_SIZE (sizeof(real_t) * 12)
  116. typedef struct {
  117. uint8_t _dont_touch_that[GODOT_TRANSFORM3D_SIZE];
  118. } godot_transform3d;
  119. #define GODOT_PROJECTION_SIZE (sizeof(real_t) * 4 * 4)
  120. typedef struct {
  121. uint8_t _dont_touch_that[GODOT_PROJECTION_SIZE];
  122. } godot_projection;
  123. // Colors should always use 32-bit floats, so don't use real_t here.
  124. #define GODOT_COLOR_SIZE (sizeof(float) * 4)
  125. typedef struct {
  126. uint8_t _dont_touch_that[GODOT_COLOR_SIZE];
  127. } godot_color;
  128. #define GODOT_NODE_PATH_SIZE sizeof(void *)
  129. typedef struct {
  130. uint8_t _dont_touch_that[GODOT_NODE_PATH_SIZE];
  131. } godot_node_path;
  132. #define GODOT_RID_SIZE sizeof(uint64_t)
  133. typedef struct {
  134. uint8_t _dont_touch_that[GODOT_RID_SIZE];
  135. } godot_rid;
  136. // Alignment hardcoded in `core/variant/callable.h`.
  137. #define GODOT_CALLABLE_SIZE (16)
  138. typedef struct {
  139. uint8_t _dont_touch_that[GODOT_CALLABLE_SIZE];
  140. } godot_callable;
  141. // Alignment hardcoded in `core/variant/callable.h`.
  142. #define GODOT_SIGNAL_SIZE (16)
  143. typedef struct {
  144. uint8_t _dont_touch_that[GODOT_SIGNAL_SIZE];
  145. } godot_signal;
  146. #ifdef __cplusplus
  147. }
  148. #endif
  149. #endif // INTEROP_TYPES_H