packed_arrays.cpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*************************************************************************/
  2. /* packed_arrays.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 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. // extra functions for packed arrays
  31. #include <godot_cpp/godot.hpp>
  32. #include <godot_cpp/variant/packed_byte_array.hpp>
  33. #include <godot_cpp/variant/packed_color_array.hpp>
  34. #include <godot_cpp/variant/packed_float32_array.hpp>
  35. #include <godot_cpp/variant/packed_float64_array.hpp>
  36. #include <godot_cpp/variant/packed_int32_array.hpp>
  37. #include <godot_cpp/variant/packed_int64_array.hpp>
  38. #include <godot_cpp/variant/packed_string_array.hpp>
  39. #include <godot_cpp/variant/packed_vector2_array.hpp>
  40. #include <godot_cpp/variant/packed_vector3_array.hpp>
  41. namespace godot {
  42. const uint8_t &PackedByteArray::operator[](int p_index) const {
  43. return *internal::gdn_interface->packed_byte_array_operator_index_const((GDNativeTypePtr *)this, p_index);
  44. }
  45. uint8_t &PackedByteArray::operator[](int p_index) {
  46. return *internal::gdn_interface->packed_byte_array_operator_index((GDNativeTypePtr *)this, p_index);
  47. }
  48. const Color &PackedColorArray::operator[](int p_index) const {
  49. const Color *color = (const Color *)internal::gdn_interface->packed_color_array_operator_index_const((GDNativeTypePtr *)this, p_index);
  50. return *color;
  51. }
  52. Color &PackedColorArray::operator[](int p_index) {
  53. Color *color = (Color *)internal::gdn_interface->packed_color_array_operator_index((GDNativeTypePtr *)this, p_index);
  54. return *color;
  55. }
  56. const float &PackedFloat32Array::operator[](int p_index) const {
  57. return *internal::gdn_interface->packed_float32_array_operator_index_const((GDNativeTypePtr *)this, p_index);
  58. }
  59. float &PackedFloat32Array::operator[](int p_index) {
  60. return *internal::gdn_interface->packed_float32_array_operator_index((GDNativeTypePtr *)this, p_index);
  61. }
  62. const double &PackedFloat64Array::operator[](int p_index) const {
  63. return *internal::gdn_interface->packed_float64_array_operator_index_const((GDNativeTypePtr *)this, p_index);
  64. }
  65. double &PackedFloat64Array::operator[](int p_index) {
  66. return *internal::gdn_interface->packed_float64_array_operator_index((GDNativeTypePtr *)this, p_index);
  67. }
  68. const int32_t &PackedInt32Array::operator[](int p_index) const {
  69. return *internal::gdn_interface->packed_int32_array_operator_index_const((GDNativeTypePtr *)this, p_index);
  70. }
  71. int32_t &PackedInt32Array::operator[](int p_index) {
  72. return *internal::gdn_interface->packed_int32_array_operator_index((GDNativeTypePtr *)this, p_index);
  73. }
  74. const int64_t &PackedInt64Array::operator[](int p_index) const {
  75. return *internal::gdn_interface->packed_int64_array_operator_index_const((GDNativeTypePtr *)this, p_index);
  76. }
  77. int64_t &PackedInt64Array::operator[](int p_index) {
  78. return *internal::gdn_interface->packed_int64_array_operator_index((GDNativeTypePtr *)this, p_index);
  79. }
  80. const String &PackedStringArray::operator[](int p_index) const {
  81. const String *string = (const String *)internal::gdn_interface->packed_string_array_operator_index_const((GDNativeTypePtr *)this, p_index);
  82. return *string;
  83. }
  84. String &PackedStringArray::operator[](int p_index) {
  85. String *string = (String *)internal::gdn_interface->packed_string_array_operator_index((GDNativeTypePtr *)this, p_index);
  86. return *string;
  87. }
  88. const Vector2 &PackedVector2Array::operator[](int p_index) const {
  89. const Vector2 *vec = (const Vector2 *)internal::gdn_interface->packed_vector2_array_operator_index_const((GDNativeTypePtr *)this, p_index);
  90. return *vec;
  91. }
  92. Vector2 &PackedVector2Array::operator[](int p_index) {
  93. Vector2 *vec = (Vector2 *)internal::gdn_interface->packed_vector2_array_operator_index((GDNativeTypePtr *)this, p_index);
  94. return *vec;
  95. }
  96. const Vector3 &PackedVector3Array::operator[](int p_index) const {
  97. const Vector3 *vec = (const Vector3 *)internal::gdn_interface->packed_vector3_array_operator_index_const((GDNativeTypePtr *)this, p_index);
  98. return *vec;
  99. }
  100. Vector3 &PackedVector3Array::operator[](int p_index) {
  101. Vector3 *vec = (Vector3 *)internal::gdn_interface->packed_vector3_array_operator_index((GDNativeTypePtr *)this, p_index);
  102. return *vec;
  103. }
  104. } // namespace godot