| 1 | /**************************************************************************/ |
| 2 | /* variant_call.cpp */ |
| 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 | |
| 31 | #include "variant.h" |
| 32 | |
| 33 | #include "core/crypto/crypto_core.h" |
| 34 | #include "core/debugger/engine_debugger.h" |
| 35 | #include "core/io/compression.h" |
| 36 | #include "core/io/marshalls.h" |
| 37 | #include "core/object/class_db.h" |
| 38 | #include "core/os/os.h" |
| 39 | #include "core/templates/a_hash_map.h" |
| 40 | #include "core/templates/local_vector.h" |
| 41 | |
| 42 | typedef void (*VariantFunc)(Variant &r_ret, Variant &p_self, const Variant **p_args); |
| 43 | typedef void (*VariantConstructFunc)(Variant &r_ret, const Variant **p_args); |
| 44 | |
| 45 | template <typename R, typename... P> |
| 46 | static _FORCE_INLINE_ void vc_static_method_call(R (*method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { |
| 47 | call_with_variant_args_static_ret_dv(method, p_args, p_argcount, r_ret, r_error, p_defvals); |
| 48 | } |
| 49 | |
| 50 | template <typename... P> |
| 51 | static _FORCE_INLINE_ void vc_static_method_call(void (*method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { |
| 52 | call_with_variant_args_static_dv(method, p_args, p_argcount, r_error, p_defvals); |
| 53 | } |
| 54 | |
| 55 | template <typename R, typename T, typename... P> |
| 56 | static _FORCE_INLINE_ void vc_method_call(R (T::*method)(P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { |
| 57 | call_with_variant_args_ret_dv(&VariantInternalAccessor<T>::get(base), method, p_args, p_argcount, r_ret, r_error, p_defvals); |
| 58 | } |
| 59 | |
| 60 | template <typename R, typename T, typename... P> |
| 61 | static _FORCE_INLINE_ void vc_method_call(R (T::*method)(P...) const, Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { |
| 62 | call_with_variant_args_retc_dv(&VariantInternalAccessor<T>::get(base), method, p_args, p_argcount, r_ret, r_error, p_defvals); |
| 63 | } |
| 64 | |
| 65 | template <typename T, typename... P> |
| 66 | static _FORCE_INLINE_ void vc_method_call(void (T::*method)(P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { |
| 67 | VariantInternal::clear(&r_ret); |
| 68 | call_with_variant_args_dv(&VariantInternalAccessor<T>::get(base), method, p_args, p_argcount, r_error, p_defvals); |
| 69 | } |
| 70 | |
| 71 | template <typename T, typename... P> |
| 72 | static _FORCE_INLINE_ void vc_method_call(void (T::*method)(P...) const, Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { |
| 73 | VariantInternal::clear(&r_ret); |
| 74 | call_with_variant_argsc_dv(&VariantInternalAccessor<T>::get(base), method, p_args, p_argcount, r_error, p_defvals); |
| 75 | } |
| 76 | |
| 77 | template <typename From, typename R, typename T, typename... P> |
| 78 | static _FORCE_INLINE_ void vc_convert_method_call(R (T::*method)(P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { |
| 79 | T converted(static_cast<T>(VariantInternalAccessor<From>::get(base))); |
| 80 | call_with_variant_args_ret_dv(&converted, method, p_args, p_argcount, r_ret, r_error, p_defvals); |
| 81 | } |
| 82 | |
| 83 | template <typename From, typename R, typename T, typename... P> |
| 84 | static _FORCE_INLINE_ void vc_convert_method_call(R (T::*method)(P...) const, Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { |
| 85 | T converted(static_cast<T>(VariantInternalAccessor<From>::get(base))); |
| 86 | call_with_variant_args_retc_dv(&converted, method, p_args, p_argcount, r_ret, r_error, p_defvals); |
| 87 | } |
| 88 | |
| 89 | template <typename From, typename T, typename... P> |
| 90 | static _FORCE_INLINE_ void vc_convert_method_call(void (T::*method)(P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { |
| 91 | T converted(static_cast<T>(VariantInternalAccessor<From>::get(base))); |
| 92 | call_with_variant_args_dv(&converted, method, p_args, p_argcount, r_error, p_defvals); |
| 93 | } |
| 94 | |
| 95 | template <typename From, typename T, typename... P> |
| 96 | static _FORCE_INLINE_ void vc_convert_method_call(void (T::*method)(P...) const, Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { |
| 97 | T converted(static_cast<T>(VariantInternalAccessor<From>::get(base))); |
| 98 | call_with_variant_argsc_dv(&converted, method, p_args, p_argcount, r_error, p_defvals); |
| 99 | } |
| 100 | |
| 101 | template <typename R, typename T, typename... P> |
| 102 | static _FORCE_INLINE_ void vc_method_call_static(R (*method)(T *, P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { |
| 103 | call_with_variant_args_retc_static_helper_dv(&VariantInternalAccessor<T>::get(base), method, p_args, p_argcount, r_ret, p_defvals, r_error); |
| 104 | } |
| 105 | |
| 106 | template <typename T, typename... P> |
| 107 | static _FORCE_INLINE_ void vc_method_call_static(void (*method)(T *, P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { |
| 108 | call_with_variant_args_static_helper_dv(&VariantInternalAccessor<T>::get(base), method, p_args, p_argcount, p_defvals, r_error); |
| 109 | } |
| 110 | |
| 111 | template <typename R, typename T, typename... P> |
| 112 | static _FORCE_INLINE_ void vc_validated_call(R (T::*method)(P...), Variant *base, const Variant **p_args, Variant *r_ret) { |
| 113 | call_with_validated_variant_args_ret(base, method, p_args, r_ret); |
| 114 | } |
| 115 | |
| 116 | template <typename R, typename T, typename... P> |
| 117 | static _FORCE_INLINE_ void vc_validated_call(R (T::*method)(P...) const, Variant *base, const Variant **p_args, Variant *r_ret) { |
| 118 | call_with_validated_variant_args_retc(base, method, p_args, r_ret); |
| 119 | } |
| 120 | template <typename T, typename... P> |
| 121 | static _FORCE_INLINE_ void vc_validated_call(void (T::*method)(P...), Variant *base, const Variant **p_args, Variant *r_ret) { |
| 122 | call_with_validated_variant_args(base, method, p_args); |
| 123 | } |
| 124 | |
| 125 | template <typename T, typename... P> |
| 126 | static _FORCE_INLINE_ void vc_validated_call(void (T::*method)(P...) const, Variant *base, const Variant **p_args, Variant *r_ret) { |
| 127 | call_with_validated_variant_argsc(base, method, p_args); |
| 128 | } |
| 129 | |
| 130 | template <typename From, typename R, typename T, typename... P> |
| 131 | static _FORCE_INLINE_ void vc_convert_validated_call(R (T::*method)(P...), Variant *base, const Variant **p_args, Variant *r_ret) { |
| 132 | T converted(static_cast<T>(VariantInternalAccessor<From>::get(base))); |
| 133 | call_with_validated_variant_args_ret_helper<T, R, P...>(&converted, method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); |
| 134 | } |
| 135 | |
| 136 | template <typename From, typename R, typename T, typename... P> |
| 137 | static _FORCE_INLINE_ void vc_convert_validated_call(R (T::*method)(P...) const, Variant *base, const Variant **p_args, Variant *r_ret) { |
| 138 | T converted(static_cast<T>(VariantInternalAccessor<From>::get(base))); |
| 139 | call_with_validated_variant_args_retc_helper<T, R, P...>(&converted, method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); |
| 140 | } |
| 141 | template <typename From, typename T, typename... P> |
| 142 | static _FORCE_INLINE_ void vc_convert_validated_call(void (T::*method)(P...), Variant *base, const Variant **p_args, Variant *r_ret) { |
| 143 | T converted(static_cast<T>(VariantInternalAccessor<From>::get(base))); |
| 144 | call_with_validated_variant_args_helper<T, P...>(&converted, method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); |
| 145 | } |
| 146 | |
| 147 | template <typename From, typename T, typename... P> |
| 148 | static _FORCE_INLINE_ void vc_convert_validated_call(void (T::*method)(P...) const, Variant *base, const Variant **p_args, Variant *r_ret) { |
| 149 | T converted(static_cast<T>(VariantInternalAccessor<From>::get(base))); |
| 150 | call_with_validated_variant_argsc_helper<T, P...>(&converted, method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); |
| 151 | } |
| 152 | |
| 153 | template <typename R, typename T, typename... P> |
| 154 | static _FORCE_INLINE_ void vc_validated_call_static(R (*method)(T *, P...), Variant *base, const Variant **p_args, Variant *r_ret) { |
| 155 | call_with_validated_variant_args_static_retc(base, method, p_args, r_ret); |
| 156 | } |
| 157 | |
| 158 | template <typename T, typename... P> |
| 159 | static _FORCE_INLINE_ void vc_validated_call_static(void (*method)(T *, P...), Variant *base, const Variant **p_args, Variant *r_ret) { |
| 160 | call_with_validated_variant_args_static(base, method, p_args); |
| 161 | } |
| 162 | |
| 163 | template <typename R, typename... P> |
| 164 | static _FORCE_INLINE_ void vc_validated_static_call(R (*method)(P...), const Variant **p_args, Variant *r_ret) { |
| 165 | call_with_validated_variant_args_static_method_ret(method, p_args, r_ret); |
| 166 | } |
| 167 | |
| 168 | template <typename... P> |
| 169 | static _FORCE_INLINE_ void vc_validated_static_call(void (*method)(P...), const Variant **p_args, Variant *r_ret) { |
| 170 | call_with_validated_variant_args_static_method(method, p_args); |
| 171 | } |
| 172 | |
| 173 | template <typename R, typename T, typename... P> |
| 174 | static _FORCE_INLINE_ void vc_ptrcall(R (T::*method)(P...), void *p_base, const void **p_args, void *r_ret) { |
| 175 | call_with_ptr_args_ret(reinterpret_cast<T *>(p_base), method, p_args, r_ret); |
| 176 | } |
| 177 | |
| 178 | template <typename R, typename T, typename... P> |
| 179 | static _FORCE_INLINE_ void vc_ptrcall(R (T::*method)(P...) const, void *p_base, const void **p_args, void *r_ret) { |
| 180 | call_with_ptr_args_retc(reinterpret_cast<T *>(p_base), method, p_args, r_ret); |
| 181 | } |
| 182 | |
| 183 | template <typename T, typename... P> |
| 184 | static _FORCE_INLINE_ void vc_ptrcall(void (T::*method)(P...), void *p_base, const void **p_args, void *r_ret) { |
| 185 | call_with_ptr_args(reinterpret_cast<T *>(p_base), method, p_args); |
| 186 | } |
| 187 | |
| 188 | template <typename T, typename... P> |
| 189 | static _FORCE_INLINE_ void vc_ptrcall(void (T::*method)(P...) const, void *p_base, const void **p_args, void *r_ret) { |
| 190 | call_with_ptr_argsc(reinterpret_cast<T *>(p_base), method, p_args); |
| 191 | } |
| 192 | |
| 193 | template <typename From, typename R, typename T, typename... P> |
| 194 | static _FORCE_INLINE_ void vc_convert_ptrcall(R (T::*method)(P...), void *p_base, const void **p_args, void *r_ret) { |
| 195 | T converted(*reinterpret_cast<From *>(p_base)); |
| 196 | call_with_ptr_args_ret(&converted, method, p_args, r_ret); |
| 197 | } |
| 198 | |
| 199 | template <typename From, typename R, typename T, typename... P> |
| 200 | static _FORCE_INLINE_ void vc_convert_ptrcall(R (T::*method)(P...) const, void *p_base, const void **p_args, void *r_ret) { |
| 201 | T converted(*reinterpret_cast<From *>(p_base)); |
| 202 | call_with_ptr_args_retc(&converted, method, p_args, r_ret); |
| 203 | } |
| 204 | |
| 205 | template <typename From, typename T, typename... P> |
| 206 | static _FORCE_INLINE_ void vc_convert_ptrcall(void (T::*method)(P...), void *p_base, const void **p_args, void *r_ret) { |
| 207 | T converted(*reinterpret_cast<From *>(p_base)); |
| 208 | call_with_ptr_args(&converted, method, p_args); |
| 209 | } |
| 210 | |
| 211 | template <typename From, typename T, typename... P> |
| 212 | static _FORCE_INLINE_ void vc_convert_ptrcall(void (T::*method)(P...) const, void *p_base, const void **p_args, void *r_ret) { |
| 213 | T converted(*reinterpret_cast<From *>(p_base)); |
| 214 | call_with_ptr_argsc(&converted, method, p_args); |
| 215 | } |
| 216 | |
| 217 | template <typename R, typename T, typename... P> |
| 218 | static _FORCE_INLINE_ int vc_get_argument_count(R (T::*method)(P...)) { |
| 219 | return sizeof...(P); |
| 220 | } |
| 221 | template <typename R, typename T, typename... P> |
| 222 | static _FORCE_INLINE_ int vc_get_argument_count(R (T::*method)(P...) const) { |
| 223 | return sizeof...(P); |
| 224 | } |
| 225 | |
| 226 | template <typename T, typename... P> |
| 227 | static _FORCE_INLINE_ int vc_get_argument_count(void (T::*method)(P...)) { |
| 228 | return sizeof...(P); |
| 229 | } |
| 230 | |
| 231 | template <typename T, typename... P> |
| 232 | static _FORCE_INLINE_ int vc_get_argument_count(void (T::*method)(P...) const) { |
| 233 | return sizeof...(P); |
| 234 | } |
| 235 | |
| 236 | template <typename R, typename T, typename... P> |
| 237 | static _FORCE_INLINE_ int vc_get_argument_count(R (*method)(T *, P...)) { |
| 238 | return sizeof...(P); |
| 239 | } |
| 240 | |
| 241 | template <typename R, typename... P> |
| 242 | static _FORCE_INLINE_ int vc_get_argument_count_static(R (*method)(P...)) { |
| 243 | return sizeof...(P); |
| 244 | } |
| 245 | |
| 246 | template <typename R, typename T, typename... P> |
| 247 | static _FORCE_INLINE_ Variant::Type vc_get_argument_type(R (T::*method)(P...), int p_arg) { |
| 248 | return call_get_argument_type<P...>(p_arg); |
| 249 | } |
| 250 | template <typename R, typename T, typename... P> |
| 251 | static _FORCE_INLINE_ Variant::Type vc_get_argument_type(R (T::*method)(P...) const, int p_arg) { |
| 252 | return call_get_argument_type<P...>(p_arg); |
| 253 | } |
| 254 | |
| 255 | template <typename T, typename... P> |
| 256 | static _FORCE_INLINE_ Variant::Type vc_get_argument_type(void (T::*method)(P...), int p_arg) { |
| 257 | return call_get_argument_type<P...>(p_arg); |
| 258 | } |
| 259 | |
| 260 | template <typename T, typename... P> |
| 261 | static _FORCE_INLINE_ Variant::Type vc_get_argument_type(void (T::*method)(P...) const, int p_arg) { |
| 262 | return call_get_argument_type<P...>(p_arg); |
| 263 | } |
| 264 | |
| 265 | template <typename R, typename T, typename... P> |
| 266 | static _FORCE_INLINE_ Variant::Type vc_get_argument_type(R (*method)(T *, P...), int p_arg) { |
| 267 | return call_get_argument_type<P...>(p_arg); |
| 268 | } |
| 269 | |
| 270 | template <typename R, typename... P> |
| 271 | static _FORCE_INLINE_ Variant::Type vc_get_argument_type_static(R (*method)(P...), int p_arg) { |
| 272 | return call_get_argument_type<P...>(p_arg); |
| 273 | } |
| 274 | |
| 275 | template <typename R, typename T, typename... P> |
| 276 | static _FORCE_INLINE_ Variant::Type vc_get_return_type(R (T::*method)(P...)) { |
| 277 | return GetTypeInfo<R>::VARIANT_TYPE; |
| 278 | } |
| 279 | |
| 280 | template <typename R, typename T, typename... P> |
| 281 | static _FORCE_INLINE_ Variant::Type vc_get_return_type(R (T::*method)(P...) const) { |
| 282 | return GetTypeInfo<R>::VARIANT_TYPE; |
| 283 | } |
| 284 | |
| 285 | template <typename T, typename... P> |
| 286 | static _FORCE_INLINE_ Variant::Type vc_get_return_type(void (T::*method)(P...)) { |
| 287 | return Variant::NIL; |
| 288 | } |
| 289 | |
| 290 | template <typename T, typename... P> |
| 291 | static _FORCE_INLINE_ Variant::Type vc_get_return_type(void (T::*method)(P...) const) { |
| 292 | return Variant::NIL; |
| 293 | } |
| 294 | |
| 295 | template <typename R, typename... P> |
| 296 | static _FORCE_INLINE_ Variant::Type vc_get_return_type(R (*method)(P...)) { |
| 297 | return GetTypeInfo<R>::VARIANT_TYPE; |
| 298 | } |
| 299 | |
| 300 | template <typename... P> |
| 301 | static _FORCE_INLINE_ Variant::Type vc_get_return_type(void (*method)(P...)) { |
| 302 | return Variant::NIL; |
| 303 | } |
| 304 | |
| 305 | template <typename R, typename T, typename... P> |
| 306 | static _FORCE_INLINE_ bool vc_has_return_type(R (T::*method)(P...)) { |
| 307 | return true; |
| 308 | } |
| 309 | template <typename R, typename T, typename... P> |
| 310 | static _FORCE_INLINE_ bool vc_has_return_type(R (T::*method)(P...) const) { |
| 311 | return true; |
| 312 | } |
| 313 | |
| 314 | template <typename T, typename... P> |
| 315 | static _FORCE_INLINE_ bool vc_has_return_type(void (T::*method)(P...)) { |
| 316 | return false; |
| 317 | } |
| 318 | |
| 319 | template <typename T, typename... P> |
| 320 | static _FORCE_INLINE_ bool vc_has_return_type(void (T::*method)(P...) const) { |
| 321 | return false; |
| 322 | } |
| 323 | |
| 324 | template <typename... P> |
| 325 | static _FORCE_INLINE_ bool vc_has_return_type_static(void (*method)(P...)) { |
| 326 | return false; |
| 327 | } |
| 328 | |
| 329 | template <typename R, typename... P> |
| 330 | static _FORCE_INLINE_ bool vc_has_return_type_static(R (*method)(P...)) { |
| 331 | return true; |
| 332 | } |
| 333 | |
| 334 | template <typename R, typename T, typename... P> |
| 335 | static _FORCE_INLINE_ bool vc_is_const(R (T::*method)(P...)) { |
| 336 | return false; |
| 337 | } |
| 338 | template <typename R, typename T, typename... P> |
| 339 | static _FORCE_INLINE_ bool vc_is_const(R (T::*method)(P...) const) { |
| 340 | return true; |
| 341 | } |
| 342 | |
| 343 | template <typename T, typename... P> |
| 344 | static _FORCE_INLINE_ bool vc_is_const(void (T::*method)(P...)) { |
| 345 | return false; |
| 346 | } |
| 347 | |
| 348 | template <typename T, typename... P> |
| 349 | static _FORCE_INLINE_ bool vc_is_const(void (T::*method)(P...) const) { |
| 350 | return true; |
| 351 | } |
| 352 | |
| 353 | template <typename R, typename T, typename... P> |
| 354 | static _FORCE_INLINE_ Variant::Type vc_get_base_type(R (T::*method)(P...)) { |
| 355 | return GetTypeInfo<T>::VARIANT_TYPE; |
| 356 | } |
| 357 | template <typename R, typename T, typename... P> |
| 358 | static _FORCE_INLINE_ Variant::Type vc_get_base_type(R (T::*method)(P...) const) { |
| 359 | return GetTypeInfo<T>::VARIANT_TYPE; |
| 360 | } |
| 361 | |
| 362 | template <typename T, typename... P> |
| 363 | static _FORCE_INLINE_ Variant::Type vc_get_base_type(void (T::*method)(P...)) { |
| 364 | return GetTypeInfo<T>::VARIANT_TYPE; |
| 365 | } |
| 366 | |
| 367 | template <typename T, typename... P> |
| 368 | static _FORCE_INLINE_ Variant::Type vc_get_base_type(void (T::*method)(P...) const) { |
| 369 | return GetTypeInfo<T>::VARIANT_TYPE; |
| 370 | } |
| 371 | |
| 372 | #define METHOD_CLASS(m_class, m_exposed_name, m_method_name, m_method_ptr) \ |
| 373 | struct Method_##m_class##_##m_method_name { \ |
| 374 | static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { \ |
| 375 | vc_method_call(m_method_ptr, base, p_args, p_argcount, r_ret, p_defvals, r_error); \ |
| 376 | } \ |
| 377 | static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ |
| 378 | vc_validated_call(m_method_ptr, base, p_args, r_ret); \ |
| 379 | } \ |
| 380 | static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ |
| 381 | vc_ptrcall(m_method_ptr, p_base, p_args, r_ret); \ |
| 382 | } \ |
| 383 | static int get_argument_count() { \ |
| 384 | return vc_get_argument_count(m_method_ptr); \ |
| 385 | } \ |
| 386 | static Variant::Type get_argument_type(int p_arg) { \ |
| 387 | return vc_get_argument_type(m_method_ptr, p_arg); \ |
| 388 | } \ |
| 389 | static Variant::Type get_return_type() { \ |
| 390 | return vc_get_return_type(m_method_ptr); \ |
| 391 | } \ |
| 392 | static bool has_return_type() { \ |
| 393 | return vc_has_return_type(m_method_ptr); \ |
| 394 | } \ |
| 395 | static bool is_const() { \ |
| 396 | return vc_is_const(m_method_ptr); \ |
| 397 | } \ |
| 398 | static bool is_static() { \ |
| 399 | return false; \ |
| 400 | } \ |
| 401 | static bool is_vararg() { \ |
| 402 | return false; \ |
| 403 | } \ |
| 404 | static Variant::Type get_base_type() { \ |
| 405 | return vc_get_base_type(m_method_ptr); \ |
| 406 | } \ |
| 407 | static StringName get_name() { \ |
| 408 | return #m_exposed_name; \ |
| 409 | } \ |
| 410 | }; |
| 411 | |
| 412 | #define CONVERT_METHOD_CLASS(m_class, m_exposed_name, m_method_name, m_method_ptr) \ |
| 413 | struct Method_##m_class##_##m_method_name { \ |
| 414 | static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { \ |
| 415 | vc_convert_method_call<m_class>(m_method_ptr, base, p_args, p_argcount, r_ret, p_defvals, r_error); \ |
| 416 | } \ |
| 417 | static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ |
| 418 | vc_convert_validated_call<m_class>(m_method_ptr, base, p_args, r_ret); \ |
| 419 | } \ |
| 420 | static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ |
| 421 | vc_convert_ptrcall<m_class>(m_method_ptr, p_base, p_args, r_ret); \ |
| 422 | } \ |
| 423 | static int get_argument_count() { \ |
| 424 | return vc_get_argument_count(m_method_ptr); \ |
| 425 | } \ |
| 426 | static Variant::Type get_argument_type(int p_arg) { \ |
| 427 | return vc_get_argument_type(m_method_ptr, p_arg); \ |
| 428 | } \ |
| 429 | static Variant::Type get_return_type() { \ |
| 430 | return vc_get_return_type(m_method_ptr); \ |
| 431 | } \ |
| 432 | static bool has_return_type() { \ |
| 433 | return vc_has_return_type(m_method_ptr); \ |
| 434 | } \ |
| 435 | static bool is_const() { \ |
| 436 | return vc_is_const(m_method_ptr); \ |
| 437 | } \ |
| 438 | static bool is_static() { \ |
| 439 | return false; \ |
| 440 | } \ |
| 441 | static bool is_vararg() { \ |
| 442 | return false; \ |
| 443 | } \ |
| 444 | static Variant::Type get_base_type() { \ |
| 445 | return GetTypeInfo<m_class>::VARIANT_TYPE; \ |
| 446 | } \ |
| 447 | static StringName get_name() { \ |
| 448 | return #m_exposed_name; \ |
| 449 | } \ |
| 450 | }; |
| 451 | |
| 452 | template <typename R, typename... P> |
| 453 | static _FORCE_INLINE_ void vc_static_ptrcall(R (*method)(P...), const void **p_args, void *r_ret) { |
| 454 | call_with_ptr_args_static_method_ret<R, P...>(method, p_args, r_ret); |
| 455 | } |
| 456 | |
| 457 | template <typename... P> |
| 458 | static _FORCE_INLINE_ void vc_static_ptrcall(void (*method)(P...), const void **p_args, void *r_ret) { |
| 459 | call_with_ptr_args_static_method<P...>(method, p_args); |
| 460 | } |
| 461 | |
| 462 | #define STATIC_METHOD_CLASS(m_class, m_exposed_name, m_method_name, m_method_ptr) \ |
| 463 | struct Method_##m_class##_##m_method_name { \ |
| 464 | static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { \ |
| 465 | vc_static_method_call(m_method_ptr, p_args, p_argcount, r_ret, p_defvals, r_error); \ |
| 466 | } \ |
| 467 | static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ |
| 468 | vc_validated_static_call(m_method_ptr, p_args, r_ret); \ |
| 469 | } \ |
| 470 | static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ |
| 471 | vc_static_ptrcall(m_method_ptr, p_args, r_ret); \ |
| 472 | } \ |
| 473 | static int get_argument_count() { \ |
| 474 | return vc_get_argument_count_static(m_method_ptr); \ |
| 475 | } \ |
| 476 | static Variant::Type get_argument_type(int p_arg) { \ |
| 477 | return vc_get_argument_type_static(m_method_ptr, p_arg); \ |
| 478 | } \ |
| 479 | static Variant::Type get_return_type() { \ |
| 480 | return vc_get_return_type(m_method_ptr); \ |
| 481 | } \ |
| 482 | static bool has_return_type() { \ |
| 483 | return vc_has_return_type_static(m_method_ptr); \ |
| 484 | } \ |
| 485 | static bool is_const() { \ |
| 486 | return false; \ |
| 487 | } \ |
| 488 | static bool is_static() { \ |
| 489 | return true; \ |
| 490 | } \ |
| 491 | static bool is_vararg() { \ |
| 492 | return false; \ |
| 493 | } \ |
| 494 | static Variant::Type get_base_type() { \ |
| 495 | return GetTypeInfo<m_class>::VARIANT_TYPE; \ |
| 496 | } \ |
| 497 | static StringName get_name() { \ |
| 498 | return #m_exposed_name; \ |
| 499 | } \ |
| 500 | }; |
| 501 | |
| 502 | template <typename R, typename T, typename... P> |
| 503 | static _FORCE_INLINE_ void vc_ptrcall(R (*method)(T *, P...), void *p_base, const void **p_args, void *r_ret) { |
| 504 | call_with_ptr_args_static_retc<T, R, P...>(reinterpret_cast<T *>(p_base), method, p_args, r_ret); |
| 505 | } |
| 506 | |
| 507 | template <typename T, typename... P> |
| 508 | static _FORCE_INLINE_ void vc_ptrcall(void (*method)(T *, P...), void *p_base, const void **p_args, void *r_ret) { |
| 509 | call_with_ptr_args_static<T, P...>(reinterpret_cast<T *>(p_base), method, p_args); |
| 510 | } |
| 511 | |
| 512 | #define FUNCTION_CLASS(m_class, m_exposed_name, m_method_name, m_method_ptr, m_const) \ |
| 513 | struct Method_##m_class##_##m_method_name { \ |
| 514 | static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { \ |
| 515 | vc_method_call_static(m_method_ptr, base, p_args, p_argcount, r_ret, p_defvals, r_error); \ |
| 516 | } \ |
| 517 | static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ |
| 518 | vc_validated_call_static(m_method_ptr, base, p_args, r_ret); \ |
| 519 | } \ |
| 520 | static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ |
| 521 | vc_ptrcall(m_method_ptr, p_base, p_args, r_ret); \ |
| 522 | } \ |
| 523 | static int get_argument_count() { \ |
| 524 | return vc_get_argument_count(m_method_ptr); \ |
| 525 | } \ |
| 526 | static Variant::Type get_argument_type(int p_arg) { \ |
| 527 | return vc_get_argument_type(m_method_ptr, p_arg); \ |
| 528 | } \ |
| 529 | static Variant::Type get_return_type() { \ |
| 530 | return vc_get_return_type(m_method_ptr); \ |
| 531 | } \ |
| 532 | static bool has_return_type() { \ |
| 533 | return vc_has_return_type_static(m_method_ptr); \ |
| 534 | } \ |
| 535 | static bool is_const() { \ |
| 536 | return m_const; \ |
| 537 | } \ |
| 538 | static bool is_static() { \ |
| 539 | return false; \ |
| 540 | } \ |
| 541 | static bool is_vararg() { \ |
| 542 | return false; \ |
| 543 | } \ |
| 544 | static Variant::Type get_base_type() { \ |
| 545 | return GetTypeInfo<m_class>::VARIANT_TYPE; \ |
| 546 | } \ |
| 547 | static StringName get_name() { \ |
| 548 | return #m_exposed_name; \ |
| 549 | } \ |
| 550 | }; |
| 551 | |
| 552 | #define VARARG_CLASS(m_class, m_exposed_name, m_method_name, m_method_ptr, m_has_return, m_return_type) \ |
| 553 | struct Method_##m_class##_##m_method_name { \ |
| 554 | static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { \ |
| 555 | m_method_ptr(base, p_args, p_argcount, r_ret, r_error); \ |
| 556 | } \ |
| 557 | static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ |
| 558 | Callable::CallError ce; \ |
| 559 | m_method_ptr(base, p_args, p_argcount, *r_ret, ce); \ |
| 560 | } \ |
| 561 | static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ |
| 562 | LocalVector<Variant> vars; \ |
| 563 | LocalVector<const Variant *> vars_ptrs; \ |
| 564 | vars.resize(p_argcount); \ |
| 565 | vars_ptrs.resize(p_argcount); \ |
| 566 | for (int i = 0; i < p_argcount; i++) { \ |
| 567 | vars[i] = PtrToArg<Variant>::convert(p_args[i]); \ |
| 568 | vars_ptrs[i] = &vars[i]; \ |
| 569 | } \ |
| 570 | Variant base = PtrToArg<m_class>::convert(p_base); \ |
| 571 | Variant ret; \ |
| 572 | Callable::CallError ce; \ |
| 573 | m_method_ptr(&base, vars_ptrs.ptr(), p_argcount, ret, ce); \ |
| 574 | if (m_has_return) { \ |
| 575 | m_return_type r = ret; \ |
| 576 | PtrToArg<m_return_type>::encode(ret, r_ret); \ |
| 577 | } \ |
| 578 | } \ |
| 579 | static int get_argument_count() { \ |
| 580 | return 0; \ |
| 581 | } \ |
| 582 | static Variant::Type get_argument_type(int p_arg) { \ |
| 583 | return Variant::NIL; \ |
| 584 | } \ |
| 585 | static Variant::Type get_return_type() { \ |
| 586 | return GetTypeInfo<m_return_type>::VARIANT_TYPE; \ |
| 587 | } \ |
| 588 | static bool has_return_type() { \ |
| 589 | return m_has_return; \ |
| 590 | } \ |
| 591 | static bool is_const() { \ |
| 592 | return true; \ |
| 593 | } \ |
| 594 | static bool is_static() { \ |
| 595 | return false; \ |
| 596 | } \ |
| 597 | static bool is_vararg() { \ |
| 598 | return true; \ |
| 599 | } \ |
| 600 | static Variant::Type get_base_type() { \ |
| 601 | return GetTypeInfo<m_class>::VARIANT_TYPE; \ |
| 602 | } \ |
| 603 | static StringName get_name() { \ |
| 604 | return #m_exposed_name; \ |
| 605 | } \ |
| 606 | }; |
| 607 | |
| 608 | #define VARARG_CLASS1(m_class, m_exposed_name, m_method_name, m_method_ptr, m_arg_type) \ |
| 609 | struct Method_##m_class##_##m_method_name { \ |
| 610 | static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { \ |
| 611 | m_method_ptr(base, p_args, p_argcount, r_ret, r_error); \ |
| 612 | } \ |
| 613 | static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ |
| 614 | Callable::CallError ce; \ |
| 615 | m_method_ptr(base, p_args, p_argcount, *r_ret, ce); \ |
| 616 | } \ |
| 617 | static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ |
| 618 | LocalVector<Variant> vars; \ |
| 619 | LocalVector<const Variant *> vars_ptrs; \ |
| 620 | vars.resize(p_argcount); \ |
| 621 | vars_ptrs.resize(p_argcount); \ |
| 622 | for (int i = 0; i < p_argcount; i++) { \ |
| 623 | vars[i] = PtrToArg<Variant>::convert(p_args[i]); \ |
| 624 | vars_ptrs[i] = &vars[i]; \ |
| 625 | } \ |
| 626 | Variant base = PtrToArg<m_class>::convert(p_base); \ |
| 627 | Variant ret; \ |
| 628 | Callable::CallError ce; \ |
| 629 | m_method_ptr(&base, vars_ptrs.ptr(), p_argcount, ret, ce); \ |
| 630 | } \ |
| 631 | static int get_argument_count() { \ |
| 632 | return 1; \ |
| 633 | } \ |
| 634 | static Variant::Type get_argument_type(int p_arg) { \ |
| 635 | return m_arg_type; \ |
| 636 | } \ |
| 637 | static Variant::Type get_return_type() { \ |
| 638 | return Variant::NIL; \ |
| 639 | } \ |
| 640 | static bool has_return_type() { \ |
| 641 | return false; \ |
| 642 | } \ |
| 643 | static bool is_const() { \ |
| 644 | return true; \ |
| 645 | } \ |
| 646 | static bool is_static() { \ |
| 647 | return false; \ |
| 648 | } \ |
| 649 | static bool is_vararg() { \ |
| 650 | return true; \ |
| 651 | } \ |
| 652 | static Variant::Type get_base_type() { \ |
| 653 | return GetTypeInfo<m_class>::VARIANT_TYPE; \ |
| 654 | } \ |
| 655 | static StringName get_name() { \ |
| 656 | return #m_exposed_name; \ |
| 657 | } \ |
| 658 | }; |
| 659 | |
| 660 | #define VARCALL_ARRAY_GETTER_SETTER(m_packed_type, m_type) \ |
| 661 | static m_type func_##m_packed_type##_get(m_packed_type *p_instance, int64_t p_index) { \ |
| 662 | ERR_FAIL_INDEX_V(p_index, p_instance->size(), m_type()); \ |
| 663 | return p_instance->get(p_index); \ |
| 664 | } \ |
| 665 | static void func_##m_packed_type##_set(m_packed_type *p_instance, int64_t p_index, const m_type &p_value) { \ |
| 666 | ERR_FAIL_INDEX(p_index, p_instance->size()); \ |
| 667 | p_instance->set(p_index, p_value); \ |
| 668 | } |
| 669 | |
| 670 | struct _VariantCall { |
| 671 | VARCALL_ARRAY_GETTER_SETTER(PackedByteArray, uint8_t) |
| 672 | VARCALL_ARRAY_GETTER_SETTER(PackedColorArray, Color) |
| 673 | VARCALL_ARRAY_GETTER_SETTER(PackedFloat32Array, float) |
| 674 | VARCALL_ARRAY_GETTER_SETTER(PackedFloat64Array, double) |
| 675 | VARCALL_ARRAY_GETTER_SETTER(PackedInt32Array, int32_t) |
| 676 | VARCALL_ARRAY_GETTER_SETTER(PackedInt64Array, int64_t) |
| 677 | VARCALL_ARRAY_GETTER_SETTER(PackedStringArray, String) |
| 678 | VARCALL_ARRAY_GETTER_SETTER(PackedVector2Array, Vector2) |
| 679 | VARCALL_ARRAY_GETTER_SETTER(PackedVector3Array, Vector3) |
| 680 | VARCALL_ARRAY_GETTER_SETTER(PackedVector4Array, Vector4) |
| 681 | VARCALL_ARRAY_GETTER_SETTER(Array, Variant) |
| 682 | |
| 683 | static String func_PackedByteArray_get_string_from_ascii(PackedByteArray *p_instance) { |
| 684 | String s; |
| 685 | if (p_instance->size() > 0) { |
| 686 | const uint8_t *r = p_instance->ptr(); |
| 687 | CharString cs; |
| 688 | cs.resize_uninitialized(p_instance->size() + 1); |
| 689 | memcpy(cs.ptrw(), r, p_instance->size()); |
| 690 | cs[(int)p_instance->size()] = 0; |
| 691 | |
| 692 | s = cs.get_data(); |
| 693 | } |
| 694 | return s; |
| 695 | } |
| 696 | |
| 697 | static void func_PackedByteArray_bswap16(PackedByteArray *p_instance, int64_t p_offset, int64_t p_count) { |
| 698 | size_t sz = p_instance->size(); |
| 699 | if (sz == 0 || p_count == 0) { |
| 700 | return; |
| 701 | } |
| 702 | ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(sz) - 2); |
| 703 | if (p_count < 0) { |
| 704 | p_count = floor((sz - p_offset) / 2); |
| 705 | } |
| 706 | ERR_FAIL_COND(p_count > floor((sz - p_offset) / 2)); |
| 707 | |
| 708 | uint16_t *w = (uint16_t *)(p_instance->ptrw() + p_offset); |
| 709 | for (int64_t i = 0; i < p_count; i++) { |
| 710 | w[i] = BSWAP16(w[i]); |
| 711 | } |
| 712 | } |
| 713 | |
| 714 | static void func_PackedByteArray_bswap32(PackedByteArray *p_instance, int64_t p_offset, int64_t p_count) { |
| 715 | size_t sz = p_instance->size(); |
| 716 | if (sz == 0 || p_count == 0) { |
| 717 | return; |
| 718 | } |
| 719 | ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(sz) - 4); |
| 720 | if (p_count < 0) { |
| 721 | p_count = floor((sz - p_offset) / 4); |
| 722 | } |
| 723 | ERR_FAIL_COND(p_count > floor((sz - p_offset) / 4)); |
| 724 | |
| 725 | uint32_t *w = (uint32_t *)(p_instance->ptrw() + p_offset); |
| 726 | for (int64_t i = 0; i < p_count; i++) { |
| 727 | w[i] = BSWAP32(w[i]); |
| 728 | } |
| 729 | } |
| 730 | |
| 731 | static void func_PackedByteArray_bswap64(PackedByteArray *p_instance, int64_t p_offset, int64_t p_count) { |
| 732 | size_t sz = p_instance->size(); |
| 733 | if (sz == 0 || p_count == 0) { |
| 734 | return; |
| 735 | } |
| 736 | ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(sz) - 8); |
| 737 | if (p_count < 0) { |
| 738 | p_count = floor((sz - p_offset) / 8); |
| 739 | } |
| 740 | ERR_FAIL_COND(p_count > floor((sz - p_offset) / 8)); |
| 741 | |
| 742 | uint64_t *w = (uint64_t *)(p_instance->ptrw() + p_offset); |
| 743 | for (int64_t i = 0; i < p_count; i++) { |
| 744 | w[i] = BSWAP64(w[i]); |
| 745 | } |
| 746 | } |
| 747 | |
| 748 | static String func_PackedByteArray_get_string_from_utf8(PackedByteArray *p_instance) { |
| 749 | String s; |
| 750 | if (p_instance->size() > 0) { |
| 751 | const uint8_t *r = p_instance->ptr(); |
| 752 | s.append_utf8((const char *)r, p_instance->size()); |
| 753 | } |
| 754 | return s; |
| 755 | } |
| 756 | |
| 757 | static String func_PackedByteArray_get_string_from_utf16(PackedByteArray *p_instance) { |
| 758 | String s; |
| 759 | if (p_instance->size() > 0) { |
| 760 | const uint8_t *r = p_instance->ptr(); |
| 761 | s.append_utf16((const char16_t *)r, std::floor((double)p_instance->size() / (double)sizeof(char16_t))); |
| 762 | } |
| 763 | return s; |
| 764 | } |
| 765 | |
| 766 | static String func_PackedByteArray_get_string_from_utf32(PackedByteArray *p_instance) { |
| 767 | String s; |
| 768 | if (p_instance->size() > 0) { |
| 769 | const uint8_t *r = p_instance->ptr(); |
| 770 | s.append_utf32(Span((const char32_t *)r, std::floor((double)p_instance->size() / (double)sizeof(char32_t)))); |
| 771 | } |
| 772 | return s; |
| 773 | } |
| 774 | |
| 775 | static String func_PackedByteArray_get_string_from_wchar(PackedByteArray *p_instance) { |
| 776 | String s; |
| 777 | if (p_instance->size() > 0) { |
| 778 | const uint8_t *r = p_instance->ptr(); |
| 779 | #ifdef WINDOWS_ENABLED |
| 780 | s.append_utf16((const char16_t *)r, std::floor((double)p_instance->size() / (double)sizeof(char16_t))); |
| 781 | #else |
| 782 | s.append_utf32(Span((const char32_t *)r, std::floor((double)p_instance->size() / (double)sizeof(char32_t)))); |
| 783 | #endif |
| 784 | } |
| 785 | return s; |
| 786 | } |
| 787 | |
| 788 | static String func_PackedByteArray_get_string_from_multibyte_char(PackedByteArray *p_instance, const String &p_encoding) { |
| 789 | String s; |
| 790 | if (p_instance->size() > 0) { |
| 791 | s = OS::get_singleton()->multibyte_to_string(p_encoding, *p_instance); |
| 792 | } |
| 793 | return s; |
| 794 | } |
| 795 | |
| 796 | static PackedByteArray func_PackedByteArray_compress(PackedByteArray *p_instance, int p_mode) { |
| 797 | PackedByteArray compressed; |
| 798 | |
| 799 | if (p_instance->size() > 0) { |
| 800 | Compression::Mode mode = (Compression::Mode)(p_mode); |
| 801 | compressed.resize(Compression::get_max_compressed_buffer_size(p_instance->size(), mode)); |
| 802 | int64_t result = Compression::compress(compressed.ptrw(), p_instance->ptr(), p_instance->size(), mode); |
| 803 | |
| 804 | result = result >= 0 ? result : 0; |
| 805 | compressed.resize(result); |
| 806 | } |
| 807 | |
| 808 | return compressed; |
| 809 | } |
| 810 | |
| 811 | static PackedByteArray func_PackedByteArray_decompress(PackedByteArray *p_instance, int64_t p_buffer_size, int p_mode) { |
| 812 | PackedByteArray decompressed; |
| 813 | Compression::Mode mode = (Compression::Mode)(p_mode); |
| 814 | |
| 815 | int64_t buffer_size = p_buffer_size; |
| 816 | |
| 817 | if (buffer_size <= 0) { |
| 818 | ERR_FAIL_V_MSG(decompressed, "Decompression buffer size must be greater than zero."); |
| 819 | } |
| 820 | if (p_instance->size() == 0) { |
| 821 | ERR_FAIL_V_MSG(decompressed, "Compressed buffer size must be greater than zero."); |
| 822 | } |
| 823 | |
| 824 | decompressed.resize(buffer_size); |
| 825 | int64_t result = Compression::decompress(decompressed.ptrw(), buffer_size, p_instance->ptr(), p_instance->size(), mode); |
| 826 | |
| 827 | result = result >= 0 ? result : 0; |
| 828 | decompressed.resize(result); |
| 829 | |
| 830 | return decompressed; |
| 831 | } |
| 832 | |
| 833 | static PackedByteArray func_PackedByteArray_decompress_dynamic(PackedByteArray *p_instance, int64_t p_buffer_size, int p_mode) { |
| 834 | PackedByteArray decompressed; |
| 835 | int64_t max_output_size = p_buffer_size; |
| 836 | Compression::Mode mode = (Compression::Mode)(p_mode); |
| 837 | |
| 838 | int result = Compression::decompress_dynamic(&decompressed, max_output_size, p_instance->ptr(), p_instance->size(), mode); |
| 839 | |
| 840 | if (result == OK) { |
| 841 | return decompressed; |
| 842 | } else { |
| 843 | decompressed.clear(); |
| 844 | ERR_FAIL_V_MSG(decompressed, "Decompression failed."); |
| 845 | } |
| 846 | } |
| 847 | |
| 848 | static String func_PackedByteArray_hex_encode(PackedByteArray *p_instance) { |
| 849 | if (p_instance->size() == 0) { |
| 850 | return String(); |
| 851 | } |
| 852 | const uint8_t *r = p_instance->ptr(); |
| 853 | String s = String::hex_encode_buffer(&r[0], p_instance->size()); |
| 854 | return s; |
| 855 | } |
| 856 | |
| 857 | static int64_t func_PackedByteArray_decode_u8(PackedByteArray *p_instance, int64_t p_offset) { |
| 858 | uint64_t size = p_instance->size(); |
| 859 | ERR_FAIL_COND_V(p_offset < 0 || p_offset > int64_t(size) - 1, 0); |
| 860 | const uint8_t *r = p_instance->ptr(); |
| 861 | return r[p_offset]; |
| 862 | } |
| 863 | static int64_t func_PackedByteArray_decode_s8(PackedByteArray *p_instance, int64_t p_offset) { |
| 864 | uint64_t size = p_instance->size(); |
| 865 | ERR_FAIL_COND_V(p_offset < 0 || p_offset > int64_t(size) - 1, 0); |
| 866 | const uint8_t *r = p_instance->ptr(); |
| 867 | return *((const int8_t *)&r[p_offset]); |
| 868 | } |
| 869 | static int64_t func_PackedByteArray_decode_u16(PackedByteArray *p_instance, int64_t p_offset) { |
| 870 | uint64_t size = p_instance->size(); |
| 871 | ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 2), 0); |
| 872 | const uint8_t *r = p_instance->ptr(); |
| 873 | return decode_uint16(&r[p_offset]); |
| 874 | } |
| 875 | static int64_t func_PackedByteArray_decode_s16(PackedByteArray *p_instance, int64_t p_offset) { |
| 876 | uint64_t size = p_instance->size(); |
| 877 | ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 2), 0); |
| 878 | const uint8_t *r = p_instance->ptr(); |
| 879 | return (int16_t)decode_uint16(&r[p_offset]); |
| 880 | } |
| 881 | static int64_t func_PackedByteArray_decode_u32(PackedByteArray *p_instance, int64_t p_offset) { |
| 882 | uint64_t size = p_instance->size(); |
| 883 | ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 4), 0); |
| 884 | const uint8_t *r = p_instance->ptr(); |
| 885 | return decode_uint32(&r[p_offset]); |
| 886 | } |
| 887 | static int64_t func_PackedByteArray_decode_s32(PackedByteArray *p_instance, int64_t p_offset) { |
| 888 | uint64_t size = p_instance->size(); |
| 889 | ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 4), 0); |
| 890 | const uint8_t *r = p_instance->ptr(); |
| 891 | return (int32_t)decode_uint32(&r[p_offset]); |
| 892 | } |
| 893 | static int64_t func_PackedByteArray_decode_u64(PackedByteArray *p_instance, int64_t p_offset) { |
| 894 | uint64_t size = p_instance->size(); |
| 895 | ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 8), 0); |
| 896 | const uint8_t *r = p_instance->ptr(); |
| 897 | return (int64_t)decode_uint64(&r[p_offset]); |
| 898 | } |
| 899 | static int64_t func_PackedByteArray_decode_s64(PackedByteArray *p_instance, int64_t p_offset) { |
| 900 | uint64_t size = p_instance->size(); |
| 901 | ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 8), 0); |
| 902 | const uint8_t *r = p_instance->ptr(); |
| 903 | return (int64_t)decode_uint64(&r[p_offset]); |
| 904 | } |
| 905 | static double func_PackedByteArray_decode_half(PackedByteArray *p_instance, int64_t p_offset) { |
| 906 | uint64_t size = p_instance->size(); |
| 907 | ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 2), 0); |
| 908 | const uint8_t *r = p_instance->ptr(); |
| 909 | return Math::half_to_float(decode_uint16(&r[p_offset])); |
| 910 | } |
| 911 | static double func_PackedByteArray_decode_float(PackedByteArray *p_instance, int64_t p_offset) { |
| 912 | uint64_t size = p_instance->size(); |
| 913 | ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 4), 0); |
| 914 | const uint8_t *r = p_instance->ptr(); |
| 915 | return decode_float(&r[p_offset]); |
| 916 | } |
| 917 | |
| 918 | static double func_PackedByteArray_decode_double(PackedByteArray *p_instance, int64_t p_offset) { |
| 919 | uint64_t size = p_instance->size(); |
| 920 | ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 8), 0); |
| 921 | const uint8_t *r = p_instance->ptr(); |
| 922 | return decode_double(&r[p_offset]); |
| 923 | } |
| 924 | |
| 925 | static bool func_PackedByteArray_has_encoded_var(PackedByteArray *p_instance, int64_t p_offset, bool p_allow_objects) { |
| 926 | uint64_t size = p_instance->size(); |
| 927 | ERR_FAIL_COND_V(p_offset < 0, false); |
| 928 | const uint8_t *r = p_instance->ptr(); |
| 929 | Variant ret; |
| 930 | Error err = decode_variant(ret, r + p_offset, size - p_offset, nullptr, p_allow_objects); |
| 931 | return err == OK; |
| 932 | } |
| 933 | |
| 934 | static Variant func_PackedByteArray_decode_var(PackedByteArray *p_instance, int64_t p_offset, bool p_allow_objects) { |
| 935 | uint64_t size = p_instance->size(); |
| 936 | ERR_FAIL_COND_V(p_offset < 0, Variant()); |
| 937 | const uint8_t *r = p_instance->ptr(); |
| 938 | Variant ret; |
| 939 | Error err = decode_variant(ret, r + p_offset, size - p_offset, nullptr, p_allow_objects); |
| 940 | if (err != OK) { |
| 941 | ret = Variant(); |
| 942 | } |
| 943 | return ret; |
| 944 | } |
| 945 | |
| 946 | static int64_t func_PackedByteArray_decode_var_size(PackedByteArray *p_instance, int64_t p_offset, bool p_allow_objects) { |
| 947 | uint64_t size = p_instance->size(); |
| 948 | ERR_FAIL_COND_V(p_offset < 0, 0); |
| 949 | const uint8_t *r = p_instance->ptr(); |
| 950 | Variant ret; |
| 951 | int r_size; |
| 952 | Error err = decode_variant(ret, r + p_offset, size - p_offset, &r_size, p_allow_objects); |
| 953 | if (err == OK) { |
| 954 | return r_size; |
| 955 | } |
| 956 | return 0; |
| 957 | } |
| 958 | |
| 959 | static PackedInt32Array func_PackedByteArray_decode_s32_array(PackedByteArray *p_instance) { |
| 960 | uint64_t size = p_instance->size(); |
| 961 | PackedInt32Array dest; |
| 962 | if (size == 0) { |
| 963 | return dest; |
| 964 | } |
| 965 | ERR_FAIL_COND_V_MSG(size % sizeof(int32_t), dest, "PackedByteArray size must be a multiple of 4 (size of 32-bit integer) to convert to PackedInt32Array."); |
| 966 | const uint8_t *r = p_instance->ptr(); |
| 967 | dest.resize(size / sizeof(int32_t)); |
| 968 | ERR_FAIL_COND_V(dest.is_empty(), dest); // Avoid UB in case resize failed. |
| 969 | memcpy(dest.ptrw(), r, dest.size() * sizeof(int32_t)); |
| 970 | return dest; |
| 971 | } |
| 972 | |
| 973 | static PackedInt64Array func_PackedByteArray_decode_s64_array(PackedByteArray *p_instance) { |
| 974 | uint64_t size = p_instance->size(); |
| 975 | PackedInt64Array dest; |
| 976 | if (size == 0) { |
| 977 | return dest; |
| 978 | } |
| 979 | ERR_FAIL_COND_V_MSG(size % sizeof(int64_t), dest, "PackedByteArray size must be a multiple of 8 (size of 64-bit integer) to convert to PackedInt64Array."); |
| 980 | const uint8_t *r = p_instance->ptr(); |
| 981 | dest.resize(size / sizeof(int64_t)); |
| 982 | ERR_FAIL_COND_V(dest.is_empty(), dest); // Avoid UB in case resize failed. |
| 983 | memcpy(dest.ptrw(), r, dest.size() * sizeof(int64_t)); |
| 984 | return dest; |
| 985 | } |
| 986 | |
| 987 | static PackedFloat32Array func_PackedByteArray_decode_float_array(PackedByteArray *p_instance) { |
| 988 | uint64_t size = p_instance->size(); |
| 989 | PackedFloat32Array dest; |
| 990 | if (size == 0) { |
| 991 | return dest; |
| 992 | } |
| 993 | ERR_FAIL_COND_V_MSG(size % sizeof(float), dest, "PackedByteArray size must be a multiple of 4 (size of 32-bit float) to convert to PackedFloat32Array."); |
| 994 | const uint8_t *r = p_instance->ptr(); |
| 995 | dest.resize(size / sizeof(float)); |
| 996 | ERR_FAIL_COND_V(dest.is_empty(), dest); // Avoid UB in case resize failed. |
| 997 | memcpy(dest.ptrw(), r, dest.size() * sizeof(float)); |
| 998 | return dest; |
| 999 | } |
| 1000 | |
| 1001 | static PackedFloat64Array func_PackedByteArray_decode_double_array(PackedByteArray *p_instance) { |
| 1002 | uint64_t size = p_instance->size(); |
| 1003 | PackedFloat64Array dest; |
| 1004 | if (size == 0) { |
| 1005 | return dest; |
| 1006 | } |
| 1007 | ERR_FAIL_COND_V_MSG(size % sizeof(double), dest, "PackedByteArray size must be a multiple of 8 (size of 64-bit double) to convert to PackedFloat64Array."); |
| 1008 | const uint8_t *r = p_instance->ptr(); |
| 1009 | dest.resize(size / sizeof(double)); |
| 1010 | ERR_FAIL_COND_V(dest.is_empty(), dest); // Avoid UB in case resize failed. |
| 1011 | memcpy(dest.ptrw(), r, dest.size() * sizeof(double)); |
| 1012 | return dest; |
| 1013 | } |
| 1014 | |
| 1015 | static PackedVector2Array func_PackedByteArray_decode_vector2_array(PackedByteArray *p_instance) { |
| 1016 | uint64_t size = p_instance->size(); |
| 1017 | PackedVector2Array dest; |
| 1018 | if (size == 0) { |
| 1019 | return dest; |
| 1020 | } |
| 1021 | ERR_FAIL_COND_V_MSG(size % sizeof(Vector2), dest, "PackedByteArray size must be a multiple of " + itos(sizeof(Vector2)) + " (size of Vector2) to convert to PackedVector2Array."); |
| 1022 | const uint8_t *r = p_instance->ptr(); |
| 1023 | dest.resize(size / sizeof(Vector2)); |
| 1024 | ERR_FAIL_COND_V(dest.is_empty(), dest); // Avoid UB in case resize failed. |
| 1025 | memcpy(dest.ptrw(), r, dest.size() * sizeof(Vector2)); |
| 1026 | return dest; |
| 1027 | } |
| 1028 | |
| 1029 | static PackedVector3Array func_PackedByteArray_decode_vector3_array(PackedByteArray *p_instance) { |
| 1030 | uint64_t size = p_instance->size(); |
| 1031 | PackedVector3Array dest; |
| 1032 | if (size == 0) { |
| 1033 | return dest; |
| 1034 | } |
| 1035 | ERR_FAIL_COND_V_MSG(size % sizeof(Vector3), dest, "PackedByteArray size must be a multiple of " + itos(sizeof(Vector3)) + " (size of Vector3) to convert to PackedVector3Array."); |
| 1036 | const uint8_t *r = p_instance->ptr(); |
| 1037 | dest.resize(size / sizeof(Vector3)); |
| 1038 | ERR_FAIL_COND_V(dest.is_empty(), dest); // Avoid UB in case resize failed. |
| 1039 | memcpy(dest.ptrw(), r, dest.size() * sizeof(Vector3)); |
| 1040 | return dest; |
| 1041 | } |
| 1042 | |
| 1043 | static PackedVector4Array func_PackedByteArray_decode_vector4_array(PackedByteArray *p_instance) { |
| 1044 | uint64_t size = p_instance->size(); |
| 1045 | PackedVector4Array dest; |
| 1046 | if (size == 0) { |
| 1047 | return dest; |
| 1048 | } |
| 1049 | ERR_FAIL_COND_V_MSG(size % sizeof(Vector4), dest, "PackedByteArray size must be a multiple of " + itos(sizeof(Vector4)) + " (size of Vector4) to convert to PackedVector4Array."); |
| 1050 | const uint8_t *r = p_instance->ptr(); |
| 1051 | dest.resize(size / sizeof(Vector4)); |
| 1052 | ERR_FAIL_COND_V(dest.is_empty(), dest); // Avoid UB in case resize failed. |
| 1053 | memcpy(dest.ptrw(), r, dest.size() * sizeof(Vector4)); |
| 1054 | return dest; |
| 1055 | } |
| 1056 | |
| 1057 | static PackedColorArray func_PackedByteArray_decode_color_array(PackedByteArray *p_instance) { |
| 1058 | uint64_t size = p_instance->size(); |
| 1059 | PackedColorArray dest; |
| 1060 | if (size == 0) { |
| 1061 | return dest; |
| 1062 | } |
| 1063 | ERR_FAIL_COND_V_MSG(size % sizeof(Color), dest, "PackedByteArray size must be a multiple of " + itos(sizeof(Color)) + " (size of Color variant) to convert to PackedColorArray."); |
| 1064 | const uint8_t *r = p_instance->ptr(); |
| 1065 | dest.resize(size / sizeof(Color)); |
| 1066 | ERR_FAIL_COND_V(dest.is_empty(), dest); // Avoid UB in case resize failed. |
| 1067 | memcpy(dest.ptrw(), r, dest.size() * sizeof(Color)); |
| 1068 | return dest; |
| 1069 | } |
| 1070 | |
| 1071 | static void func_PackedByteArray_encode_u8(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) { |
| 1072 | uint64_t size = p_instance->size(); |
| 1073 | ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 1); |
| 1074 | uint8_t *w = p_instance->ptrw(); |
| 1075 | *((uint8_t *)&w[p_offset]) = p_value; |
| 1076 | } |
| 1077 | static void func_PackedByteArray_encode_s8(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) { |
| 1078 | uint64_t size = p_instance->size(); |
| 1079 | ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 1); |
| 1080 | uint8_t *w = p_instance->ptrw(); |
| 1081 | *((int8_t *)&w[p_offset]) = p_value; |
| 1082 | } |
| 1083 | |
| 1084 | static void func_PackedByteArray_encode_u16(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) { |
| 1085 | uint64_t size = p_instance->size(); |
| 1086 | ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 2); |
| 1087 | uint8_t *w = p_instance->ptrw(); |
| 1088 | encode_uint16((uint16_t)p_value, &w[p_offset]); |
| 1089 | } |
| 1090 | static void func_PackedByteArray_encode_s16(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) { |
| 1091 | uint64_t size = p_instance->size(); |
| 1092 | ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 2); |
| 1093 | uint8_t *w = p_instance->ptrw(); |
| 1094 | encode_uint16((int16_t)p_value, &w[p_offset]); |
| 1095 | } |
| 1096 | |
| 1097 | static void func_PackedByteArray_encode_u32(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) { |
| 1098 | uint64_t size = p_instance->size(); |
| 1099 | ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 4); |
| 1100 | uint8_t *w = p_instance->ptrw(); |
| 1101 | encode_uint32((uint32_t)p_value, &w[p_offset]); |
| 1102 | } |
| 1103 | static void func_PackedByteArray_encode_s32(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) { |
| 1104 | uint64_t size = p_instance->size(); |
| 1105 | ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 4); |
| 1106 | uint8_t *w = p_instance->ptrw(); |
| 1107 | encode_uint32((int32_t)p_value, &w[p_offset]); |
| 1108 | } |
| 1109 | |
| 1110 | static void func_PackedByteArray_encode_u64(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) { |
| 1111 | uint64_t size = p_instance->size(); |
| 1112 | ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 8); |
| 1113 | uint8_t *w = p_instance->ptrw(); |
| 1114 | encode_uint64((uint64_t)p_value, &w[p_offset]); |
| 1115 | } |
| 1116 | static void func_PackedByteArray_encode_s64(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) { |
| 1117 | uint64_t size = p_instance->size(); |
| 1118 | ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 8); |
| 1119 | uint8_t *w = p_instance->ptrw(); |
| 1120 | encode_uint64((int64_t)p_value, &w[p_offset]); |
| 1121 | } |
| 1122 | |
| 1123 | static void func_PackedByteArray_encode_half(PackedByteArray *p_instance, int64_t p_offset, double p_value) { |
| 1124 | uint64_t size = p_instance->size(); |
| 1125 | ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 2); |
| 1126 | uint8_t *w = p_instance->ptrw(); |
| 1127 | encode_uint16(Math::make_half_float(p_value), &w[p_offset]); |
| 1128 | } |
| 1129 | static void func_PackedByteArray_encode_float(PackedByteArray *p_instance, int64_t p_offset, double p_value) { |
| 1130 | uint64_t size = p_instance->size(); |
| 1131 | ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 4); |
| 1132 | uint8_t *w = p_instance->ptrw(); |
| 1133 | encode_float(p_value, &w[p_offset]); |
| 1134 | } |
| 1135 | static void func_PackedByteArray_encode_double(PackedByteArray *p_instance, int64_t p_offset, double p_value) { |
| 1136 | uint64_t size = p_instance->size(); |
| 1137 | ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 8); |
| 1138 | uint8_t *w = p_instance->ptrw(); |
| 1139 | encode_double(p_value, &w[p_offset]); |
| 1140 | } |
| 1141 | static int64_t func_PackedByteArray_encode_var(PackedByteArray *p_instance, int64_t p_offset, const Variant &p_value, bool p_allow_objects) { |
| 1142 | uint64_t size = p_instance->size(); |
| 1143 | ERR_FAIL_COND_V(p_offset < 0, -1); |
| 1144 | uint8_t *w = p_instance->ptrw(); |
| 1145 | int len; |
| 1146 | Error err = encode_variant(p_value, nullptr, len, p_allow_objects); |
| 1147 | if (err != OK) { |
| 1148 | return -1; |
| 1149 | } |
| 1150 | if (uint64_t(p_offset + len) > size) { |
| 1151 | return -1; // did not fit |
| 1152 | } |
| 1153 | encode_variant(p_value, w + p_offset, len, p_allow_objects); |
| 1154 | |
| 1155 | return len; |
| 1156 | } |
| 1157 | |
| 1158 | static PackedByteArray func_PackedStringArray_to_byte_array(PackedStringArray *p_instance) { |
| 1159 | PackedByteArray ret; |
| 1160 | uint64_t size = p_instance->size(); |
| 1161 | const String *r = p_instance->ptr(); |
| 1162 | |
| 1163 | for (uint64_t i = 0; i < size; i++) { |
| 1164 | ret.append_array(r[i].to_utf8_buffer()); |
| 1165 | ret.append(0); |
| 1166 | } |
| 1167 | return ret; |
| 1168 | } |
| 1169 | |
| 1170 | static void func_Callable_call(Variant *v, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) { |
| 1171 | Callable *callable = &VariantInternalAccessor<Callable>::get(v); |
| 1172 | callable->callp(p_args, p_argcount, r_ret, r_error); |
| 1173 | } |
| 1174 | |
| 1175 | static void func_Callable_call_deferred(Variant *v, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) { |
| 1176 | Callable *callable = &VariantInternalAccessor<Callable>::get(v); |
| 1177 | callable->call_deferredp(p_args, p_argcount); |
| 1178 | } |
| 1179 | |
| 1180 | static void func_Callable_rpc(Variant *v, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) { |
| 1181 | Callable *callable = &VariantInternalAccessor<Callable>::get(v); |
| 1182 | callable->rpcp(0, p_args, p_argcount, r_error); |
| 1183 | } |
| 1184 | |
| 1185 | static void func_Callable_rpc_id(Variant *v, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) { |
| 1186 | if (p_argcount == 0) { |
| 1187 | r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; |
| 1188 | r_error.expected = 1; |
| 1189 | } else if (p_args[0]->get_type() != Variant::INT) { |
| 1190 | r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; |
| 1191 | r_error.argument = 0; |
| 1192 | r_error.expected = Variant::INT; |
| 1193 | } else { |
| 1194 | Callable *callable = &VariantInternalAccessor<Callable>::get(v); |
| 1195 | callable->rpcp(*p_args[0], &p_args[1], p_argcount - 1, r_error); |
| 1196 | } |
| 1197 | } |
| 1198 | |
| 1199 | static void func_Callable_bind(Variant *v, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) { |
| 1200 | Callable *callable = &VariantInternalAccessor<Callable>::get(v); |
| 1201 | r_ret = callable->bindp(p_args, p_argcount); |
| 1202 | } |
| 1203 | |
| 1204 | static int func_Callable_get_argument_count(Callable *p_callable) { |
| 1205 | return p_callable->get_argument_count(); |
| 1206 | } |
| 1207 | |
| 1208 | static void func_Signal_emit(Variant *v, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) { |
| 1209 | Signal *signal = &VariantInternalAccessor<Signal>::get(v); |
| 1210 | signal->emit(p_args, p_argcount); |
| 1211 | } |
| 1212 | |
| 1213 | struct ConstantData { |
| 1214 | HashMap<StringName, int64_t> value; |
| 1215 | #ifdef DEBUG_ENABLED |
| 1216 | List<StringName> value_ordered; |
| 1217 | #endif // DEBUG_ENABLED |
| 1218 | HashMap<StringName, Variant> variant_value; |
| 1219 | #ifdef DEBUG_ENABLED |
| 1220 | List<StringName> variant_value_ordered; |
| 1221 | #endif // DEBUG_ENABLED |
| 1222 | }; |
| 1223 | |
| 1224 | static ConstantData *constant_data; |
| 1225 | |
| 1226 | static void add_constant(int p_type, const StringName &p_constant_name, int64_t p_constant_value) { |
| 1227 | #ifdef DEBUG_ENABLED |
| 1228 | ERR_FAIL_COND(constant_data[p_type].value.has(p_constant_name)); |
| 1229 | ERR_FAIL_COND(enum_data[p_type].value.has(p_constant_name)); |
| 1230 | ERR_FAIL_COND(enum_data[p_type].value_to_enum.has(p_constant_name)); |
| 1231 | #endif // DEBUG_ENABLED |
| 1232 | constant_data[p_type].value[p_constant_name] = p_constant_value; |
| 1233 | #ifdef DEBUG_ENABLED |
| 1234 | constant_data[p_type].value_ordered.push_back(p_constant_name); |
| 1235 | #endif // DEBUG_ENABLED |
| 1236 | } |
| 1237 | |
| 1238 | static void add_variant_constant(int p_type, const StringName &p_constant_name, const Variant &p_constant_value) { |
| 1239 | constant_data[p_type].variant_value[p_constant_name] = p_constant_value; |
| 1240 | #ifdef DEBUG_ENABLED |
| 1241 | constant_data[p_type].variant_value_ordered.push_back(p_constant_name); |
| 1242 | #endif // DEBUG_ENABLED |
| 1243 | } |
| 1244 | |
| 1245 | struct EnumData { |
| 1246 | HashMap<StringName, HashMap<StringName, int>> value; |
| 1247 | HashMap<StringName, StringName> value_to_enum; |
| 1248 | }; |
| 1249 | |
| 1250 | static EnumData *enum_data; |
| 1251 | |
| 1252 | static void add_enum_constant(int p_type, const StringName &p_enum_type_name, const StringName &p_enumeration_name, int p_enum_value) { |
| 1253 | #ifdef DEBUG_ENABLED |
| 1254 | ERR_FAIL_COND(constant_data[p_type].value.has(p_enumeration_name)); |
| 1255 | ERR_FAIL_COND(enum_data[p_type].value.has(p_enumeration_name)); |
| 1256 | ERR_FAIL_COND(enum_data[p_type].value_to_enum.has(p_enumeration_name)); |
| 1257 | #endif // DEBUG_ENABLED |
| 1258 | enum_data[p_type].value[p_enum_type_name][p_enumeration_name] = p_enum_value; |
| 1259 | enum_data[p_type].value_to_enum[p_enumeration_name] = p_enum_type_name; |
| 1260 | } |
| 1261 | |
| 1262 | #ifndef DISABLE_DEPRECATED |
| 1263 | template <typename T> |
| 1264 | static Vector<T> _duplicate_bind_compat_112290(Vector<T> *p_vector) { |
| 1265 | return *p_vector; |
| 1266 | } |
| 1267 | |
| 1268 | template <typename T> |
| 1269 | static int64_t _bsearch_bind_compat_112539(Vector<T> *p_vector, const T &p_value, bool p_before) { |
| 1270 | return p_vector->bsearch(p_value, p_before); |
| 1271 | } |
| 1272 | #endif |
| 1273 | }; |
| 1274 | |
| 1275 | _VariantCall::ConstantData *_VariantCall::constant_data = nullptr; |
| 1276 | _VariantCall::EnumData *_VariantCall::enum_data = nullptr; |
| 1277 | |
| 1278 | struct VariantBuiltInMethodInfo { |
| 1279 | void (*call)(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) = nullptr; |
| 1280 | Variant::ValidatedBuiltInMethod validated_call = nullptr; |
| 1281 | Variant::PTRBuiltInMethod ptrcall = nullptr; |
| 1282 | |
| 1283 | Vector<Variant> default_arguments; |
| 1284 | Vector<String> argument_names; |
| 1285 | |
| 1286 | bool is_const = false; |
| 1287 | bool is_static = false; |
| 1288 | bool has_return_type = false; |
| 1289 | bool is_vararg = false; |
| 1290 | Variant::Type return_type; |
| 1291 | int argument_count = 0; |
| 1292 | Variant::Type (*get_argument_type)(int p_arg) = nullptr; |
| 1293 | |
| 1294 | MethodInfo get_method_info(const StringName &p_name) const { |
| 1295 | MethodInfo mi; |
| 1296 | mi.name = p_name; |
| 1297 | |
| 1298 | if (has_return_type) { |
| 1299 | mi.return_val.type = return_type; |
| 1300 | if (mi.return_val.type == Variant::NIL) { |
| 1301 | mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; |
| 1302 | } |
| 1303 | } |
| 1304 | |
| 1305 | if (is_const) { |
| 1306 | mi.flags |= METHOD_FLAG_CONST; |
| 1307 | } |
| 1308 | if (is_vararg) { |
| 1309 | mi.flags |= METHOD_FLAG_VARARG; |
| 1310 | } |
| 1311 | if (is_static) { |
| 1312 | mi.flags |= METHOD_FLAG_STATIC; |
| 1313 | } |
| 1314 | |
| 1315 | for (int i = 0; i < argument_count; i++) { |
| 1316 | PropertyInfo pi; |
| 1317 | #ifdef DEBUG_ENABLED |
| 1318 | pi.name = argument_names[i]; |
| 1319 | #else |
| 1320 | pi.name = "arg" + itos(i + 1); |
| 1321 | #endif // DEBUG_ENABLED |
| 1322 | pi.type = (*get_argument_type)(i); |
| 1323 | if (pi.type == Variant::NIL) { |
| 1324 | pi.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; |
| 1325 | } |
| 1326 | mi.arguments.push_back(pi); |
| 1327 | } |
| 1328 | |
| 1329 | mi.default_arguments = default_arguments; |
| 1330 | |
| 1331 | return mi; |
| 1332 | } |
| 1333 | |
| 1334 | uint32_t get_hash() const { |
| 1335 | uint32_t hash = hash_murmur3_one_32(is_const); |
| 1336 | hash = hash_murmur3_one_32(is_static, hash); |
| 1337 | hash = hash_murmur3_one_32(is_vararg, hash); |
| 1338 | hash = hash_murmur3_one_32(has_return_type, hash); |
| 1339 | if (has_return_type) { |
| 1340 | hash = hash_murmur3_one_32(return_type, hash); |
| 1341 | } |
| 1342 | hash = hash_murmur3_one_32(argument_count, hash); |
| 1343 | for (int i = 0; i < argument_count; i++) { |
| 1344 | hash = hash_murmur3_one_32(get_argument_type(i), hash); |
| 1345 | } |
| 1346 | |
| 1347 | return hash_fmix32(hash); |
| 1348 | } |
| 1349 | }; |
| 1350 | |
| 1351 | typedef AHashMap<StringName, VariantBuiltInMethodInfo> BuiltinMethodMap; |
| 1352 | static BuiltinMethodMap *builtin_method_info; |
| 1353 | static List<StringName> *builtin_method_names; |
| 1354 | |
| 1355 | #ifndef DISABLE_DEPRECATED |
| 1356 | typedef AHashMap<StringName, LocalVector<VariantBuiltInMethodInfo>> BuiltinCompatMethodMap; |
| 1357 | static BuiltinCompatMethodMap *builtin_compat_method_info; |
| 1358 | #endif |
| 1359 | |
| 1360 | template <typename T> |
| 1361 | static void _populate_variant_builtin_method_info(VariantBuiltInMethodInfo &r_imi, const Vector<String> &p_argnames, const Vector<Variant> &p_def_args) { |
| 1362 | r_imi.call = T::call; |
| 1363 | r_imi.validated_call = T::validated_call; |
| 1364 | r_imi.ptrcall = T::ptrcall; |
| 1365 | |
| 1366 | r_imi.default_arguments = p_def_args; |
| 1367 | r_imi.argument_names = p_argnames; |
| 1368 | |
| 1369 | r_imi.is_const = T::is_const(); |
| 1370 | r_imi.is_static = T::is_static(); |
| 1371 | r_imi.is_vararg = T::is_vararg(); |
| 1372 | r_imi.has_return_type = T::has_return_type(); |
| 1373 | r_imi.return_type = T::get_return_type(); |
| 1374 | r_imi.argument_count = T::get_argument_count(); |
| 1375 | r_imi.get_argument_type = T::get_argument_type; |
| 1376 | } |
| 1377 | |
| 1378 | template <typename T> |
| 1379 | static void register_builtin_method(const Vector<String> &p_argnames, const Vector<Variant> &p_def_args) { |
| 1380 | StringName name = T::get_name(); |
| 1381 | |
| 1382 | ERR_FAIL_COND(builtin_method_info[T::get_base_type()].has(name)); |
| 1383 | |
| 1384 | VariantBuiltInMethodInfo imi; |
| 1385 | _populate_variant_builtin_method_info<T>(imi, p_argnames, p_def_args); |
| 1386 | |
| 1387 | #ifdef DEBUG_ENABLED |
| 1388 | ERR_FAIL_COND(!imi.is_vararg && imi.argument_count != imi.argument_names.size()); |
| 1389 | #endif // DEBUG_ENABLED |
| 1390 | |
| 1391 | builtin_method_info[T::get_base_type()].insert(name, imi); |
| 1392 | builtin_method_names[T::get_base_type()].push_back(name); |
| 1393 | } |
| 1394 | |
| 1395 | #ifndef DISABLE_DEPRECATED |
| 1396 | template <typename T> |
| 1397 | static void register_builtin_compat_method(const Vector<String> &p_argnames, const Vector<Variant> &p_def_args) { |
| 1398 | StringName name = T::get_name(); |
| 1399 | |
| 1400 | ERR_FAIL_COND(!builtin_method_info[T::get_base_type()].has(name)); |
| 1401 | |
| 1402 | VariantBuiltInMethodInfo imi; |
| 1403 | _populate_variant_builtin_method_info<T>(imi, p_argnames, p_def_args); |
| 1404 | |
| 1405 | #ifdef DEBUG_ENABLED |
| 1406 | ERR_FAIL_COND(!imi.is_vararg && imi.argument_count != imi.argument_names.size()); |
| 1407 | #endif // DEBUG_ENABLED |
| 1408 | |
| 1409 | if (!builtin_compat_method_info[T::get_base_type()].has(name)) { |
| 1410 | builtin_compat_method_info[T::get_base_type()].insert(name, LocalVector<VariantBuiltInMethodInfo>()); |
| 1411 | } |
| 1412 | builtin_compat_method_info[T::get_base_type()][name].push_back(imi); |
| 1413 | } |
| 1414 | #endif |
| 1415 | |
| 1416 | void Variant::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) { |
| 1417 | if (type == Variant::OBJECT) { |
| 1418 | //call object |
| 1419 | Object *obj = _get_obj().obj; |
| 1420 | if (!obj) { |
| 1421 | r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; |
| 1422 | return; |
| 1423 | } |
| 1424 | #ifdef DEBUG_ENABLED |
| 1425 | if (EngineDebugger::is_active() && !_get_obj().id.is_ref_counted() && ObjectDB::get_instance(_get_obj().id) == nullptr) { |
| 1426 | r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; |
| 1427 | return; |
| 1428 | } |
| 1429 | |
| 1430 | #endif // DEBUG_ENABLED |
| 1431 | r_ret = _get_obj().obj->callp(p_method, p_args, p_argcount, r_error); |
| 1432 | |
| 1433 | } else { |
| 1434 | r_error.error = Callable::CallError::CALL_OK; |
| 1435 | |
| 1436 | const VariantBuiltInMethodInfo *imf = builtin_method_info[type].getptr(p_method); |
| 1437 | |
| 1438 | if (!imf) { |
| 1439 | r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; |
| 1440 | return; |
| 1441 | } |
| 1442 | |
| 1443 | imf->call(this, p_args, p_argcount, r_ret, imf->default_arguments, r_error); |
| 1444 | } |
| 1445 | } |
| 1446 | |
| 1447 | void Variant::call_const(const StringName &p_method, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) { |
| 1448 | if (type == Variant::OBJECT) { |
| 1449 | //call object |
| 1450 | Object *obj = _get_obj().obj; |
| 1451 | if (!obj) { |
| 1452 | r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; |
| 1453 | return; |
| 1454 | } |
| 1455 | #ifdef DEBUG_ENABLED |
| 1456 | if (EngineDebugger::is_active() && !_get_obj().id.is_ref_counted() && ObjectDB::get_instance(_get_obj().id) == nullptr) { |
| 1457 | r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; |
| 1458 | return; |
| 1459 | } |
| 1460 | |
| 1461 | #endif // DEBUG_ENABLED |
| 1462 | r_ret = _get_obj().obj->call_const(p_method, p_args, p_argcount, r_error); |
| 1463 | |
| 1464 | //else if (type==Variant::METHOD) { |
| 1465 | } else { |
| 1466 | r_error.error = Callable::CallError::CALL_OK; |
| 1467 | |
| 1468 | const VariantBuiltInMethodInfo *imf = builtin_method_info[type].getptr(p_method); |
| 1469 | |
| 1470 | if (!imf) { |
| 1471 | r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; |
| 1472 | return; |
| 1473 | } |
| 1474 | |
| 1475 | if (!imf->is_const) { |
| 1476 | r_error.error = Callable::CallError::CALL_ERROR_METHOD_NOT_CONST; |
| 1477 | return; |
| 1478 | } |
| 1479 | |
| 1480 | imf->call(this, p_args, p_argcount, r_ret, imf->default_arguments, r_error); |
| 1481 | } |
| 1482 | } |
| 1483 | |
| 1484 | void Variant::call_static(Variant::Type p_type, const StringName &p_method, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) { |
| 1485 | r_error.error = Callable::CallError::CALL_OK; |
| 1486 | |
| 1487 | const VariantBuiltInMethodInfo *imf = builtin_method_info[p_type].getptr(p_method); |
| 1488 | |
| 1489 | if (!imf) { |
| 1490 | r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; |
| 1491 | return; |
| 1492 | } |
| 1493 | |
| 1494 | if (!imf->is_static) { |
| 1495 | r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; |
| 1496 | return; |
| 1497 | } |
| 1498 | |
| 1499 | imf->call(nullptr, p_args, p_argcount, r_ret, imf->default_arguments, r_error); |
| 1500 | } |
| 1501 | |
| 1502 | bool Variant::has_method(const StringName &p_method) const { |
| 1503 | if (type == OBJECT) { |
| 1504 | Object *obj = get_validated_object(); |
| 1505 | if (!obj) { |
| 1506 | return false; |
| 1507 | } |
| 1508 | |
| 1509 | return obj->has_method(p_method); |
| 1510 | } |
| 1511 | |
| 1512 | return builtin_method_info[type].has(p_method); |
| 1513 | } |
| 1514 | |
| 1515 | bool Variant::has_builtin_method(Variant::Type p_type, const StringName &p_method) { |
| 1516 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false); |
| 1517 | return builtin_method_info[p_type].has(p_method); |
| 1518 | } |
| 1519 | |
| 1520 | Variant::ValidatedBuiltInMethod Variant::get_validated_builtin_method(Variant::Type p_type, const StringName &p_method) { |
| 1521 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, nullptr); |
| 1522 | const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].getptr(p_method); |
| 1523 | ERR_FAIL_NULL_V(method, nullptr); |
| 1524 | return method->validated_call; |
| 1525 | } |
| 1526 | |
| 1527 | Variant::PTRBuiltInMethod Variant::get_ptr_builtin_method(Variant::Type p_type, const StringName &p_method) { |
| 1528 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, nullptr); |
| 1529 | const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].getptr(p_method); |
| 1530 | ERR_FAIL_NULL_V(method, nullptr); |
| 1531 | return method->ptrcall; |
| 1532 | } |
| 1533 | |
| 1534 | Variant::PTRBuiltInMethod Variant::get_ptr_builtin_method_with_compatibility(Variant::Type p_type, const StringName &p_method, uint32_t p_hash) { |
| 1535 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, nullptr); |
| 1536 | |
| 1537 | const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].getptr(p_method); |
| 1538 | if (method && method->get_hash() == p_hash) { |
| 1539 | return method->ptrcall; |
| 1540 | } |
| 1541 | |
| 1542 | #ifndef DISABLE_DEPRECATED |
| 1543 | const LocalVector<VariantBuiltInMethodInfo> *compat_methods = builtin_compat_method_info[p_type].getptr(p_method); |
| 1544 | if (compat_methods) { |
| 1545 | for (const VariantBuiltInMethodInfo &imi : *compat_methods) { |
| 1546 | if (imi.get_hash() == p_hash) { |
| 1547 | return imi.ptrcall; |
| 1548 | } |
| 1549 | } |
| 1550 | } |
| 1551 | #endif |
| 1552 | |
| 1553 | return nullptr; |
| 1554 | } |
| 1555 | |
| 1556 | MethodInfo Variant::get_builtin_method_info(Variant::Type p_type, const StringName &p_method) { |
| 1557 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, MethodInfo()); |
| 1558 | const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].getptr(p_method); |
| 1559 | ERR_FAIL_NULL_V(method, MethodInfo()); |
| 1560 | return method->get_method_info(p_method); |
| 1561 | } |
| 1562 | |
| 1563 | int Variant::get_builtin_method_argument_count(Variant::Type p_type, const StringName &p_method) { |
| 1564 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, 0); |
| 1565 | const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].getptr(p_method); |
| 1566 | ERR_FAIL_NULL_V(method, 0); |
| 1567 | return method->argument_count; |
| 1568 | } |
| 1569 | |
| 1570 | Variant::Type Variant::get_builtin_method_argument_type(Variant::Type p_type, const StringName &p_method, int p_argument) { |
| 1571 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, Variant::NIL); |
| 1572 | const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].getptr(p_method); |
| 1573 | ERR_FAIL_NULL_V(method, Variant::NIL); |
| 1574 | ERR_FAIL_INDEX_V(p_argument, method->argument_count, Variant::NIL); |
| 1575 | return method->get_argument_type(p_argument); |
| 1576 | } |
| 1577 | |
| 1578 | String Variant::get_builtin_method_argument_name(Variant::Type p_type, const StringName &p_method, int p_argument) { |
| 1579 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, String()); |
| 1580 | const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].getptr(p_method); |
| 1581 | ERR_FAIL_NULL_V(method, String()); |
| 1582 | #ifdef DEBUG_ENABLED |
| 1583 | ERR_FAIL_INDEX_V(p_argument, method->argument_count, String()); |
| 1584 | return method->argument_names[p_argument]; |
| 1585 | #else |
| 1586 | return "arg" + itos(p_argument + 1); |
| 1587 | #endif // DEBUG_ENABLED |
| 1588 | } |
| 1589 | |
| 1590 | Vector<Variant> Variant::get_builtin_method_default_arguments(Variant::Type p_type, const StringName &p_method) { |
| 1591 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, Vector<Variant>()); |
| 1592 | const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].getptr(p_method); |
| 1593 | ERR_FAIL_NULL_V(method, Vector<Variant>()); |
| 1594 | return method->default_arguments; |
| 1595 | } |
| 1596 | |
| 1597 | bool Variant::has_builtin_method_return_value(Variant::Type p_type, const StringName &p_method) { |
| 1598 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false); |
| 1599 | const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].getptr(p_method); |
| 1600 | ERR_FAIL_NULL_V(method, false); |
| 1601 | return method->has_return_type; |
| 1602 | } |
| 1603 | |
| 1604 | void Variant::get_builtin_method_list(Variant::Type p_type, List<StringName> *p_list) { |
| 1605 | ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX); |
| 1606 | for (const StringName &E : builtin_method_names[p_type]) { |
| 1607 | p_list->push_back(E); |
| 1608 | } |
| 1609 | } |
| 1610 | |
| 1611 | int Variant::get_builtin_method_count(Variant::Type p_type) { |
| 1612 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, -1); |
| 1613 | return builtin_method_names[p_type].size(); |
| 1614 | } |
| 1615 | |
| 1616 | Variant::Type Variant::get_builtin_method_return_type(Variant::Type p_type, const StringName &p_method) { |
| 1617 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, Variant::NIL); |
| 1618 | const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].getptr(p_method); |
| 1619 | ERR_FAIL_NULL_V(method, Variant::NIL); |
| 1620 | return method->return_type; |
| 1621 | } |
| 1622 | |
| 1623 | bool Variant::is_builtin_method_const(Variant::Type p_type, const StringName &p_method) { |
| 1624 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false); |
| 1625 | const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].getptr(p_method); |
| 1626 | ERR_FAIL_NULL_V(method, false); |
| 1627 | return method->is_const; |
| 1628 | } |
| 1629 | |
| 1630 | bool Variant::is_builtin_method_static(Variant::Type p_type, const StringName &p_method) { |
| 1631 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false); |
| 1632 | const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].getptr(p_method); |
| 1633 | ERR_FAIL_NULL_V(method, false); |
| 1634 | return method->is_static; |
| 1635 | } |
| 1636 | |
| 1637 | bool Variant::is_builtin_method_vararg(Variant::Type p_type, const StringName &p_method) { |
| 1638 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false); |
| 1639 | const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].getptr(p_method); |
| 1640 | ERR_FAIL_NULL_V(method, false); |
| 1641 | return method->is_vararg; |
| 1642 | } |
| 1643 | |
| 1644 | uint32_t Variant::get_builtin_method_hash(Variant::Type p_type, const StringName &p_method) { |
| 1645 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, 0); |
| 1646 | const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].getptr(p_method); |
| 1647 | ERR_FAIL_NULL_V(method, 0); |
| 1648 | return method->get_hash(); |
| 1649 | } |
| 1650 | |
| 1651 | Vector<uint32_t> Variant::get_builtin_method_compatibility_hashes(Variant::Type p_type, const StringName &p_method) { |
| 1652 | Vector<uint32_t> method_hashes; |
| 1653 | #ifndef DISABLE_DEPRECATED |
| 1654 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, method_hashes); |
| 1655 | const LocalVector<VariantBuiltInMethodInfo> *compat_methods = builtin_compat_method_info[p_type].getptr(p_method); |
| 1656 | if (compat_methods) { |
| 1657 | for (const VariantBuiltInMethodInfo &imi : *compat_methods) { |
| 1658 | method_hashes.push_back(imi.get_hash()); |
| 1659 | } |
| 1660 | } |
| 1661 | #endif |
| 1662 | return method_hashes; |
| 1663 | } |
| 1664 | |
| 1665 | void Variant::get_method_list(List<MethodInfo> *p_list) const { |
| 1666 | if (type == OBJECT) { |
| 1667 | Object *obj = get_validated_object(); |
| 1668 | if (obj) { |
| 1669 | obj->get_method_list(p_list); |
| 1670 | } |
| 1671 | } else { |
| 1672 | for (const StringName &E : builtin_method_names[type]) { |
| 1673 | const VariantBuiltInMethodInfo *method = builtin_method_info[type].getptr(E); |
| 1674 | ERR_CONTINUE(!method); |
| 1675 | p_list->push_back(method->get_method_info(E)); |
| 1676 | } |
| 1677 | } |
| 1678 | } |
| 1679 | |
| 1680 | void Variant::get_constants_for_type(Variant::Type p_type, List<StringName> *p_constants) { |
| 1681 | ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX); |
| 1682 | |
| 1683 | const _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type]; |
| 1684 | |
| 1685 | #ifdef DEBUG_ENABLED |
| 1686 | for (const List<StringName>::Element *E = cd.value_ordered.front(); E; E = E->next()) { |
| 1687 | p_constants->push_back(E->get()); |
| 1688 | #else |
| 1689 | for (const KeyValue<StringName, int64_t> &E : cd.value) { |
| 1690 | p_constants->push_back(E.key); |
| 1691 | #endif // DEBUG_ENABLED |
| 1692 | } |
| 1693 | |
| 1694 | #ifdef DEBUG_ENABLED |
| 1695 | for (const List<StringName>::Element *E = cd.variant_value_ordered.front(); E; E = E->next()) { |
| 1696 | p_constants->push_back(E->get()); |
| 1697 | #else |
| 1698 | for (const KeyValue<StringName, Variant> &E : cd.variant_value) { |
| 1699 | p_constants->push_back(E.key); |
| 1700 | #endif // DEBUG_ENABLED |
| 1701 | } |
| 1702 | } |
| 1703 | |
| 1704 | int Variant::get_constants_count_for_type(Variant::Type p_type) { |
| 1705 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, -1); |
| 1706 | _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type]; |
| 1707 | |
| 1708 | return cd.value.size() + cd.variant_value.size(); |
| 1709 | } |
| 1710 | |
| 1711 | bool Variant::has_constant(Variant::Type p_type, const StringName &p_value) { |
| 1712 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false); |
| 1713 | _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type]; |
| 1714 | return cd.value.has(p_value) || cd.variant_value.has(p_value); |
| 1715 | } |
| 1716 | |
| 1717 | Variant Variant::get_constant_value(Variant::Type p_type, const StringName &p_value, bool *r_valid) { |
| 1718 | if (r_valid) { |
| 1719 | *r_valid = false; |
| 1720 | } |
| 1721 | |
| 1722 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, 0); |
| 1723 | _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type]; |
| 1724 | |
| 1725 | HashMap<StringName, int64_t>::Iterator E = cd.value.find(p_value); |
| 1726 | if (!E) { |
| 1727 | HashMap<StringName, Variant>::Iterator F = cd.variant_value.find(p_value); |
| 1728 | if (F) { |
| 1729 | if (r_valid) { |
| 1730 | *r_valid = true; |
| 1731 | } |
| 1732 | return F->value; |
| 1733 | } else { |
| 1734 | return -1; |
| 1735 | } |
| 1736 | } |
| 1737 | if (r_valid) { |
| 1738 | *r_valid = true; |
| 1739 | } |
| 1740 | |
| 1741 | return E->value; |
| 1742 | } |
| 1743 | |
| 1744 | void Variant::get_enums_for_type(Variant::Type p_type, List<StringName> *p_enums) { |
| 1745 | ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX); |
| 1746 | |
| 1747 | _VariantCall::EnumData &enum_data = _VariantCall::enum_data[p_type]; |
| 1748 | |
| 1749 | for (const KeyValue<StringName, HashMap<StringName, int>> &E : enum_data.value) { |
| 1750 | p_enums->push_back(E.key); |
| 1751 | } |
| 1752 | } |
| 1753 | |
| 1754 | void Variant::get_enumerations_for_enum(Variant::Type p_type, const StringName &p_enum_name, List<StringName> *p_enumerations) { |
| 1755 | ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX); |
| 1756 | |
| 1757 | _VariantCall::EnumData &enum_data = _VariantCall::enum_data[p_type]; |
| 1758 | |
| 1759 | for (const KeyValue<StringName, HashMap<StringName, int>> &E : enum_data.value) { |
| 1760 | for (const KeyValue<StringName, int> &V : E.value) { |
| 1761 | p_enumerations->push_back(V.key); |
| 1762 | } |
| 1763 | } |
| 1764 | } |
| 1765 | |
| 1766 | int Variant::get_enum_value(Variant::Type p_type, const StringName &p_enum_name, const StringName &p_enumeration, bool *r_valid) { |
| 1767 | if (r_valid) { |
| 1768 | *r_valid = false; |
| 1769 | } |
| 1770 | |
| 1771 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, -1); |
| 1772 | |
| 1773 | _VariantCall::EnumData &enum_data = _VariantCall::enum_data[p_type]; |
| 1774 | |
| 1775 | HashMap<StringName, HashMap<StringName, int>>::Iterator E = enum_data.value.find(p_enum_name); |
| 1776 | if (!E) { |
| 1777 | return -1; |
| 1778 | } |
| 1779 | |
| 1780 | HashMap<StringName, int>::Iterator V = E->value.find(p_enumeration); |
| 1781 | if (!V) { |
| 1782 | return -1; |
| 1783 | } |
| 1784 | |
| 1785 | if (r_valid) { |
| 1786 | *r_valid = true; |
| 1787 | } |
| 1788 | |
| 1789 | return V->value; |
| 1790 | } |
| 1791 | |
| 1792 | bool Variant::has_enum(Variant::Type p_type, const StringName &p_enum_name) { |
| 1793 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false); |
| 1794 | |
| 1795 | _VariantCall::EnumData &enum_data = _VariantCall::enum_data[p_type]; |
| 1796 | |
| 1797 | return enum_data.value.has(p_enum_name); |
| 1798 | } |
| 1799 | |
| 1800 | StringName Variant::get_enum_for_enumeration(Variant::Type p_type, const StringName &p_enumeration) { |
| 1801 | ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, StringName()); |
| 1802 | |
| 1803 | _VariantCall::EnumData &enum_data = _VariantCall::enum_data[p_type]; |
| 1804 | |
| 1805 | const StringName *enum_name = enum_data.value_to_enum.getptr(p_enumeration); |
| 1806 | return (enum_name == nullptr) ? StringName() : *enum_name; |
| 1807 | } |
| 1808 | |
| 1809 | #ifdef DEBUG_ENABLED |
| 1810 | #define bind_method(m_type, m_method, m_arg_names, m_default_args) \ |
| 1811 | METHOD_CLASS(m_type, m_method, m_method, &m_type::m_method); \ |
| 1812 | register_builtin_method<Method_##m_type##_##m_method>(m_arg_names, m_default_args); |
| 1813 | #else |
| 1814 | #define bind_method(m_type, m_method, m_arg_names, m_default_args) \ |
| 1815 | METHOD_CLASS(m_type, m_method, m_method, &m_type ::m_method); \ |
| 1816 | register_builtin_method<Method_##m_type##_##m_method>(sarray(), m_default_args); |
| 1817 | #endif // DEBUG_ENABLED |
| 1818 | |
| 1819 | #ifdef DEBUG_ENABLED |
| 1820 | #define bind_compat_method(m_type, m_exposed_method, m_method, m_arg_names, m_default_args) \ |
| 1821 | METHOD_CLASS(m_type, m_exposed_method, m_method, &m_type::m_method); \ |
| 1822 | register_builtin_compat_method<Method_##m_type##_##m_method>(m_arg_names, m_default_args); |
| 1823 | #else |
| 1824 | #define bind_compat_method(m_type, m_exposed_method, m_method, m_arg_names, m_default_args) \ |
| 1825 | METHOD_CLASS(m_type, m_exposed_method, m_method, &m_type ::m_method); \ |
| 1826 | register_builtin_compat_method<Method_##m_type##_##m_method>(sarray(), m_default_args); |
| 1827 | #endif // DEBUG_ENABLED |
| 1828 | |
| 1829 | #ifdef DEBUG_ENABLED |
| 1830 | #define bind_convert_method(m_type_from, m_type_to, m_method, m_arg_names, m_default_args) \ |
| 1831 | CONVERT_METHOD_CLASS(m_type_from, m_method, m_method, &m_type_to::m_method); \ |
| 1832 | register_builtin_method<Method_##m_type_from##_##m_method>(m_arg_names, m_default_args); |
| 1833 | #else |
| 1834 | #define bind_convert_method(m_type_from, m_type_to, m_method, m_arg_names, m_default_args) \ |
| 1835 | CONVERT_METHOD_CLASS(m_type_from, m_method, m_method, &m_type_to ::m_method); \ |
| 1836 | register_builtin_method<Method_##m_type_from##_##m_method>(sarray(), m_default_args); |
| 1837 | #endif // DEBUG_ENABLED |
| 1838 | |
| 1839 | #ifdef DEBUG_ENABLED |
| 1840 | #define bind_convert_compat_method(m_type_from, m_type_to, m_exposed_method, m_method, m_arg_names, m_default_args) \ |
| 1841 | CONVERT_METHOD_CLASS(m_type_from, m_exposed_method, m_method, &m_type_to::m_method); \ |
| 1842 | register_builtin_compat_method<Method_##m_type_from##_##m_method>(m_arg_names, m_default_args); |
| 1843 | #else |
| 1844 | #define bind_convert_compat_method(m_type_from, m_type_to, m_exposed_method, m_method, m_arg_names, m_default_args) \ |
| 1845 | CONVERT_METHOD_CLASS(m_type_from, m_exposed_method, m_method, &m_type_to ::m_method); \ |
| 1846 | register_builtin_compat_method<Method_##m_type_from##_##m_method>(sarray(), m_default_args); |
| 1847 | #endif // DEBUG_ENABLED |
| 1848 | |
| 1849 | #ifdef DEBUG_ENABLED |
| 1850 | #define bind_static_method(m_type, m_method, m_arg_names, m_default_args) \ |
| 1851 | STATIC_METHOD_CLASS(m_type, m_method, m_method, m_type::m_method); \ |
| 1852 | register_builtin_method<Method_##m_type##_##m_method>(m_arg_names, m_default_args); |
| 1853 | #else |
| 1854 | #define bind_static_method(m_type, m_method, m_arg_names, m_default_args) \ |
| 1855 | STATIC_METHOD_CLASS(m_type, m_method, m_method, m_type ::m_method); \ |
| 1856 | register_builtin_method<Method_##m_type##_##m_method>(sarray(), m_default_args); |
| 1857 | #endif // DEBUG_ENABLED |
| 1858 | |
| 1859 | #ifdef DEBUG_ENABLED |
| 1860 | #define bind_static_compat_method(m_type, m_exposed_method, m_method, m_arg_names, m_default_args) \ |
| 1861 | STATIC_METHOD_CLASS(m_type, m_exposed_method, m_method, m_type::m_method); \ |
| 1862 | register_builtin_compat_method<Method_##m_type##_##m_method>(m_arg_names, m_default_args); |
| 1863 | #else |
| 1864 | #define bind_static_compat_method(m_type, m_exposed_method, m_method, m_arg_names, m_default_args) \ |
| 1865 | STATIC_METHOD_CLASS(m_type, m_exposed_method, m_method, m_type ::m_method); \ |
| 1866 | register_builtin_compat_method<Method_##m_type##_##m_method>(sarray(), m_default_args); |
| 1867 | #endif // DEBUG_ENABLED |
| 1868 | |
| 1869 | #ifdef DEBUG_ENABLED |
| 1870 | #define bind_static_methodv(m_type, m_name, m_method, m_arg_names, m_default_args) \ |
| 1871 | STATIC_METHOD_CLASS(m_type, m_name, m_name, m_method); \ |
| 1872 | register_builtin_method<Method_##m_type##_##m_name>(m_arg_names, m_default_args); |
| 1873 | #else |
| 1874 | #define bind_static_methodv(m_type, m_name, m_method, m_arg_names, m_default_args) \ |
| 1875 | STATIC_METHOD_CLASS(m_type, m_name, m_name, m_method); \ |
| 1876 | register_builtin_method<Method_##m_type##_##m_name>(sarray(), m_default_args); |
| 1877 | #endif |
| 1878 | |
| 1879 | #ifdef DEBUG_ENABLED |
| 1880 | #define bind_static_compat_methodv(m_type, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ |
| 1881 | STATIC_METHOD_CLASS(m_type, m_exposed_name, m_name, m_method); \ |
| 1882 | register_builtin_compat_method<Method_##m_type##_##m_name>(m_arg_names, m_default_args); |
| 1883 | #else |
| 1884 | #define bind_static_compat_methodv(m_type, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ |
| 1885 | STATIC_METHOD_CLASS(m_type, m_exposed_name, m_name, m_method); \ |
| 1886 | register_builtin_compat_method<Method_##m_type##_##m_name>(sarray(), m_default_args); |
| 1887 | #endif |
| 1888 | |
| 1889 | #ifdef DEBUG_ENABLED |
| 1890 | #define bind_methodv(m_type, m_name, m_method, m_arg_names, m_default_args) \ |
| 1891 | METHOD_CLASS(m_type, m_name, m_name, m_method); \ |
| 1892 | register_builtin_method<Method_##m_type##_##m_name>(m_arg_names, m_default_args); |
| 1893 | #else |
| 1894 | #define bind_methodv(m_type, m_name, m_method, m_arg_names, m_default_args) \ |
| 1895 | METHOD_CLASS(m_type, m_name, m_name, m_method); \ |
| 1896 | register_builtin_method<Method_##m_type##_##m_name>(sarray(), m_default_args); |
| 1897 | #endif // DEBUG_ENABLED |
| 1898 | |
| 1899 | #ifdef DEBUG_ENABLED |
| 1900 | #define bind_compat_methodv(m_type, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ |
| 1901 | METHOD_CLASS(m_type, m_exposed_name, m_name, m_method); \ |
| 1902 | register_builtin_compat_method<Method_##m_type##_##m_name>(m_arg_names, m_default_args); |
| 1903 | #else |
| 1904 | #define bind_compat_methodv(m_type, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ |
| 1905 | METHOD_CLASS(m_type, m_exposed_name, m_name, m_method); \ |
| 1906 | register_builtin_compat_method<Method_##m_type##_##m_name>(sarray(), m_default_args); |
| 1907 | #endif // DEBUG_ENABLED |
| 1908 | |
| 1909 | #ifdef DEBUG_ENABLED |
| 1910 | #define bind_convert_methodv(m_type_from, m_type_to, m_name, m_method, m_arg_names, m_default_args) \ |
| 1911 | CONVERT_METHOD_CLASS(m_type_from, m_name, m_name, m_method); \ |
| 1912 | register_builtin_method<Method_##m_type_from##_##m_name>(m_arg_names, m_default_args); |
| 1913 | #else |
| 1914 | #define bind_convert_methodv(m_type_from, m_type_to, m_name, m_method, m_arg_names, m_default_args) \ |
| 1915 | CONVERT_METHOD_CLASS(m_type_from, m_name, m_name, m_method); \ |
| 1916 | register_builtin_method<Method_##m_type_from##_##m_name>(sarray(), m_default_args); |
| 1917 | #endif // DEBUG_ENABLED |
| 1918 | |
| 1919 | #ifdef DEBUG_ENABLED |
| 1920 | #define bind_convert_compat_methodv(m_type_from, m_type_to, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ |
| 1921 | CONVERT_METHOD_CLASS(m_type_from, m_exposed_name, m_name, m_method); \ |
| 1922 | register_builtin_compat_method<Method_##m_type_from##_##m_name>(m_arg_names, m_default_args); |
| 1923 | #else |
| 1924 | #define bind_convert_compat_methodv(m_type_from, m_type_to, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ |
| 1925 | CONVERT_METHOD_CLASS(m_type_from, m_exposed_name, m_name, m_method); \ |
| 1926 | register_builtin_compat_method<Method_##m_type_from##_##m_name>(sarray(), m_default_args); |
| 1927 | #endif // DEBUG_ENABLED |
| 1928 | |
| 1929 | #ifdef DEBUG_ENABLED |
| 1930 | #define bind_function(m_type, m_name, m_method, m_arg_names, m_default_args) \ |
| 1931 | FUNCTION_CLASS(m_type, m_name, m_name, m_method, true); \ |
| 1932 | register_builtin_method<Method_##m_type##_##m_name>(m_arg_names, m_default_args); |
| 1933 | #else |
| 1934 | #define bind_function(m_type, m_name, m_method, m_arg_names, m_default_args) \ |
| 1935 | FUNCTION_CLASS(m_type, m_name, m_name, m_method, true); \ |
| 1936 | register_builtin_method<Method_##m_type##_##m_name>(sarray(), m_default_args); |
| 1937 | #endif // DEBUG_ENABLED |
| 1938 | |
| 1939 | #ifdef DEBUG_ENABLED |
| 1940 | #define bind_compat_function(m_type, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ |
| 1941 | FUNCTION_CLASS(m_type, m_exposed_name, m_name, m_method, true); \ |
| 1942 | register_builtin_compat_method<Method_##m_type##_##m_name>(m_arg_names, m_default_args); |
| 1943 | #else |
| 1944 | #define bind_compat_function(m_type, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ |
| 1945 | FUNCTION_CLASS(m_type, m_exposed_name, m_name, m_method, true); \ |
| 1946 | register_builtin_compat_method<Method_##m_type##_##m_name>(sarray(), m_default_args); |
| 1947 | #endif // DEBUG_ENABLED |
| 1948 | |
| 1949 | #ifdef DEBUG_ENABLED |
| 1950 | #define bind_functionnc(m_type, m_name, m_method, m_arg_names, m_default_args) \ |
| 1951 | FUNCTION_CLASS(m_type, m_name, m_name, m_method, false); \ |
| 1952 | register_builtin_method<Method_##m_type##_##m_name>(m_arg_names, m_default_args); |
| 1953 | #else |
| 1954 | #define bind_functionnc(m_type, m_name, m_method, m_arg_names, m_default_args) \ |
| 1955 | FUNCTION_CLASS(m_type, m_name, m_name, m_method, false); \ |
| 1956 | register_builtin_method<Method_##m_type##_##m_name>(sarray(), m_default_args); |
| 1957 | #endif // DEBUG_ENABLED |
| 1958 | |
| 1959 | #ifdef DEBUG_ENABLED |
| 1960 | #define bind_compat_functionnc(m_type, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ |
| 1961 | FUNCTION_CLASS(m_type, m_exposed_name, m_name, m_method, false); \ |
| 1962 | register_builtin_compat_method<Method_##m_type##_##m_name>(m_arg_names, m_default_args); |
| 1963 | #else |
| 1964 | #define bind_compat_functionnc(m_type, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ |
| 1965 | FUNCTION_CLASS(m_type, m_exposed_name, m_name, m_method, false); \ |
| 1966 | register_builtin_compat_method<Method_##m_type##_##m_name>(sarray(), m_default_args); |
| 1967 | #endif // DEBUG_ENABLED |
| 1968 | |
| 1969 | #define bind_string_method(m_method, m_arg_names, m_default_args) \ |
| 1970 | bind_method(String, m_method, m_arg_names, m_default_args); \ |
| 1971 | bind_convert_method(StringName, String, m_method, m_arg_names, m_default_args); |
| 1972 | |
| 1973 | #define bind_string_methodv(m_name, m_method, m_arg_names, m_default_args) \ |
| 1974 | bind_methodv(String, m_name, m_method, m_arg_names, m_default_args); \ |
| 1975 | bind_convert_methodv(StringName, String, m_name, m_method, m_arg_names, m_default_args); |
| 1976 | |
| 1977 | #define bind_string_compat_method(m_exposed_name, m_method, m_arg_names, m_default_args) \ |
| 1978 | bind_compat_method(String, m_exposed_name, m_method, m_arg_names, m_default_args); \ |
| 1979 | bind_convert_compat_method(StringName, String, m_exposed_name, m_method, m_arg_names, m_default_args); |
| 1980 | |
| 1981 | #define bind_string_compat_methodv(m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ |
| 1982 | bind_compat_methodv(String, m_exposed_name, m_name, m_method, m_arg_names, m_default_args); \ |
| 1983 | bind_convert_compat_methodv(StringName, String, m_exposed_name, m_name, m_method, m_arg_names, m_default_args); |
| 1984 | |
| 1985 | #define bind_custom(m_type, m_name, m_method, m_has_return, m_ret_type) \ |
| 1986 | VARARG_CLASS(m_type, m_name, m_name, m_method, m_has_return, m_ret_type) \ |
| 1987 | register_builtin_method<Method_##m_type##_##m_name>(sarray(), Vector<Variant>()); |
| 1988 | |
| 1989 | #define bind_custom1(m_type, m_name, m_method, m_arg_type, m_arg_name) \ |
| 1990 | VARARG_CLASS1(m_type, m_name, m_name, m_method, m_arg_type) \ |
| 1991 | register_builtin_method<Method_##m_type##_##m_name>(sarray(m_arg_name), Vector<Variant>()); |
| 1992 | |
| 1993 | #define bind_compat_custom(m_type, m_exposed_name, m_name, m_method, m_has_return, m_ret_type) \ |
| 1994 | VARARG_CLASS(m_type, m_exposed_name, m_name, m_method, m_has_return, m_ret_type) \ |
| 1995 | register_builtin_compat_method<Method_##m_type##_##m_name>(sarray(), Vector<Variant>()); |
| 1996 | |
| 1997 | #define bind_compat_custom1(m_type, m_exposed_name, m_name, m_method, m_arg_type, m_arg_name) \ |
| 1998 | VARARG_CLASS1(m_type, m_exposed_name, m_name, m_method, m_arg_type) \ |
| 1999 | register_builtin_compat_method<Method_##m_type##_##m_name>(sarray(m_arg_name), Vector<Variant>()); |
| 2000 | |
| 2001 | static void _register_variant_builtin_methods_string() { |
| 2002 | _VariantCall::constant_data = memnew_arr(_VariantCall::ConstantData, Variant::VARIANT_MAX); |
| 2003 | _VariantCall::enum_data = memnew_arr(_VariantCall::EnumData, Variant::VARIANT_MAX); |
| 2004 | builtin_method_info = memnew_arr(BuiltinMethodMap, Variant::VARIANT_MAX); |
| 2005 | builtin_method_names = memnew_arr(List<StringName>, Variant::VARIANT_MAX); |
| 2006 | #ifndef DISABLE_DEPRECATED |
| 2007 | builtin_compat_method_info = memnew_arr(BuiltinCompatMethodMap, Variant::VARIANT_MAX); |
| 2008 | #endif |
| 2009 | |
| 2010 | /* String */ |
| 2011 | |
| 2012 | bind_string_method(casecmp_to, sarray("to"), varray()); |
| 2013 | bind_string_method(nocasecmp_to, sarray("to"), varray()); |
| 2014 | bind_string_method(naturalcasecmp_to, sarray("to"), varray()); |
| 2015 | bind_string_method(naturalnocasecmp_to, sarray("to"), varray()); |
| 2016 | bind_string_method(filecasecmp_to, sarray("to"), varray()); |
| 2017 | bind_string_method(filenocasecmp_to, sarray("to"), varray()); |
| 2018 | bind_string_method(length, sarray(), varray()); |
| 2019 | bind_string_method(substr, sarray("from", "len"), varray(-1)); |
| 2020 | bind_string_methodv(get_slice, static_cast<String (String::*)(const String &, int) const>(&String::get_slice), sarray("delimiter", "slice"), varray()); |
| 2021 | bind_string_method(get_slicec, sarray("delimiter", "slice"), varray()); |
| 2022 | bind_string_methodv(get_slice_count, static_cast<int (String::*)(const String &) const>(&String::get_slice_count), sarray("delimiter"), varray()); |
| 2023 | bind_string_methodv(find, static_cast<int (String::*)(const String &, int) const>(&String::find), sarray("what", "from"), varray(0)); |
| 2024 | bind_string_methodv(findn, static_cast<int (String::*)(const String &, int) const>(&String::findn), sarray("what", "from"), varray(0)); |
| 2025 | bind_string_methodv(count, static_cast<int (String::*)(const String &, int, int) const>(&String::count), sarray("what", "from", "to"), varray(0, 0)); |
| 2026 | bind_string_methodv(countn, static_cast<int (String::*)(const String &, int, int) const>(&String::countn), sarray("what", "from", "to"), varray(0, 0)); |
| 2027 | bind_string_methodv(rfind, static_cast<int (String::*)(const String &, int) const>(&String::rfind), sarray("what", "from"), varray(-1)); |
| 2028 | bind_string_methodv(rfindn, static_cast<int (String::*)(const String &, int) const>(&String::rfindn), sarray("what", "from"), varray(-1)); |
| 2029 | bind_string_method(match, sarray("expr"), varray()); |
| 2030 | bind_string_method(matchn, sarray("expr"), varray()); |
| 2031 | bind_string_methodv(begins_with, static_cast<bool (String::*)(const String &) const>(&String::begins_with), sarray("text"), varray()); |
| 2032 | bind_string_methodv(ends_with, static_cast<bool (String::*)(const String &) const>(&String::ends_with), sarray("text"), varray()); |
| 2033 | bind_string_method(is_subsequence_of, sarray("text"), varray()); |
| 2034 | bind_string_method(is_subsequence_ofn, sarray("text"), varray()); |
| 2035 | bind_string_method(bigrams, sarray(), varray()); |
| 2036 | bind_string_method(similarity, sarray("text"), varray()); |
| 2037 | |
| 2038 | bind_string_method(format, sarray("values", "placeholder"), varray("{_}")); |
| 2039 | bind_string_methodv(replace, static_cast<String (String::*)(const String &, const String &) const>(&String::replace), sarray("what", "forwhat"), varray()); |
| 2040 | bind_string_methodv(replacen, static_cast<String (String::*)(const String &, const String &) const>(&String::replacen), sarray("what", "forwhat"), varray()); |
| 2041 | bind_string_method(replace_char, sarray("key", "with"), varray()); |
| 2042 | bind_string_methodv(replace_chars, static_cast<String (String::*)(const String &, char32_t) const>(&String::replace_chars), sarray("keys", "with"), varray()); |
| 2043 | bind_string_method(remove_char, sarray("what"), varray()); |
| 2044 | bind_string_methodv(remove_chars, static_cast<String (String::*)(const String &) const>(&String::remove_chars), sarray("chars"), varray()); |
| 2045 | bind_string_method(repeat, sarray("count"), varray()); |
| 2046 | bind_string_method(reverse, sarray(), varray()); |
| 2047 | bind_string_method(insert, sarray("position", "what"), varray()); |
| 2048 | bind_string_method(erase, sarray("position", "chars"), varray(1)); |
| 2049 | bind_string_method(capitalize, sarray(), varray()); |
| 2050 | bind_string_method(to_camel_case, sarray(), varray()); |
| 2051 | bind_string_method(to_pascal_case, sarray(), varray()); |
| 2052 | bind_string_method(to_snake_case, sarray(), varray()); |
| 2053 | bind_string_method(to_kebab_case, sarray(), varray()); |
| 2054 | bind_string_methodv(split, static_cast<Vector<String> (String::*)(const String &, bool, int) const>(&String::split), sarray("delimiter", "allow_empty", "maxsplit"), varray("", true, 0)); |
| 2055 | bind_string_methodv(rsplit, static_cast<Vector<String> (String::*)(const String &, bool, int) const>(&String::rsplit), sarray("delimiter", "allow_empty", "maxsplit"), varray("", true, 0)); |
| 2056 | bind_string_method(split_floats, sarray("delimiter", "allow_empty"), varray(true)); |
| 2057 | bind_string_method(join, sarray("parts"), varray()); |
| 2058 | |
| 2059 | bind_string_method(to_upper, sarray(), varray()); |
| 2060 | bind_string_method(to_lower, sarray(), varray()); |
| 2061 | |
| 2062 | bind_string_method(left, sarray("length"), varray()); |
| 2063 | bind_string_method(right, sarray("length"), varray()); |
| 2064 | |
| 2065 | bind_string_method(strip_edges, sarray("left", "right"), varray(true, true)); |
| 2066 | bind_string_method(strip_escapes, sarray(), varray()); |
| 2067 | bind_string_method(lstrip, sarray("chars"), varray()); |
| 2068 | bind_string_method(rstrip, sarray("chars"), varray()); |
| 2069 | bind_string_method(get_extension, sarray(), varray()); |
| 2070 | bind_string_method(get_basename, sarray(), varray()); |
| 2071 | bind_string_method(path_join, sarray("path"), varray()); |
| 2072 | bind_string_method(unicode_at, sarray("at"), varray()); |
| 2073 | bind_string_method(indent, sarray("prefix"), varray()); |
| 2074 | bind_string_method(dedent, sarray(), varray()); |
| 2075 | bind_method(String, hash, sarray(), varray()); |
| 2076 | bind_string_method(md5_text, sarray(), varray()); |
| 2077 | bind_string_method(sha1_text, sarray(), varray()); |
| 2078 | bind_string_method(sha256_text, sarray(), varray()); |
| 2079 | bind_string_method(md5_buffer, sarray(), varray()); |
| 2080 | bind_string_method(sha1_buffer, sarray(), varray()); |
| 2081 | bind_string_method(sha256_buffer, sarray(), varray()); |
| 2082 | bind_string_method(is_empty, sarray(), varray()); |
| 2083 | bind_string_methodv(contains, static_cast<bool (String::*)(const String &) const>(&String::contains), sarray("what"), varray()); |
| 2084 | bind_string_methodv(containsn, static_cast<bool (String::*)(const String &) const>(&String::containsn), sarray("what"), varray()); |
| 2085 | |
| 2086 | bind_string_method(is_absolute_path, sarray(), varray()); |
| 2087 | bind_string_method(is_relative_path, sarray(), varray()); |
| 2088 | bind_string_method(simplify_path, sarray(), varray()); |
| 2089 | bind_string_method(get_base_dir, sarray(), varray()); |
| 2090 | bind_string_method(get_file, sarray(), varray()); |
| 2091 | bind_string_method(xml_escape, sarray("escape_quotes"), varray(false)); |
| 2092 | bind_string_method(xml_unescape, sarray(), varray()); |
| 2093 | bind_string_method(uri_encode, sarray(), varray()); |
| 2094 | bind_string_method(uri_decode, sarray(), varray()); |
| 2095 | bind_string_method(uri_file_decode, sarray(), varray()); |
| 2096 | bind_string_method(c_escape, sarray(), varray()); |
| 2097 | bind_string_method(c_unescape, sarray(), varray()); |
| 2098 | bind_string_method(json_escape, sarray(), varray()); |
| 2099 | |
| 2100 | bind_string_method(validate_node_name, sarray(), varray()); |
| 2101 | bind_string_method(validate_filename, sarray(), varray()); |
| 2102 | |
| 2103 | bind_string_method(is_valid_ascii_identifier, sarray(), varray()); |
| 2104 | bind_string_method(is_valid_unicode_identifier, sarray(), varray()); |
| 2105 | bind_string_method(is_valid_identifier, sarray(), varray()); |
| 2106 | bind_string_method(is_valid_int, sarray(), varray()); |
| 2107 | bind_string_method(is_valid_float, sarray(), varray()); |
| 2108 | bind_string_method(is_valid_hex_number, sarray("with_prefix"), varray(false)); |
| 2109 | bind_string_method(is_valid_html_color, sarray(), varray()); |
| 2110 | bind_string_method(is_valid_ip_address, sarray(), varray()); |
| 2111 | bind_string_method(is_valid_filename, sarray(), varray()); |
| 2112 | |
| 2113 | bind_string_method(to_int, sarray(), varray()); |
| 2114 | bind_string_method(to_float, sarray(), varray()); |
| 2115 | bind_string_method(hex_to_int, sarray(), varray()); |
| 2116 | bind_string_method(bin_to_int, sarray(), varray()); |
| 2117 | |
| 2118 | bind_string_method(lpad, sarray("min_length", "character"), varray(" ")); |
| 2119 | bind_string_method(rpad, sarray("min_length", "character"), varray(" ")); |
| 2120 | bind_string_method(pad_decimals, sarray("digits"), varray()); |
| 2121 | bind_string_method(pad_zeros, sarray("digits"), varray()); |
| 2122 | bind_string_methodv(trim_prefix, static_cast<String (String::*)(const String &) const>(&String::trim_prefix), sarray("prefix"), varray()); |
| 2123 | bind_string_methodv(trim_suffix, static_cast<String (String::*)(const String &) const>(&String::trim_suffix), sarray("suffix"), varray()); |
| 2124 | |
| 2125 | bind_string_method(to_ascii_buffer, sarray(), varray()); |
| 2126 | bind_string_method(to_utf8_buffer, sarray(), varray()); |
| 2127 | bind_string_method(to_utf16_buffer, sarray(), varray()); |
| 2128 | bind_string_method(to_utf32_buffer, sarray(), varray()); |
| 2129 | bind_string_method(to_wchar_buffer, sarray(), varray()); |
| 2130 | bind_string_method(to_multibyte_char_buffer, sarray("encoding"), varray(String())); |
| 2131 | bind_string_method(hex_decode, sarray(), varray()); |
| 2132 | |
| 2133 | bind_static_methodv(String, num_scientific, static_cast<String (*)(double)>(&String::num_scientific), sarray("number"), varray()); |
| 2134 | bind_static_method(String, num, sarray("number", "decimals"), varray(-1)); |
| 2135 | bind_static_method(String, num_int64, sarray("number", "base", "capitalize_hex"), varray(10, false)); |
| 2136 | bind_static_method(String, num_uint64, sarray("number", "base", "capitalize_hex"), varray(10, false)); |
| 2137 | bind_static_method(String, chr, sarray("code"), varray()); |
| 2138 | bind_static_method(String, humanize_size, sarray("size"), varray()); |
| 2139 | |
| 2140 | /* StringName */ |
| 2141 | |
| 2142 | bind_method(StringName, hash, sarray(), varray()); |
| 2143 | } |
| 2144 | |
| 2145 | static void _register_variant_builtin_methods_math() { |
| 2146 | /* Vector2 */ |
| 2147 | |
| 2148 | bind_method(Vector2, angle, sarray(), varray()); |
| 2149 | bind_method(Vector2, angle_to, sarray("to"), varray()); |
| 2150 | bind_method(Vector2, angle_to_point, sarray("to"), varray()); |
| 2151 | bind_method(Vector2, direction_to, sarray("to"), varray()); |
| 2152 | bind_method(Vector2, distance_to, sarray("to"), varray()); |
| 2153 | bind_method(Vector2, distance_squared_to, sarray("to"), varray()); |
| 2154 | bind_method(Vector2, length, sarray(), varray()); |
| 2155 | bind_method(Vector2, length_squared, sarray(), varray()); |
| 2156 | bind_method(Vector2, limit_length, sarray("length"), varray(1.0)); |
| 2157 | bind_method(Vector2, normalized, sarray(), varray()); |
| 2158 | bind_method(Vector2, is_normalized, sarray(), varray()); |
| 2159 | bind_method(Vector2, is_equal_approx, sarray("to"), varray()); |
| 2160 | bind_method(Vector2, is_zero_approx, sarray(), varray()); |
| 2161 | bind_method(Vector2, is_finite, sarray(), varray()); |
| 2162 | bind_method(Vector2, posmod, sarray("mod"), varray()); |
| 2163 | bind_method(Vector2, posmodv, sarray("modv"), varray()); |
| 2164 | bind_method(Vector2, project, sarray("b"), varray()); |
| 2165 | bind_method(Vector2, lerp, sarray("to", "weight"), varray()); |
| 2166 | bind_method(Vector2, slerp, sarray("to", "weight"), varray()); |
| 2167 | bind_method(Vector2, cubic_interpolate, sarray("b", "pre_a", "post_b", "weight"), varray()); |
| 2168 | bind_method(Vector2, cubic_interpolate_in_time, sarray("b", "pre_a", "post_b", "weight", "b_t", "pre_a_t", "post_b_t"), varray()); |
| 2169 | bind_method(Vector2, bezier_interpolate, sarray("control_1", "control_2", "end", "t"), varray()); |
| 2170 | bind_method(Vector2, bezier_derivative, sarray("control_1", "control_2", "end", "t"), varray()); |
| 2171 | bind_method(Vector2, max_axis_index, sarray(), varray()); |
| 2172 | bind_method(Vector2, min_axis_index, sarray(), varray()); |
| 2173 | bind_method(Vector2, move_toward, sarray("to", "delta"), varray()); |
| 2174 | bind_method(Vector2, rotated, sarray("angle"), varray()); |
| 2175 | bind_method(Vector2, orthogonal, sarray(), varray()); |
| 2176 | bind_method(Vector2, floor, sarray(), varray()); |
| 2177 | bind_method(Vector2, ceil, sarray(), varray()); |
| 2178 | bind_method(Vector2, round, sarray(), varray()); |
| 2179 | bind_method(Vector2, aspect, sarray(), varray()); |
| 2180 | bind_method(Vector2, dot, sarray("with"), varray()); |
| 2181 | bind_method(Vector2, slide, sarray("n"), varray()); |
| 2182 | bind_method(Vector2, bounce, sarray("n"), varray()); |
| 2183 | bind_method(Vector2, reflect, sarray("line"), varray()); |
| 2184 | bind_method(Vector2, cross, sarray("with"), varray()); |
| 2185 | bind_method(Vector2, abs, sarray(), varray()); |
| 2186 | bind_method(Vector2, sign, sarray(), varray()); |
| 2187 | bind_method(Vector2, clamp, sarray("min", "max"), varray()); |
| 2188 | bind_method(Vector2, clampf, sarray("min", "max"), varray()); |
| 2189 | bind_method(Vector2, snapped, sarray("step"), varray()); |
| 2190 | bind_method(Vector2, snappedf, sarray("step"), varray()); |
| 2191 | bind_method(Vector2, min, sarray("with"), varray()); |
| 2192 | bind_method(Vector2, minf, sarray("with"), varray()); |
| 2193 | bind_method(Vector2, max, sarray("with"), varray()); |
| 2194 | bind_method(Vector2, maxf, sarray("with"), varray()); |
| 2195 | |
| 2196 | bind_static_method(Vector2, from_angle, sarray("angle"), varray()); |
| 2197 | |
| 2198 | /* Vector2i */ |
| 2199 | |
| 2200 | bind_method(Vector2i, aspect, sarray(), varray()); |
| 2201 | bind_method(Vector2i, max_axis_index, sarray(), varray()); |
| 2202 | bind_method(Vector2i, min_axis_index, sarray(), varray()); |
| 2203 | bind_method(Vector2i, distance_to, sarray("to"), varray()); |
| 2204 | bind_method(Vector2i, distance_squared_to, sarray("to"), varray()); |
| 2205 | bind_method(Vector2i, length, sarray(), varray()); |
| 2206 | bind_method(Vector2i, length_squared, sarray(), varray()); |
| 2207 | bind_method(Vector2i, sign, sarray(), varray()); |
| 2208 | bind_method(Vector2i, abs, sarray(), varray()); |
| 2209 | bind_method(Vector2i, clamp, sarray("min", "max"), varray()); |
| 2210 | bind_method(Vector2i, clampi, sarray("min", "max"), varray()); |
| 2211 | bind_method(Vector2i, snapped, sarray("step"), varray()); |
| 2212 | bind_method(Vector2i, snappedi, sarray("step"), varray()); |
| 2213 | bind_method(Vector2i, min, sarray("with"), varray()); |
| 2214 | bind_method(Vector2i, mini, sarray("with"), varray()); |
| 2215 | bind_method(Vector2i, max, sarray("with"), varray()); |
| 2216 | bind_method(Vector2i, maxi, sarray("with"), varray()); |
| 2217 | |
| 2218 | /* Rect2 */ |
| 2219 | |
| 2220 | bind_method(Rect2, get_center, sarray(), varray()); |
| 2221 | bind_method(Rect2, get_area, sarray(), varray()); |
| 2222 | bind_method(Rect2, has_area, sarray(), varray()); |
| 2223 | bind_method(Rect2, has_point, sarray("point"), varray()); |
| 2224 | bind_method(Rect2, is_equal_approx, sarray("rect"), varray()); |
| 2225 | bind_method(Rect2, is_finite, sarray(), varray()); |
| 2226 | bind_method(Rect2, intersects, sarray("b", "include_borders"), varray(false)); |
| 2227 | bind_method(Rect2, encloses, sarray("b"), varray()); |
| 2228 | bind_method(Rect2, intersection, sarray("b"), varray()); |
| 2229 | bind_method(Rect2, merge, sarray("b"), varray()); |
| 2230 | bind_method(Rect2, expand, sarray("to"), varray()); |
| 2231 | bind_method(Rect2, get_support, sarray("direction"), varray()); |
| 2232 | bind_method(Rect2, grow, sarray("amount"), varray()); |
| 2233 | bind_methodv(Rect2, grow_side, &Rect2::grow_side_bind, sarray("side", "amount"), varray()); |
| 2234 | bind_method(Rect2, grow_individual, sarray("left", "top", "right", "bottom"), varray()); |
| 2235 | bind_method(Rect2, abs, sarray(), varray()); |
| 2236 | |
| 2237 | /* Rect2i */ |
| 2238 | |
| 2239 | bind_method(Rect2i, get_center, sarray(), varray()); |
| 2240 | bind_method(Rect2i, get_area, sarray(), varray()); |
| 2241 | bind_method(Rect2i, has_area, sarray(), varray()); |
| 2242 | bind_method(Rect2i, has_point, sarray("point"), varray()); |
| 2243 | bind_method(Rect2i, intersects, sarray("b"), varray()); |
| 2244 | bind_method(Rect2i, encloses, sarray("b"), varray()); |
| 2245 | bind_method(Rect2i, intersection, sarray("b"), varray()); |
| 2246 | bind_method(Rect2i, merge, sarray("b"), varray()); |
| 2247 | bind_method(Rect2i, expand, sarray("to"), varray()); |
| 2248 | bind_method(Rect2i, grow, sarray("amount"), varray()); |
| 2249 | bind_methodv(Rect2i, grow_side, &Rect2i::grow_side_bind, sarray("side", "amount"), varray()); |
| 2250 | bind_method(Rect2i, grow_individual, sarray("left", "top", "right", "bottom"), varray()); |
| 2251 | bind_method(Rect2i, abs, sarray(), varray()); |
| 2252 | |
| 2253 | /* Vector3 */ |
| 2254 | |
| 2255 | bind_method(Vector3, min_axis_index, sarray(), varray()); |
| 2256 | bind_method(Vector3, max_axis_index, sarray(), varray()); |
| 2257 | bind_method(Vector3, angle_to, sarray("to"), varray()); |
| 2258 | bind_method(Vector3, signed_angle_to, sarray("to", "axis"), varray()); |
| 2259 | bind_method(Vector3, direction_to, sarray("to"), varray()); |
| 2260 | bind_method(Vector3, distance_to, sarray("to"), varray()); |
| 2261 | bind_method(Vector3, distance_squared_to, sarray("to"), varray()); |
| 2262 | bind_method(Vector3, length, sarray(), varray()); |
| 2263 | bind_method(Vector3, length_squared, sarray(), varray()); |
| 2264 | bind_method(Vector3, limit_length, sarray("length"), varray(1.0)); |
| 2265 | bind_method(Vector3, normalized, sarray(), varray()); |
| 2266 | bind_method(Vector3, is_normalized, sarray(), varray()); |
| 2267 | bind_method(Vector3, is_equal_approx, sarray("to"), varray()); |
| 2268 | bind_method(Vector3, is_zero_approx, sarray(), varray()); |
| 2269 | bind_method(Vector3, is_finite, sarray(), varray()); |
| 2270 | bind_method(Vector3, inverse, sarray(), varray()); |
| 2271 | bind_method(Vector3, clamp, sarray("min", "max"), varray()); |
| 2272 | bind_method(Vector3, clampf, sarray("min", "max"), varray()); |
| 2273 | bind_method(Vector3, snapped, sarray("step"), varray()); |
| 2274 | bind_method(Vector3, snappedf, sarray("step"), varray()); |
| 2275 | bind_method(Vector3, rotated, sarray("axis", "angle"), varray()); |
| 2276 | bind_method(Vector3, lerp, sarray("to", "weight"), varray()); |
| 2277 | bind_method(Vector3, slerp, sarray("to", "weight"), varray()); |
| 2278 | bind_method(Vector3, cubic_interpolate, sarray("b", "pre_a", "post_b", "weight"), varray()); |
| 2279 | bind_method(Vector3, cubic_interpolate_in_time, sarray("b", "pre_a", "post_b", "weight", "b_t", "pre_a_t", "post_b_t"), varray()); |
| 2280 | bind_method(Vector3, bezier_interpolate, sarray("control_1", "control_2", "end", "t"), varray()); |
| 2281 | bind_method(Vector3, bezier_derivative, sarray("control_1", "control_2", "end", "t"), varray()); |
| 2282 | bind_method(Vector3, move_toward, sarray("to", "delta"), varray()); |
| 2283 | bind_method(Vector3, dot, sarray("with"), varray()); |
| 2284 | bind_method(Vector3, cross, sarray("with"), varray()); |
| 2285 | bind_method(Vector3, outer, sarray("with"), varray()); |
| 2286 | bind_method(Vector3, abs, sarray(), varray()); |
| 2287 | bind_method(Vector3, floor, sarray(), varray()); |
| 2288 | bind_method(Vector3, ceil, sarray(), varray()); |
| 2289 | bind_method(Vector3, round, sarray(), varray()); |
| 2290 | bind_method(Vector3, posmod, sarray("mod"), varray()); |
| 2291 | bind_method(Vector3, posmodv, sarray("modv"), varray()); |
| 2292 | bind_method(Vector3, project, sarray("b"), varray()); |
| 2293 | bind_method(Vector3, slide, sarray("n"), varray()); |
| 2294 | bind_method(Vector3, bounce, sarray("n"), varray()); |
| 2295 | bind_method(Vector3, reflect, sarray("n"), varray()); |
| 2296 | bind_method(Vector3, sign, sarray(), varray()); |
| 2297 | bind_method(Vector3, octahedron_encode, sarray(), varray()); |
| 2298 | bind_method(Vector3, min, sarray("with"), varray()); |
| 2299 | bind_method(Vector3, minf, sarray("with"), varray()); |
| 2300 | bind_method(Vector3, max, sarray("with"), varray()); |
| 2301 | bind_method(Vector3, maxf, sarray("with"), varray()); |
| 2302 | bind_static_method(Vector3, octahedron_decode, sarray("uv"), varray()); |
| 2303 | |
| 2304 | /* Vector3i */ |
| 2305 | |
| 2306 | bind_method(Vector3i, min_axis_index, sarray(), varray()); |
| 2307 | bind_method(Vector3i, max_axis_index, sarray(), varray()); |
| 2308 | bind_method(Vector3i, distance_to, sarray("to"), varray()); |
| 2309 | bind_method(Vector3i, distance_squared_to, sarray("to"), varray()); |
| 2310 | bind_method(Vector3i, length, sarray(), varray()); |
| 2311 | bind_method(Vector3i, length_squared, sarray(), varray()); |
| 2312 | bind_method(Vector3i, sign, sarray(), varray()); |
| 2313 | bind_method(Vector3i, abs, sarray(), varray()); |
| 2314 | bind_method(Vector3i, clamp, sarray("min", "max"), varray()); |
| 2315 | bind_method(Vector3i, clampi, sarray("min", "max"), varray()); |
| 2316 | bind_method(Vector3i, snapped, sarray("step"), varray()); |
| 2317 | bind_method(Vector3i, snappedi, sarray("step"), varray()); |
| 2318 | bind_method(Vector3i, min, sarray("with"), varray()); |
| 2319 | bind_method(Vector3i, mini, sarray("with"), varray()); |
| 2320 | bind_method(Vector3i, max, sarray("with"), varray()); |
| 2321 | bind_method(Vector3i, maxi, sarray("with"), varray()); |
| 2322 | |
| 2323 | /* Vector4 */ |
| 2324 | |
| 2325 | bind_method(Vector4, min_axis_index, sarray(), varray()); |
| 2326 | bind_method(Vector4, max_axis_index, sarray(), varray()); |
| 2327 | bind_method(Vector4, length, sarray(), varray()); |
| 2328 | bind_method(Vector4, length_squared, sarray(), varray()); |
| 2329 | bind_method(Vector4, abs, sarray(), varray()); |
| 2330 | bind_method(Vector4, sign, sarray(), varray()); |
| 2331 | bind_method(Vector4, floor, sarray(), varray()); |
| 2332 | bind_method(Vector4, ceil, sarray(), varray()); |
| 2333 | bind_method(Vector4, round, sarray(), varray()); |
| 2334 | bind_method(Vector4, lerp, sarray("to", "weight"), varray()); |
| 2335 | bind_method(Vector4, cubic_interpolate, sarray("b", "pre_a", "post_b", "weight"), varray()); |
| 2336 | bind_method(Vector4, cubic_interpolate_in_time, sarray("b", "pre_a", "post_b", "weight", "b_t", "pre_a_t", "post_b_t"), varray()); |
| 2337 | bind_method(Vector4, posmod, sarray("mod"), varray()); |
| 2338 | bind_method(Vector4, posmodv, sarray("modv"), varray()); |
| 2339 | bind_method(Vector4, snapped, sarray("step"), varray()); |
| 2340 | bind_method(Vector4, snappedf, sarray("step"), varray()); |
| 2341 | bind_method(Vector4, clamp, sarray("min", "max"), varray()); |
| 2342 | bind_method(Vector4, clampf, sarray("min", "max"), varray()); |
| 2343 | bind_method(Vector4, normalized, sarray(), varray()); |
| 2344 | bind_method(Vector4, is_normalized, sarray(), varray()); |
| 2345 | bind_method(Vector4, direction_to, sarray("to"), varray()); |
| 2346 | bind_method(Vector4, distance_to, sarray("to"), varray()); |
| 2347 | bind_method(Vector4, distance_squared_to, sarray("to"), varray()); |
| 2348 | bind_method(Vector4, dot, sarray("with"), varray()); |
| 2349 | bind_method(Vector4, inverse, sarray(), varray()); |
| 2350 | bind_method(Vector4, is_equal_approx, sarray("to"), varray()); |
| 2351 | bind_method(Vector4, is_zero_approx, sarray(), varray()); |
| 2352 | bind_method(Vector4, is_finite, sarray(), varray()); |
| 2353 | bind_method(Vector4, min, sarray("with"), varray()); |
| 2354 | bind_method(Vector4, minf, sarray("with"), varray()); |
| 2355 | bind_method(Vector4, max, sarray("with"), varray()); |
| 2356 | bind_method(Vector4, maxf, sarray("with"), varray()); |
| 2357 | |
| 2358 | /* Vector4i */ |
| 2359 | |
| 2360 | bind_method(Vector4i, min_axis_index, sarray(), varray()); |
| 2361 | bind_method(Vector4i, max_axis_index, sarray(), varray()); |
| 2362 | bind_method(Vector4i, length, sarray(), varray()); |
| 2363 | bind_method(Vector4i, length_squared, sarray(), varray()); |
| 2364 | bind_method(Vector4i, sign, sarray(), varray()); |
| 2365 | bind_method(Vector4i, abs, sarray(), varray()); |
| 2366 | bind_method(Vector4i, clamp, sarray("min", "max"), varray()); |
| 2367 | bind_method(Vector4i, clampi, sarray("min", "max"), varray()); |
| 2368 | bind_method(Vector4i, snapped, sarray("step"), varray()); |
| 2369 | bind_method(Vector4i, snappedi, sarray("step"), varray()); |
| 2370 | bind_method(Vector4i, min, sarray("with"), varray()); |
| 2371 | bind_method(Vector4i, mini, sarray("with"), varray()); |
| 2372 | bind_method(Vector4i, max, sarray("with"), varray()); |
| 2373 | bind_method(Vector4i, maxi, sarray("with"), varray()); |
| 2374 | bind_method(Vector4i, distance_to, sarray("to"), varray()); |
| 2375 | bind_method(Vector4i, distance_squared_to, sarray("to"), varray()); |
| 2376 | |
| 2377 | /* Plane */ |
| 2378 | |
| 2379 | bind_method(Plane, normalized, sarray(), varray()); |
| 2380 | bind_method(Plane, get_center, sarray(), varray()); |
| 2381 | bind_method(Plane, is_equal_approx, sarray("to_plane"), varray()); |
| 2382 | bind_method(Plane, is_finite, sarray(), varray()); |
| 2383 | bind_method(Plane, is_point_over, sarray("point"), varray()); |
| 2384 | bind_method(Plane, distance_to, sarray("point"), varray()); |
| 2385 | bind_method(Plane, has_point, sarray("point", "tolerance"), varray(CMP_EPSILON)); |
| 2386 | bind_method(Plane, project, sarray("point"), varray()); |
| 2387 | bind_methodv(Plane, intersect_3, &Plane::intersect_3_bind, sarray("b", "c"), varray()); |
| 2388 | bind_methodv(Plane, intersects_ray, &Plane::intersects_ray_bind, sarray("from", "dir"), varray()); |
| 2389 | bind_methodv(Plane, intersects_segment, &Plane::intersects_segment_bind, sarray("from", "to"), varray()); |
| 2390 | |
| 2391 | /* Quaternion */ |
| 2392 | |
| 2393 | bind_method(Quaternion, length, sarray(), varray()); |
| 2394 | bind_method(Quaternion, length_squared, sarray(), varray()); |
| 2395 | bind_method(Quaternion, normalized, sarray(), varray()); |
| 2396 | bind_method(Quaternion, is_normalized, sarray(), varray()); |
| 2397 | bind_method(Quaternion, is_equal_approx, sarray("to"), varray()); |
| 2398 | bind_method(Quaternion, is_finite, sarray(), varray()); |
| 2399 | bind_method(Quaternion, inverse, sarray(), varray()); |
| 2400 | bind_method(Quaternion, log, sarray(), varray()); |
| 2401 | bind_method(Quaternion, exp, sarray(), varray()); |
| 2402 | bind_method(Quaternion, angle_to, sarray("to"), varray()); |
| 2403 | bind_method(Quaternion, dot, sarray("with"), varray()); |
| 2404 | bind_method(Quaternion, slerp, sarray("to", "weight"), varray()); |
| 2405 | bind_method(Quaternion, slerpni, sarray("to", "weight"), varray()); |
| 2406 | bind_method(Quaternion, spherical_cubic_interpolate, sarray("b", "pre_a", "post_b", "weight"), varray()); |
| 2407 | bind_method(Quaternion, spherical_cubic_interpolate_in_time, sarray("b", "pre_a", "post_b", "weight", "b_t", "pre_a_t", "post_b_t"), varray()); |
| 2408 | bind_method(Quaternion, get_euler, sarray("order"), varray((int64_t)EulerOrder::YXZ)); |
| 2409 | bind_static_method(Quaternion, from_euler, sarray("euler"), varray()); |
| 2410 | bind_method(Quaternion, get_axis, sarray(), varray()); |
| 2411 | bind_method(Quaternion, get_angle, sarray(), varray()); |
| 2412 | |
| 2413 | /* Color */ |
| 2414 | |
| 2415 | bind_method(Color, to_argb32, sarray(), varray()); |
| 2416 | bind_method(Color, to_abgr32, sarray(), varray()); |
| 2417 | bind_method(Color, to_rgba32, sarray(), varray()); |
| 2418 | bind_method(Color, to_argb64, sarray(), varray()); |
| 2419 | bind_method(Color, to_abgr64, sarray(), varray()); |
| 2420 | bind_method(Color, to_rgba64, sarray(), varray()); |
| 2421 | bind_method(Color, to_html, sarray("with_alpha"), varray(true)); |
| 2422 | |
| 2423 | bind_method(Color, clamp, sarray("min", "max"), varray(Color(0, 0, 0, 0), Color(1, 1, 1, 1))); |
| 2424 | bind_method(Color, inverted, sarray(), varray()); |
| 2425 | bind_method(Color, lerp, sarray("to", "weight"), varray()); |
| 2426 | bind_method(Color, lightened, sarray("amount"), varray()); |
| 2427 | bind_method(Color, darkened, sarray("amount"), varray()); |
| 2428 | bind_method(Color, blend, sarray("over"), varray()); |
| 2429 | bind_method(Color, get_luminance, sarray(), varray()); |
| 2430 | bind_method(Color, srgb_to_linear, sarray(), varray()); |
| 2431 | bind_method(Color, linear_to_srgb, sarray(), varray()); |
| 2432 | |
| 2433 | bind_method(Color, is_equal_approx, sarray("to"), varray()); |
| 2434 | |
| 2435 | bind_static_method(Color, hex, sarray("hex"), varray()); |
| 2436 | bind_static_method(Color, hex64, sarray("hex"), varray()); |
| 2437 | bind_static_method(Color, html, sarray("rgba"), varray()); |
| 2438 | bind_static_method(Color, html_is_valid, sarray("color"), varray()); |
| 2439 | |
| 2440 | bind_static_method(Color, from_string, sarray("str", "default"), varray()); |
| 2441 | bind_static_method(Color, from_hsv, sarray("h", "s", "v", "alpha"), varray(1.0)); |
| 2442 | bind_static_method(Color, from_ok_hsl, sarray("h", "s", "l", "alpha"), varray(1.0)); |
| 2443 | bind_static_method(Color, from_rgbe9995, sarray("rgbe"), varray()); |
| 2444 | bind_static_method(Color, from_rgba8, sarray("r8", "g8", "b8", "a8"), varray(255)); |
| 2445 | } |
| 2446 | |
| 2447 | VARIANT_ENUM_CAST(ResourceDeepDuplicateMode); |
| 2448 | |
| 2449 | static void _register_variant_builtin_methods_misc() { |
| 2450 | /* RID */ |
| 2451 | |
| 2452 | bind_method(RID, is_valid, sarray(), varray()); |
| 2453 | bind_method(RID, get_id, sarray(), varray()); |
| 2454 | |
| 2455 | /* NodePath */ |
| 2456 | |
| 2457 | bind_method(NodePath, is_absolute, sarray(), varray()); |
| 2458 | bind_method(NodePath, get_name_count, sarray(), varray()); |
| 2459 | bind_method(NodePath, get_name, sarray("idx"), varray()); |
| 2460 | bind_method(NodePath, get_subname_count, sarray(), varray()); |
| 2461 | bind_method(NodePath, hash, sarray(), varray()); |
| 2462 | bind_method(NodePath, get_subname, sarray("idx"), varray()); |
| 2463 | bind_method(NodePath, get_concatenated_names, sarray(), varray()); |
| 2464 | bind_method(NodePath, get_concatenated_subnames, sarray(), varray()); |
| 2465 | bind_method(NodePath, slice, sarray("begin", "end"), varray(INT_MAX)); |
| 2466 | bind_method(NodePath, get_as_property_path, sarray(), varray()); |
| 2467 | bind_method(NodePath, is_empty, sarray(), varray()); |
| 2468 | |
| 2469 | /* Callable */ |
| 2470 | |
| 2471 | bind_static_method(Callable, create, sarray("variant", "method"), varray()); |
| 2472 | bind_method(Callable, callv, sarray("arguments"), varray()); |
| 2473 | bind_method(Callable, is_null, sarray(), varray()); |
| 2474 | bind_method(Callable, is_custom, sarray(), varray()); |
| 2475 | bind_method(Callable, is_standard, sarray(), varray()); |
| 2476 | bind_method(Callable, is_valid, sarray(), varray()); |
| 2477 | bind_method(Callable, get_object, sarray(), varray()); |
| 2478 | bind_method(Callable, get_object_id, sarray(), varray()); |
| 2479 | bind_method(Callable, get_method, sarray(), varray()); |
| 2480 | bind_function(Callable, get_argument_count, _VariantCall::func_Callable_get_argument_count, sarray(), varray()); |
| 2481 | bind_method(Callable, get_bound_arguments_count, sarray(), varray()); |
| 2482 | bind_method(Callable, get_bound_arguments, sarray(), varray()); |
| 2483 | bind_method(Callable, get_unbound_arguments_count, sarray(), varray()); |
| 2484 | bind_method(Callable, hash, sarray(), varray()); |
| 2485 | bind_method(Callable, bindv, sarray("arguments"), varray()); |
| 2486 | bind_method(Callable, unbind, sarray("argcount"), varray()); |
| 2487 | |
| 2488 | bind_custom(Callable, call, _VariantCall::func_Callable_call, true, Variant); |
| 2489 | bind_custom(Callable, call_deferred, _VariantCall::func_Callable_call_deferred, false, Variant); |
| 2490 | bind_custom(Callable, rpc, _VariantCall::func_Callable_rpc, false, Variant); |
| 2491 | bind_custom1(Callable, rpc_id, _VariantCall::func_Callable_rpc_id, Variant::INT, "peer_id"); |
| 2492 | bind_custom(Callable, bind, _VariantCall::func_Callable_bind, true, Callable); |
| 2493 | |
| 2494 | /* Signal */ |
| 2495 | |
| 2496 | bind_method(Signal, is_null, sarray(), varray()); |
| 2497 | bind_method(Signal, get_object, sarray(), varray()); |
| 2498 | bind_method(Signal, get_object_id, sarray(), varray()); |
| 2499 | bind_method(Signal, get_name, sarray(), varray()); |
| 2500 | |
| 2501 | bind_method(Signal, connect, sarray("callable", "flags"), varray(0)); |
| 2502 | bind_method(Signal, disconnect, sarray("callable"), varray()); |
| 2503 | bind_method(Signal, is_connected, sarray("callable"), varray()); |
| 2504 | bind_method(Signal, get_connections, sarray(), varray()); |
| 2505 | bind_method(Signal, has_connections, sarray(), varray()); |
| 2506 | |
| 2507 | bind_custom(Signal, emit, _VariantCall::func_Signal_emit, false, Variant); |
| 2508 | |
| 2509 | /* Transform2D */ |
| 2510 | |
| 2511 | bind_method(Transform2D, inverse, sarray(), varray()); |
| 2512 | bind_method(Transform2D, affine_inverse, sarray(), varray()); |
| 2513 | bind_method(Transform2D, get_rotation, sarray(), varray()); |
| 2514 | bind_method(Transform2D, get_origin, sarray(), varray()); |
| 2515 | bind_method(Transform2D, get_scale, sarray(), varray()); |
| 2516 | bind_method(Transform2D, get_skew, sarray(), varray()); |
| 2517 | bind_method(Transform2D, orthonormalized, sarray(), varray()); |
| 2518 | bind_method(Transform2D, rotated, sarray("angle"), varray()); |
| 2519 | bind_method(Transform2D, rotated_local, sarray("angle"), varray()); |
| 2520 | bind_method(Transform2D, scaled, sarray("scale"), varray()); |
| 2521 | bind_method(Transform2D, scaled_local, sarray("scale"), varray()); |
| 2522 | bind_method(Transform2D, translated, sarray("offset"), varray()); |
| 2523 | bind_method(Transform2D, translated_local, sarray("offset"), varray()); |
| 2524 | bind_method(Transform2D, determinant, sarray(), varray()); |
| 2525 | bind_method(Transform2D, basis_xform, sarray("v"), varray()); |
| 2526 | bind_method(Transform2D, basis_xform_inv, sarray("v"), varray()); |
| 2527 | bind_method(Transform2D, interpolate_with, sarray("xform", "weight"), varray()); |
| 2528 | bind_method(Transform2D, is_conformal, sarray(), varray()); |
| 2529 | bind_method(Transform2D, is_equal_approx, sarray("xform"), varray()); |
| 2530 | bind_method(Transform2D, is_finite, sarray(), varray()); |
| 2531 | // Do not bind functions like set_rotation, set_scale, set_skew, etc because this type is immutable and can't be modified. |
| 2532 | bind_method(Transform2D, looking_at, sarray("target"), varray(Vector2())); |
| 2533 | |
| 2534 | /* Basis */ |
| 2535 | |
| 2536 | bind_method(Basis, inverse, sarray(), varray()); |
| 2537 | bind_method(Basis, transposed, sarray(), varray()); |
| 2538 | bind_method(Basis, orthonormalized, sarray(), varray()); |
| 2539 | bind_method(Basis, determinant, sarray(), varray()); |
| 2540 | bind_methodv(Basis, rotated, static_cast<Basis (Basis::*)(const Vector3 &, real_t) const>(&Basis::rotated), sarray("axis", "angle"), varray()); |
| 2541 | bind_method(Basis, scaled, sarray("scale"), varray()); |
| 2542 | bind_method(Basis, scaled_local, sarray("scale"), varray()); |
| 2543 | bind_method(Basis, get_scale, sarray(), varray()); |
| 2544 | bind_method(Basis, get_euler, sarray("order"), varray((int64_t)EulerOrder::YXZ)); |
| 2545 | bind_method(Basis, tdotx, sarray("with"), varray()); |
| 2546 | bind_method(Basis, tdoty, sarray("with"), varray()); |
| 2547 | bind_method(Basis, tdotz, sarray("with"), varray()); |
| 2548 | bind_method(Basis, slerp, sarray("to", "weight"), varray()); |
| 2549 | bind_method(Basis, is_conformal, sarray(), varray()); |
| 2550 | bind_method(Basis, is_equal_approx, sarray("b"), varray()); |
| 2551 | bind_method(Basis, is_finite, sarray(), varray()); |
| 2552 | bind_method(Basis, get_rotation_quaternion, sarray(), varray()); |
| 2553 | bind_static_method(Basis, looking_at, sarray("target", "up", "use_model_front"), varray(Vector3::UP, false)); |
| 2554 | bind_static_method(Basis, from_scale, sarray("scale"), varray()); |
| 2555 | bind_static_method(Basis, from_euler, sarray("euler", "order"), varray((int64_t)EulerOrder::YXZ)); |
| 2556 | |
| 2557 | /* AABB */ |
| 2558 | |
| 2559 | bind_method(AABB, abs, sarray(), varray()); |
| 2560 | bind_method(AABB, get_center, sarray(), varray()); |
| 2561 | bind_method(AABB, get_volume, sarray(), varray()); |
| 2562 | bind_method(AABB, has_volume, sarray(), varray()); |
| 2563 | bind_method(AABB, has_surface, sarray(), varray()); |
| 2564 | bind_method(AABB, has_point, sarray("point"), varray()); |
| 2565 | bind_method(AABB, is_equal_approx, sarray("aabb"), varray()); |
| 2566 | bind_method(AABB, is_finite, sarray(), varray()); |
| 2567 | bind_method(AABB, intersects, sarray("with"), varray()); |
| 2568 | bind_method(AABB, encloses, sarray("with"), varray()); |
| 2569 | bind_method(AABB, intersects_plane, sarray("plane"), varray()); |
| 2570 | bind_method(AABB, intersection, sarray("with"), varray()); |
| 2571 | bind_method(AABB, merge, sarray("with"), varray()); |
| 2572 | bind_method(AABB, expand, sarray("to_point"), varray()); |
| 2573 | bind_method(AABB, grow, sarray("by"), varray()); |
| 2574 | bind_method(AABB, get_support, sarray("direction"), varray()); |
| 2575 | bind_method(AABB, get_longest_axis, sarray(), varray()); |
| 2576 | bind_method(AABB, get_longest_axis_index, sarray(), varray()); |
| 2577 | bind_method(AABB, get_longest_axis_size, sarray(), varray()); |
| 2578 | bind_method(AABB, get_shortest_axis, sarray(), varray()); |
| 2579 | bind_method(AABB, get_shortest_axis_index, sarray(), varray()); |
| 2580 | bind_method(AABB, get_shortest_axis_size, sarray(), varray()); |
| 2581 | bind_method(AABB, get_endpoint, sarray("idx"), varray()); |
| 2582 | bind_methodv(AABB, intersects_segment, &AABB::intersects_segment_bind, sarray("from", "to"), varray()); |
| 2583 | bind_methodv(AABB, intersects_ray, &AABB::intersects_ray_bind, sarray("from", "dir"), varray()); |
| 2584 | |
| 2585 | /* Transform3D */ |
| 2586 | |
| 2587 | bind_method(Transform3D, inverse, sarray(), varray()); |
| 2588 | bind_method(Transform3D, affine_inverse, sarray(), varray()); |
| 2589 | bind_method(Transform3D, orthonormalized, sarray(), varray()); |
| 2590 | bind_method(Transform3D, rotated, sarray("axis", "angle"), varray()); |
| 2591 | bind_method(Transform3D, rotated_local, sarray("axis", "angle"), varray()); |
| 2592 | bind_method(Transform3D, scaled, sarray("scale"), varray()); |
| 2593 | bind_method(Transform3D, scaled_local, sarray("scale"), varray()); |
| 2594 | bind_method(Transform3D, translated, sarray("offset"), varray()); |
| 2595 | bind_method(Transform3D, translated_local, sarray("offset"), varray()); |
| 2596 | bind_method(Transform3D, looking_at, sarray("target", "up", "use_model_front"), varray(Vector3::UP, false)); |
| 2597 | bind_method(Transform3D, interpolate_with, sarray("xform", "weight"), varray()); |
| 2598 | bind_method(Transform3D, is_equal_approx, sarray("xform"), varray()); |
| 2599 | bind_method(Transform3D, is_finite, sarray(), varray()); |
| 2600 | |
| 2601 | /* Projection */ |
| 2602 | |
| 2603 | bind_static_method(Projection, create_depth_correction, sarray("flip_y"), varray()); |
| 2604 | bind_static_method(Projection, create_light_atlas_rect, sarray("rect"), varray()); |
| 2605 | bind_static_method(Projection, create_perspective, sarray("fovy", "aspect", "z_near", "z_far", "flip_fov"), varray(false)); |
| 2606 | bind_static_method(Projection, create_perspective_hmd, sarray("fovy", "aspect", "z_near", "z_far", "flip_fov", "eye", "intraocular_dist", "convergence_dist"), varray()); |
| 2607 | bind_static_method(Projection, create_for_hmd, sarray("eye", "aspect", "intraocular_dist", "display_width", "display_to_lens", "oversample", "z_near", "z_far"), varray()); |
| 2608 | bind_static_method(Projection, create_orthogonal, sarray("left", "right", "bottom", "top", "z_near", "z_far"), varray()); |
| 2609 | bind_static_method(Projection, create_orthogonal_aspect, sarray("size", "aspect", "z_near", "z_far", "flip_fov"), varray(false)); |
| 2610 | bind_static_method(Projection, create_frustum, sarray("left", "right", "bottom", "top", "z_near", "z_far"), varray()); |
| 2611 | bind_static_method(Projection, create_frustum_aspect, sarray("size", "aspect", "offset", "z_near", "z_far", "flip_fov"), varray(false)); |
| 2612 | bind_static_method(Projection, create_fit_aabb, sarray("aabb"), varray()); |
| 2613 | |
| 2614 | bind_method(Projection, determinant, sarray(), varray()); |
| 2615 | bind_method(Projection, perspective_znear_adjusted, sarray("new_znear"), varray()); |
| 2616 | bind_method(Projection, get_projection_plane, sarray("plane"), varray()); |
| 2617 | bind_method(Projection, flipped_y, sarray(), varray()); |
| 2618 | bind_method(Projection, jitter_offseted, sarray("offset"), varray()); |
| 2619 | |
| 2620 | bind_static_method(Projection, get_fovy, sarray("fovx", "aspect"), varray()); |
| 2621 | |
| 2622 | bind_method(Projection, get_z_far, sarray(), varray()); |
| 2623 | bind_method(Projection, get_z_near, sarray(), varray()); |
| 2624 | bind_method(Projection, get_aspect, sarray(), varray()); |
| 2625 | bind_method(Projection, get_fov, sarray(), varray()); |
| 2626 | bind_method(Projection, is_orthogonal, sarray(), varray()); |
| 2627 | |
| 2628 | bind_method(Projection, get_viewport_half_extents, sarray(), varray()); |
| 2629 | bind_method(Projection, get_far_plane_half_extents, sarray(), varray()); |
| 2630 | |
| 2631 | bind_method(Projection, inverse, sarray(), varray()); |
| 2632 | bind_method(Projection, get_pixels_per_meter, sarray("for_pixel_width"), varray()); |
| 2633 | bind_method(Projection, get_lod_multiplier, sarray(), varray()); |
| 2634 | |
| 2635 | /* Dictionary */ |
| 2636 | |
| 2637 | bind_method(Dictionary, size, sarray(), varray()); |
| 2638 | bind_method(Dictionary, is_empty, sarray(), varray()); |
| 2639 | bind_method(Dictionary, clear, sarray(), varray()); |
| 2640 | bind_method(Dictionary, assign, sarray("dictionary"), varray()); |
| 2641 | bind_method(Dictionary, sort, sarray(), varray()); |
| 2642 | bind_method(Dictionary, merge, sarray("dictionary", "overwrite"), varray(false)); |
| 2643 | bind_method(Dictionary, merged, sarray("dictionary", "overwrite"), varray(false)); |
| 2644 | bind_method(Dictionary, has, sarray("key"), varray()); |
| 2645 | bind_method(Dictionary, has_all, sarray("keys"), varray()); |
| 2646 | bind_method(Dictionary, find_key, sarray("value"), varray()); |
| 2647 | bind_method(Dictionary, erase, sarray("key"), varray()); |
| 2648 | bind_method(Dictionary, hash, sarray(), varray()); |
| 2649 | bind_method(Dictionary, keys, sarray(), varray()); |
| 2650 | bind_method(Dictionary, values, sarray(), varray()); |
| 2651 | bind_method(Dictionary, duplicate, sarray("deep"), varray(false)); |
| 2652 | bind_method(Dictionary, duplicate_deep, sarray("deep_subresources_mode"), varray(RESOURCE_DEEP_DUPLICATE_INTERNAL)); |
| 2653 | bind_method(Dictionary, get, sarray("key", "default"), varray(Variant())); |
| 2654 | bind_method(Dictionary, get_or_add, sarray("key", "default"), varray(Variant())); |
| 2655 | bind_method(Dictionary, set, sarray("key", "value"), varray()); |
| 2656 | bind_method(Dictionary, is_typed, sarray(), varray()); |
| 2657 | bind_method(Dictionary, is_typed_key, sarray(), varray()); |
| 2658 | bind_method(Dictionary, is_typed_value, sarray(), varray()); |
| 2659 | bind_method(Dictionary, is_same_typed, sarray("dictionary"), varray()); |
| 2660 | bind_method(Dictionary, is_same_typed_key, sarray("dictionary"), varray()); |
| 2661 | bind_method(Dictionary, is_same_typed_value, sarray("dictionary"), varray()); |
| 2662 | bind_method(Dictionary, get_typed_key_builtin, sarray(), varray()); |
| 2663 | bind_method(Dictionary, get_typed_value_builtin, sarray(), varray()); |
| 2664 | bind_method(Dictionary, get_typed_key_class_name, sarray(), varray()); |
| 2665 | bind_method(Dictionary, get_typed_value_class_name, sarray(), varray()); |
| 2666 | bind_method(Dictionary, get_typed_key_script, sarray(), varray()); |
| 2667 | bind_method(Dictionary, get_typed_value_script, sarray(), varray()); |
| 2668 | bind_method(Dictionary, make_read_only, sarray(), varray()); |
| 2669 | bind_method(Dictionary, is_read_only, sarray(), varray()); |
| 2670 | bind_method(Dictionary, recursive_equal, sarray("dictionary", "recursion_count"), varray()); |
| 2671 | } |
| 2672 | |
| 2673 | static void _register_variant_builtin_methods_array() { |
| 2674 | /* Array */ |
| 2675 | |
| 2676 | bind_method(Array, size, sarray(), varray()); |
| 2677 | bind_method(Array, is_empty, sarray(), varray()); |
| 2678 | bind_method(Array, clear, sarray(), varray()); |
| 2679 | bind_method(Array, hash, sarray(), varray()); |
| 2680 | bind_method(Array, assign, sarray("array"), varray()); |
| 2681 | bind_function(Array, get, _VariantCall::func_Array_get, sarray("index"), varray()); |
| 2682 | bind_functionnc(Array, set, _VariantCall::func_Array_set, sarray("index", "value"), varray()); |
| 2683 | bind_method(Array, push_back, sarray("value"), varray()); |
| 2684 | bind_method(Array, push_front, sarray("value"), varray()); |
| 2685 | bind_method(Array, append, sarray("value"), varray()); |
| 2686 | bind_method(Array, append_array, sarray("array"), varray()); |
| 2687 | bind_method(Array, resize, sarray("size"), varray()); |
| 2688 | bind_method(Array, insert, sarray("position", "value"), varray()); |
| 2689 | bind_method(Array, remove_at, sarray("position"), varray()); |
| 2690 | bind_method(Array, fill, sarray("value"), varray()); |
| 2691 | bind_method(Array, erase, sarray("value"), varray()); |
| 2692 | bind_method(Array, front, sarray(), varray()); |
| 2693 | bind_method(Array, back, sarray(), varray()); |
| 2694 | bind_method(Array, pick_random, sarray(), varray()); |
| 2695 | bind_method(Array, find, sarray("what", "from"), varray(0)); |
| 2696 | bind_method(Array, find_custom, sarray("method", "from"), varray(0)); |
| 2697 | bind_method(Array, rfind, sarray("what", "from"), varray(-1)); |
| 2698 | bind_method(Array, rfind_custom, sarray("method", "from"), varray(-1)); |
| 2699 | bind_method(Array, count, sarray("value"), varray()); |
| 2700 | bind_method(Array, has, sarray("value"), varray()); |
| 2701 | bind_method(Array, pop_back, sarray(), varray()); |
| 2702 | bind_method(Array, pop_front, sarray(), varray()); |
| 2703 | bind_method(Array, pop_at, sarray("position"), varray()); |
| 2704 | bind_method(Array, sort, sarray(), varray()); |
| 2705 | bind_method(Array, sort_custom, sarray("func"), varray()); |
| 2706 | bind_method(Array, shuffle, sarray(), varray()); |
| 2707 | bind_method(Array, bsearch, sarray("value", "before"), varray(true)); |
| 2708 | bind_method(Array, bsearch_custom, sarray("value", "func", "before"), varray(true)); |
| 2709 | bind_method(Array, reverse, sarray(), varray()); |
| 2710 | bind_method(Array, duplicate, sarray("deep"), varray(false)); |
| 2711 | bind_method(Array, duplicate_deep, sarray("deep_subresources_mode"), varray(RESOURCE_DEEP_DUPLICATE_INTERNAL)); |
| 2712 | bind_method(Array, slice, sarray("begin", "end", "step", "deep"), varray(INT_MAX, 1, false)); |
| 2713 | bind_method(Array, filter, sarray("method"), varray()); |
| 2714 | bind_method(Array, map, sarray("method"), varray()); |
| 2715 | bind_method(Array, reduce, sarray("method", "accum"), varray(Variant())); |
| 2716 | bind_method(Array, any, sarray("method"), varray()); |
| 2717 | bind_method(Array, all, sarray("method"), varray()); |
| 2718 | bind_method(Array, max, sarray(), varray()); |
| 2719 | bind_method(Array, min, sarray(), varray()); |
| 2720 | bind_method(Array, is_typed, sarray(), varray()); |
| 2721 | bind_method(Array, is_same_typed, sarray("array"), varray()); |
| 2722 | bind_method(Array, get_typed_builtin, sarray(), varray()); |
| 2723 | bind_method(Array, get_typed_class_name, sarray(), varray()); |
| 2724 | bind_method(Array, get_typed_script, sarray(), varray()); |
| 2725 | bind_method(Array, make_read_only, sarray(), varray()); |
| 2726 | bind_method(Array, is_read_only, sarray(), varray()); |
| 2727 | |
| 2728 | /* Packed*Array get/set (see VARCALL_ARRAY_GETTER_SETTER macro) */ |
| 2729 | bind_function(PackedByteArray, get, _VariantCall::func_PackedByteArray_get, sarray("index"), varray()); |
| 2730 | bind_function(PackedColorArray, get, _VariantCall::func_PackedColorArray_get, sarray("index"), varray()); |
| 2731 | bind_function(PackedFloat32Array, get, _VariantCall::func_PackedFloat32Array_get, sarray("index"), varray()); |
| 2732 | bind_function(PackedFloat64Array, get, _VariantCall::func_PackedFloat64Array_get, sarray("index"), varray()); |
| 2733 | bind_function(PackedInt32Array, get, _VariantCall::func_PackedInt32Array_get, sarray("index"), varray()); |
| 2734 | bind_function(PackedInt64Array, get, _VariantCall::func_PackedInt64Array_get, sarray("index"), varray()); |
| 2735 | bind_function(PackedStringArray, get, _VariantCall::func_PackedStringArray_get, sarray("index"), varray()); |
| 2736 | bind_function(PackedVector2Array, get, _VariantCall::func_PackedVector2Array_get, sarray("index"), varray()); |
| 2737 | bind_function(PackedVector3Array, get, _VariantCall::func_PackedVector3Array_get, sarray("index"), varray()); |
| 2738 | bind_function(PackedVector4Array, get, _VariantCall::func_PackedVector4Array_get, sarray("index"), varray()); |
| 2739 | |
| 2740 | bind_functionnc(PackedByteArray, set, _VariantCall::func_PackedByteArray_set, sarray("index", "value"), varray()); |
| 2741 | bind_functionnc(PackedColorArray, set, _VariantCall::func_PackedColorArray_set, sarray("index", "value"), varray()); |
| 2742 | bind_functionnc(PackedFloat32Array, set, _VariantCall::func_PackedFloat32Array_set, sarray("index", "value"), varray()); |
| 2743 | bind_functionnc(PackedFloat64Array, set, _VariantCall::func_PackedFloat64Array_set, sarray("index", "value"), varray()); |
| 2744 | bind_functionnc(PackedInt32Array, set, _VariantCall::func_PackedInt32Array_set, sarray("index", "value"), varray()); |
| 2745 | bind_functionnc(PackedInt64Array, set, _VariantCall::func_PackedInt64Array_set, sarray("index", "value"), varray()); |
| 2746 | bind_functionnc(PackedStringArray, set, _VariantCall::func_PackedStringArray_set, sarray("index", "value"), varray()); |
| 2747 | bind_functionnc(PackedVector2Array, set, _VariantCall::func_PackedVector2Array_set, sarray("index", "value"), varray()); |
| 2748 | bind_functionnc(PackedVector3Array, set, _VariantCall::func_PackedVector3Array_set, sarray("index", "value"), varray()); |
| 2749 | bind_functionnc(PackedVector4Array, set, _VariantCall::func_PackedVector4Array_set, sarray("index", "value"), varray()); |
| 2750 | |
| 2751 | /* Byte Array */ |
| 2752 | bind_method(PackedByteArray, size, sarray(), varray()); |
| 2753 | bind_method(PackedByteArray, is_empty, sarray(), varray()); |
| 2754 | bind_method(PackedByteArray, push_back, sarray("value"), varray()); |
| 2755 | bind_method(PackedByteArray, append, sarray("value"), varray()); |
| 2756 | bind_method(PackedByteArray, append_array, sarray("array"), varray()); |
| 2757 | bind_method(PackedByteArray, remove_at, sarray("index"), varray()); |
| 2758 | bind_method(PackedByteArray, insert, sarray("at_index", "value"), varray()); |
| 2759 | bind_method(PackedByteArray, fill, sarray("value"), varray()); |
| 2760 | bind_methodv(PackedByteArray, resize, &PackedByteArray::resize_initialized, sarray("new_size"), varray()); |
| 2761 | bind_method(PackedByteArray, clear, sarray(), varray()); |
| 2762 | bind_method(PackedByteArray, has, sarray("value"), varray()); |
| 2763 | bind_method(PackedByteArray, reverse, sarray(), varray()); |
| 2764 | bind_method(PackedByteArray, slice, sarray("begin", "end"), varray(INT_MAX)); |
| 2765 | bind_method(PackedByteArray, sort, sarray(), varray()); |
| 2766 | bind_method(PackedByteArray, bsearch, sarray("value", "before"), varray(true)); |
| 2767 | bind_method(PackedByteArray, duplicate, sarray(), varray()); |
| 2768 | #ifndef DISABLE_DEPRECATED |
| 2769 | bind_compat_functionnc(PackedByteArray, duplicate, _duplicate_bind_compat_112290, _VariantCall::_duplicate_bind_compat_112290<uint8_t>, sarray(), varray()); |
| 2770 | bind_compat_functionnc(PackedByteArray, bsearch, _bsearch_bind_compat_112539, _VariantCall::_bsearch_bind_compat_112539<uint8_t>, sarray("value", "before"), varray(true)); |
| 2771 | #endif |
| 2772 | bind_method(PackedByteArray, find, sarray("value", "from"), varray(0)); |
| 2773 | bind_method(PackedByteArray, rfind, sarray("value", "from"), varray(-1)); |
| 2774 | bind_method(PackedByteArray, count, sarray("value"), varray()); |
| 2775 | bind_method(PackedByteArray, erase, sarray("value"), varray()); |
| 2776 | |
| 2777 | bind_function(PackedByteArray, get_string_from_ascii, _VariantCall::func_PackedByteArray_get_string_from_ascii, sarray(), varray()); |
| 2778 | bind_function(PackedByteArray, get_string_from_utf8, _VariantCall::func_PackedByteArray_get_string_from_utf8, sarray(), varray()); |
| 2779 | bind_function(PackedByteArray, get_string_from_utf16, _VariantCall::func_PackedByteArray_get_string_from_utf16, sarray(), varray()); |
| 2780 | bind_function(PackedByteArray, get_string_from_utf32, _VariantCall::func_PackedByteArray_get_string_from_utf32, sarray(), varray()); |
| 2781 | bind_function(PackedByteArray, get_string_from_wchar, _VariantCall::func_PackedByteArray_get_string_from_wchar, sarray(), varray()); |
| 2782 | bind_function(PackedByteArray, get_string_from_multibyte_char, _VariantCall::func_PackedByteArray_get_string_from_multibyte_char, sarray("encoding"), varray(String())); |
| 2783 | bind_function(PackedByteArray, hex_encode, _VariantCall::func_PackedByteArray_hex_encode, sarray(), varray()); |
| 2784 | bind_function(PackedByteArray, compress, _VariantCall::func_PackedByteArray_compress, sarray("compression_mode"), varray(0)); |
| 2785 | bind_function(PackedByteArray, decompress, _VariantCall::func_PackedByteArray_decompress, sarray("buffer_size", "compression_mode"), varray(0)); |
| 2786 | bind_function(PackedByteArray, decompress_dynamic, _VariantCall::func_PackedByteArray_decompress_dynamic, sarray("max_output_size", "compression_mode"), varray(0)); |
| 2787 | |
| 2788 | bind_function(PackedByteArray, decode_u8, _VariantCall::func_PackedByteArray_decode_u8, sarray("byte_offset"), varray()); |
| 2789 | bind_function(PackedByteArray, decode_s8, _VariantCall::func_PackedByteArray_decode_s8, sarray("byte_offset"), varray()); |
| 2790 | bind_function(PackedByteArray, decode_u16, _VariantCall::func_PackedByteArray_decode_u16, sarray("byte_offset"), varray()); |
| 2791 | bind_function(PackedByteArray, decode_s16, _VariantCall::func_PackedByteArray_decode_s16, sarray("byte_offset"), varray()); |
| 2792 | bind_function(PackedByteArray, decode_u32, _VariantCall::func_PackedByteArray_decode_u32, sarray("byte_offset"), varray()); |
| 2793 | bind_function(PackedByteArray, decode_s32, _VariantCall::func_PackedByteArray_decode_s32, sarray("byte_offset"), varray()); |
| 2794 | bind_function(PackedByteArray, decode_u64, _VariantCall::func_PackedByteArray_decode_u64, sarray("byte_offset"), varray()); |
| 2795 | bind_function(PackedByteArray, decode_s64, _VariantCall::func_PackedByteArray_decode_s64, sarray("byte_offset"), varray()); |
| 2796 | bind_function(PackedByteArray, decode_half, _VariantCall::func_PackedByteArray_decode_half, sarray("byte_offset"), varray()); |
| 2797 | bind_function(PackedByteArray, decode_float, _VariantCall::func_PackedByteArray_decode_float, sarray("byte_offset"), varray()); |
| 2798 | bind_function(PackedByteArray, decode_double, _VariantCall::func_PackedByteArray_decode_double, sarray("byte_offset"), varray()); |
| 2799 | bind_function(PackedByteArray, has_encoded_var, _VariantCall::func_PackedByteArray_has_encoded_var, sarray("byte_offset", "allow_objects"), varray(false)); |
| 2800 | bind_function(PackedByteArray, decode_var, _VariantCall::func_PackedByteArray_decode_var, sarray("byte_offset", "allow_objects"), varray(false)); |
| 2801 | bind_function(PackedByteArray, decode_var_size, _VariantCall::func_PackedByteArray_decode_var_size, sarray("byte_offset", "allow_objects"), varray(false)); |
| 2802 | |
| 2803 | bind_function(PackedByteArray, to_int32_array, _VariantCall::func_PackedByteArray_decode_s32_array, sarray(), varray()); |
| 2804 | bind_function(PackedByteArray, to_int64_array, _VariantCall::func_PackedByteArray_decode_s64_array, sarray(), varray()); |
| 2805 | bind_function(PackedByteArray, to_float32_array, _VariantCall::func_PackedByteArray_decode_float_array, sarray(), varray()); |
| 2806 | bind_function(PackedByteArray, to_float64_array, _VariantCall::func_PackedByteArray_decode_double_array, sarray(), varray()); |
| 2807 | bind_function(PackedByteArray, to_vector2_array, _VariantCall::func_PackedByteArray_decode_vector2_array, sarray(), varray()); |
| 2808 | bind_function(PackedByteArray, to_vector3_array, _VariantCall::func_PackedByteArray_decode_vector3_array, sarray(), varray()); |
| 2809 | bind_function(PackedByteArray, to_vector4_array, _VariantCall::func_PackedByteArray_decode_vector4_array, sarray(), varray()); |
| 2810 | bind_function(PackedByteArray, to_color_array, _VariantCall::func_PackedByteArray_decode_color_array, sarray(), varray()); |
| 2811 | |
| 2812 | bind_functionnc(PackedByteArray, bswap16, _VariantCall::func_PackedByteArray_bswap16, sarray("offset", "count"), varray(0, -1)); |
| 2813 | bind_functionnc(PackedByteArray, bswap32, _VariantCall::func_PackedByteArray_bswap32, sarray("offset", "count"), varray(0, -1)); |
| 2814 | bind_functionnc(PackedByteArray, bswap64, _VariantCall::func_PackedByteArray_bswap64, sarray("offset", "count"), varray(0, -1)); |
| 2815 | |
| 2816 | bind_functionnc(PackedByteArray, encode_u8, _VariantCall::func_PackedByteArray_encode_u8, sarray("byte_offset", "value"), varray()); |
| 2817 | bind_functionnc(PackedByteArray, encode_s8, _VariantCall::func_PackedByteArray_encode_s8, sarray("byte_offset", "value"), varray()); |
| 2818 | bind_functionnc(PackedByteArray, encode_u16, _VariantCall::func_PackedByteArray_encode_u16, sarray("byte_offset", "value"), varray()); |
| 2819 | bind_functionnc(PackedByteArray, encode_s16, _VariantCall::func_PackedByteArray_encode_s16, sarray("byte_offset", "value"), varray()); |
| 2820 | bind_functionnc(PackedByteArray, encode_u32, _VariantCall::func_PackedByteArray_encode_u32, sarray("byte_offset", "value"), varray()); |
| 2821 | bind_functionnc(PackedByteArray, encode_s32, _VariantCall::func_PackedByteArray_encode_s32, sarray("byte_offset", "value"), varray()); |
| 2822 | bind_functionnc(PackedByteArray, encode_u64, _VariantCall::func_PackedByteArray_encode_u64, sarray("byte_offset", "value"), varray()); |
| 2823 | bind_functionnc(PackedByteArray, encode_s64, _VariantCall::func_PackedByteArray_encode_s64, sarray("byte_offset", "value"), varray()); |
| 2824 | bind_functionnc(PackedByteArray, encode_half, _VariantCall::func_PackedByteArray_encode_half, sarray("byte_offset", "value"), varray()); |
| 2825 | bind_functionnc(PackedByteArray, encode_float, _VariantCall::func_PackedByteArray_encode_float, sarray("byte_offset", "value"), varray()); |
| 2826 | bind_functionnc(PackedByteArray, encode_double, _VariantCall::func_PackedByteArray_encode_double, sarray("byte_offset", "value"), varray()); |
| 2827 | bind_functionnc(PackedByteArray, encode_var, _VariantCall::func_PackedByteArray_encode_var, sarray("byte_offset", "value", "allow_objects"), varray(false)); |
| 2828 | |
| 2829 | /* Int32 Array */ |
| 2830 | |
| 2831 | bind_method(PackedInt32Array, size, sarray(), varray()); |
| 2832 | bind_method(PackedInt32Array, is_empty, sarray(), varray()); |
| 2833 | bind_method(PackedInt32Array, push_back, sarray("value"), varray()); |
| 2834 | bind_method(PackedInt32Array, append, sarray("value"), varray()); |
| 2835 | bind_method(PackedInt32Array, append_array, sarray("array"), varray()); |
| 2836 | bind_method(PackedInt32Array, remove_at, sarray("index"), varray()); |
| 2837 | bind_method(PackedInt32Array, insert, sarray("at_index", "value"), varray()); |
| 2838 | bind_method(PackedInt32Array, fill, sarray("value"), varray()); |
| 2839 | bind_methodv(PackedInt32Array, resize, &PackedInt32Array::resize_initialized, sarray("new_size"), varray()); |
| 2840 | bind_method(PackedInt32Array, clear, sarray(), varray()); |
| 2841 | bind_method(PackedInt32Array, has, sarray("value"), varray()); |
| 2842 | bind_method(PackedInt32Array, reverse, sarray(), varray()); |
| 2843 | bind_method(PackedInt32Array, slice, sarray("begin", "end"), varray(INT_MAX)); |
| 2844 | bind_method(PackedInt32Array, to_byte_array, sarray(), varray()); |
| 2845 | bind_method(PackedInt32Array, sort, sarray(), varray()); |
| 2846 | bind_method(PackedInt32Array, bsearch, sarray("value", "before"), varray(true)); |
| 2847 | bind_method(PackedInt32Array, duplicate, sarray(), varray()); |
| 2848 | #ifndef DISABLE_DEPRECATED |
| 2849 | bind_compat_functionnc(PackedInt32Array, duplicate, _duplicate_bind_compat_112290, _VariantCall::_duplicate_bind_compat_112290<int32_t>, sarray(), varray()); |
| 2850 | bind_compat_functionnc(PackedInt32Array, bsearch, _bsearch_bind_compat_112539, _VariantCall::_bsearch_bind_compat_112539<int32_t>, sarray("value", "before"), varray(true)); |
| 2851 | #endif |
| 2852 | bind_method(PackedInt32Array, find, sarray("value", "from"), varray(0)); |
| 2853 | bind_method(PackedInt32Array, rfind, sarray("value", "from"), varray(-1)); |
| 2854 | bind_method(PackedInt32Array, count, sarray("value"), varray()); |
| 2855 | bind_method(PackedInt32Array, erase, sarray("value"), varray()); |
| 2856 | |
| 2857 | /* Int64 Array */ |
| 2858 | |
| 2859 | bind_method(PackedInt64Array, size, sarray(), varray()); |
| 2860 | bind_method(PackedInt64Array, is_empty, sarray(), varray()); |
| 2861 | bind_method(PackedInt64Array, push_back, sarray("value"), varray()); |
| 2862 | bind_method(PackedInt64Array, append, sarray("value"), varray()); |
| 2863 | bind_method(PackedInt64Array, append_array, sarray("array"), varray()); |
| 2864 | bind_method(PackedInt64Array, remove_at, sarray("index"), varray()); |
| 2865 | bind_method(PackedInt64Array, insert, sarray("at_index", "value"), varray()); |
| 2866 | bind_method(PackedInt64Array, fill, sarray("value"), varray()); |
| 2867 | bind_methodv(PackedInt64Array, resize, &PackedInt64Array::resize_initialized, sarray("new_size"), varray()); |
| 2868 | bind_method(PackedInt64Array, clear, sarray(), varray()); |
| 2869 | bind_method(PackedInt64Array, has, sarray("value"), varray()); |
| 2870 | bind_method(PackedInt64Array, reverse, sarray(), varray()); |
| 2871 | bind_method(PackedInt64Array, slice, sarray("begin", "end"), varray(INT_MAX)); |
| 2872 | bind_method(PackedInt64Array, to_byte_array, sarray(), varray()); |
| 2873 | bind_method(PackedInt64Array, sort, sarray(), varray()); |
| 2874 | bind_method(PackedInt64Array, bsearch, sarray("value", "before"), varray(true)); |
| 2875 | bind_method(PackedInt64Array, duplicate, sarray(), varray()); |
| 2876 | #ifndef DISABLE_DEPRECATED |
| 2877 | bind_compat_functionnc(PackedInt64Array, duplicate, _duplicate_bind_compat_112290, _VariantCall::_duplicate_bind_compat_112290<int64_t>, sarray(), varray()); |
| 2878 | bind_compat_functionnc(PackedInt64Array, bsearch, _bsearch_bind_compat_112539, _VariantCall::_bsearch_bind_compat_112539<int64_t>, sarray("value", "before"), varray(true)); |
| 2879 | #endif |
| 2880 | bind_method(PackedInt64Array, find, sarray("value", "from"), varray(0)); |
| 2881 | bind_method(PackedInt64Array, rfind, sarray("value", "from"), varray(-1)); |
| 2882 | bind_method(PackedInt64Array, count, sarray("value"), varray()); |
| 2883 | bind_method(PackedInt64Array, erase, sarray("value"), varray()); |
| 2884 | |
| 2885 | /* Float32 Array */ |
| 2886 | |
| 2887 | bind_method(PackedFloat32Array, size, sarray(), varray()); |
| 2888 | bind_method(PackedFloat32Array, is_empty, sarray(), varray()); |
| 2889 | bind_method(PackedFloat32Array, push_back, sarray("value"), varray()); |
| 2890 | bind_method(PackedFloat32Array, append, sarray("value"), varray()); |
| 2891 | bind_method(PackedFloat32Array, append_array, sarray("array"), varray()); |
| 2892 | bind_method(PackedFloat32Array, remove_at, sarray("index"), varray()); |
| 2893 | bind_method(PackedFloat32Array, insert, sarray("at_index", "value"), varray()); |
| 2894 | bind_method(PackedFloat32Array, fill, sarray("value"), varray()); |
| 2895 | bind_methodv(PackedFloat32Array, resize, &PackedFloat32Array::resize_initialized, sarray("new_size"), varray()); |
| 2896 | bind_method(PackedFloat32Array, clear, sarray(), varray()); |
| 2897 | bind_method(PackedFloat32Array, has, sarray("value"), varray()); |
| 2898 | bind_method(PackedFloat32Array, reverse, sarray(), varray()); |
| 2899 | bind_method(PackedFloat32Array, slice, sarray("begin", "end"), varray(INT_MAX)); |
| 2900 | bind_method(PackedFloat32Array, to_byte_array, sarray(), varray()); |
| 2901 | bind_method(PackedFloat32Array, sort, sarray(), varray()); |
| 2902 | bind_method(PackedFloat32Array, bsearch, sarray("value", "before"), varray(true)); |
| 2903 | bind_method(PackedFloat32Array, duplicate, sarray(), varray()); |
| 2904 | #ifndef DISABLE_DEPRECATED |
| 2905 | bind_compat_functionnc(PackedFloat32Array, duplicate, _duplicate_bind_compat_112290, _VariantCall::_duplicate_bind_compat_112290<float>, sarray(), varray()); |
| 2906 | bind_compat_functionnc(PackedFloat32Array, bsearch, _bsearch_bind_compat_112539, _VariantCall::_bsearch_bind_compat_112539<float>, sarray("value", "before"), varray(true)); |
| 2907 | #endif |
| 2908 | bind_method(PackedFloat32Array, find, sarray("value", "from"), varray(0)); |
| 2909 | bind_method(PackedFloat32Array, rfind, sarray("value", "from"), varray(-1)); |
| 2910 | bind_method(PackedFloat32Array, count, sarray("value"), varray()); |
| 2911 | bind_method(PackedFloat32Array, erase, sarray("value"), varray()); |
| 2912 | |
| 2913 | /* Float64 Array */ |
| 2914 | |
| 2915 | bind_method(PackedFloat64Array, size, sarray(), varray()); |
| 2916 | bind_method(PackedFloat64Array, is_empty, sarray(), varray()); |
| 2917 | bind_method(PackedFloat64Array, push_back, sarray("value"), varray()); |
| 2918 | bind_method(PackedFloat64Array, append, sarray("value"), varray()); |
| 2919 | bind_method(PackedFloat64Array, append_array, sarray("array"), varray()); |
| 2920 | bind_method(PackedFloat64Array, remove_at, sarray("index"), varray()); |
| 2921 | bind_method(PackedFloat64Array, insert, sarray("at_index", "value"), varray()); |
| 2922 | bind_method(PackedFloat64Array, fill, sarray("value"), varray()); |
| 2923 | bind_methodv(PackedFloat64Array, resize, &PackedFloat64Array::resize_initialized, sarray("new_size"), varray()); |
| 2924 | bind_method(PackedFloat64Array, clear, sarray(), varray()); |
| 2925 | bind_method(PackedFloat64Array, has, sarray("value"), varray()); |
| 2926 | bind_method(PackedFloat64Array, reverse, sarray(), varray()); |
| 2927 | bind_method(PackedFloat64Array, slice, sarray("begin", "end"), varray(INT_MAX)); |
| 2928 | bind_method(PackedFloat64Array, to_byte_array, sarray(), varray()); |
| 2929 | bind_method(PackedFloat64Array, sort, sarray(), varray()); |
| 2930 | bind_method(PackedFloat64Array, bsearch, sarray("value", "before"), varray(true)); |
| 2931 | bind_method(PackedFloat64Array, duplicate, sarray(), varray()); |
| 2932 | #ifndef DISABLE_DEPRECATED |
| 2933 | bind_compat_functionnc(PackedFloat64Array, duplicate, _duplicate_bind_compat_112290, _VariantCall::_duplicate_bind_compat_112290<double>, sarray(), varray()); |
| 2934 | bind_compat_functionnc(PackedFloat64Array, bsearch, _bsearch_bind_compat_112539, _VariantCall::_bsearch_bind_compat_112539<double>, sarray("value", "before"), varray(true)); |
| 2935 | #endif |
| 2936 | bind_method(PackedFloat64Array, find, sarray("value", "from"), varray(0)); |
| 2937 | bind_method(PackedFloat64Array, rfind, sarray("value", "from"), varray(-1)); |
| 2938 | bind_method(PackedFloat64Array, count, sarray("value"), varray()); |
| 2939 | bind_method(PackedFloat64Array, erase, sarray("value"), varray()); |
| 2940 | |
| 2941 | /* String Array */ |
| 2942 | |
| 2943 | bind_method(PackedStringArray, size, sarray(), varray()); |
| 2944 | bind_method(PackedStringArray, is_empty, sarray(), varray()); |
| 2945 | bind_method(PackedStringArray, push_back, sarray("value"), varray()); |
| 2946 | bind_method(PackedStringArray, append, sarray("value"), varray()); |
| 2947 | bind_method(PackedStringArray, append_array, sarray("array"), varray()); |
| 2948 | bind_method(PackedStringArray, remove_at, sarray("index"), varray()); |
| 2949 | bind_method(PackedStringArray, insert, sarray("at_index", "value"), varray()); |
| 2950 | bind_method(PackedStringArray, fill, sarray("value"), varray()); |
| 2951 | bind_methodv(PackedStringArray, resize, &PackedStringArray::resize_initialized, sarray("new_size"), varray()); |
| 2952 | bind_method(PackedStringArray, clear, sarray(), varray()); |
| 2953 | bind_method(PackedStringArray, has, sarray("value"), varray()); |
| 2954 | bind_method(PackedStringArray, reverse, sarray(), varray()); |
| 2955 | bind_method(PackedStringArray, slice, sarray("begin", "end"), varray(INT_MAX)); |
| 2956 | bind_function(PackedStringArray, to_byte_array, _VariantCall::func_PackedStringArray_to_byte_array, sarray(), varray()); |
| 2957 | bind_method(PackedStringArray, sort, sarray(), varray()); |
| 2958 | bind_method(PackedStringArray, bsearch, sarray("value", "before"), varray(true)); |
| 2959 | bind_method(PackedStringArray, duplicate, sarray(), varray()); |
| 2960 | #ifndef DISABLE_DEPRECATED |
| 2961 | bind_compat_functionnc(PackedStringArray, duplicate, _duplicate_bind_compat_112290, _VariantCall::_duplicate_bind_compat_112290<String>, sarray(), varray()); |
| 2962 | bind_compat_functionnc(PackedStringArray, bsearch, _bsearch_bind_compat_112539, _VariantCall::_bsearch_bind_compat_112539<String>, sarray("value", "before"), varray(true)); |
| 2963 | #endif |
| 2964 | bind_method(PackedStringArray, find, sarray("value", "from"), varray(0)); |
| 2965 | bind_method(PackedStringArray, rfind, sarray("value", "from"), varray(-1)); |
| 2966 | bind_method(PackedStringArray, count, sarray("value"), varray()); |
| 2967 | bind_method(PackedStringArray, erase, sarray("value"), varray()); |
| 2968 | |
| 2969 | /* Vector2 Array */ |
| 2970 | |
| 2971 | bind_method(PackedVector2Array, size, sarray(), varray()); |
| 2972 | bind_method(PackedVector2Array, is_empty, sarray(), varray()); |
| 2973 | bind_method(PackedVector2Array, push_back, sarray("value"), varray()); |
| 2974 | bind_method(PackedVector2Array, append, sarray("value"), varray()); |
| 2975 | bind_method(PackedVector2Array, append_array, sarray("array"), varray()); |
| 2976 | bind_method(PackedVector2Array, remove_at, sarray("index"), varray()); |
| 2977 | bind_method(PackedVector2Array, insert, sarray("at_index", "value"), varray()); |
| 2978 | bind_method(PackedVector2Array, fill, sarray("value"), varray()); |
| 2979 | bind_methodv(PackedVector2Array, resize, &PackedVector2Array::resize_initialized, sarray("new_size"), varray()); |
| 2980 | bind_method(PackedVector2Array, clear, sarray(), varray()); |
| 2981 | bind_method(PackedVector2Array, has, sarray("value"), varray()); |
| 2982 | bind_method(PackedVector2Array, reverse, sarray(), varray()); |
| 2983 | bind_method(PackedVector2Array, slice, sarray("begin", "end"), varray(INT_MAX)); |
| 2984 | bind_method(PackedVector2Array, to_byte_array, sarray(), varray()); |
| 2985 | bind_method(PackedVector2Array, sort, sarray(), varray()); |
| 2986 | bind_method(PackedVector2Array, bsearch, sarray("value", "before"), varray(true)); |
| 2987 | bind_method(PackedVector2Array, duplicate, sarray(), varray()); |
| 2988 | #ifndef DISABLE_DEPRECATED |
| 2989 | bind_compat_functionnc(PackedVector2Array, duplicate, _duplicate_bind_compat_112290, _VariantCall::_duplicate_bind_compat_112290<Vector2>, sarray(), varray()); |
| 2990 | bind_compat_functionnc(PackedVector2Array, bsearch, _bsearch_bind_compat_112539, _VariantCall::_bsearch_bind_compat_112539<Vector2>, sarray("value", "before"), varray(true)); |
| 2991 | #endif |
| 2992 | bind_method(PackedVector2Array, find, sarray("value", "from"), varray(0)); |
| 2993 | bind_method(PackedVector2Array, rfind, sarray("value", "from"), varray(-1)); |
| 2994 | bind_method(PackedVector2Array, count, sarray("value"), varray()); |
| 2995 | bind_method(PackedVector2Array, erase, sarray("value"), varray()); |
| 2996 | |
| 2997 | /* Vector3 Array */ |
| 2998 | |
| 2999 | bind_method(PackedVector3Array, size, sarray(), varray()); |
| 3000 | bind_method(PackedVector3Array, is_empty, sarray(), varray()); |
| 3001 | bind_method(PackedVector3Array, push_back, sarray("value"), varray()); |
| 3002 | bind_method(PackedVector3Array, append, sarray("value"), varray()); |
| 3003 | bind_method(PackedVector3Array, append_array, sarray("array"), varray()); |
| 3004 | bind_method(PackedVector3Array, remove_at, sarray("index"), varray()); |
| 3005 | bind_method(PackedVector3Array, insert, sarray("at_index", "value"), varray()); |
| 3006 | bind_method(PackedVector3Array, fill, sarray("value"), varray()); |
| 3007 | bind_methodv(PackedVector3Array, resize, &PackedVector3Array::resize_initialized, sarray("new_size"), varray()); |
| 3008 | bind_method(PackedVector3Array, clear, sarray(), varray()); |
| 3009 | bind_method(PackedVector3Array, has, sarray("value"), varray()); |
| 3010 | bind_method(PackedVector3Array, reverse, sarray(), varray()); |
| 3011 | bind_method(PackedVector3Array, slice, sarray("begin", "end"), varray(INT_MAX)); |
| 3012 | bind_method(PackedVector3Array, to_byte_array, sarray(), varray()); |
| 3013 | bind_method(PackedVector3Array, sort, sarray(), varray()); |
| 3014 | bind_method(PackedVector3Array, bsearch, sarray("value", "before"), varray(true)); |
| 3015 | bind_method(PackedVector3Array, duplicate, sarray(), varray()); |
| 3016 | #ifndef DISABLE_DEPRECATED |
| 3017 | bind_compat_functionnc(PackedVector3Array, duplicate, _duplicate_bind_compat_112290, _VariantCall::_duplicate_bind_compat_112290<Vector3>, sarray(), varray()); |
| 3018 | bind_compat_functionnc(PackedVector3Array, bsearch, _bsearch_bind_compat_112539, _VariantCall::_bsearch_bind_compat_112539<Vector3>, sarray("value", "before"), varray(true)); |
| 3019 | #endif |
| 3020 | bind_method(PackedVector3Array, find, sarray("value", "from"), varray(0)); |
| 3021 | bind_method(PackedVector3Array, rfind, sarray("value", "from"), varray(-1)); |
| 3022 | bind_method(PackedVector3Array, count, sarray("value"), varray()); |
| 3023 | bind_method(PackedVector3Array, erase, sarray("value"), varray()); |
| 3024 | |
| 3025 | /* Color Array */ |
| 3026 | |
| 3027 | bind_method(PackedColorArray, size, sarray(), varray()); |
| 3028 | bind_method(PackedColorArray, is_empty, sarray(), varray()); |
| 3029 | bind_method(PackedColorArray, push_back, sarray("value"), varray()); |
| 3030 | bind_method(PackedColorArray, append, sarray("value"), varray()); |
| 3031 | bind_method(PackedColorArray, append_array, sarray("array"), varray()); |
| 3032 | bind_method(PackedColorArray, remove_at, sarray("index"), varray()); |
| 3033 | bind_method(PackedColorArray, insert, sarray("at_index", "value"), varray()); |
| 3034 | bind_method(PackedColorArray, fill, sarray("value"), varray()); |
| 3035 | bind_methodv(PackedColorArray, resize, &PackedColorArray::resize_initialized, sarray("new_size"), varray()); |
| 3036 | bind_method(PackedColorArray, clear, sarray(), varray()); |
| 3037 | bind_method(PackedColorArray, has, sarray("value"), varray()); |
| 3038 | bind_method(PackedColorArray, reverse, sarray(), varray()); |
| 3039 | bind_method(PackedColorArray, slice, sarray("begin", "end"), varray(INT_MAX)); |
| 3040 | bind_method(PackedColorArray, to_byte_array, sarray(), varray()); |
| 3041 | bind_method(PackedColorArray, sort, sarray(), varray()); |
| 3042 | bind_method(PackedColorArray, bsearch, sarray("value", "before"), varray(true)); |
| 3043 | bind_method(PackedColorArray, duplicate, sarray(), varray()); |
| 3044 | #ifndef DISABLE_DEPRECATED |
| 3045 | bind_compat_functionnc(PackedColorArray, duplicate, _duplicate_bind_compat_112290, _VariantCall::_duplicate_bind_compat_112290<Color>, sarray(), varray()); |
| 3046 | bind_compat_functionnc(PackedColorArray, bsearch, _bsearch_bind_compat_112539, _VariantCall::_bsearch_bind_compat_112539<Color>, sarray("value", "before"), varray(true)); |
| 3047 | #endif |
| 3048 | bind_method(PackedColorArray, find, sarray("value", "from"), varray(0)); |
| 3049 | bind_method(PackedColorArray, rfind, sarray("value", "from"), varray(-1)); |
| 3050 | bind_method(PackedColorArray, count, sarray("value"), varray()); |
| 3051 | bind_method(PackedColorArray, erase, sarray("value"), varray()); |
| 3052 | |
| 3053 | /* Vector4 Array */ |
| 3054 | |
| 3055 | bind_method(PackedVector4Array, size, sarray(), varray()); |
| 3056 | bind_method(PackedVector4Array, is_empty, sarray(), varray()); |
| 3057 | bind_method(PackedVector4Array, push_back, sarray("value"), varray()); |
| 3058 | bind_method(PackedVector4Array, append, sarray("value"), varray()); |
| 3059 | bind_method(PackedVector4Array, append_array, sarray("array"), varray()); |
| 3060 | bind_method(PackedVector4Array, remove_at, sarray("index"), varray()); |
| 3061 | bind_method(PackedVector4Array, insert, sarray("at_index", "value"), varray()); |
| 3062 | bind_method(PackedVector4Array, fill, sarray("value"), varray()); |
| 3063 | bind_methodv(PackedVector4Array, resize, &PackedVector4Array::resize_initialized, sarray("new_size"), varray()); |
| 3064 | bind_method(PackedVector4Array, clear, sarray(), varray()); |
| 3065 | bind_method(PackedVector4Array, has, sarray("value"), varray()); |
| 3066 | bind_method(PackedVector4Array, reverse, sarray(), varray()); |
| 3067 | bind_method(PackedVector4Array, slice, sarray("begin", "end"), varray(INT_MAX)); |
| 3068 | bind_method(PackedVector4Array, to_byte_array, sarray(), varray()); |
| 3069 | bind_method(PackedVector4Array, sort, sarray(), varray()); |
| 3070 | bind_method(PackedVector4Array, bsearch, sarray("value", "before"), varray(true)); |
| 3071 | bind_method(PackedVector4Array, duplicate, sarray(), varray()); |
| 3072 | #ifndef DISABLE_DEPRECATED |
| 3073 | bind_compat_functionnc(PackedVector4Array, duplicate, _duplicate_bind_compat_112290, _VariantCall::_duplicate_bind_compat_112290<Vector4>, sarray(), varray()); |
| 3074 | bind_compat_functionnc(PackedVector4Array, bsearch, _bsearch_bind_compat_112539, _VariantCall::_bsearch_bind_compat_112539<Vector4>, sarray("value", "before"), varray(true)); |
| 3075 | #endif |
| 3076 | bind_method(PackedVector4Array, find, sarray("value", "from"), varray(0)); |
| 3077 | bind_method(PackedVector4Array, rfind, sarray("value", "from"), varray(-1)); |
| 3078 | bind_method(PackedVector4Array, count, sarray("value"), varray()); |
| 3079 | bind_method(PackedVector4Array, erase, sarray("value"), varray()); |
| 3080 | } |
| 3081 | |
| 3082 | static void _register_variant_builtin_constants() { |
| 3083 | /* Register constants */ |
| 3084 | |
| 3085 | int ncc = Color::get_named_color_count(); |
| 3086 | for (int i = 0; i < ncc; i++) { |
| 3087 | _VariantCall::add_variant_constant(Variant::COLOR, Color::get_named_color_name(i), Color::get_named_color(i)); |
| 3088 | } |
| 3089 | |
| 3090 | _VariantCall::add_enum_constant(Variant::VECTOR3, "Axis", "AXIS_X", Vector3::AXIS_X); |
| 3091 | _VariantCall::add_enum_constant(Variant::VECTOR3, "Axis", "AXIS_Y", Vector3::AXIS_Y); |
| 3092 | _VariantCall::add_enum_constant(Variant::VECTOR3, "Axis", "AXIS_Z", Vector3::AXIS_Z); |
| 3093 | |
| 3094 | _VariantCall::add_variant_constant(Variant::VECTOR3, "ZERO", Vector3(0, 0, 0)); |
| 3095 | _VariantCall::add_variant_constant(Variant::VECTOR3, "ONE", Vector3(1, 1, 1)); |
| 3096 | _VariantCall::add_variant_constant(Variant::VECTOR3, "INF", Vector3(Math::INF, Math::INF, Math::INF)); |
| 3097 | _VariantCall::add_variant_constant(Variant::VECTOR3, "LEFT", Vector3::LEFT); |
| 3098 | _VariantCall::add_variant_constant(Variant::VECTOR3, "RIGHT", Vector3::RIGHT); |
| 3099 | _VariantCall::add_variant_constant(Variant::VECTOR3, "UP", Vector3::UP); |
| 3100 | _VariantCall::add_variant_constant(Variant::VECTOR3, "DOWN", Vector3::DOWN); |
| 3101 | _VariantCall::add_variant_constant(Variant::VECTOR3, "FORWARD", Vector3::FORWARD); |
| 3102 | _VariantCall::add_variant_constant(Variant::VECTOR3, "BACK", Vector3::BACK); |
| 3103 | |
| 3104 | _VariantCall::add_variant_constant(Variant::VECTOR3, "MODEL_LEFT", Vector3::MODEL_LEFT); |
| 3105 | _VariantCall::add_variant_constant(Variant::VECTOR3, "MODEL_RIGHT", Vector3::MODEL_RIGHT); |
| 3106 | _VariantCall::add_variant_constant(Variant::VECTOR3, "MODEL_TOP", Vector3::MODEL_TOP); |
| 3107 | _VariantCall::add_variant_constant(Variant::VECTOR3, "MODEL_BOTTOM", Vector3::MODEL_BOTTOM); |
| 3108 | _VariantCall::add_variant_constant(Variant::VECTOR3, "MODEL_FRONT", Vector3::MODEL_FRONT); |
| 3109 | _VariantCall::add_variant_constant(Variant::VECTOR3, "MODEL_REAR", Vector3::MODEL_REAR); |
| 3110 | |
| 3111 | _VariantCall::add_enum_constant(Variant::VECTOR4, "Axis", "AXIS_X", Vector4::AXIS_X); |
| 3112 | _VariantCall::add_enum_constant(Variant::VECTOR4, "Axis", "AXIS_Y", Vector4::AXIS_Y); |
| 3113 | _VariantCall::add_enum_constant(Variant::VECTOR4, "Axis", "AXIS_Z", Vector4::AXIS_Z); |
| 3114 | _VariantCall::add_enum_constant(Variant::VECTOR4, "Axis", "AXIS_W", Vector4::AXIS_W); |
| 3115 | |
| 3116 | _VariantCall::add_variant_constant(Variant::VECTOR4, "ZERO", Vector4(0, 0, 0, 0)); |
| 3117 | _VariantCall::add_variant_constant(Variant::VECTOR4, "ONE", Vector4(1, 1, 1, 1)); |
| 3118 | _VariantCall::add_variant_constant(Variant::VECTOR4, "INF", Vector4(Math::INF, Math::INF, Math::INF, Math::INF)); |
| 3119 | |
| 3120 | _VariantCall::add_enum_constant(Variant::VECTOR3I, "Axis", "AXIS_X", Vector3i::AXIS_X); |
| 3121 | _VariantCall::add_enum_constant(Variant::VECTOR3I, "Axis", "AXIS_Y", Vector3i::AXIS_Y); |
| 3122 | _VariantCall::add_enum_constant(Variant::VECTOR3I, "Axis", "AXIS_Z", Vector3i::AXIS_Z); |
| 3123 | |
| 3124 | _VariantCall::add_enum_constant(Variant::VECTOR4I, "Axis", "AXIS_X", Vector4i::AXIS_X); |
| 3125 | _VariantCall::add_enum_constant(Variant::VECTOR4I, "Axis", "AXIS_Y", Vector4i::AXIS_Y); |
| 3126 | _VariantCall::add_enum_constant(Variant::VECTOR4I, "Axis", "AXIS_Z", Vector4i::AXIS_Z); |
| 3127 | _VariantCall::add_enum_constant(Variant::VECTOR4I, "Axis", "AXIS_W", Vector4i::AXIS_W); |
| 3128 | |
| 3129 | _VariantCall::add_variant_constant(Variant::VECTOR4I, "ZERO", Vector4i(0, 0, 0, 0)); |
| 3130 | _VariantCall::add_variant_constant(Variant::VECTOR4I, "ONE", Vector4i(1, 1, 1, 1)); |
| 3131 | _VariantCall::add_variant_constant(Variant::VECTOR4I, "MIN", Vector4i(INT32_MIN, INT32_MIN, INT32_MIN, INT32_MIN)); |
| 3132 | _VariantCall::add_variant_constant(Variant::VECTOR4I, "MAX", Vector4i(INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX)); |
| 3133 | |
| 3134 | _VariantCall::add_variant_constant(Variant::VECTOR3I, "ZERO", Vector3i(0, 0, 0)); |
| 3135 | _VariantCall::add_variant_constant(Variant::VECTOR3I, "ONE", Vector3i(1, 1, 1)); |
| 3136 | _VariantCall::add_variant_constant(Variant::VECTOR3I, "MIN", Vector3i(INT32_MIN, INT32_MIN, INT32_MIN)); |
| 3137 | _VariantCall::add_variant_constant(Variant::VECTOR3I, "MAX", Vector3i(INT32_MAX, INT32_MAX, INT32_MAX)); |
| 3138 | _VariantCall::add_variant_constant(Variant::VECTOR3I, "LEFT", Vector3i::LEFT); |
| 3139 | _VariantCall::add_variant_constant(Variant::VECTOR3I, "RIGHT", Vector3i::RIGHT); |
| 3140 | _VariantCall::add_variant_constant(Variant::VECTOR3I, "UP", Vector3i::UP); |
| 3141 | _VariantCall::add_variant_constant(Variant::VECTOR3I, "DOWN", Vector3i::DOWN); |
| 3142 | _VariantCall::add_variant_constant(Variant::VECTOR3I, "FORWARD", Vector3i::FORWARD); |
| 3143 | _VariantCall::add_variant_constant(Variant::VECTOR3I, "BACK", Vector3i::BACK); |
| 3144 | |
| 3145 | _VariantCall::add_enum_constant(Variant::VECTOR2, "Axis", "AXIS_X", Vector2::AXIS_X); |
| 3146 | _VariantCall::add_enum_constant(Variant::VECTOR2, "Axis", "AXIS_Y", Vector2::AXIS_Y); |
| 3147 | |
| 3148 | _VariantCall::add_enum_constant(Variant::VECTOR2I, "Axis", "AXIS_X", Vector2i::AXIS_X); |
| 3149 | _VariantCall::add_enum_constant(Variant::VECTOR2I, "Axis", "AXIS_Y", Vector2i::AXIS_Y); |
| 3150 | |
| 3151 | _VariantCall::add_variant_constant(Variant::VECTOR2, "ZERO", Vector2(0, 0)); |
| 3152 | _VariantCall::add_variant_constant(Variant::VECTOR2, "ONE", Vector2(1, 1)); |
| 3153 | _VariantCall::add_variant_constant(Variant::VECTOR2, "INF", Vector2(Math::INF, Math::INF)); |
| 3154 | _VariantCall::add_variant_constant(Variant::VECTOR2, "LEFT", Vector2::LEFT); |
| 3155 | _VariantCall::add_variant_constant(Variant::VECTOR2, "RIGHT", Vector2::RIGHT); |
| 3156 | _VariantCall::add_variant_constant(Variant::VECTOR2, "UP", Vector2::UP); |
| 3157 | _VariantCall::add_variant_constant(Variant::VECTOR2, "DOWN", Vector2::DOWN); |
| 3158 | |
| 3159 | _VariantCall::add_variant_constant(Variant::VECTOR2I, "ZERO", Vector2i(0, 0)); |
| 3160 | _VariantCall::add_variant_constant(Variant::VECTOR2I, "ONE", Vector2i(1, 1)); |
| 3161 | _VariantCall::add_variant_constant(Variant::VECTOR2I, "MIN", Vector2i(INT32_MIN, INT32_MIN)); |
| 3162 | _VariantCall::add_variant_constant(Variant::VECTOR2I, "MAX", Vector2i(INT32_MAX, INT32_MAX)); |
| 3163 | _VariantCall::add_variant_constant(Variant::VECTOR2I, "LEFT", Vector2i::LEFT); |
| 3164 | _VariantCall::add_variant_constant(Variant::VECTOR2I, "RIGHT", Vector2i::RIGHT); |
| 3165 | _VariantCall::add_variant_constant(Variant::VECTOR2I, "UP", Vector2i::UP); |
| 3166 | _VariantCall::add_variant_constant(Variant::VECTOR2I, "DOWN", Vector2i::DOWN); |
| 3167 | |
| 3168 | _VariantCall::add_variant_constant(Variant::TRANSFORM2D, "IDENTITY", Transform2D()); |
| 3169 | _VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_X", Transform2D::FLIP_X); |
| 3170 | _VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_Y", Transform2D::FLIP_Y); |
| 3171 | |
| 3172 | _VariantCall::add_variant_constant(Variant::TRANSFORM3D, "IDENTITY", Transform3D()); |
| 3173 | _VariantCall::add_variant_constant(Variant::TRANSFORM3D, "FLIP_X", Transform3D::FLIP_X); |
| 3174 | _VariantCall::add_variant_constant(Variant::TRANSFORM3D, "FLIP_Y", Transform3D::FLIP_Y); |
| 3175 | _VariantCall::add_variant_constant(Variant::TRANSFORM3D, "FLIP_Z", Transform3D::FLIP_Z); |
| 3176 | |
| 3177 | _VariantCall::add_variant_constant(Variant::BASIS, "IDENTITY", Basis()); |
| 3178 | _VariantCall::add_variant_constant(Variant::BASIS, "FLIP_X", Basis::FLIP_X); |
| 3179 | _VariantCall::add_variant_constant(Variant::BASIS, "FLIP_Y", Basis::FLIP_Y); |
| 3180 | _VariantCall::add_variant_constant(Variant::BASIS, "FLIP_Z", Basis::FLIP_Z); |
| 3181 | |
| 3182 | _VariantCall::add_variant_constant(Variant::PLANE, "PLANE_YZ", Plane::PLANE_YZ); |
| 3183 | _VariantCall::add_variant_constant(Variant::PLANE, "PLANE_XZ", Plane::PLANE_XZ); |
| 3184 | _VariantCall::add_variant_constant(Variant::PLANE, "PLANE_XY", Plane::PLANE_XY); |
| 3185 | |
| 3186 | _VariantCall::add_variant_constant(Variant::QUATERNION, "IDENTITY", Quaternion()); |
| 3187 | |
| 3188 | _VariantCall::add_enum_constant(Variant::PROJECTION, "Planes", "PLANE_NEAR", Projection::PLANE_NEAR); |
| 3189 | _VariantCall::add_enum_constant(Variant::PROJECTION, "Planes", "PLANE_FAR", Projection::PLANE_FAR); |
| 3190 | _VariantCall::add_enum_constant(Variant::PROJECTION, "Planes", "PLANE_LEFT", Projection::PLANE_LEFT); |
| 3191 | _VariantCall::add_enum_constant(Variant::PROJECTION, "Planes", "PLANE_TOP", Projection::PLANE_TOP); |
| 3192 | _VariantCall::add_enum_constant(Variant::PROJECTION, "Planes", "PLANE_RIGHT", Projection::PLANE_RIGHT); |
| 3193 | _VariantCall::add_enum_constant(Variant::PROJECTION, "Planes", "PLANE_BOTTOM", Projection::PLANE_BOTTOM); |
| 3194 | |
| 3195 | Projection p; |
| 3196 | _VariantCall::add_variant_constant(Variant::PROJECTION, "IDENTITY", p); |
| 3197 | p.set_zero(); |
| 3198 | _VariantCall::add_variant_constant(Variant::PROJECTION, "ZERO", p); |
| 3199 | } |
| 3200 | |
| 3201 | void Variant::_register_variant_methods() { |
| 3202 | _register_variant_builtin_methods_string(); |
| 3203 | _register_variant_builtin_methods_math(); |
| 3204 | _register_variant_builtin_methods_misc(); |
| 3205 | _register_variant_builtin_methods_array(); |
| 3206 | _register_variant_builtin_constants(); |
| 3207 | } |
| 3208 | |
| 3209 | void Variant::_unregister_variant_methods() { |
| 3210 | //clear methods |
| 3211 | memdelete_arr(builtin_method_names); |
| 3212 | memdelete_arr(builtin_method_info); |
| 3213 | #ifndef DISABLE_DEPRECATED |
| 3214 | memdelete_arr(builtin_compat_method_info); |
| 3215 | #endif |
| 3216 | memdelete_arr(_VariantCall::constant_data); |
| 3217 | memdelete_arr(_VariantCall::enum_data); |
| 3218 | } |