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