interop_types.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. #pragma once
  31. #include "core/math/math_defs.h"
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. // This is taken from the old GDNative, which was removed.
  36. #define GODOT_VARIANT_SIZE (sizeof(real_t) * 4 + sizeof(int64_t))
  37. typedef struct {
  38. uint8_t _dont_touch_that[GODOT_VARIANT_SIZE];
  39. } godot_variant;
  40. #define GODOT_ARRAY_SIZE sizeof(void *)
  41. typedef struct {
  42. uint8_t _dont_touch_that[GODOT_ARRAY_SIZE];
  43. } godot_array;
  44. #define GODOT_DICTIONARY_SIZE sizeof(void *)
  45. typedef struct {
  46. uint8_t _dont_touch_that[GODOT_DICTIONARY_SIZE];
  47. } godot_dictionary;
  48. #define GODOT_STRING_SIZE sizeof(void *)
  49. typedef struct {
  50. uint8_t _dont_touch_that[GODOT_STRING_SIZE];
  51. } godot_string;
  52. #define GODOT_STRING_NAME_SIZE sizeof(void *)
  53. typedef struct {
  54. uint8_t _dont_touch_that[GODOT_STRING_NAME_SIZE];
  55. } godot_string_name;
  56. #define GODOT_PACKED_ARRAY_SIZE (2 * sizeof(void *))
  57. typedef struct {
  58. uint8_t _dont_touch_that[GODOT_PACKED_ARRAY_SIZE];
  59. } godot_packed_array;
  60. #define GODOT_VECTOR2_SIZE (sizeof(real_t) * 2)
  61. typedef struct {
  62. uint8_t _dont_touch_that[GODOT_VECTOR2_SIZE];
  63. } godot_vector2;
  64. #define GODOT_VECTOR2I_SIZE (sizeof(int32_t) * 2)
  65. typedef struct {
  66. uint8_t _dont_touch_that[GODOT_VECTOR2I_SIZE];
  67. } godot_vector2i;
  68. #define GODOT_RECT2_SIZE (sizeof(real_t) * 4)
  69. typedef struct godot_rect2 {
  70. uint8_t _dont_touch_that[GODOT_RECT2_SIZE];
  71. } godot_rect2;
  72. #define GODOT_RECT2I_SIZE (sizeof(int32_t) * 4)
  73. typedef struct godot_rect2i {
  74. uint8_t _dont_touch_that[GODOT_RECT2I_SIZE];
  75. } godot_rect2i;
  76. #define GODOT_VECTOR3_SIZE (sizeof(real_t) * 3)
  77. typedef struct {
  78. uint8_t _dont_touch_that[GODOT_VECTOR3_SIZE];
  79. } godot_vector3;
  80. #define GODOT_VECTOR3I_SIZE (sizeof(int32_t) * 3)
  81. typedef struct {
  82. uint8_t _dont_touch_that[GODOT_VECTOR3I_SIZE];
  83. } godot_vector3i;
  84. #define GODOT_TRANSFORM2D_SIZE (sizeof(real_t) * 6)
  85. typedef struct {
  86. uint8_t _dont_touch_that[GODOT_TRANSFORM2D_SIZE];
  87. } godot_transform2d;
  88. #define GODOT_VECTOR4_SIZE (sizeof(real_t) * 4)
  89. typedef struct {
  90. uint8_t _dont_touch_that[GODOT_VECTOR4_SIZE];
  91. } godot_vector4;
  92. #define GODOT_VECTOR4I_SIZE (sizeof(int32_t) * 4)
  93. typedef struct {
  94. uint8_t _dont_touch_that[GODOT_VECTOR4I_SIZE];
  95. } godot_vector4i;
  96. #define GODOT_PLANE_SIZE (sizeof(real_t) * 4)
  97. typedef struct {
  98. uint8_t _dont_touch_that[GODOT_PLANE_SIZE];
  99. } godot_plane;
  100. #define GODOT_QUATERNION_SIZE (sizeof(real_t) * 4)
  101. typedef struct {
  102. uint8_t _dont_touch_that[GODOT_QUATERNION_SIZE];
  103. } godot_quaternion;
  104. #define GODOT_AABB_SIZE (sizeof(real_t) * 6)
  105. typedef struct {
  106. uint8_t _dont_touch_that[GODOT_AABB_SIZE];
  107. } godot_aabb;
  108. #define GODOT_BASIS_SIZE (sizeof(real_t) * 9)
  109. typedef struct {
  110. uint8_t _dont_touch_that[GODOT_BASIS_SIZE];
  111. } godot_basis;
  112. #define GODOT_TRANSFORM3D_SIZE (sizeof(real_t) * 12)
  113. typedef struct {
  114. uint8_t _dont_touch_that[GODOT_TRANSFORM3D_SIZE];
  115. } godot_transform3d;
  116. #define GODOT_PROJECTION_SIZE (sizeof(real_t) * 4 * 4)
  117. typedef struct {
  118. uint8_t _dont_touch_that[GODOT_PROJECTION_SIZE];
  119. } godot_projection;
  120. // Colors should always use 32-bit floats, so don't use real_t here.
  121. #define GODOT_COLOR_SIZE (sizeof(float) * 4)
  122. typedef struct {
  123. uint8_t _dont_touch_that[GODOT_COLOR_SIZE];
  124. } godot_color;
  125. #define GODOT_NODE_PATH_SIZE sizeof(void *)
  126. typedef struct {
  127. uint8_t _dont_touch_that[GODOT_NODE_PATH_SIZE];
  128. } godot_node_path;
  129. #define GODOT_RID_SIZE sizeof(uint64_t)
  130. typedef struct {
  131. uint8_t _dont_touch_that[GODOT_RID_SIZE];
  132. } godot_rid;
  133. // Alignment hardcoded in `core/variant/callable.h`.
  134. #define GODOT_CALLABLE_SIZE (16)
  135. typedef struct {
  136. uint8_t _dont_touch_that[GODOT_CALLABLE_SIZE];
  137. } godot_callable;
  138. // Alignment hardcoded in `core/variant/callable.h`.
  139. #define GODOT_SIGNAL_SIZE (16)
  140. typedef struct {
  141. uint8_t _dont_touch_that[GODOT_SIGNAL_SIZE];
  142. } godot_signal;
  143. #ifdef __cplusplus
  144. }
  145. #endif