2014-02-10 02:10:30 +01:00
/*************************************************************************/
/* variant_call.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
2017-08-27 14:16:55 +02:00
/* https://godotengine.org */
2014-02-10 02:10:30 +01:00
/*************************************************************************/
2022-01-03 21:27:34 +01:00
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
2014-02-10 02:10:30 +01:00
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
2018-01-05 00:50:27 +01:00
2014-02-10 02:10:30 +01:00
# include "variant.h"
2017-01-16 08:04:19 +01:00
2018-09-11 18:13:45 +02:00
# include "core/core_string_names.h"
2019-07-11 15:21:47 +02:00
# include "core/crypto/crypto_core.h"
2020-02-27 03:30:20 +01:00
# include "core/debugger/engine_debugger.h"
2018-09-11 18:13:45 +02:00
# include "core/io/compression.h"
Add marshalling to PackedByteArray
-Decode/Encode functions for u8,s8,u16,s16,u32,s32,u64,s64,half,float,double,variant
-Improved binder template to allow this
Given in Godot 4.0 PackedByteArray is passed as reference, it is now possible to have these functions there, which makes the most sense.
2021-04-09 22:57:37 +02:00
# include "core/io/marshalls.h"
2020-11-07 23:33:38 +01:00
# include "core/object/class_db.h"
2018-09-11 18:13:45 +02:00
# include "core/os/os.h"
2020-11-11 17:16:08 +01:00
# include "core/templates/local_vector.h"
2020-11-07 23:33:38 +01:00
# include "core/templates/oa_hash_map.h"
2014-02-10 02:10:30 +01:00
typedef void ( * VariantFunc ) ( Variant & r_ret , Variant & p_self , const Variant * * p_args ) ;
typedef void ( * VariantConstructFunc ) ( Variant & r_ret , const Variant * * p_args ) ;
2021-02-24 14:56:34 +01:00
template < class R , class . . . P >
static _FORCE_INLINE_ void vc_static_method_call ( R ( * method ) ( P . . . ) , const Variant * * p_args , int p_argcount , Variant & r_ret , const Vector < Variant > & p_defvals , Callable : : CallError & r_error ) {
call_with_variant_args_static_ret_dv ( method , p_args , p_argcount , r_ret , r_error , p_defvals ) ;
}
template < class . . . P >
static _FORCE_INLINE_ void vc_static_method_call ( void ( * method ) ( P . . . ) , const Variant * * p_args , int p_argcount , Variant & r_ret , const Vector < Variant > & p_defvals , Callable : : CallError & r_error ) {
call_with_variant_args_static_dv ( method , p_args , p_argcount , r_error , p_defvals ) ;
}
2020-11-11 17:16:08 +01:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ void vc_method_call ( R ( T : : * method ) ( P . . . ) , Variant * base , const Variant * * p_args , int p_argcount , Variant & r_ret , const Vector < Variant > & p_defvals , Callable : : CallError & r_error ) {
call_with_variant_args_ret_dv ( VariantGetInternalPtr < T > : : get_ptr ( base ) , method , p_args , p_argcount , r_ret , r_error , p_defvals ) ;
}
2020-10-13 20:59:37 +02:00
2020-11-11 17:16:08 +01:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ void vc_method_call ( R ( T : : * method ) ( P . . . ) const , Variant * base , const Variant * * p_args , int p_argcount , Variant & r_ret , const Vector < Variant > & p_defvals , Callable : : CallError & r_error ) {
call_with_variant_args_retc_dv ( VariantGetInternalPtr < T > : : get_ptr ( base ) , method , p_args , p_argcount , r_ret , r_error , p_defvals ) ;
}
2014-02-10 02:10:30 +01:00
2020-11-11 17:16:08 +01:00
template < class T , class . . . P >
static _FORCE_INLINE_ void vc_method_call ( void ( T : : * method ) ( P . . . ) , Variant * base , const Variant * * p_args , int p_argcount , Variant & r_ret , const Vector < Variant > & p_defvals , Callable : : CallError & r_error ) {
call_with_variant_args_dv ( VariantGetInternalPtr < T > : : get_ptr ( base ) , method , p_args , p_argcount , r_error , p_defvals ) ;
}
2014-02-10 02:10:30 +01:00
2020-11-11 17:16:08 +01:00
template < class T , class . . . P >
static _FORCE_INLINE_ void vc_method_call ( void ( T : : * method ) ( P . . . ) const , Variant * base , const Variant * * p_args , int p_argcount , Variant & r_ret , const Vector < Variant > & p_defvals , Callable : : CallError & r_error ) {
call_with_variant_argsc_dv ( VariantGetInternalPtr < T > : : get_ptr ( base ) , method , p_args , p_argcount , r_error , p_defvals ) ;
}
2014-02-10 02:10:30 +01:00
Add marshalling to PackedByteArray
-Decode/Encode functions for u8,s8,u16,s16,u32,s32,u64,s64,half,float,double,variant
-Improved binder template to allow this
Given in Godot 4.0 PackedByteArray is passed as reference, it is now possible to have these functions there, which makes the most sense.
2021-04-09 22:57:37 +02:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ void vc_method_call_static ( R ( * method ) ( T * , P . . . ) , Variant * base , const Variant * * p_args , int p_argcount , Variant & r_ret , const Vector < Variant > & p_defvals , Callable : : CallError & r_error ) {
call_with_variant_args_retc_static_helper_dv ( VariantGetInternalPtr < T > : : get_ptr ( base ) , method , p_args , p_argcount , r_ret , p_defvals , r_error ) ;
}
template < class T , class . . . P >
static _FORCE_INLINE_ void vc_method_call_static ( void ( * method ) ( T * , P . . . ) , Variant * base , const Variant * * p_args , int p_argcount , Variant & r_ret , const Vector < Variant > & p_defvals , Callable : : CallError & r_error ) {
call_with_variant_args_static_helper_dv ( VariantGetInternalPtr < T > : : get_ptr ( base ) , method , p_args , p_argcount , p_defvals , r_error ) ;
}
2020-11-11 17:16:08 +01:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ void vc_validated_call ( R ( T : : * method ) ( P . . . ) , Variant * base , const Variant * * p_args , Variant * r_ret ) {
call_with_validated_variant_args_ret ( base , method , p_args , r_ret ) ;
}
2014-02-10 02:10:30 +01:00
2020-11-11 17:16:08 +01:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ void vc_validated_call ( R ( T : : * method ) ( P . . . ) const , Variant * base , const Variant * * p_args , Variant * r_ret ) {
call_with_validated_variant_args_retc ( base , method , p_args , r_ret ) ;
}
template < class T , class . . . P >
static _FORCE_INLINE_ void vc_validated_call ( void ( T : : * method ) ( P . . . ) , Variant * base , const Variant * * p_args , Variant * r_ret ) {
call_with_validated_variant_args ( base , method , p_args ) ;
}
2014-02-10 02:10:30 +01:00
2020-11-11 17:16:08 +01:00
template < class T , class . . . P >
static _FORCE_INLINE_ void vc_validated_call ( void ( T : : * method ) ( P . . . ) const , Variant * base , const Variant * * p_args , Variant * r_ret ) {
call_with_validated_variant_argsc ( base , method , p_args ) ;
}
2017-01-09 02:40:00 +01:00
Add marshalling to PackedByteArray
-Decode/Encode functions for u8,s8,u16,s16,u32,s32,u64,s64,half,float,double,variant
-Improved binder template to allow this
Given in Godot 4.0 PackedByteArray is passed as reference, it is now possible to have these functions there, which makes the most sense.
2021-04-09 22:57:37 +02:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ void vc_validated_call_static ( R ( * method ) ( T * , P . . . ) , Variant * base , const Variant * * p_args , Variant * r_ret ) {
call_with_validated_variant_args_static_retc ( base , method , p_args , r_ret ) ;
}
template < class T , class . . . P >
static _FORCE_INLINE_ void vc_validated_call_static ( void ( * method ) ( T * , P . . . ) , Variant * base , const Variant * * p_args , Variant * r_ret ) {
call_with_validated_variant_args_static ( base , method , p_args ) ;
}
2021-02-24 14:56:34 +01:00
template < class R , class . . . P >
static _FORCE_INLINE_ void vc_validated_static_call ( R ( * method ) ( P . . . ) , const Variant * * p_args , Variant * r_ret ) {
call_with_validated_variant_args_static_method_ret ( method , p_args , r_ret ) ;
}
template < class . . . P >
static _FORCE_INLINE_ void vc_validated_static_call ( void ( * method ) ( P . . . ) , const Variant * * p_args , Variant * r_ret ) {
call_with_validated_variant_args_static_method ( method , p_args ) ;
}
2020-11-11 17:16:08 +01:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ void vc_ptrcall ( R ( T : : * method ) ( P . . . ) , void * p_base , const void * * p_args , void * r_ret ) {
call_with_ptr_args_ret ( reinterpret_cast < T * > ( p_base ) , method , p_args , r_ret ) ;
}
2017-01-09 02:40:00 +01:00
2020-11-11 17:16:08 +01:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ void vc_ptrcall ( R ( T : : * method ) ( P . . . ) const , void * p_base , const void * * p_args , void * r_ret ) {
call_with_ptr_args_retc ( reinterpret_cast < T * > ( p_base ) , method , p_args , r_ret ) ;
}
2014-02-10 02:10:30 +01:00
2020-11-11 17:16:08 +01:00
template < class T , class . . . P >
static _FORCE_INLINE_ void vc_ptrcall ( void ( T : : * method ) ( P . . . ) , void * p_base , const void * * p_args , void * r_ret ) {
call_with_ptr_args ( reinterpret_cast < T * > ( p_base ) , method , p_args ) ;
}
2014-02-10 02:10:30 +01:00
2020-11-11 17:16:08 +01:00
template < class T , class . . . P >
static _FORCE_INLINE_ void vc_ptrcall ( void ( T : : * method ) ( P . . . ) const , void * p_base , const void * * p_args , void * r_ret ) {
call_with_ptr_argsc ( reinterpret_cast < T * > ( p_base ) , method , p_args ) ;
}
2014-02-10 02:10:30 +01:00
2020-11-11 17:16:08 +01:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ int vc_get_argument_count ( R ( T : : * method ) ( P . . . ) ) {
return sizeof . . . ( P ) ;
}
template < class R , class T , class . . . P >
static _FORCE_INLINE_ int vc_get_argument_count ( R ( T : : * method ) ( P . . . ) const ) {
return sizeof . . . ( P ) ;
}
2014-02-10 02:10:30 +01:00
2020-11-11 17:16:08 +01:00
template < class T , class . . . P >
static _FORCE_INLINE_ int vc_get_argument_count ( void ( T : : * method ) ( P . . . ) ) {
return sizeof . . . ( P ) ;
}
2014-02-10 02:10:30 +01:00
2020-11-11 17:16:08 +01:00
template < class T , class . . . P >
static _FORCE_INLINE_ int vc_get_argument_count ( void ( T : : * method ) ( P . . . ) const ) {
return sizeof . . . ( P ) ;
}
2014-02-10 02:10:30 +01:00
2020-11-11 17:16:08 +01:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ int vc_get_argument_count ( R ( * method ) ( T * , P . . . ) ) {
return sizeof . . . ( P ) ;
}
2014-02-10 02:10:30 +01:00
2021-02-24 14:56:34 +01:00
template < class R , class . . . P >
static _FORCE_INLINE_ int vc_get_argument_count_static ( R ( * method ) ( P . . . ) ) {
return sizeof . . . ( P ) ;
}
2020-11-11 17:16:08 +01:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ Variant : : Type vc_get_argument_type ( R ( T : : * method ) ( P . . . ) , int p_arg ) {
return call_get_argument_type < P . . . > ( p_arg ) ;
}
template < class R , class T , class . . . P >
static _FORCE_INLINE_ Variant : : Type vc_get_argument_type ( R ( T : : * method ) ( P . . . ) const , int p_arg ) {
return call_get_argument_type < P . . . > ( p_arg ) ;
}
2014-02-10 02:10:30 +01:00
2020-11-11 17:16:08 +01:00
template < class T , class . . . P >
static _FORCE_INLINE_ Variant : : Type vc_get_argument_type ( void ( T : : * method ) ( P . . . ) , int p_arg ) {
return call_get_argument_type < P . . . > ( p_arg ) ;
}
2015-06-04 01:46:14 +02:00
2020-11-11 17:16:08 +01:00
template < class T , class . . . P >
static _FORCE_INLINE_ Variant : : Type vc_get_argument_type ( void ( T : : * method ) ( P . . . ) const , int p_arg ) {
return call_get_argument_type < P . . . > ( p_arg ) ;
}
2015-06-04 01:46:14 +02:00
2020-11-11 17:16:08 +01:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ Variant : : Type vc_get_argument_type ( R ( * method ) ( T * , P . . . ) , int p_arg ) {
return call_get_argument_type < P . . . > ( p_arg ) ;
}
2015-06-04 01:46:14 +02:00
2021-02-24 14:56:34 +01:00
template < class R , class . . . P >
static _FORCE_INLINE_ Variant : : Type vc_get_argument_type_static ( R ( * method ) ( P . . . ) , int p_arg ) {
return call_get_argument_type < P . . . > ( p_arg ) ;
}
2020-11-11 17:16:08 +01:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ Variant : : Type vc_get_return_type ( R ( T : : * method ) ( P . . . ) ) {
return GetTypeInfo < R > : : VARIANT_TYPE ;
}
2015-06-04 01:46:14 +02:00
2020-11-11 17:16:08 +01:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ Variant : : Type vc_get_return_type ( R ( T : : * method ) ( P . . . ) const ) {
return GetTypeInfo < R > : : VARIANT_TYPE ;
}
2015-06-04 01:46:14 +02:00
2020-11-11 17:16:08 +01:00
template < class T , class . . . P >
static _FORCE_INLINE_ Variant : : Type vc_get_return_type ( void ( T : : * method ) ( P . . . ) ) {
return Variant : : NIL ;
}
2015-06-04 01:46:14 +02:00
2020-11-11 17:16:08 +01:00
template < class T , class . . . P >
static _FORCE_INLINE_ Variant : : Type vc_get_return_type ( void ( T : : * method ) ( P . . . ) const ) {
return Variant : : NIL ;
}
2020-07-27 12:43:20 +02:00
2020-11-11 17:16:08 +01:00
template < class R , class . . . P >
static _FORCE_INLINE_ Variant : : Type vc_get_return_type ( R ( * method ) ( P . . . ) ) {
return GetTypeInfo < R > : : VARIANT_TYPE ;
}
2020-07-27 12:43:20 +02:00
Add marshalling to PackedByteArray
-Decode/Encode functions for u8,s8,u16,s16,u32,s32,u64,s64,half,float,double,variant
-Improved binder template to allow this
Given in Godot 4.0 PackedByteArray is passed as reference, it is now possible to have these functions there, which makes the most sense.
2021-04-09 22:57:37 +02:00
template < class . . . P >
static _FORCE_INLINE_ Variant : : Type vc_get_return_type ( void ( * method ) ( P . . . ) ) {
return Variant : : NIL ;
}
2020-11-11 17:16:08 +01:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ bool vc_has_return_type ( R ( T : : * method ) ( P . . . ) ) {
return true ;
}
template < class R , class T , class . . . P >
static _FORCE_INLINE_ bool vc_has_return_type ( R ( T : : * method ) ( P . . . ) const ) {
return true ;
}
2020-07-27 12:43:20 +02:00
2020-11-11 17:16:08 +01:00
template < class T , class . . . P >
static _FORCE_INLINE_ bool vc_has_return_type ( void ( T : : * method ) ( P . . . ) ) {
return false ;
}
2020-07-27 12:43:20 +02:00
2020-11-11 17:16:08 +01:00
template < class T , class . . . P >
static _FORCE_INLINE_ bool vc_has_return_type ( void ( T : : * method ) ( P . . . ) const ) {
return false ;
}
2014-02-10 02:10:30 +01:00
2021-02-24 14:56:34 +01:00
template < class . . . P >
static _FORCE_INLINE_ bool vc_has_return_type_static ( void ( * method ) ( P . . . ) ) {
return false ;
}
template < class R , class . . . P >
static _FORCE_INLINE_ bool vc_has_return_type_static ( R ( * method ) ( P . . . ) ) {
return true ;
}
2020-11-11 17:16:08 +01:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ bool vc_is_const ( R ( T : : * method ) ( P . . . ) ) {
return false ;
}
template < class R , class T , class . . . P >
static _FORCE_INLINE_ bool vc_is_const ( R ( T : : * method ) ( P . . . ) const ) {
return true ;
}
2020-10-13 20:59:37 +02:00
2020-11-11 17:16:08 +01:00
template < class T , class . . . P >
static _FORCE_INLINE_ bool vc_is_const ( void ( T : : * method ) ( P . . . ) ) {
return false ;
}
2020-10-13 20:59:37 +02:00
2020-11-11 17:16:08 +01:00
template < class T , class . . . P >
static _FORCE_INLINE_ bool vc_is_const ( void ( T : : * method ) ( P . . . ) const ) {
return true ;
}
2020-10-13 20:59:37 +02:00
2020-11-11 17:16:08 +01:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ Variant : : Type vc_get_base_type ( R ( T : : * method ) ( P . . . ) ) {
return GetTypeInfo < T > : : VARIANT_TYPE ;
}
template < class R , class T , class . . . P >
static _FORCE_INLINE_ Variant : : Type vc_get_base_type ( R ( T : : * method ) ( P . . . ) const ) {
return GetTypeInfo < T > : : VARIANT_TYPE ;
}
2020-10-13 20:59:37 +02:00
2020-11-11 17:16:08 +01:00
template < class T , class . . . P >
static _FORCE_INLINE_ Variant : : Type vc_get_base_type ( void ( T : : * method ) ( P . . . ) ) {
return GetTypeInfo < T > : : VARIANT_TYPE ;
}
2014-02-10 02:10:30 +01:00
2020-11-11 17:16:08 +01:00
template < class T , class . . . P >
static _FORCE_INLINE_ Variant : : Type vc_get_base_type ( void ( T : : * method ) ( P . . . ) const ) {
return GetTypeInfo < T > : : VARIANT_TYPE ;
}
2020-10-13 20:59:37 +02:00
2020-11-11 17:16:08 +01:00
# define METHOD_CLASS(m_class, m_method_name, m_method_ptr) \
struct Method_ # # m_class # # _ # # m_method_name { \
static void call ( Variant * base , const Variant * * p_args , int p_argcount , Variant & r_ret , const Vector < Variant > & p_defvals , Callable : : CallError & r_error ) { \
vc_method_call ( m_method_ptr , base , p_args , p_argcount , r_ret , p_defvals , r_error ) ; \
} \
static void validated_call ( Variant * base , const Variant * * p_args , int p_argcount , Variant * r_ret ) { \
vc_validated_call ( m_method_ptr , base , p_args , r_ret ) ; \
} \
static void ptrcall ( void * p_base , const void * * p_args , void * r_ret , int p_argcount ) { \
vc_ptrcall ( m_method_ptr , p_base , p_args , r_ret ) ; \
} \
static int get_argument_count ( ) { \
return vc_get_argument_count ( m_method_ptr ) ; \
} \
static Variant : : Type get_argument_type ( int p_arg ) { \
return vc_get_argument_type ( m_method_ptr , p_arg ) ; \
} \
static Variant : : Type get_return_type ( ) { \
return vc_get_return_type ( m_method_ptr ) ; \
} \
static bool has_return_type ( ) { \
return vc_has_return_type ( m_method_ptr ) ; \
} \
static bool is_const ( ) { \
return vc_is_const ( m_method_ptr ) ; \
} \
2021-02-24 14:56:34 +01:00
static bool is_static ( ) { \
return false ; \
} \
2020-11-11 17:16:08 +01:00
static bool is_vararg ( ) { \
return false ; \
} \
static Variant : : Type get_base_type ( ) { \
return vc_get_base_type ( m_method_ptr ) ; \
} \
static StringName get_name ( ) { \
return # m_method_name ; \
} \
} ;
2020-10-13 20:59:37 +02:00
2021-02-24 14:56:34 +01:00
template < class R , class . . . P >
static _FORCE_INLINE_ void vc_static_ptrcall ( R ( * method ) ( P . . . ) , const void * * p_args , void * r_ret ) {
call_with_ptr_args_static_method_ret < R , P . . . > ( method , p_args , r_ret ) ;
}
template < class . . . P >
static _FORCE_INLINE_ void vc_static_ptrcall ( void ( * method ) ( P . . . ) , const void * * p_args , void * r_ret ) {
call_with_ptr_args_static_method < P . . . > ( method , p_args ) ;
}
# define STATIC_METHOD_CLASS(m_class, m_method_name, m_method_ptr) \
struct Method_ # # m_class # # _ # # m_method_name { \
static void call ( Variant * base , const Variant * * p_args , int p_argcount , Variant & r_ret , const Vector < Variant > & p_defvals , Callable : : CallError & r_error ) { \
vc_static_method_call ( m_method_ptr , p_args , p_argcount , r_ret , p_defvals , r_error ) ; \
} \
static void validated_call ( Variant * base , const Variant * * p_args , int p_argcount , Variant * r_ret ) { \
vc_validated_static_call ( m_method_ptr , p_args , r_ret ) ; \
} \
static void ptrcall ( void * p_base , const void * * p_args , void * r_ret , int p_argcount ) { \
vc_static_ptrcall ( m_method_ptr , p_args , r_ret ) ; \
} \
static int get_argument_count ( ) { \
return vc_get_argument_count_static ( m_method_ptr ) ; \
} \
static Variant : : Type get_argument_type ( int p_arg ) { \
return vc_get_argument_type_static ( m_method_ptr , p_arg ) ; \
} \
static Variant : : Type get_return_type ( ) { \
return vc_get_return_type ( m_method_ptr ) ; \
} \
static bool has_return_type ( ) { \
return vc_has_return_type_static ( m_method_ptr ) ; \
} \
static bool is_const ( ) { \
return false ; \
} \
static bool is_static ( ) { \
return true ; \
} \
static bool is_vararg ( ) { \
return false ; \
} \
static Variant : : Type get_base_type ( ) { \
return GetTypeInfo < m_class > : : VARIANT_TYPE ; \
} \
static StringName get_name ( ) { \
return # m_method_name ; \
} \
} ;
2020-11-11 17:16:08 +01:00
template < class R , class T , class . . . P >
static _FORCE_INLINE_ void vc_ptrcall ( R ( * method ) ( T * , P . . . ) , void * p_base , const void * * p_args , void * r_ret ) {
call_with_ptr_args_static_retc < T , R , P . . . > ( reinterpret_cast < T * > ( p_base ) , method , p_args , r_ret ) ;
}
2020-10-13 20:59:37 +02:00
Add marshalling to PackedByteArray
-Decode/Encode functions for u8,s8,u16,s16,u32,s32,u64,s64,half,float,double,variant
-Improved binder template to allow this
Given in Godot 4.0 PackedByteArray is passed as reference, it is now possible to have these functions there, which makes the most sense.
2021-04-09 22:57:37 +02:00
template < class T , class . . . P >
static _FORCE_INLINE_ void vc_ptrcall ( void ( * method ) ( T * , P . . . ) , void * p_base , const void * * p_args , void * r_ret ) {
call_with_ptr_args_static < T , P . . . > ( reinterpret_cast < T * > ( p_base ) , method , p_args ) ;
}
# define FUNCTION_CLASS(m_class, m_method_name, m_method_ptr, m_const) \
struct Method_ # # m_class # # _ # # m_method_name { \
static void call ( Variant * base , const Variant * * p_args , int p_argcount , Variant & r_ret , const Vector < Variant > & p_defvals , Callable : : CallError & r_error ) { \
vc_method_call_static ( m_method_ptr , base , p_args , p_argcount , r_ret , p_defvals , r_error ) ; \
} \
static void validated_call ( Variant * base , const Variant * * p_args , int p_argcount , Variant * r_ret ) { \
vc_validated_call_static ( m_method_ptr , base , p_args , r_ret ) ; \
} \
static void ptrcall ( void * p_base , const void * * p_args , void * r_ret , int p_argcount ) { \
vc_ptrcall ( m_method_ptr , p_base , p_args , r_ret ) ; \
} \
static int get_argument_count ( ) { \
return vc_get_argument_count ( m_method_ptr ) ; \
} \
static Variant : : Type get_argument_type ( int p_arg ) { \
return vc_get_argument_type ( m_method_ptr , p_arg ) ; \
} \
static Variant : : Type get_return_type ( ) { \
return vc_get_return_type ( m_method_ptr ) ; \
} \
static bool has_return_type ( ) { \
return vc_has_return_type_static ( m_method_ptr ) ; \
} \
static bool is_const ( ) { \
return m_const ; \
} \
static bool is_static ( ) { \
return false ; \
} \
static bool is_vararg ( ) { \
return false ; \
} \
static Variant : : Type get_base_type ( ) { \
return GetTypeInfo < m_class > : : VARIANT_TYPE ; \
} \
static StringName get_name ( ) { \
return # m_method_name ; \
} \
2020-11-11 17:16:08 +01:00
} ;
2020-10-13 20:59:37 +02:00
2020-11-11 17:16:08 +01:00
# define VARARG_CLASS(m_class, m_method_name, m_method_ptr, m_has_return, m_return_type) \
struct Method_ # # m_class # # _ # # m_method_name { \
static void call ( Variant * base , const Variant * * p_args , int p_argcount , Variant & r_ret , const Vector < Variant > & p_defvals , Callable : : CallError & r_error ) { \
m_method_ptr ( base , p_args , p_argcount , r_ret , r_error ) ; \
} \
static void validated_call ( Variant * base , const Variant * * p_args , int p_argcount , Variant * r_ret ) { \
Callable : : CallError ce ; \
m_method_ptr ( base , p_args , p_argcount , * r_ret , ce ) ; \
} \
static void ptrcall ( void * p_base , const void * * p_args , void * r_ret , int p_argcount ) { \
LocalVector < Variant > vars ; \
vars . resize ( p_argcount ) ; \
LocalVector < const Variant * > vars_ptrs ; \
vars_ptrs . resize ( p_argcount ) ; \
for ( int i = 0 ; i < p_argcount ; i + + ) { \
vars [ i ] = PtrToArg < Variant > : : convert ( p_args [ i ] ) ; \
vars_ptrs [ i ] = & vars [ i ] ; \
} \
Variant base = PtrToArg < m_class > : : convert ( p_base ) ; \
Variant ret ; \
Callable : : CallError ce ; \
m_method_ptr ( & base , ( const Variant * * ) & vars_ptrs [ 0 ] , p_argcount , ret , ce ) ; \
if ( m_has_return ) { \
m_return_type r = ret ; \
PtrToArg < m_return_type > : : encode ( ret , r_ret ) ; \
} \
} \
static int get_argument_count ( ) { \
return 0 ; \
} \
static Variant : : Type get_argument_type ( int p_arg ) { \
return Variant : : NIL ; \
} \
static Variant : : Type get_return_type ( ) { \
return GetTypeInfo < m_return_type > : : VARIANT_TYPE ; \
} \
static bool has_return_type ( ) { \
return m_has_return ; \
} \
static bool is_const ( ) { \
return true ; \
} \
2021-02-24 14:56:34 +01:00
static bool is_static ( ) { \
return false ; \
} \
2020-11-11 17:16:08 +01:00
static bool is_vararg ( ) { \
return true ; \
} \
static Variant : : Type get_base_type ( ) { \
return GetTypeInfo < m_class > : : VARIANT_TYPE ; \
} \
static StringName get_name ( ) { \
return # m_method_name ; \
} \
} ;
2020-10-13 20:59:37 +02:00
2021-05-03 23:00:44 +02:00
# define VARARG_CLASS1(m_class, m_method_name, m_method_ptr, m_arg_type) \
struct Method_ # # m_class # # _ # # m_method_name { \
static void call ( Variant * base , const Variant * * p_args , int p_argcount , Variant & r_ret , const Vector < Variant > & p_defvals , Callable : : CallError & r_error ) { \
m_method_ptr ( base , p_args , p_argcount , r_ret , r_error ) ; \
} \
static void validated_call ( Variant * base , const Variant * * p_args , int p_argcount , Variant * r_ret ) { \
Callable : : CallError ce ; \
m_method_ptr ( base , p_args , p_argcount , * r_ret , ce ) ; \
} \
static void ptrcall ( void * p_base , const void * * p_args , void * r_ret , int p_argcount ) { \
LocalVector < Variant > vars ; \
vars . resize ( p_argcount ) ; \
LocalVector < const Variant * > vars_ptrs ; \
vars_ptrs . resize ( p_argcount ) ; \
for ( int i = 0 ; i < p_argcount ; i + + ) { \
vars [ i ] = PtrToArg < Variant > : : convert ( p_args [ i ] ) ; \
vars_ptrs [ i ] = & vars [ i ] ; \
} \
Variant base = PtrToArg < m_class > : : convert ( p_base ) ; \
Variant ret ; \
Callable : : CallError ce ; \
m_method_ptr ( & base , ( const Variant * * ) & vars_ptrs [ 0 ] , p_argcount , ret , ce ) ; \
} \
static int get_argument_count ( ) { \
return 1 ; \
} \
static Variant : : Type get_argument_type ( int p_arg ) { \
return m_arg_type ; \
} \
static Variant : : Type get_return_type ( ) { \
return Variant : : NIL ; \
} \
static bool has_return_type ( ) { \
return false ; \
} \
static bool is_const ( ) { \
return true ; \
} \
static bool is_static ( ) { \
return false ; \
} \
static bool is_vararg ( ) { \
return true ; \
} \
static Variant : : Type get_base_type ( ) { \
return GetTypeInfo < m_class > : : VARIANT_TYPE ; \
} \
static StringName get_name ( ) { \
return # m_method_name ; \
} \
} ;
2020-11-11 17:16:08 +01:00
struct _VariantCall {
2020-10-13 20:59:37 +02:00
static String func_PackedByteArray_get_string_from_ascii ( PackedByteArray * p_instance ) {
2014-02-10 02:10:30 +01:00
String s ;
2020-10-13 20:59:37 +02:00
if ( p_instance - > size ( ) > 0 ) {
const uint8_t * r = p_instance - > ptr ( ) ;
2014-02-10 02:10:30 +01:00
CharString cs ;
2020-10-13 20:59:37 +02:00
cs . resize ( p_instance - > size ( ) + 1 ) ;
2021-04-27 16:19:21 +02:00
memcpy ( cs . ptrw ( ) , r , p_instance - > size ( ) ) ;
2020-10-13 20:59:37 +02:00
cs [ p_instance - > size ( ) ] = 0 ;
2014-02-10 02:10:30 +01:00
s = cs . get_data ( ) ;
}
2020-10-13 20:59:37 +02:00
return s ;
2014-02-10 02:10:30 +01:00
}
2020-10-13 20:59:37 +02:00
static String func_PackedByteArray_get_string_from_utf8 ( PackedByteArray * p_instance ) {
2014-02-10 02:10:30 +01:00
String s ;
2020-10-13 20:59:37 +02:00
if ( p_instance - > size ( ) > 0 ) {
const uint8_t * r = p_instance - > ptr ( ) ;
s . parse_utf8 ( ( const char * ) r , p_instance - > size ( ) ) ;
2014-02-10 02:10:30 +01:00
}
2020-10-13 20:59:37 +02:00
return s ;
2014-02-10 02:10:30 +01:00
}
2020-10-13 20:59:37 +02:00
static String func_PackedByteArray_get_string_from_utf16 ( PackedByteArray * p_instance ) {
2020-07-27 12:43:20 +02:00
String s ;
2020-10-13 20:59:37 +02:00
if ( p_instance - > size ( ) > 0 ) {
const uint8_t * r = p_instance - > ptr ( ) ;
2020-08-05 08:25:28 +02:00
s . parse_utf16 ( ( const char16_t * ) r , floor ( ( double ) p_instance - > size ( ) / ( double ) sizeof ( char16_t ) ) ) ;
2020-07-27 12:43:20 +02:00
}
2020-10-13 20:59:37 +02:00
return s ;
2020-07-27 12:43:20 +02:00
}
2020-10-13 20:59:37 +02:00
static String func_PackedByteArray_get_string_from_utf32 ( PackedByteArray * p_instance ) {
2020-07-27 12:43:20 +02:00
String s ;
2020-10-13 20:59:37 +02:00
if ( p_instance - > size ( ) > 0 ) {
const uint8_t * r = p_instance - > ptr ( ) ;
2020-08-05 08:25:28 +02:00
s = String ( ( const char32_t * ) r , floor ( ( double ) p_instance - > size ( ) / ( double ) sizeof ( char32_t ) ) ) ;
2020-07-27 12:43:20 +02:00
}
2020-10-13 20:59:37 +02:00
return s ;
2020-07-27 12:43:20 +02:00
}
2020-10-13 20:59:37 +02:00
static PackedByteArray func_PackedByteArray_compress ( PackedByteArray * p_instance , int p_mode ) {
2020-02-17 22:06:54 +01:00
PackedByteArray compressed ;
2017-06-19 07:46:29 +02:00
2020-10-13 20:59:37 +02:00
if ( p_instance - > size ( ) > 0 ) {
Compression : : Mode mode = ( Compression : : Mode ) ( p_mode ) ;
compressed . resize ( Compression : : get_max_compressed_buffer_size ( p_instance - > size ( ) , mode ) ) ;
int result = Compression : : compress ( compressed . ptrw ( ) , p_instance - > ptr ( ) , p_instance - > size ( ) , mode ) ;
2017-06-19 07:46:29 +02:00
2019-10-11 11:39:40 +02:00
result = result > = 0 ? result : 0 ;
compressed . resize ( result ) ;
}
2020-05-27 21:52:54 +02:00
2020-10-13 20:59:37 +02:00
return compressed ;
2017-06-19 07:46:29 +02:00
}
2020-10-13 20:59:37 +02:00
static PackedByteArray func_PackedByteArray_decompress ( PackedByteArray * p_instance , int64_t p_buffer_size , int p_mode ) {
2020-02-17 22:06:54 +01:00
PackedByteArray decompressed ;
2020-10-13 20:59:37 +02:00
Compression : : Mode mode = ( Compression : : Mode ) ( p_mode ) ;
2017-06-19 07:46:29 +02:00
2020-10-13 20:59:37 +02:00
int64_t buffer_size = p_buffer_size ;
2017-06-19 07:46:29 +02:00
2019-10-10 17:15:10 +02:00
if ( buffer_size < = 0 ) {
2020-10-13 20:59:37 +02:00
ERR_FAIL_V_MSG ( decompressed , " Decompression buffer size must be greater than zero. " ) ;
2017-06-19 07:46:29 +02:00
}
2021-05-25 18:43:26 +02:00
if ( p_instance - > size ( ) = = 0 ) {
ERR_FAIL_V_MSG ( decompressed , " Compressed buffer size must be greater than zero. " ) ;
}
2017-06-19 07:46:29 +02:00
decompressed . resize ( buffer_size ) ;
2020-10-13 20:59:37 +02:00
int result = Compression : : decompress ( decompressed . ptrw ( ) , buffer_size , p_instance - > ptr ( ) , p_instance - > size ( ) , mode ) ;
2017-06-19 07:46:29 +02:00
result = result > = 0 ? result : 0 ;
decompressed . resize ( result ) ;
2020-10-13 20:59:37 +02:00
return decompressed ;
2017-06-19 07:46:29 +02:00
}
2020-10-13 20:59:37 +02:00
static PackedByteArray func_PackedByteArray_decompress_dynamic ( PackedByteArray * p_instance , int64_t p_buffer_size , int p_mode ) {
2020-05-21 10:05:32 +02:00
PackedByteArray decompressed ;
2020-10-13 20:59:37 +02:00
int64_t max_output_size = p_buffer_size ;
Compression : : Mode mode = ( Compression : : Mode ) ( p_mode ) ;
2020-05-21 10:05:32 +02:00
2020-10-13 20:59:37 +02:00
int result = Compression : : decompress_dynamic ( & decompressed , max_output_size , p_instance - > ptr ( ) , p_instance - > size ( ) , mode ) ;
2020-05-21 10:05:32 +02:00
if ( result = = OK ) {
2020-10-13 20:59:37 +02:00
return decompressed ;
2020-05-21 10:05:32 +02:00
} else {
decompressed . clear ( ) ;
2020-10-13 20:59:37 +02:00
ERR_FAIL_V_MSG ( decompressed , " Decompression failed. " ) ;
2020-05-21 10:05:32 +02:00
}
}
2020-10-13 20:59:37 +02:00
static String func_PackedByteArray_hex_encode ( PackedByteArray * p_instance ) {
if ( p_instance - > size ( ) = = 0 ) {
return String ( ) ;
2014-02-10 02:10:30 +01:00
}
2020-10-13 20:59:37 +02:00
const uint8_t * r = p_instance - > ptr ( ) ;
String s = String : : hex_encode_buffer ( & r [ 0 ] , p_instance - > size ( ) ) ;
return s ;
2014-02-10 02:10:30 +01:00
}
Add marshalling to PackedByteArray
-Decode/Encode functions for u8,s8,u16,s16,u32,s32,u64,s64,half,float,double,variant
-Improved binder template to allow this
Given in Godot 4.0 PackedByteArray is passed as reference, it is now possible to have these functions there, which makes the most sense.
2021-04-09 22:57:37 +02:00
static int64_t func_PackedByteArray_decode_u8 ( PackedByteArray * p_instance , int64_t p_offset ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND_V ( p_offset < 0 | | p_offset > int64_t ( size ) - 1 , 0 ) ;
const uint8_t * r = p_instance - > ptr ( ) ;
return r [ p_offset ] ;
}
static int64_t func_PackedByteArray_decode_s8 ( PackedByteArray * p_instance , int64_t p_offset ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND_V ( p_offset < 0 | | p_offset > int64_t ( size ) - 1 , 0 ) ;
const uint8_t * r = p_instance - > ptr ( ) ;
return * ( ( const int8_t * ) & r [ p_offset ] ) ;
}
static int64_t func_PackedByteArray_decode_u16 ( PackedByteArray * p_instance , int64_t p_offset ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND_V ( p_offset < 0 | | p_offset > ( int64_t ( size ) - 2 ) , 0 ) ;
const uint8_t * r = p_instance - > ptr ( ) ;
return decode_uint16 ( & r [ p_offset ] ) ;
}
static int64_t func_PackedByteArray_decode_s16 ( PackedByteArray * p_instance , int64_t p_offset ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND_V ( p_offset < 0 | | p_offset > ( int64_t ( size ) - 2 ) , 0 ) ;
const uint8_t * r = p_instance - > ptr ( ) ;
return ( int16_t ) decode_uint16 ( & r [ p_offset ] ) ;
}
static int64_t func_PackedByteArray_decode_u32 ( PackedByteArray * p_instance , int64_t p_offset ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND_V ( p_offset < 0 | | p_offset > ( int64_t ( size ) - 4 ) , 0 ) ;
const uint8_t * r = p_instance - > ptr ( ) ;
return decode_uint32 ( & r [ p_offset ] ) ;
}
static int64_t func_PackedByteArray_decode_s32 ( PackedByteArray * p_instance , int64_t p_offset ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND_V ( p_offset < 0 | | p_offset > ( int64_t ( size ) - 4 ) , 0 ) ;
const uint8_t * r = p_instance - > ptr ( ) ;
return ( int32_t ) decode_uint32 ( & r [ p_offset ] ) ;
}
static int64_t func_PackedByteArray_decode_u64 ( PackedByteArray * p_instance , int64_t p_offset ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND_V ( p_offset < 0 | | p_offset > ( int64_t ( size ) - 8 ) , 0 ) ;
const uint8_t * r = p_instance - > ptr ( ) ;
return ( int64_t ) decode_uint64 ( & r [ p_offset ] ) ;
}
static int64_t func_PackedByteArray_decode_s64 ( PackedByteArray * p_instance , int64_t p_offset ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND_V ( p_offset < 0 | | p_offset > ( int64_t ( size ) - 8 ) , 0 ) ;
const uint8_t * r = p_instance - > ptr ( ) ;
return ( int64_t ) decode_uint64 ( & r [ p_offset ] ) ;
}
static double func_PackedByteArray_decode_half ( PackedByteArray * p_instance , int64_t p_offset ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND_V ( p_offset < 0 | | p_offset > ( int64_t ( size ) - 2 ) , 0 ) ;
const uint8_t * r = p_instance - > ptr ( ) ;
return Math : : half_to_float ( decode_uint16 ( & r [ p_offset ] ) ) ;
}
static double func_PackedByteArray_decode_float ( PackedByteArray * p_instance , int64_t p_offset ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND_V ( p_offset < 0 | | p_offset > ( int64_t ( size ) - 4 ) , 0 ) ;
const uint8_t * r = p_instance - > ptr ( ) ;
return decode_float ( & r [ p_offset ] ) ;
}
static double func_PackedByteArray_decode_double ( PackedByteArray * p_instance , int64_t p_offset ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND_V ( p_offset < 0 | | p_offset > ( int64_t ( size ) - 8 ) , 0 ) ;
const uint8_t * r = p_instance - > ptr ( ) ;
return decode_double ( & r [ p_offset ] ) ;
}
static bool func_PackedByteArray_has_encoded_var ( PackedByteArray * p_instance , int64_t p_offset , bool p_allow_objects ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND_V ( p_offset < 0 , false ) ;
const uint8_t * r = p_instance - > ptr ( ) ;
Variant ret ;
Error err = decode_variant ( ret , r + p_offset , size - p_offset , nullptr , p_allow_objects ) ;
return err = = OK ;
}
static Variant func_PackedByteArray_decode_var ( PackedByteArray * p_instance , int64_t p_offset , bool p_allow_objects ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND_V ( p_offset < 0 , Variant ( ) ) ;
const uint8_t * r = p_instance - > ptr ( ) ;
Variant ret ;
Error err = decode_variant ( ret , r + p_offset , size - p_offset , nullptr , p_allow_objects ) ;
if ( err ! = OK ) {
ret = Variant ( ) ;
}
return ret ;
}
static int64_t func_PackedByteArray_decode_var_size ( PackedByteArray * p_instance , int64_t p_offset , bool p_allow_objects ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND_V ( p_offset < 0 , 0 ) ;
const uint8_t * r = p_instance - > ptr ( ) ;
Variant ret ;
int r_size ;
Error err = decode_variant ( ret , r + p_offset , size - p_offset , & r_size , p_allow_objects ) ;
if ( err = = OK ) {
return r_size ;
}
return 0 ;
}
2021-07-17 00:36:45 +02:00
static PackedInt32Array func_PackedByteArray_decode_s32_array ( PackedByteArray * p_instance ) {
uint64_t size = p_instance - > size ( ) ;
PackedInt32Array dest ;
2022-06-28 04:02:42 +02:00
if ( size = = 0 ) {
return dest ;
}
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. " ) ;
2021-10-24 12:45:52 +02:00
const uint8_t * r = p_instance - > ptr ( ) ;
2021-07-17 00:36:45 +02:00
dest . resize ( size / sizeof ( int32_t ) ) ;
2022-06-28 04:02:42 +02:00
ERR_FAIL_COND_V ( dest . size ( ) = = 0 , dest ) ; // Avoid UB in case resize failed.
memcpy ( dest . ptrw ( ) , r , dest . size ( ) * sizeof ( int32_t ) ) ;
2021-07-17 00:36:45 +02:00
return dest ;
}
static PackedInt64Array func_PackedByteArray_decode_s64_array ( PackedByteArray * p_instance ) {
uint64_t size = p_instance - > size ( ) ;
PackedInt64Array dest ;
2022-06-28 04:02:42 +02:00
if ( size = = 0 ) {
return dest ;
}
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. " ) ;
2021-10-24 12:45:52 +02:00
const uint8_t * r = p_instance - > ptr ( ) ;
2021-07-17 00:36:45 +02:00
dest . resize ( size / sizeof ( int64_t ) ) ;
2022-06-28 04:02:42 +02:00
ERR_FAIL_COND_V ( dest . size ( ) = = 0 , dest ) ; // Avoid UB in case resize failed.
memcpy ( dest . ptrw ( ) , r , dest . size ( ) * sizeof ( int64_t ) ) ;
2021-07-17 00:36:45 +02:00
return dest ;
}
static PackedFloat32Array func_PackedByteArray_decode_float_array ( PackedByteArray * p_instance ) {
uint64_t size = p_instance - > size ( ) ;
PackedFloat32Array dest ;
2022-06-28 04:02:42 +02:00
if ( size = = 0 ) {
return dest ;
}
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. " ) ;
2021-10-24 12:45:52 +02:00
const uint8_t * r = p_instance - > ptr ( ) ;
2021-07-17 00:36:45 +02:00
dest . resize ( size / sizeof ( float ) ) ;
2022-06-28 04:02:42 +02:00
ERR_FAIL_COND_V ( dest . size ( ) = = 0 , dest ) ; // Avoid UB in case resize failed.
memcpy ( dest . ptrw ( ) , r , dest . size ( ) * sizeof ( float ) ) ;
2021-07-17 00:36:45 +02:00
return dest ;
}
static PackedFloat64Array func_PackedByteArray_decode_double_array ( PackedByteArray * p_instance ) {
uint64_t size = p_instance - > size ( ) ;
PackedFloat64Array dest ;
2022-06-28 04:02:42 +02:00
if ( size = = 0 ) {
return dest ;
}
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. " ) ;
2021-10-24 12:45:52 +02:00
const uint8_t * r = p_instance - > ptr ( ) ;
2021-07-17 00:36:45 +02:00
dest . resize ( size / sizeof ( double ) ) ;
2022-06-28 04:02:42 +02:00
ERR_FAIL_COND_V ( dest . size ( ) = = 0 , dest ) ; // Avoid UB in case resize failed.
memcpy ( dest . ptrw ( ) , r , dest . size ( ) * sizeof ( double ) ) ;
2021-07-17 00:36:45 +02:00
return dest ;
}
Add marshalling to PackedByteArray
-Decode/Encode functions for u8,s8,u16,s16,u32,s32,u64,s64,half,float,double,variant
-Improved binder template to allow this
Given in Godot 4.0 PackedByteArray is passed as reference, it is now possible to have these functions there, which makes the most sense.
2021-04-09 22:57:37 +02:00
static void func_PackedByteArray_encode_u8 ( PackedByteArray * p_instance , int64_t p_offset , int64_t p_value ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND ( p_offset < 0 | | p_offset > int64_t ( size ) - 1 ) ;
uint8_t * w = p_instance - > ptrw ( ) ;
* ( ( uint8_t * ) & w [ p_offset ] ) = p_value ;
}
static void func_PackedByteArray_encode_s8 ( PackedByteArray * p_instance , int64_t p_offset , int64_t p_value ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND ( p_offset < 0 | | p_offset > int64_t ( size ) - 1 ) ;
uint8_t * w = p_instance - > ptrw ( ) ;
* ( ( int8_t * ) & w [ p_offset ] ) = p_value ;
}
static void func_PackedByteArray_encode_u16 ( PackedByteArray * p_instance , int64_t p_offset , int64_t p_value ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND ( p_offset < 0 | | p_offset > int64_t ( size ) - 2 ) ;
uint8_t * w = p_instance - > ptrw ( ) ;
encode_uint16 ( ( uint16_t ) p_value , & w [ p_offset ] ) ;
}
static void func_PackedByteArray_encode_s16 ( PackedByteArray * p_instance , int64_t p_offset , int64_t p_value ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND ( p_offset < 0 | | p_offset > int64_t ( size ) - 2 ) ;
uint8_t * w = p_instance - > ptrw ( ) ;
encode_uint16 ( ( int16_t ) p_value , & w [ p_offset ] ) ;
}
static void func_PackedByteArray_encode_u32 ( PackedByteArray * p_instance , int64_t p_offset , int64_t p_value ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND ( p_offset < 0 | | p_offset > int64_t ( size ) - 4 ) ;
uint8_t * w = p_instance - > ptrw ( ) ;
encode_uint32 ( ( uint32_t ) p_value , & w [ p_offset ] ) ;
}
static void func_PackedByteArray_encode_s32 ( PackedByteArray * p_instance , int64_t p_offset , int64_t p_value ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND ( p_offset < 0 | | p_offset > int64_t ( size ) - 4 ) ;
uint8_t * w = p_instance - > ptrw ( ) ;
encode_uint32 ( ( int32_t ) p_value , & w [ p_offset ] ) ;
}
static void func_PackedByteArray_encode_u64 ( PackedByteArray * p_instance , int64_t p_offset , int64_t p_value ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND ( p_offset < 0 | | p_offset > int64_t ( size ) - 8 ) ;
uint8_t * w = p_instance - > ptrw ( ) ;
encode_uint64 ( ( uint64_t ) p_value , & w [ p_offset ] ) ;
}
static void func_PackedByteArray_encode_s64 ( PackedByteArray * p_instance , int64_t p_offset , int64_t p_value ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND ( p_offset < 0 | | p_offset > int64_t ( size ) - 8 ) ;
uint8_t * w = p_instance - > ptrw ( ) ;
encode_uint64 ( ( int64_t ) p_value , & w [ p_offset ] ) ;
}
static void func_PackedByteArray_encode_half ( PackedByteArray * p_instance , int64_t p_offset , double p_value ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND ( p_offset < 0 | | p_offset > int64_t ( size ) - 2 ) ;
uint8_t * w = p_instance - > ptrw ( ) ;
encode_uint16 ( Math : : make_half_float ( p_value ) , & w [ p_offset ] ) ;
}
static void func_PackedByteArray_encode_float ( PackedByteArray * p_instance , int64_t p_offset , double p_value ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND ( p_offset < 0 | | p_offset > int64_t ( size ) - 4 ) ;
uint8_t * w = p_instance - > ptrw ( ) ;
encode_float ( p_value , & w [ p_offset ] ) ;
}
static void func_PackedByteArray_encode_double ( PackedByteArray * p_instance , int64_t p_offset , double p_value ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND ( p_offset < 0 | | p_offset > int64_t ( size ) - 8 ) ;
uint8_t * w = p_instance - > ptrw ( ) ;
encode_double ( p_value , & w [ p_offset ] ) ;
}
static int64_t func_PackedByteArray_encode_var ( PackedByteArray * p_instance , int64_t p_offset , const Variant & p_value , bool p_allow_objects ) {
uint64_t size = p_instance - > size ( ) ;
ERR_FAIL_COND_V ( p_offset < 0 , - 1 ) ;
uint8_t * w = p_instance - > ptrw ( ) ;
int len ;
Error err = encode_variant ( p_value , nullptr , len , p_allow_objects ) ;
if ( err ! = OK ) {
return - 1 ;
}
if ( uint64_t ( p_offset + len ) > size ) {
return - 1 ; // did not fit
}
encode_variant ( p_value , w + p_offset , len , p_allow_objects ) ;
return len ;
}
2020-10-13 20:59:37 +02:00
static void func_Callable_call ( Variant * v , const Variant * * p_args , int p_argcount , Variant & r_ret , Callable : : CallError & r_error ) {
Callable * callable = VariantGetInternalPtr < Callable > : : get_ptr ( v ) ;
2022-07-28 22:56:41 +02:00
callable - > callp ( p_args , p_argcount , r_ret , r_error ) ;
2014-02-10 02:10:30 +01:00
}
2020-10-13 20:59:37 +02:00
static void func_Callable_call_deferred ( Variant * v , const Variant * * p_args , int p_argcount , Variant & r_ret , Callable : : CallError & r_error ) {
Callable * callable = VariantGetInternalPtr < Callable > : : get_ptr ( v ) ;
2022-07-28 22:56:41 +02:00
callable - > call_deferredp ( p_args , p_argcount ) ;
2014-10-03 05:10:51 +02:00
}
2021-05-03 23:00:44 +02:00
static void func_Callable_rpc ( Variant * v , const Variant * * p_args , int p_argcount , Variant & r_ret , Callable : : CallError & r_error ) {
Callable * callable = VariantGetInternalPtr < Callable > : : get_ptr ( v ) ;
2022-07-28 22:56:41 +02:00
callable - > rpcp ( 0 , p_args , p_argcount , r_error ) ;
2021-05-03 23:00:44 +02:00
}
static void func_Callable_rpc_id ( Variant * v , const Variant * * p_args , int p_argcount , Variant & r_ret , Callable : : CallError & r_error ) {
if ( p_argcount = = 0 ) {
r_error . error = Callable : : CallError : : CALL_ERROR_TOO_FEW_ARGUMENTS ;
r_error . argument = 0 ;
r_error . expected = 1 ;
} else if ( p_args [ 0 ] - > get_type ( ) ! = Variant : : INT ) {
r_error . error = Callable : : CallError : : CALL_ERROR_INVALID_ARGUMENT ;
r_error . argument = 0 ;
r_error . expected = Variant : : INT ;
} else {
Callable * callable = VariantGetInternalPtr < Callable > : : get_ptr ( v ) ;
2022-07-28 22:56:41 +02:00
callable - > rpcp ( * p_args [ 0 ] , & p_args [ 1 ] , p_argcount - 1 , r_error ) ;
2021-05-03 23:00:44 +02:00
}
}
2020-10-13 20:59:37 +02:00
static void func_Callable_bind ( Variant * v , const Variant * * p_args , int p_argcount , Variant & r_ret , Callable : : CallError & r_error ) {
Callable * callable = VariantGetInternalPtr < Callable > : : get_ptr ( v ) ;
2022-07-28 22:56:41 +02:00
r_ret = callable - > bindp ( p_args , p_argcount ) ;
2014-02-10 02:10:30 +01:00
}
2020-10-13 20:59:37 +02:00
static void func_Signal_emit ( Variant * v , const Variant * * p_args , int p_argcount , Variant & r_ret , Callable : : CallError & r_error ) {
Signal * signal = VariantGetInternalPtr < Signal > : : get_ptr ( v ) ;
signal - > emit ( p_args , p_argcount ) ;
2014-02-10 02:10:30 +01:00
}
struct ConstantData {
2022-05-09 11:47:10 +02:00
HashMap < StringName , int64_t > value ;
2016-07-05 21:57:17 +02:00
# ifdef DEBUG_ENABLED
List < StringName > value_ordered ;
# endif
2022-05-13 15:04:37 +02:00
HashMap < StringName , Variant > variant_value ;
2020-05-20 15:45:42 +02:00
# ifdef DEBUG_ENABLED
List < StringName > variant_value_ordered ;
# endif
2014-02-10 02:10:30 +01:00
} ;
static ConstantData * constant_data ;
2022-05-09 11:47:10 +02:00
static void add_constant ( int p_type , StringName p_constant_name , int64_t p_constant_value ) {
2016-07-05 21:57:17 +02:00
constant_data [ p_type ] . value [ p_constant_name ] = p_constant_value ;
# ifdef DEBUG_ENABLED
constant_data [ p_type ] . value_ordered . push_back ( p_constant_name ) ;
# endif
}
2017-12-15 16:43:27 +01:00
static void add_variant_constant ( int p_type , StringName p_constant_name , const Variant & p_constant_value ) {
constant_data [ p_type ] . variant_value [ p_constant_name ] = p_constant_value ;
2020-05-20 15:45:42 +02:00
# ifdef DEBUG_ENABLED
constant_data [ p_type ] . variant_value_ordered . push_back ( p_constant_name ) ;
# endif
2017-12-15 16:43:27 +01:00
}
2022-04-18 20:17:03 +02:00
struct EnumData {
HashMap < StringName , HashMap < StringName , int > > value ;
} ;
static EnumData * enum_data ;
static void add_enum_constant ( int p_type , StringName p_enum_type_name , StringName p_enumeration_name , int p_enum_value ) {
enum_data [ p_type ] . value [ p_enum_type_name ] [ p_enumeration_name ] = p_enum_value ;
}
2014-02-10 02:10:30 +01:00
} ;
2020-04-02 01:20:12 +02:00
_VariantCall : : ConstantData * _VariantCall : : constant_data = nullptr ;
2022-04-18 20:17:03 +02:00
_VariantCall : : EnumData * _VariantCall : : enum_data = nullptr ;
2014-02-10 02:10:30 +01:00
2020-11-11 17:16:08 +01:00
struct VariantBuiltInMethodInfo {
2022-05-02 16:28:25 +02:00
void ( * call ) ( Variant * base , const Variant * * p_args , int p_argcount , Variant & r_ret , const Vector < Variant > & p_defvals , Callable : : CallError & r_error ) = nullptr ;
Variant : : ValidatedBuiltInMethod validated_call = nullptr ;
Variant : : PTRBuiltInMethod ptrcall = nullptr ;
2016-06-20 06:15:02 +02:00
2020-11-11 17:16:08 +01:00
Vector < Variant > default_arguments ;
Vector < String > argument_names ;
2014-02-10 02:10:30 +01:00
2022-05-02 16:28:25 +02:00
bool is_const = false ;
bool is_static = false ;
bool has_return_type = false ;
bool is_vararg = false ;
2020-11-11 17:16:08 +01:00
Variant : : Type return_type ;
2022-05-02 16:28:25 +02:00
int argument_count = 0 ;
Variant : : Type ( * get_argument_type ) ( int p_arg ) = nullptr ;
2020-11-11 17:16:08 +01:00
} ;
typedef OAHashMap < StringName , VariantBuiltInMethodInfo > BuiltinMethodMap ;
static BuiltinMethodMap * builtin_method_info ;
static List < StringName > * builtin_method_names ;
template < class T >
static void register_builtin_method ( const Vector < String > & p_argnames , const Vector < Variant > & p_def_args ) {
StringName name = T : : get_name ( ) ;
ERR_FAIL_COND ( builtin_method_info [ T : : get_base_type ( ) ] . has ( name ) ) ;
VariantBuiltInMethodInfo imi ;
imi . call = T : : call ;
imi . validated_call = T : : validated_call ;
if ( T : : is_vararg ( ) ) {
imi . ptrcall = nullptr ;
} else {
imi . ptrcall = T : : ptrcall ;
}
imi . default_arguments = p_def_args ;
imi . argument_names = p_argnames ;
imi . is_const = T : : is_const ( ) ;
2021-02-24 14:56:34 +01:00
imi . is_static = T : : is_static ( ) ;
2020-11-11 17:16:08 +01:00
imi . is_vararg = T : : is_vararg ( ) ;
imi . has_return_type = T : : has_return_type ( ) ;
imi . return_type = T : : get_return_type ( ) ;
imi . argument_count = T : : get_argument_count ( ) ;
imi . get_argument_type = T : : get_argument_type ;
# ifdef DEBUG_METHODS_ENABLED
ERR_FAIL_COND ( ! imi . is_vararg & & imi . argument_count ! = imi . argument_names . size ( ) ) ;
# endif
builtin_method_info [ T : : get_base_type ( ) ] . insert ( name , imi ) ;
builtin_method_names [ T : : get_base_type ( ) ] . push_back ( name ) ;
}
2022-03-09 14:58:40 +01:00
void Variant : : callp ( const StringName & p_method , const Variant * * p_args , int p_argcount , Variant & r_ret , Callable : : CallError & r_error ) {
2014-02-10 02:10:30 +01:00
if ( type = = Variant : : OBJECT ) {
//call object
Object * obj = _get_obj ( ) . obj ;
if ( ! obj ) {
2020-02-19 20:27:19 +01:00
r_error . error = Callable : : CallError : : CALL_ERROR_INSTANCE_IS_NULL ;
2016-06-20 06:15:02 +02:00
return ;
2014-02-10 02:10:30 +01:00
}
# ifdef DEBUG_ENABLED
2021-06-04 18:03:15 +02:00
if ( EngineDebugger : : is_active ( ) & & ! _get_obj ( ) . id . is_ref_counted ( ) & & ObjectDB : : get_instance ( _get_obj ( ) . id ) = = nullptr ) {
2020-02-19 20:27:19 +01:00
r_error . error = Callable : : CallError : : CALL_ERROR_INSTANCE_IS_NULL ;
2020-02-13 20:03:10 +01:00
return ;
2014-02-10 02:10:30 +01:00
}
# endif
2022-03-09 14:58:40 +01:00
r_ret = _get_obj ( ) . obj - > callp ( p_method , p_args , p_argcount , r_error ) ;
2014-02-10 02:10:30 +01:00
2022-06-27 22:10:04 +02:00
} else {
r_error . error = Callable : : CallError : : CALL_OK ;
const VariantBuiltInMethodInfo * imf = builtin_method_info [ type ] . lookup_ptr ( p_method ) ;
if ( ! imf ) {
r_error . error = Callable : : CallError : : CALL_ERROR_INVALID_METHOD ;
return ;
}
imf - > call ( this , p_args , p_argcount , r_ret , imf - > default_arguments , r_error ) ;
}
}
void Variant : : call_const ( const StringName & p_method , const Variant * * p_args , int p_argcount , Variant & r_ret , Callable : : CallError & r_error ) {
if ( type = = Variant : : OBJECT ) {
//call object
Object * obj = _get_obj ( ) . obj ;
if ( ! obj ) {
r_error . error = Callable : : CallError : : CALL_ERROR_INSTANCE_IS_NULL ;
return ;
}
# ifdef DEBUG_ENABLED
if ( EngineDebugger : : is_active ( ) & & ! _get_obj ( ) . id . is_ref_counted ( ) & & ObjectDB : : get_instance ( _get_obj ( ) . id ) = = nullptr ) {
r_error . error = Callable : : CallError : : CALL_ERROR_INSTANCE_IS_NULL ;
return ;
}
# endif
r_ret = _get_obj ( ) . obj - > call_const ( p_method , p_args , p_argcount , r_error ) ;
2014-02-10 02:10:30 +01:00
//else if (type==Variant::METHOD) {
} else {
2020-02-19 20:27:19 +01:00
r_error . error = Callable : : CallError : : CALL_OK ;
2014-02-10 02:10:30 +01:00
2020-11-11 17:16:08 +01:00
const VariantBuiltInMethodInfo * imf = builtin_method_info [ type ] . lookup_ptr ( p_method ) ;
2020-02-19 20:27:19 +01:00
2020-11-11 17:16:08 +01:00
if ( ! imf ) {
2020-10-13 20:59:37 +02:00
r_error . error = Callable : : CallError : : CALL_ERROR_INVALID_METHOD ;
return ;
2014-02-10 02:10:30 +01:00
}
2022-06-27 22:10:04 +02:00
if ( ! imf - > is_const ) {
r_error . error = Callable : : CallError : : CALL_ERROR_METHOD_NOT_CONST ;
return ;
}
2020-11-11 17:16:08 +01:00
imf - > call ( this , p_args , p_argcount , r_ret , imf - > default_arguments , r_error ) ;
2020-05-14 16:41:43 +02:00
}
2014-02-10 02:10:30 +01:00
}
2021-02-24 14:56:34 +01:00
void Variant : : call_static ( Variant : : Type p_type , const StringName & p_method , const Variant * * p_args , int p_argcount , Variant & r_ret , Callable : : CallError & r_error ) {
r_error . error = Callable : : CallError : : CALL_OK ;
const VariantBuiltInMethodInfo * imf = builtin_method_info [ p_type ] . lookup_ptr ( p_method ) ;
if ( ! imf ) {
r_error . error = Callable : : CallError : : CALL_ERROR_INVALID_METHOD ;
return ;
}
if ( ! imf - > is_static ) {
r_error . error = Callable : : CallError : : CALL_ERROR_INSTANCE_IS_NULL ;
return ;
}
imf - > call ( nullptr , p_args , p_argcount , r_ret , imf - > default_arguments , r_error ) ;
}
2014-09-20 02:01:41 +02:00
bool Variant : : has_method ( const StringName & p_method ) const {
if ( type = = OBJECT ) {
2020-02-13 20:03:10 +01:00
Object * obj = get_validated_object ( ) ;
2020-05-14 16:41:43 +02:00
if ( ! obj ) {
2014-09-20 02:01:41 +02:00
return false ;
2020-05-14 16:41:43 +02:00
}
2020-02-13 20:03:10 +01:00
return obj - > has_method ( p_method ) ;
2014-09-20 02:01:41 +02:00
}
2020-11-11 17:16:08 +01:00
return builtin_method_info [ type ] . has ( p_method ) ;
2014-09-20 02:01:41 +02:00
}
2020-11-11 17:16:08 +01:00
bool Variant : : has_builtin_method ( Variant : : Type p_type , const StringName & p_method ) {
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , false ) ;
return builtin_method_info [ p_type ] . has ( p_method ) ;
}
2016-08-03 16:28:20 +02:00
2020-11-11 17:16:08 +01:00
Variant : : ValidatedBuiltInMethod Variant : : get_validated_builtin_method ( Variant : : Type p_type , const StringName & p_method ) {
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , nullptr ) ;
const VariantBuiltInMethodInfo * method = builtin_method_info [ p_type ] . lookup_ptr ( p_method ) ;
ERR_FAIL_COND_V ( ! method , nullptr ) ;
return method - > validated_call ;
}
2016-08-03 16:28:20 +02:00
2020-11-11 17:16:08 +01:00
Variant : : PTRBuiltInMethod Variant : : get_ptr_builtin_method ( Variant : : Type p_type , const StringName & p_method ) {
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , nullptr ) ;
const VariantBuiltInMethodInfo * method = builtin_method_info [ p_type ] . lookup_ptr ( p_method ) ;
ERR_FAIL_COND_V ( ! method , nullptr ) ;
return method - > ptrcall ;
2016-08-03 16:28:20 +02:00
}
2020-11-11 17:16:08 +01:00
int Variant : : get_builtin_method_argument_count ( Variant : : Type p_type , const StringName & p_method ) {
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , 0 ) ;
const VariantBuiltInMethodInfo * method = builtin_method_info [ p_type ] . lookup_ptr ( p_method ) ;
ERR_FAIL_COND_V ( ! method , 0 ) ;
return method - > argument_count ;
2017-09-25 22:08:48 +02:00
}
2020-11-11 17:16:08 +01:00
Variant : : Type Variant : : get_builtin_method_argument_type ( Variant : : Type p_type , const StringName & p_method , int p_argument ) {
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , Variant : : NIL ) ;
const VariantBuiltInMethodInfo * method = builtin_method_info [ p_type ] . lookup_ptr ( p_method ) ;
ERR_FAIL_COND_V ( ! method , Variant : : NIL ) ;
ERR_FAIL_INDEX_V ( p_argument , method - > argument_count , Variant : : NIL ) ;
return method - > get_argument_type ( p_argument ) ;
}
2016-08-03 16:28:20 +02:00
2020-11-11 17:16:08 +01:00
String Variant : : get_builtin_method_argument_name ( Variant : : Type p_type , const StringName & p_method , int p_argument ) {
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , String ( ) ) ;
const VariantBuiltInMethodInfo * method = builtin_method_info [ p_type ] . lookup_ptr ( p_method ) ;
ERR_FAIL_COND_V ( ! method , String ( ) ) ;
# ifdef DEBUG_METHODS_ENABLED
ERR_FAIL_INDEX_V ( p_argument , method - > argument_count , String ( ) ) ;
return method - > argument_names [ p_argument ] ;
# else
return " arg " + itos ( p_argument + 1 ) ;
2020-10-13 20:59:37 +02:00
# endif
2016-08-03 16:28:20 +02:00
}
2020-11-11 17:16:08 +01:00
Vector < Variant > Variant : : get_builtin_method_default_arguments ( Variant : : Type p_type , const StringName & p_method ) {
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , Vector < Variant > ( ) ) ;
const VariantBuiltInMethodInfo * method = builtin_method_info [ p_type ] . lookup_ptr ( p_method ) ;
ERR_FAIL_COND_V ( ! method , Vector < Variant > ( ) ) ;
return method - > default_arguments ;
2016-08-03 16:28:20 +02:00
}
2020-11-11 17:16:08 +01:00
bool Variant : : has_builtin_method_return_value ( Variant : : Type p_type , const StringName & p_method ) {
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , false ) ;
const VariantBuiltInMethodInfo * method = builtin_method_info [ p_type ] . lookup_ptr ( p_method ) ;
ERR_FAIL_COND_V ( ! method , false ) ;
return method - > has_return_type ;
}
void Variant : : get_builtin_method_list ( Variant : : Type p_type , List < StringName > * p_list ) {
ERR_FAIL_INDEX ( p_type , Variant : : VARIANT_MAX ) ;
2021-07-24 15:46:25 +02:00
for ( const StringName & E : builtin_method_names [ p_type ] ) {
2021-07-16 05:45:57 +02:00
p_list - > push_back ( E ) ;
2020-05-14 16:41:43 +02:00
}
2020-11-11 17:16:08 +01:00
}
2020-12-27 15:09:06 +01:00
int Variant : : get_builtin_method_count ( Variant : : Type p_type ) {
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , - 1 ) ;
return builtin_method_names [ p_type ] . size ( ) ;
}
2020-11-11 17:16:08 +01:00
Variant : : Type Variant : : get_builtin_method_return_type ( Variant : : Type p_type , const StringName & p_method ) {
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , Variant : : NIL ) ;
const VariantBuiltInMethodInfo * method = builtin_method_info [ p_type ] . lookup_ptr ( p_method ) ;
ERR_FAIL_COND_V ( ! method , Variant : : NIL ) ;
return method - > return_type ;
}
bool Variant : : is_builtin_method_const ( Variant : : Type p_type , const StringName & p_method ) {
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , false ) ;
const VariantBuiltInMethodInfo * method = builtin_method_info [ p_type ] . lookup_ptr ( p_method ) ;
ERR_FAIL_COND_V ( ! method , false ) ;
return method - > is_const ;
}
2021-02-24 14:56:34 +01:00
bool Variant : : is_builtin_method_static ( Variant : : Type p_type , const StringName & p_method ) {
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , false ) ;
const VariantBuiltInMethodInfo * method = builtin_method_info [ p_type ] . lookup_ptr ( p_method ) ;
ERR_FAIL_COND_V ( ! method , false ) ;
return method - > is_static ;
}
2020-11-11 17:16:08 +01:00
bool Variant : : is_builtin_method_vararg ( Variant : : Type p_type , const StringName & p_method ) {
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , false ) ;
const VariantBuiltInMethodInfo * method = builtin_method_info [ p_type ] . lookup_ptr ( p_method ) ;
ERR_FAIL_COND_V ( ! method , false ) ;
return method - > is_vararg ;
2016-08-03 16:28:20 +02:00
}
2021-06-19 17:58:49 +02:00
uint32_t Variant : : get_builtin_method_hash ( Variant : : Type p_type , const StringName & p_method ) {
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , 0 ) ;
const VariantBuiltInMethodInfo * method = builtin_method_info [ p_type ] . lookup_ptr ( p_method ) ;
ERR_FAIL_COND_V ( ! method , 0 ) ;
2022-06-18 16:20:55 +02:00
uint32_t hash = hash_murmur3_one_32 ( method - > is_const ) ;
hash = hash_murmur3_one_32 ( method - > is_static , hash ) ;
hash = hash_murmur3_one_32 ( method - > is_vararg , hash ) ;
hash = hash_murmur3_one_32 ( method - > has_return_type , hash ) ;
2021-06-19 17:58:49 +02:00
if ( method - > has_return_type ) {
2022-06-18 16:20:55 +02:00
hash = hash_murmur3_one_32 ( method - > return_type , hash ) ;
2021-06-19 17:58:49 +02:00
}
2022-06-18 16:20:55 +02:00
hash = hash_murmur3_one_32 ( method - > argument_count , hash ) ;
2021-06-19 17:58:49 +02:00
for ( int i = 0 ; i < method - > argument_count ; i + + ) {
2022-06-18 16:20:55 +02:00
hash = hash_murmur3_one_32 ( method - > get_argument_type ( i ) , hash ) ;
2021-06-19 17:58:49 +02:00
}
2022-06-18 16:20:55 +02:00
return hash_fmix32 ( hash ) ;
2021-06-19 17:58:49 +02:00
}
2014-02-10 02:10:30 +01:00
void Variant : : get_method_list ( List < MethodInfo > * p_list ) const {
2020-11-11 17:16:08 +01:00
if ( type = = OBJECT ) {
Object * obj = get_validated_object ( ) ;
if ( obj ) {
obj - > get_method_list ( p_list ) ;
2014-02-10 02:10:30 +01:00
}
2020-11-11 17:16:08 +01:00
} else {
2021-07-24 15:46:25 +02:00
for ( const StringName & E : builtin_method_names [ type ] ) {
2021-07-16 05:45:57 +02:00
const VariantBuiltInMethodInfo * method = builtin_method_info [ type ] . lookup_ptr ( E ) ;
2020-11-11 17:16:08 +01:00
ERR_CONTINUE ( ! method ) ;
MethodInfo mi ;
2021-07-16 05:45:57 +02:00
mi . name = E ;
2020-11-11 17:16:08 +01:00
//return type
if ( method - > has_return_type ) {
mi . return_val . type = method - > return_type ;
if ( mi . return_val . type = = Variant : : NIL ) {
mi . return_val . usage | = PROPERTY_USAGE_NIL_IS_VARIANT ;
}
}
2014-02-10 02:10:30 +01:00
2020-11-11 17:16:08 +01:00
if ( method - > is_const ) {
mi . flags | = METHOD_FLAG_CONST ;
}
if ( method - > is_vararg ) {
mi . flags | = METHOD_FLAG_VARARG ;
}
2021-02-24 14:56:34 +01:00
if ( method - > is_static ) {
mi . flags | = METHOD_FLAG_STATIC ;
}
2020-11-11 17:16:08 +01:00
for ( int i = 0 ; i < method - > argument_count ; i + + ) {
PropertyInfo pi ;
# ifdef DEBUG_METHODS_ENABLED
pi . name = method - > argument_names [ i ] ;
2020-10-13 20:59:37 +02:00
# else
2020-11-11 17:16:08 +01:00
pi . name = " arg " + itos ( i + 1 ) ;
2015-07-15 01:59:35 +02:00
# endif
2020-11-11 17:16:08 +01:00
pi . type = method - > get_argument_type ( i ) ;
if ( pi . type = = Variant : : NIL ) {
pi . usage | = PROPERTY_USAGE_NIL_IS_VARIANT ;
}
mi . arguments . push_back ( pi ) ;
}
2014-02-10 02:10:30 +01:00
2020-11-11 17:16:08 +01:00
mi . default_arguments = method - > default_arguments ;
p_list - > push_back ( mi ) ;
}
2020-02-19 20:27:19 +01:00
}
2014-02-10 02:10:30 +01:00
}
2017-12-15 16:43:27 +01:00
void Variant : : get_constants_for_type ( Variant : : Type p_type , List < StringName > * p_constants ) {
2014-02-10 02:10:30 +01:00
ERR_FAIL_INDEX ( p_type , Variant : : VARIANT_MAX ) ;
2022-04-07 12:23:40 +02:00
const _VariantCall : : ConstantData & cd = _VariantCall : : constant_data [ p_type ] ;
2014-02-10 02:10:30 +01:00
2016-07-05 21:57:17 +02:00
# ifdef DEBUG_ENABLED
2022-04-07 12:23:40 +02:00
for ( const List < StringName > : : Element * E = cd . value_ordered . front ( ) ; E ; E = E - > next ( ) ) {
2016-07-05 21:57:17 +02:00
p_constants - > push_back ( E - > get ( ) ) ;
# else
2022-05-09 11:47:10 +02:00
for ( const KeyValue < StringName , int64_t > & E : cd . value ) {
2021-08-09 22:13:42 +02:00
p_constants - > push_back ( E . key ) ;
2016-07-05 21:57:17 +02:00
# endif
2014-02-10 02:10:30 +01:00
}
2017-12-15 16:43:27 +01:00
2020-05-20 15:45:42 +02:00
# ifdef DEBUG_ENABLED
2022-04-07 12:23:40 +02:00
for ( const List < StringName > : : Element * E = cd . variant_value_ordered . front ( ) ; E ; E = E - > next ( ) ) {
2020-05-20 15:45:42 +02:00
p_constants - > push_back ( E - > get ( ) ) ;
# else
2021-08-09 22:13:42 +02:00
for ( const KeyValue < StringName , Variant > & E : cd . variant_value ) {
p_constants - > push_back ( E . key ) ;
2020-05-20 15:45:42 +02:00
# endif
2017-12-15 16:43:27 +01:00
}
2014-02-10 02:10:30 +01:00
}
2020-12-27 15:09:06 +01:00
int Variant : : get_constants_count_for_type ( Variant : : Type p_type ) {
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , - 1 ) ;
_VariantCall : : ConstantData & cd = _VariantCall : : constant_data [ p_type ] ;
return cd . value . size ( ) + cd . variant_value . size ( ) ;
}
2017-12-15 16:43:27 +01:00
bool Variant : : has_constant ( Variant : : Type p_type , const StringName & p_value ) {
2014-02-10 02:10:30 +01:00
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , false ) ;
_VariantCall : : ConstantData & cd = _VariantCall : : constant_data [ p_type ] ;
2017-12-15 16:43:27 +01:00
return cd . value . has ( p_value ) | | cd . variant_value . has ( p_value ) ;
2014-02-10 02:10:30 +01:00
}
2017-12-15 16:43:27 +01:00
Variant Variant : : get_constant_value ( Variant : : Type p_type , const StringName & p_value , bool * r_valid ) {
2020-05-14 16:41:43 +02:00
if ( r_valid ) {
2016-09-02 07:13:12 +02:00
* r_valid = false ;
2020-05-14 16:41:43 +02:00
}
2014-02-10 02:10:30 +01:00
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , 0 ) ;
_VariantCall : : ConstantData & cd = _VariantCall : : constant_data [ p_type ] ;
2022-05-09 11:47:10 +02:00
HashMap < StringName , int64_t > : : Iterator E = cd . value . find ( p_value ) ;
2016-09-02 07:13:12 +02:00
if ( ! E ) {
2022-05-13 15:04:37 +02:00
HashMap < StringName , Variant > : : Iterator F = cd . variant_value . find ( p_value ) ;
2019-02-12 21:10:08 +01:00
if ( F ) {
2020-05-14 16:41:43 +02:00
if ( r_valid ) {
2017-12-15 16:43:27 +01:00
* r_valid = true ;
2020-05-14 16:41:43 +02:00
}
2022-05-13 15:04:37 +02:00
return F - > value ;
2017-12-15 16:43:27 +01:00
} else {
return - 1 ;
}
2016-09-02 07:13:12 +02:00
}
2020-05-14 16:41:43 +02:00
if ( r_valid ) {
2016-09-02 07:13:12 +02:00
* r_valid = true ;
2020-05-14 16:41:43 +02:00
}
2016-09-02 07:13:12 +02:00
2022-05-13 15:04:37 +02:00
return E - > value ;
2014-02-10 02:10:30 +01:00
}
2022-04-18 20:17:03 +02:00
void Variant : : get_enums_for_type ( Variant : : Type p_type , List < StringName > * p_enums ) {
ERR_FAIL_INDEX ( p_type , Variant : : VARIANT_MAX ) ;
_VariantCall : : EnumData & enum_data = _VariantCall : : enum_data [ p_type ] ;
for ( const KeyValue < StringName , HashMap < StringName , int > > & E : enum_data . value ) {
p_enums - > push_back ( E . key ) ;
}
}
void Variant : : get_enumerations_for_enum ( Variant : : Type p_type , StringName p_enum_name , List < StringName > * p_enumerations ) {
ERR_FAIL_INDEX ( p_type , Variant : : VARIANT_MAX ) ;
_VariantCall : : EnumData & enum_data = _VariantCall : : enum_data [ p_type ] ;
for ( const KeyValue < StringName , HashMap < StringName , int > > & E : enum_data . value ) {
for ( const KeyValue < StringName , int > & V : E . value ) {
p_enumerations - > push_back ( V . key ) ;
}
}
}
int Variant : : get_enum_value ( Variant : : Type p_type , StringName p_enum_name , StringName p_enumeration , bool * r_valid ) {
if ( r_valid ) {
* r_valid = false ;
}
ERR_FAIL_INDEX_V ( p_type , Variant : : VARIANT_MAX , - 1 ) ;
_VariantCall : : EnumData & enum_data = _VariantCall : : enum_data [ p_type ] ;
HashMap < StringName , HashMap < StringName , int > > : : Iterator E = enum_data . value . find ( p_enum_name ) ;
if ( ! E ) {
return - 1 ;
}
HashMap < StringName , int > : : Iterator V = E - > value . find ( p_enumeration ) ;
if ( ! V ) {
return - 1 ;
}
if ( r_valid ) {
* r_valid = true ;
}
return V - > value ;
}
2020-11-11 17:16:08 +01:00
# ifdef DEBUG_METHODS_ENABLED
# define bind_method(m_type, m_method, m_arg_names, m_default_args) \
METHOD_CLASS ( m_type , m_method , & m_type : : m_method ) ; \
register_builtin_method < Method_ # # m_type # # _ # # m_method > ( m_arg_names , m_default_args ) ;
# else
# define bind_method(m_type, m_method, m_arg_names, m_default_args) \
METHOD_CLASS ( m_type , m_method , & m_type : : m_method ) ; \
register_builtin_method < Method_ # # m_type # # _ # # m_method > ( sarray ( ) , m_default_args ) ;
# endif
2014-02-10 02:10:30 +01:00
2021-02-24 14:56:34 +01:00
# ifdef DEBUG_METHODS_ENABLED
# define bind_static_method(m_type, m_method, m_arg_names, m_default_args) \
STATIC_METHOD_CLASS ( m_type , m_method , m_type : : m_method ) ; \
register_builtin_method < Method_ # # m_type # # _ # # m_method > ( m_arg_names , m_default_args ) ;
# else
# define bind_static_method(m_type, m_method, m_arg_names, m_default_args) \
STATIC_METHOD_CLASS ( m_type , m_method , m_type : : m_method ) ; \
register_builtin_method < Method_ # # m_type # # _ # # m_method > ( sarray ( ) , m_default_args ) ;
# endif
2020-11-11 17:16:08 +01:00
# ifdef DEBUG_METHODS_ENABLED
# define bind_methodv(m_type, m_name, m_method, m_arg_names, m_default_args) \
METHOD_CLASS ( m_type , m_name , m_method ) ; \
register_builtin_method < Method_ # # m_type # # _ # # m_name > ( m_arg_names , m_default_args ) ;
# else
# define bind_methodv(m_type, m_name, m_method, m_arg_names, m_default_args) \
METHOD_CLASS ( m_type , m_name , m_method ) ; \
register_builtin_method < Method_ # # m_type # # _ # # m_name > ( sarray ( ) , m_default_args ) ;
# endif
2020-10-13 20:59:37 +02:00
2020-11-11 17:16:08 +01:00
# ifdef DEBUG_METHODS_ENABLED
# define bind_function(m_type, m_name, m_method, m_arg_names, m_default_args) \
Add marshalling to PackedByteArray
-Decode/Encode functions for u8,s8,u16,s16,u32,s32,u64,s64,half,float,double,variant
-Improved binder template to allow this
Given in Godot 4.0 PackedByteArray is passed as reference, it is now possible to have these functions there, which makes the most sense.
2021-04-09 22:57:37 +02:00
FUNCTION_CLASS ( m_type , m_name , m_method , true ) ; \
2020-11-11 17:16:08 +01:00
register_builtin_method < Method_ # # m_type # # _ # # m_name > ( m_arg_names , m_default_args ) ;
# else
# define bind_function(m_type, m_name, m_method, m_arg_names, m_default_args) \
Add marshalling to PackedByteArray
-Decode/Encode functions for u8,s8,u16,s16,u32,s32,u64,s64,half,float,double,variant
-Improved binder template to allow this
Given in Godot 4.0 PackedByteArray is passed as reference, it is now possible to have these functions there, which makes the most sense.
2021-04-09 22:57:37 +02:00
FUNCTION_CLASS ( m_type , m_name , m_method , true ) ; \
register_builtin_method < Method_ # # m_type # # _ # # m_name > ( sarray ( ) , m_default_args ) ;
# endif
# ifdef DEBUG_METHODS_ENABLED
# define bind_functionnc(m_type, m_name, m_method, m_arg_names, m_default_args) \
FUNCTION_CLASS ( m_type , m_name , m_method , false ) ; \
register_builtin_method < Method_ # # m_type # # _ # # m_name > ( m_arg_names , m_default_args ) ;
# else
# define bind_functionnc(m_type, m_name, m_method, m_arg_names, m_default_args) \
FUNCTION_CLASS ( m_type , m_name , m_method , false ) ; \
2020-11-11 17:16:08 +01:00
register_builtin_method < Method_ # # m_type # # _ # # m_name > ( sarray ( ) , m_default_args ) ;
# endif
# define bind_custom(m_type, m_name, m_method, m_has_return, m_ret_type) \
VARARG_CLASS ( m_type , m_name , m_method , m_has_return , m_ret_type ) \
register_builtin_method < Method_ # # m_type # # _ # # m_name > ( sarray ( ) , Vector < Variant > ( ) ) ;
2021-05-03 23:00:44 +02:00
# define bind_custom1(m_type, m_name, m_method, m_arg_type, m_arg_name) \
VARARG_CLASS1 ( m_type , m_name , m_method , m_arg_type ) \
register_builtin_method < Method_ # # m_type # # _ # # m_name > ( sarray ( m_arg_name ) , Vector < Variant > ( ) ) ;
2020-11-11 17:16:08 +01:00
static void _register_variant_builtin_methods ( ) {
2014-02-10 02:10:30 +01:00
_VariantCall : : constant_data = memnew_arr ( _VariantCall : : ConstantData , Variant : : VARIANT_MAX ) ;
2022-04-18 20:17:03 +02:00
_VariantCall : : enum_data = memnew_arr ( _VariantCall : : EnumData , Variant : : VARIANT_MAX ) ;
2020-11-11 17:16:08 +01:00
builtin_method_info = memnew_arr ( BuiltinMethodMap , Variant : : VARIANT_MAX ) ;
builtin_method_names = memnew_arr ( List < StringName > , Variant : : VARIANT_MAX ) ;
2014-02-10 02:10:30 +01:00
2020-11-04 15:38:26 +01:00
/* String */
2020-10-13 20:59:37 +02:00
bind_method ( String , casecmp_to , sarray ( " to " ) , varray ( ) ) ;
bind_method ( String , nocasecmp_to , sarray ( " to " ) , varray ( ) ) ;
bind_method ( String , naturalnocasecmp_to , sarray ( " to " ) , varray ( ) ) ;
bind_method ( String , length , sarray ( ) , varray ( ) ) ;
bind_method ( String , substr , sarray ( " from " , " len " ) , varray ( - 1 ) ) ;
2021-10-31 15:36:16 +01:00
bind_method ( String , get_slice , sarray ( " delimiter " , " slice " ) , varray ( ) ) ;
2022-02-08 08:49:14 +01:00
bind_method ( String , get_slicec , sarray ( " delimiter " , " slice " ) , varray ( ) ) ;
bind_method ( String , get_slice_count , sarray ( " delimiter " ) , varray ( ) ) ;
2020-11-11 17:16:08 +01:00
bind_methodv ( String , find , static_cast < int ( String : : * ) ( const String & , int ) const > ( & String : : find ) , sarray ( " what " , " from " ) , varray ( 0 ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( String , count , sarray ( " what " , " from " , " to " ) , varray ( 0 , 0 ) ) ;
bind_method ( String , countn , sarray ( " what " , " from " , " to " ) , varray ( 0 , 0 ) ) ;
bind_method ( String , findn , sarray ( " what " , " from " ) , varray ( 0 ) ) ;
bind_method ( String , rfind , sarray ( " what " , " from " ) , varray ( - 1 ) ) ;
bind_method ( String , rfindn , sarray ( " what " , " from " ) , varray ( - 1 ) ) ;
bind_method ( String , match , sarray ( " expr " ) , varray ( ) ) ;
bind_method ( String , matchn , sarray ( " expr " ) , varray ( ) ) ;
2020-11-11 17:16:08 +01:00
bind_methodv ( String , begins_with , static_cast < bool ( String : : * ) ( const String & ) const > ( & String : : begins_with ) , sarray ( " text " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( String , ends_with , sarray ( " text " ) , varray ( ) ) ;
bind_method ( String , is_subsequence_of , sarray ( " text " ) , varray ( ) ) ;
2022-01-27 00:03:56 +01:00
bind_method ( String , is_subsequence_ofn , sarray ( " text " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( String , bigrams , sarray ( ) , varray ( ) ) ;
bind_method ( String , similarity , sarray ( " text " ) , varray ( ) ) ;
bind_method ( String , format , sarray ( " values " , " placeholder " ) , varray ( " {_} " ) ) ;
2020-11-11 17:16:08 +01:00
bind_methodv ( String , replace , static_cast < String ( String : : * ) ( const String & , const String & ) const > ( & String : : replace ) , sarray ( " what " , " forwhat " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( String , replacen , sarray ( " what " , " forwhat " ) , varray ( ) ) ;
bind_method ( String , repeat , sarray ( " count " ) , varray ( ) ) ;
bind_method ( String , insert , sarray ( " position " , " what " ) , varray ( ) ) ;
bind_method ( String , capitalize , sarray ( ) , varray ( ) ) ;
2022-08-30 11:36:24 +02:00
bind_method ( String , to_camel_case , sarray ( ) , varray ( ) ) ;
bind_method ( String , to_pascal_case , sarray ( ) , varray ( ) ) ;
bind_method ( String , to_snake_case , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( String , split , sarray ( " delimiter " , " allow_empty " , " maxsplit " ) , varray ( true , 0 ) ) ;
bind_method ( String , rsplit , sarray ( " delimiter " , " allow_empty " , " maxsplit " ) , varray ( true , 0 ) ) ;
bind_method ( String , split_floats , sarray ( " delimiter " , " allow_empty " ) , varray ( true ) ) ;
bind_method ( String , join , sarray ( " parts " ) , varray ( ) ) ;
bind_method ( String , to_upper , sarray ( ) , varray ( ) ) ;
bind_method ( String , to_lower , sarray ( ) , varray ( ) ) ;
2022-06-12 04:45:58 +02:00
bind_method ( String , left , sarray ( " length " ) , varray ( ) ) ;
bind_method ( String , right , sarray ( " length " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( String , strip_edges , sarray ( " left " , " right " ) , varray ( true , true ) ) ;
bind_method ( String , strip_escapes , sarray ( ) , varray ( ) ) ;
bind_method ( String , lstrip , sarray ( " chars " ) , varray ( ) ) ;
bind_method ( String , rstrip , sarray ( " chars " ) , varray ( ) ) ;
bind_method ( String , get_extension , sarray ( ) , varray ( ) ) ;
bind_method ( String , get_basename , sarray ( ) , varray ( ) ) ;
2022-08-30 02:34:01 +02:00
bind_method ( String , path_join , sarray ( " file " ) , varray ( ) ) ;
2020-11-23 12:47:11 +01:00
bind_method ( String , unicode_at , sarray ( " at " ) , varray ( ) ) ;
2021-12-15 16:01:06 +01:00
bind_method ( String , indent , sarray ( " prefix " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( String , dedent , sarray ( ) , varray ( ) ) ;
bind_method ( String , hash , sarray ( ) , varray ( ) ) ;
bind_method ( String , md5_text , sarray ( ) , varray ( ) ) ;
bind_method ( String , sha1_text , sarray ( ) , varray ( ) ) ;
bind_method ( String , sha256_text , sarray ( ) , varray ( ) ) ;
bind_method ( String , md5_buffer , sarray ( ) , varray ( ) ) ;
bind_method ( String , sha1_buffer , sarray ( ) , varray ( ) ) ;
bind_method ( String , sha256_buffer , sarray ( ) , varray ( ) ) ;
2020-12-15 13:04:21 +01:00
bind_method ( String , is_empty , sarray ( ) , varray ( ) ) ;
2022-02-03 17:03:38 +01:00
bind_methodv ( String , contains , static_cast < bool ( String : : * ) ( const String & ) const > ( & String : : contains ) , sarray ( " what " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
2021-06-03 15:41:22 +02:00
bind_method ( String , is_absolute_path , sarray ( ) , varray ( ) ) ;
2021-08-30 01:43:47 +02:00
bind_method ( String , is_relative_path , sarray ( ) , varray ( ) ) ;
2021-08-24 01:39:10 +02:00
bind_method ( String , simplify_path , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( String , get_base_dir , sarray ( ) , varray ( ) ) ;
bind_method ( String , get_file , sarray ( ) , varray ( ) ) ;
bind_method ( String , xml_escape , sarray ( " escape_quotes " ) , varray ( false ) ) ;
bind_method ( String , xml_unescape , sarray ( ) , varray ( ) ) ;
2020-11-30 04:43:38 +01:00
bind_method ( String , uri_encode , sarray ( ) , varray ( ) ) ;
bind_method ( String , uri_decode , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( String , c_escape , sarray ( ) , varray ( ) ) ;
bind_method ( String , c_unescape , sarray ( ) , varray ( ) ) ;
bind_method ( String , json_escape , sarray ( ) , varray ( ) ) ;
2021-01-28 21:48:12 +01:00
bind_method ( String , validate_node_name , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( String , is_valid_identifier , sarray ( ) , varray ( ) ) ;
2021-06-16 18:24:34 +02:00
bind_method ( String , is_valid_int , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( String , is_valid_float , sarray ( ) , varray ( ) ) ;
bind_method ( String , is_valid_hex_number , sarray ( " with_prefix " ) , varray ( false ) ) ;
bind_method ( String , is_valid_html_color , sarray ( ) , varray ( ) ) ;
bind_method ( String , is_valid_ip_address , sarray ( ) , varray ( ) ) ;
bind_method ( String , is_valid_filename , sarray ( ) , varray ( ) ) ;
bind_method ( String , to_int , sarray ( ) , varray ( ) ) ;
bind_method ( String , to_float , sarray ( ) , varray ( ) ) ;
2021-01-28 13:39:05 +01:00
bind_method ( String , hex_to_int , sarray ( ) , varray ( ) ) ;
bind_method ( String , bin_to_int , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( String , lpad , sarray ( " min_length " , " character " ) , varray ( " " ) ) ;
bind_method ( String , rpad , sarray ( " min_length " , " character " ) , varray ( " " ) ) ;
bind_method ( String , pad_decimals , sarray ( " digits " ) , varray ( ) ) ;
bind_method ( String , pad_zeros , sarray ( " digits " ) , varray ( ) ) ;
bind_method ( String , trim_prefix , sarray ( " prefix " ) , varray ( ) ) ;
bind_method ( String , trim_suffix , sarray ( " suffix " ) , varray ( ) ) ;
bind_method ( String , to_ascii_buffer , sarray ( ) , varray ( ) ) ;
bind_method ( String , to_utf8_buffer , sarray ( ) , varray ( ) ) ;
bind_method ( String , to_utf16_buffer , sarray ( ) , varray ( ) ) ;
bind_method ( String , to_utf32_buffer , sarray ( ) , varray ( ) ) ;
2021-02-24 14:56:34 +01:00
bind_static_method ( String , num_scientific , sarray ( " number " ) , varray ( ) ) ;
bind_static_method ( String , num , sarray ( " number " , " decimals " ) , varray ( - 1 ) ) ;
2022-02-13 13:41:29 +01:00
bind_static_method ( String , num_int64 , sarray ( " number " , " base " , " capitalize_hex " ) , varray ( 10 , false ) ) ;
bind_static_method ( String , num_uint64 , sarray ( " number " , " base " , " capitalize_hex " ) , varray ( 10 , false ) ) ;
2021-02-24 14:56:34 +01:00
bind_static_method ( String , chr , sarray ( " char " ) , varray ( ) ) ;
bind_static_method ( String , humanize_size , sarray ( " size " ) , varray ( ) ) ;
2022-06-06 11:19:56 +02:00
/* StringName */
bind_method ( StringName , hash , sarray ( ) , varray ( ) ) ;
2020-11-04 15:38:26 +01:00
/* Vector2 */
2020-10-13 20:59:37 +02:00
bind_method ( Vector2 , angle , sarray ( ) , varray ( ) ) ;
bind_method ( Vector2 , angle_to , sarray ( " to " ) , varray ( ) ) ;
bind_method ( Vector2 , angle_to_point , sarray ( " to " ) , varray ( ) ) ;
2021-11-29 18:02:42 +01:00
bind_method ( Vector2 , direction_to , sarray ( " to " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Vector2 , distance_to , sarray ( " to " ) , varray ( ) ) ;
bind_method ( Vector2 , distance_squared_to , sarray ( " to " ) , varray ( ) ) ;
bind_method ( Vector2 , length , sarray ( ) , varray ( ) ) ;
bind_method ( Vector2 , length_squared , sarray ( ) , varray ( ) ) ;
2021-02-01 06:42:00 +01:00
bind_method ( Vector2 , limit_length , sarray ( " length " ) , varray ( 1.0 ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Vector2 , normalized , sarray ( ) , varray ( ) ) ;
bind_method ( Vector2 , is_normalized , sarray ( ) , varray ( ) ) ;
bind_method ( Vector2 , is_equal_approx , sarray ( " to " ) , varray ( ) ) ;
2022-09-02 02:32:33 +02:00
bind_method ( Vector2 , is_zero_approx , sarray ( ) , varray ( ) ) ;
2022-08-11 10:12:27 +02:00
bind_method ( Vector2 , is_finite , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Vector2 , posmod , sarray ( " mod " ) , varray ( ) ) ;
bind_method ( Vector2 , posmodv , sarray ( " modv " ) , varray ( ) ) ;
bind_method ( Vector2 , project , sarray ( " b " ) , varray ( ) ) ;
2020-12-07 09:16:31 +01:00
bind_method ( Vector2 , lerp , sarray ( " to " , " weight " ) , varray ( ) ) ;
bind_method ( Vector2 , slerp , sarray ( " to " , " weight " ) , varray ( ) ) ;
bind_method ( Vector2 , cubic_interpolate , sarray ( " b " , " pre_a " , " post_b " , " weight " ) , varray ( ) ) ;
2022-07-28 21:55:10 +02:00
bind_method ( Vector2 , cubic_interpolate_in_time , sarray ( " b " , " pre_a " , " post_b " , " weight " , " b_t " , " pre_a_t " , " post_b_t " ) , varray ( ) ) ;
2022-06-27 19:41:32 +02:00
bind_method ( Vector2 , bezier_interpolate , sarray ( " control_1 " , " control_2 " , " end " , " t " ) , varray ( ) ) ;
2019-11-28 09:48:51 +01:00
bind_method ( Vector2 , max_axis_index , sarray ( ) , varray ( ) ) ;
bind_method ( Vector2 , min_axis_index , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Vector2 , move_toward , sarray ( " to " , " delta " ) , varray ( ) ) ;
2022-05-05 13:25:04 +02:00
bind_method ( Vector2 , rotated , sarray ( " angle " ) , varray ( ) ) ;
2020-12-06 19:16:06 +01:00
bind_method ( Vector2 , orthogonal , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Vector2 , floor , sarray ( ) , varray ( ) ) ;
bind_method ( Vector2 , ceil , sarray ( ) , varray ( ) ) ;
bind_method ( Vector2 , round , sarray ( ) , varray ( ) ) ;
bind_method ( Vector2 , aspect , sarray ( ) , varray ( ) ) ;
bind_method ( Vector2 , dot , sarray ( " with " ) , varray ( ) ) ;
bind_method ( Vector2 , slide , sarray ( " n " ) , varray ( ) ) ;
bind_method ( Vector2 , bounce , sarray ( " n " ) , varray ( ) ) ;
bind_method ( Vector2 , reflect , sarray ( " n " ) , varray ( ) ) ;
bind_method ( Vector2 , cross , sarray ( " with " ) , varray ( ) ) ;
bind_method ( Vector2 , abs , sarray ( ) , varray ( ) ) ;
bind_method ( Vector2 , sign , sarray ( ) , varray ( ) ) ;
2021-02-01 06:10:52 +01:00
bind_method ( Vector2 , clamp , sarray ( " min " , " max " ) , varray ( ) ) ;
2020-12-21 19:02:57 +01:00
bind_method ( Vector2 , snapped , sarray ( " step " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
2021-04-27 15:53:04 +02:00
bind_static_method ( Vector2 , from_angle , sarray ( " angle " ) , varray ( ) ) ;
2020-11-04 15:38:26 +01:00
/* Vector2i */
2020-10-13 20:59:37 +02:00
bind_method ( Vector2i , aspect , sarray ( ) , varray ( ) ) ;
2019-11-28 09:48:51 +01:00
bind_method ( Vector2i , max_axis_index , sarray ( ) , varray ( ) ) ;
bind_method ( Vector2i , min_axis_index , sarray ( ) , varray ( ) ) ;
2021-11-29 18:13:31 +01:00
bind_method ( Vector2i , length , sarray ( ) , varray ( ) ) ;
bind_method ( Vector2i , length_squared , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Vector2i , sign , sarray ( ) , varray ( ) ) ;
bind_method ( Vector2i , abs , sarray ( ) , varray ( ) ) ;
2021-02-01 06:10:52 +01:00
bind_method ( Vector2i , clamp , sarray ( " min " , " max " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
2020-11-04 15:38:26 +01:00
/* Rect2 */
2020-10-13 20:59:37 +02:00
2021-09-20 20:48:52 +02:00
bind_method ( Rect2 , get_center , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Rect2 , get_area , sarray ( ) , varray ( ) ) ;
2022-08-15 04:51:45 +02:00
bind_method ( Rect2 , has_area , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Rect2 , has_point , sarray ( " point " ) , varray ( ) ) ;
bind_method ( Rect2 , is_equal_approx , sarray ( " rect " ) , varray ( ) ) ;
2022-08-11 10:12:27 +02:00
bind_method ( Rect2 , is_finite , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Rect2 , intersects , sarray ( " b " , " include_borders " ) , varray ( false ) ) ;
bind_method ( Rect2 , encloses , sarray ( " b " ) , varray ( ) ) ;
2020-12-19 13:43:35 +01:00
bind_method ( Rect2 , intersection , sarray ( " b " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Rect2 , merge , sarray ( " b " ) , varray ( ) ) ;
bind_method ( Rect2 , expand , sarray ( " to " ) , varray ( ) ) ;
2020-12-28 10:11:58 +01:00
bind_method ( Rect2 , grow , sarray ( " amount " ) , varray ( ) ) ;
bind_methodv ( Rect2 , grow_side , & Rect2 : : grow_side_bind , sarray ( " side " , " amount " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Rect2 , grow_individual , sarray ( " left " , " top " , " right " , " bottom " ) , varray ( ) ) ;
bind_method ( Rect2 , abs , sarray ( ) , varray ( ) ) ;
/* Rect2i */
2021-09-20 20:48:52 +02:00
bind_method ( Rect2i , get_center , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Rect2i , get_area , sarray ( ) , varray ( ) ) ;
2022-08-15 04:51:45 +02:00
bind_method ( Rect2i , has_area , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Rect2i , has_point , sarray ( " point " ) , varray ( ) ) ;
bind_method ( Rect2i , intersects , sarray ( " b " ) , varray ( ) ) ;
bind_method ( Rect2i , encloses , sarray ( " b " ) , varray ( ) ) ;
2020-12-19 13:43:35 +01:00
bind_method ( Rect2i , intersection , sarray ( " b " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Rect2i , merge , sarray ( " b " ) , varray ( ) ) ;
bind_method ( Rect2i , expand , sarray ( " to " ) , varray ( ) ) ;
2020-12-28 10:11:58 +01:00
bind_method ( Rect2i , grow , sarray ( " amount " ) , varray ( ) ) ;
bind_methodv ( Rect2i , grow_side , & Rect2i : : grow_side_bind , sarray ( " side " , " amount " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Rect2i , grow_individual , sarray ( " left " , " top " , " right " , " bottom " ) , varray ( ) ) ;
bind_method ( Rect2i , abs , sarray ( ) , varray ( ) ) ;
/* Vector3 */
2019-11-28 09:48:51 +01:00
bind_method ( Vector3 , min_axis_index , sarray ( ) , varray ( ) ) ;
bind_method ( Vector3 , max_axis_index , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Vector3 , angle_to , sarray ( " to " ) , varray ( ) ) ;
2021-02-15 15:01:46 +01:00
bind_method ( Vector3 , signed_angle_to , sarray ( " to " , " axis " ) , varray ( ) ) ;
2021-11-29 18:02:42 +01:00
bind_method ( Vector3 , direction_to , sarray ( " to " ) , varray ( ) ) ;
bind_method ( Vector3 , distance_to , sarray ( " to " ) , varray ( ) ) ;
bind_method ( Vector3 , distance_squared_to , sarray ( " to " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Vector3 , length , sarray ( ) , varray ( ) ) ;
bind_method ( Vector3 , length_squared , sarray ( ) , varray ( ) ) ;
2021-02-01 06:42:00 +01:00
bind_method ( Vector3 , limit_length , sarray ( " length " ) , varray ( 1.0 ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Vector3 , normalized , sarray ( ) , varray ( ) ) ;
bind_method ( Vector3 , is_normalized , sarray ( ) , varray ( ) ) ;
bind_method ( Vector3 , is_equal_approx , sarray ( " to " ) , varray ( ) ) ;
2022-09-02 02:32:33 +02:00
bind_method ( Vector3 , is_zero_approx , sarray ( ) , varray ( ) ) ;
2022-08-11 10:12:27 +02:00
bind_method ( Vector3 , is_finite , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Vector3 , inverse , sarray ( ) , varray ( ) ) ;
2021-02-01 06:10:52 +01:00
bind_method ( Vector3 , clamp , sarray ( " min " , " max " ) , varray ( ) ) ;
2020-12-21 19:02:57 +01:00
bind_method ( Vector3 , snapped , sarray ( " step " ) , varray ( ) ) ;
2022-05-05 13:25:04 +02:00
bind_method ( Vector3 , rotated , sarray ( " axis " , " angle " ) , varray ( ) ) ;
2020-12-07 09:16:31 +01:00
bind_method ( Vector3 , lerp , sarray ( " to " , " weight " ) , varray ( ) ) ;
bind_method ( Vector3 , slerp , sarray ( " to " , " weight " ) , varray ( ) ) ;
bind_method ( Vector3 , cubic_interpolate , sarray ( " b " , " pre_a " , " post_b " , " weight " ) , varray ( ) ) ;
2022-07-28 21:55:10 +02:00
bind_method ( Vector3 , cubic_interpolate_in_time , sarray ( " b " , " pre_a " , " post_b " , " weight " , " b_t " , " pre_a_t " , " post_b_t " ) , varray ( ) ) ;
2022-06-27 19:41:32 +02:00
bind_method ( Vector3 , bezier_interpolate , sarray ( " control_1 " , " control_2 " , " end " , " t " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Vector3 , move_toward , sarray ( " to " , " delta " ) , varray ( ) ) ;
bind_method ( Vector3 , dot , sarray ( " with " ) , varray ( ) ) ;
bind_method ( Vector3 , cross , sarray ( " with " ) , varray ( ) ) ;
bind_method ( Vector3 , outer , sarray ( " with " ) , varray ( ) ) ;
bind_method ( Vector3 , abs , sarray ( ) , varray ( ) ) ;
bind_method ( Vector3 , floor , sarray ( ) , varray ( ) ) ;
bind_method ( Vector3 , ceil , sarray ( ) , varray ( ) ) ;
bind_method ( Vector3 , round , sarray ( ) , varray ( ) ) ;
bind_method ( Vector3 , posmod , sarray ( " mod " ) , varray ( ) ) ;
bind_method ( Vector3 , posmodv , sarray ( " modv " ) , varray ( ) ) ;
bind_method ( Vector3 , project , sarray ( " b " ) , varray ( ) ) ;
bind_method ( Vector3 , slide , sarray ( " n " ) , varray ( ) ) ;
bind_method ( Vector3 , bounce , sarray ( " n " ) , varray ( ) ) ;
bind_method ( Vector3 , reflect , sarray ( " n " ) , varray ( ) ) ;
bind_method ( Vector3 , sign , sarray ( ) , varray ( ) ) ;
2021-10-21 01:42:22 +02:00
bind_method ( Vector3 , octahedron_encode , sarray ( ) , varray ( ) ) ;
bind_static_method ( Vector3 , octahedron_decode , sarray ( " uv " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
/* Vector3i */
2019-11-28 09:48:51 +01:00
bind_method ( Vector3i , min_axis_index , sarray ( ) , varray ( ) ) ;
bind_method ( Vector3i , max_axis_index , sarray ( ) , varray ( ) ) ;
2021-11-29 18:13:31 +01:00
bind_method ( Vector3i , length , sarray ( ) , varray ( ) ) ;
bind_method ( Vector3i , length_squared , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Vector3i , sign , sarray ( ) , varray ( ) ) ;
bind_method ( Vector3i , abs , sarray ( ) , varray ( ) ) ;
2021-02-01 06:10:52 +01:00
bind_method ( Vector3i , clamp , sarray ( " min " , " max " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-20 01:11:13 +02:00
/* Vector4 */
bind_method ( Vector4 , min_axis_index , sarray ( ) , varray ( ) ) ;
bind_method ( Vector4 , max_axis_index , sarray ( ) , varray ( ) ) ;
bind_method ( Vector4 , length , sarray ( ) , varray ( ) ) ;
bind_method ( Vector4 , length_squared , sarray ( ) , varray ( ) ) ;
bind_method ( Vector4 , abs , sarray ( ) , varray ( ) ) ;
2022-07-25 22:49:18 +02:00
bind_method ( Vector4 , sign , sarray ( ) , varray ( ) ) ;
bind_method ( Vector4 , floor , sarray ( ) , varray ( ) ) ;
bind_method ( Vector4 , ceil , sarray ( ) , varray ( ) ) ;
bind_method ( Vector4 , round , sarray ( ) , varray ( ) ) ;
bind_method ( Vector4 , lerp , sarray ( " to " , " weight " ) , varray ( ) ) ;
2022-08-07 12:25:05 +02:00
bind_method ( Vector4 , cubic_interpolate , sarray ( " b " , " pre_a " , " post_b " , " weight " ) , varray ( ) ) ;
2022-07-28 21:55:10 +02:00
bind_method ( Vector4 , cubic_interpolate_in_time , sarray ( " b " , " pre_a " , " post_b " , " weight " , " b_t " , " pre_a_t " , " post_b_t " ) , varray ( ) ) ;
2022-08-07 12:25:05 +02:00
bind_method ( Vector4 , posmod , sarray ( " mod " ) , varray ( ) ) ;
bind_method ( Vector4 , posmodv , sarray ( " modv " ) , varray ( ) ) ;
bind_method ( Vector4 , snapped , sarray ( " step " ) , varray ( ) ) ;
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-20 01:11:13 +02:00
bind_method ( Vector4 , clamp , sarray ( " min " , " max " ) , varray ( ) ) ;
bind_method ( Vector4 , normalized , sarray ( ) , varray ( ) ) ;
bind_method ( Vector4 , is_normalized , sarray ( ) , varray ( ) ) ;
2022-08-07 12:25:05 +02:00
bind_method ( Vector4 , direction_to , sarray ( " to " ) , varray ( ) ) ;
bind_method ( Vector4 , distance_to , sarray ( " to " ) , varray ( ) ) ;
2022-08-08 17:05:55 +02:00
bind_method ( Vector4 , distance_squared_to , sarray ( " to " ) , varray ( ) ) ;
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-20 01:11:13 +02:00
bind_method ( Vector4 , dot , sarray ( " with " ) , varray ( ) ) ;
bind_method ( Vector4 , inverse , sarray ( ) , varray ( ) ) ;
bind_method ( Vector4 , is_equal_approx , sarray ( " with " ) , varray ( ) ) ;
2022-09-02 02:32:33 +02:00
bind_method ( Vector4 , is_zero_approx , sarray ( ) , varray ( ) ) ;
2022-08-11 10:12:27 +02:00
bind_method ( Vector4 , is_finite , sarray ( ) , varray ( ) ) ;
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-20 01:11:13 +02:00
/* Vector4i */
bind_method ( Vector4i , min_axis_index , sarray ( ) , varray ( ) ) ;
bind_method ( Vector4i , max_axis_index , sarray ( ) , varray ( ) ) ;
bind_method ( Vector4i , length , sarray ( ) , varray ( ) ) ;
bind_method ( Vector4i , length_squared , sarray ( ) , varray ( ) ) ;
bind_method ( Vector4i , sign , sarray ( ) , varray ( ) ) ;
bind_method ( Vector4i , abs , sarray ( ) , varray ( ) ) ;
bind_method ( Vector4i , clamp , sarray ( " min " , " max " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
/* Plane */
bind_method ( Plane , normalized , sarray ( ) , varray ( ) ) ;
bind_method ( Plane , center , sarray ( ) , varray ( ) ) ;
bind_method ( Plane , is_equal_approx , sarray ( " to_plane " ) , varray ( ) ) ;
2022-08-11 10:12:27 +02:00
bind_method ( Plane , is_finite , sarray ( ) , varray ( ) ) ;
2022-07-24 11:30:32 +02:00
bind_method ( Plane , is_point_over , sarray ( " point " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Plane , distance_to , sarray ( " point " ) , varray ( ) ) ;
2022-07-21 18:34:09 +02:00
bind_method ( Plane , has_point , sarray ( " point " , " tolerance " ) , varray ( CMP_EPSILON ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Plane , project , sarray ( " point " ) , varray ( ) ) ;
2020-11-11 17:16:08 +01:00
bind_methodv ( Plane , intersect_3 , & Plane : : intersect_3_bind , sarray ( " b " , " c " ) , varray ( ) ) ;
bind_methodv ( Plane , intersects_ray , & Plane : : intersects_ray_bind , sarray ( " from " , " dir " ) , varray ( ) ) ;
bind_methodv ( Plane , intersects_segment , & Plane : : intersects_segment_bind , sarray ( " from " , " to " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
2021-01-20 08:02:02 +01:00
/* Quaternion */
bind_method ( Quaternion , length , sarray ( ) , varray ( ) ) ;
bind_method ( Quaternion , length_squared , sarray ( ) , varray ( ) ) ;
bind_method ( Quaternion , normalized , sarray ( ) , varray ( ) ) ;
bind_method ( Quaternion , is_normalized , sarray ( ) , varray ( ) ) ;
bind_method ( Quaternion , is_equal_approx , sarray ( " to " ) , varray ( ) ) ;
2022-08-11 10:12:27 +02:00
bind_method ( Quaternion , is_finite , sarray ( ) , varray ( ) ) ;
2021-01-20 08:02:02 +01:00
bind_method ( Quaternion , inverse , sarray ( ) , varray ( ) ) ;
2022-03-15 17:35:25 +01:00
bind_method ( Quaternion , log , sarray ( ) , varray ( ) ) ;
bind_method ( Quaternion , exp , sarray ( ) , varray ( ) ) ;
2020-12-07 07:40:46 +01:00
bind_method ( Quaternion , angle_to , sarray ( " to " ) , varray ( ) ) ;
2021-01-20 08:02:02 +01:00
bind_method ( Quaternion , dot , sarray ( " with " ) , varray ( ) ) ;
bind_method ( Quaternion , slerp , sarray ( " to " , " weight " ) , varray ( ) ) ;
bind_method ( Quaternion , slerpni , sarray ( " to " , " weight " ) , varray ( ) ) ;
2022-07-27 14:27:51 +02:00
bind_method ( Quaternion , spherical_cubic_interpolate , sarray ( " b " , " pre_a " , " post_b " , " weight " ) , varray ( ) ) ;
2022-07-28 21:55:10 +02:00
bind_method ( Quaternion , spherical_cubic_interpolate_in_time , sarray ( " b " , " pre_a " , " post_b " , " weight " , " b_t " , " pre_a_t " , " post_b_t " ) , varray ( ) ) ;
2021-01-20 08:02:02 +01:00
bind_method ( Quaternion , get_euler , sarray ( ) , varray ( ) ) ;
2021-10-21 01:42:22 +02:00
bind_method ( Quaternion , get_axis , sarray ( ) , varray ( ) ) ;
bind_method ( Quaternion , get_angle , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
/* Color */
bind_method ( Color , to_argb32 , sarray ( ) , varray ( ) ) ;
bind_method ( Color , to_abgr32 , sarray ( ) , varray ( ) ) ;
bind_method ( Color , to_rgba32 , sarray ( ) , varray ( ) ) ;
bind_method ( Color , to_argb64 , sarray ( ) , varray ( ) ) ;
bind_method ( Color , to_abgr64 , sarray ( ) , varray ( ) ) ;
bind_method ( Color , to_rgba64 , sarray ( ) , varray ( ) ) ;
2021-11-11 09:01:39 +01:00
bind_method ( Color , to_html , sarray ( " with_alpha " ) , varray ( true ) ) ;
2020-10-13 20:59:37 +02:00
2021-02-01 06:10:52 +01:00
bind_method ( Color , clamp , sarray ( " min " , " max " ) , varray ( Color ( 0 , 0 , 0 , 0 ) , Color ( 1 , 1 , 1 , 1 ) ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Color , inverted , sarray ( ) , varray ( ) ) ;
2020-12-07 09:16:31 +01:00
bind_method ( Color , lerp , sarray ( " to " , " weight " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Color , lightened , sarray ( " amount " ) , varray ( ) ) ;
bind_method ( Color , darkened , sarray ( " amount " ) , varray ( ) ) ;
2020-10-15 17:29:59 +02:00
bind_method ( Color , blend , sarray ( " over " ) , varray ( ) ) ;
2021-12-16 06:59:04 +01:00
bind_method ( Color , get_luminance , sarray ( ) , varray ( ) ) ;
2022-04-13 10:37:22 +02:00
bind_method ( Color , srgb_to_linear , sarray ( ) , varray ( ) ) ;
bind_method ( Color , linear_to_srgb , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Color , is_equal_approx , sarray ( " to " ) , varray ( ) ) ;
2021-02-24 14:56:34 +01:00
bind_static_method ( Color , hex , sarray ( " hex " ) , varray ( ) ) ;
bind_static_method ( Color , hex64 , sarray ( " hex " ) , varray ( ) ) ;
bind_static_method ( Color , html , sarray ( " rgba " ) , varray ( ) ) ;
bind_static_method ( Color , html_is_valid , sarray ( " color " ) , varray ( ) ) ;
bind_static_method ( Color , find_named_color , sarray ( " name " ) , varray ( ) ) ;
bind_static_method ( Color , get_named_color_count , sarray ( ) , varray ( ) ) ;
bind_static_method ( Color , get_named_color_name , sarray ( " idx " ) , varray ( ) ) ;
bind_static_method ( Color , get_named_color , sarray ( " idx " ) , varray ( ) ) ;
bind_static_method ( Color , from_string , sarray ( " str " , " default " ) , varray ( ) ) ;
2021-11-11 09:01:39 +01:00
bind_static_method ( Color , from_hsv , sarray ( " h " , " s " , " v " , " alpha " ) , varray ( 1.0 ) ) ;
2022-04-18 20:29:29 +02:00
bind_static_method ( Color , from_ok_hsl , sarray ( " h " , " s " , " l " , " alpha " ) , varray ( 1.0 ) ) ;
2021-02-24 14:56:34 +01:00
bind_static_method ( Color , from_rgbe9995 , sarray ( " rgbe " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
/* RID */
2022-02-08 08:49:14 +01:00
bind_method ( RID , is_valid , sarray ( ) , varray ( ) ) ;
2020-11-11 17:16:08 +01:00
bind_method ( RID , get_id , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
/* NodePath */
bind_method ( NodePath , is_absolute , sarray ( ) , varray ( ) ) ;
bind_method ( NodePath , get_name_count , sarray ( ) , varray ( ) ) ;
bind_method ( NodePath , get_name , sarray ( " idx " ) , varray ( ) ) ;
bind_method ( NodePath , get_subname_count , sarray ( ) , varray ( ) ) ;
2022-06-06 11:19:56 +02:00
bind_method ( NodePath , hash , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( NodePath , get_subname , sarray ( " idx " ) , varray ( ) ) ;
2022-06-27 10:06:50 +02:00
bind_method ( NodePath , get_concatenated_names , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( NodePath , get_concatenated_subnames , sarray ( ) , varray ( ) ) ;
bind_method ( NodePath , get_as_property_path , sarray ( ) , varray ( ) ) ;
bind_method ( NodePath , is_empty , sarray ( ) , varray ( ) ) ;
/* Callable */
2022-09-20 22:32:46 +02:00
bind_method ( Callable , callv , sarray ( " arguments " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Callable , is_null , sarray ( ) , varray ( ) ) ;
bind_method ( Callable , is_custom , sarray ( ) , varray ( ) ) ;
bind_method ( Callable , is_standard , sarray ( ) , varray ( ) ) ;
2021-06-30 16:36:46 +02:00
bind_method ( Callable , is_valid , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Callable , get_object , sarray ( ) , varray ( ) ) ;
bind_method ( Callable , get_object_id , sarray ( ) , varray ( ) ) ;
bind_method ( Callable , get_method , sarray ( ) , varray ( ) ) ;
bind_method ( Callable , hash , sarray ( ) , varray ( ) ) ;
bind_method ( Callable , unbind , sarray ( " argcount " ) , varray ( ) ) ;
2020-11-11 17:16:08 +01:00
bind_custom ( Callable , call , _VariantCall : : func_Callable_call , true , Variant ) ;
bind_custom ( Callable , call_deferred , _VariantCall : : func_Callable_call_deferred , false , Variant ) ;
2021-05-03 23:00:44 +02:00
bind_custom ( Callable , rpc , _VariantCall : : func_Callable_rpc , false , Variant ) ;
bind_custom1 ( Callable , rpc_id , _VariantCall : : func_Callable_rpc_id , Variant : : INT , " peer_id " ) ;
2020-11-11 17:16:08 +01:00
bind_custom ( Callable , bind , _VariantCall : : func_Callable_bind , true , Callable ) ;
2020-10-13 20:59:37 +02:00
/* Signal */
bind_method ( Signal , is_null , sarray ( ) , varray ( ) ) ;
bind_method ( Signal , get_object , sarray ( ) , varray ( ) ) ;
bind_method ( Signal , get_object_id , sarray ( ) , varray ( ) ) ;
bind_method ( Signal , get_name , sarray ( ) , varray ( ) ) ;
2021-09-19 18:55:23 +02:00
bind_method ( Signal , connect , sarray ( " callable " , " flags " ) , varray ( 0 ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Signal , disconnect , sarray ( " callable " ) , varray ( ) ) ;
bind_method ( Signal , is_connected , sarray ( " callable " ) , varray ( ) ) ;
bind_method ( Signal , get_connections , sarray ( ) , varray ( ) ) ;
2020-11-11 17:16:08 +01:00
bind_custom ( Signal , emit , _VariantCall : : func_Signal_emit , false , Variant ) ;
2020-10-13 20:59:37 +02:00
/* Transform2D */
bind_method ( Transform2D , inverse , sarray ( ) , varray ( ) ) ;
bind_method ( Transform2D , affine_inverse , sarray ( ) , varray ( ) ) ;
bind_method ( Transform2D , get_rotation , sarray ( ) , varray ( ) ) ;
bind_method ( Transform2D , get_origin , sarray ( ) , varray ( ) ) ;
bind_method ( Transform2D , get_scale , sarray ( ) , varray ( ) ) ;
2021-09-02 11:36:19 +02:00
bind_method ( Transform2D , get_skew , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Transform2D , orthonormalized , sarray ( ) , varray ( ) ) ;
2022-05-05 13:25:04 +02:00
bind_method ( Transform2D , rotated , sarray ( " angle " ) , varray ( ) ) ;
2022-07-30 12:17:33 +02:00
bind_method ( Transform2D , rotated_local , sarray ( " angle " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Transform2D , scaled , sarray ( " scale " ) , varray ( ) ) ;
2022-07-30 12:17:33 +02:00
bind_method ( Transform2D , scaled_local , sarray ( " scale " ) , varray ( ) ) ;
bind_method ( Transform2D , translated , sarray ( " offset " ) , varray ( ) ) ;
2022-07-16 11:47:54 +02:00
bind_method ( Transform2D , translated_local , sarray ( " offset " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Transform2D , basis_xform , sarray ( " v " ) , varray ( ) ) ;
bind_method ( Transform2D , basis_xform_inv , sarray ( " v " ) , varray ( ) ) ;
2020-12-07 09:16:31 +01:00
bind_method ( Transform2D , interpolate_with , sarray ( " xform " , " weight " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Transform2D , is_equal_approx , sarray ( " xform " ) , varray ( ) ) ;
2022-08-11 10:12:27 +02:00
bind_method ( Transform2D , is_finite , sarray ( ) , varray ( ) ) ;
New and improved IK system for Skeleton2D
This PR and commit adds a new IK system for 2D with the Skeleton2D node
that adds several new IK solvers, a way to control bones in a Skeleton2D
node similar to that in Skeleton3D. It also adds additional changes
and functionality.
This work was sponsored by GSoC 2020 and TwistedTwigleg.
Full list of changes:
* Adds a SkeletonModifier2D resource
* This resource is the base where all IK code is written and executed
* Has a function for clamping angles, since it is so commonly used
* Modifiers are unique when duplicated so it works with instancing
* Adds a SkeletonModifierStack2D resource
* This resource manages a series of SkeletonModification2Ds
* This is what the Skeleton2D directly interfaces with to make IK possible
* Adds SkeletonModifier2D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
* Each modification is in its own file
* There is also a SkeletonModifier2D resource that acts as a stack for using multiple stacks together
* Adds a PhysicalBone2D node
* Works similar to the PhysicalBone3D node, but uses a RigidBody2D node
* Changes to Skeleton2D listed below:
* Skeleton2D now holds a single SkeletonModificationStack2D for IK
* Skeleton2D now has a local_pose_override, which overrides the Bone2D position similar to how the overrides work in Skeleton3D
* Changes to Bone2D listed below:
* The default_length property has been changed to length. Length is the length of the bone to its child bone node
* New bone_angle property, which is the angle the bone has to its first child bone node
* Bone2D caches its transform when not modified by IK for IK interpolation purposes
* Bone2D draws its own editor gizmo, though this is stated to change in the future
* Changes to CanvasItemEditor listed below:
* Bone2D gizmo drawing code removed
* The 2D IK code is removed. Now Bone2D is the only bone system for 2D
* Transform2D now has a looking_at function for rotating to face a position
* Two new node notifications: NOTIFICATION_EDITOR_PRE_SAVE and NOTIFICATION_EDITOR_POST_SAVE
* These notifications only are called in the editor right before and after saving a scene
* Needed for not saving the IK position when executing IK in the editor
* Documentation for all the changes listed above.
2020-08-03 20:02:24 +02:00
bind_method ( Transform2D , set_rotation , sarray ( " rotation " ) , varray ( ) ) ;
2021-09-02 11:36:19 +02:00
bind_method ( Transform2D , set_scale , sarray ( " scale " ) , varray ( ) ) ;
bind_method ( Transform2D , set_skew , sarray ( " skew " ) , varray ( ) ) ;
2021-07-29 15:42:05 +02:00
bind_method ( Transform2D , looking_at , sarray ( " target " ) , varray ( Vector2 ( ) ) ) ;
2020-10-13 20:59:37 +02:00
/* Basis */
bind_method ( Basis , inverse , sarray ( ) , varray ( ) ) ;
bind_method ( Basis , transposed , sarray ( ) , varray ( ) ) ;
bind_method ( Basis , orthonormalized , sarray ( ) , varray ( ) ) ;
bind_method ( Basis , determinant , sarray ( ) , varray ( ) ) ;
2022-05-05 13:25:04 +02:00
bind_methodv ( Basis , rotated , static_cast < Basis ( Basis : : * ) ( const Vector3 & , real_t ) const > ( & Basis : : rotated ) , sarray ( " axis " , " angle " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Basis , scaled , sarray ( " scale " ) , varray ( ) ) ;
bind_method ( Basis , get_scale , sarray ( ) , varray ( ) ) ;
2022-09-25 01:19:55 +02:00
bind_method ( Basis , get_euler , sarray ( " order " ) , varray ( ( int64_t ) Basis : : EULER_ORDER_YXZ ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Basis , tdotx , sarray ( " with " ) , varray ( ) ) ;
bind_method ( Basis , tdoty , sarray ( " with " ) , varray ( ) ) ;
bind_method ( Basis , tdotz , sarray ( " with " ) , varray ( ) ) ;
2020-12-07 09:16:31 +01:00
bind_method ( Basis , slerp , sarray ( " to " , " weight " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Basis , is_equal_approx , sarray ( " b " ) , varray ( ) ) ;
2022-08-11 10:12:27 +02:00
bind_method ( Basis , is_finite , sarray ( ) , varray ( ) ) ;
2021-01-20 08:02:02 +01:00
bind_method ( Basis , get_rotation_quaternion , sarray ( ) , varray ( ) ) ;
2021-07-21 05:32:00 +02:00
bind_static_method ( Basis , looking_at , sarray ( " target " , " up " ) , varray ( Vector3 ( 0 , 1 , 0 ) ) ) ;
2021-09-06 22:39:01 +02:00
bind_static_method ( Basis , from_scale , sarray ( " scale " ) , varray ( ) ) ;
2022-09-25 01:19:55 +02:00
bind_static_method ( Basis , from_euler , sarray ( " euler " , " order " ) , varray ( ( int64_t ) Basis : : EULER_ORDER_YXZ ) ) ;
2020-10-13 20:59:37 +02:00
/* AABB */
2020-11-11 17:16:08 +01:00
bind_method ( AABB , abs , sarray ( ) , varray ( ) ) ;
2021-09-20 20:48:52 +02:00
bind_method ( AABB , get_center , sarray ( ) , varray ( ) ) ;
2021-11-05 02:01:59 +01:00
bind_method ( AABB , get_volume , sarray ( ) , varray ( ) ) ;
2022-08-15 04:48:13 +02:00
bind_method ( AABB , has_volume , sarray ( ) , varray ( ) ) ;
bind_method ( AABB , has_surface , sarray ( ) , varray ( ) ) ;
2020-11-11 17:16:08 +01:00
bind_method ( AABB , has_point , sarray ( " point " ) , varray ( ) ) ;
bind_method ( AABB , is_equal_approx , sarray ( " aabb " ) , varray ( ) ) ;
2022-08-11 10:12:27 +02:00
bind_method ( AABB , is_finite , sarray ( ) , varray ( ) ) ;
2020-11-11 17:16:08 +01:00
bind_method ( AABB , intersects , sarray ( " with " ) , varray ( ) ) ;
bind_method ( AABB , encloses , sarray ( " with " ) , varray ( ) ) ;
bind_method ( AABB , intersects_plane , sarray ( " plane " ) , varray ( ) ) ;
bind_method ( AABB , intersection , sarray ( " with " ) , varray ( ) ) ;
bind_method ( AABB , merge , sarray ( " with " ) , varray ( ) ) ;
bind_method ( AABB , expand , sarray ( " to_point " ) , varray ( ) ) ;
bind_method ( AABB , grow , sarray ( " by " ) , varray ( ) ) ;
bind_method ( AABB , get_support , sarray ( " dir " ) , varray ( ) ) ;
bind_method ( AABB , get_longest_axis , sarray ( ) , varray ( ) ) ;
bind_method ( AABB , get_longest_axis_index , sarray ( ) , varray ( ) ) ;
bind_method ( AABB , get_longest_axis_size , sarray ( ) , varray ( ) ) ;
bind_method ( AABB , get_shortest_axis , sarray ( ) , varray ( ) ) ;
bind_method ( AABB , get_shortest_axis_index , sarray ( ) , varray ( ) ) ;
bind_method ( AABB , get_shortest_axis_size , sarray ( ) , varray ( ) ) ;
bind_method ( AABB , get_endpoint , sarray ( " idx " ) , varray ( ) ) ;
bind_methodv ( AABB , intersects_segment , & AABB : : intersects_segment_bind , sarray ( " from " , " to " ) , varray ( ) ) ;
bind_methodv ( AABB , intersects_ray , & AABB : : intersects_ray_bind , sarray ( " from " , " dir " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
2020-10-17 07:08:21 +02:00
/* Transform3D */
bind_method ( Transform3D , inverse , sarray ( ) , varray ( ) ) ;
bind_method ( Transform3D , affine_inverse , sarray ( ) , varray ( ) ) ;
bind_method ( Transform3D , orthonormalized , sarray ( ) , varray ( ) ) ;
2022-05-05 13:25:04 +02:00
bind_method ( Transform3D , rotated , sarray ( " axis " , " angle " ) , varray ( ) ) ;
2022-07-30 12:17:33 +02:00
bind_method ( Transform3D , rotated_local , sarray ( " axis " , " angle " ) , varray ( ) ) ;
2020-10-17 07:08:21 +02:00
bind_method ( Transform3D , scaled , sarray ( " scale " ) , varray ( ) ) ;
2022-07-30 12:17:33 +02:00
bind_method ( Transform3D , scaled_local , sarray ( " scale " ) , varray ( ) ) ;
bind_method ( Transform3D , translated , sarray ( " offset " ) , varray ( ) ) ;
2022-07-16 11:47:54 +02:00
bind_method ( Transform3D , translated_local , sarray ( " offset " ) , varray ( ) ) ;
2020-10-17 07:08:21 +02:00
bind_method ( Transform3D , looking_at , sarray ( " target " , " up " ) , varray ( Vector3 ( 0 , 1 , 0 ) ) ) ;
bind_method ( Transform3D , interpolate_with , sarray ( " xform " , " weight " ) , varray ( ) ) ;
bind_method ( Transform3D , is_equal_approx , sarray ( " xform " ) , varray ( ) ) ;
2022-08-11 10:12:27 +02:00
bind_method ( Transform3D , is_finite , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-20 01:11:13 +02:00
/* Projection */
bind_static_method ( Projection , create_depth_correction , sarray ( " flip_y " ) , varray ( ) ) ;
bind_static_method ( Projection , create_light_atlas_rect , sarray ( " rect " ) , varray ( ) ) ;
bind_static_method ( Projection , create_perspective , sarray ( " fovy " , " aspect " , " z_near " , " z_far " , " flip_fov " ) , varray ( false ) ) ;
bind_static_method ( Projection , create_perspective_hmd , sarray ( " fovy " , " aspect " , " z_near " , " z_far " , " flip_fov " , " eye " , " intraocular_dist " , " convergence_dist " ) , varray ( ) ) ;
bind_static_method ( Projection , create_for_hmd , sarray ( " eye " , " aspect " , " intraocular_dist " , " display_width " , " display_to_lens " , " oversample " , " z_near " , " z_far " ) , varray ( ) ) ;
bind_static_method ( Projection , create_orthogonal , sarray ( " left " , " right " , " bottom " , " top " , " z_near " , " z_far " ) , varray ( ) ) ;
bind_static_method ( Projection , create_orthogonal_aspect , sarray ( " size " , " aspect " , " z_near " , " z_far " , " flip_fov " ) , varray ( false ) ) ;
bind_static_method ( Projection , create_frustum , sarray ( " left " , " right " , " bottom " , " top " , " z_near " , " z_far " ) , varray ( ) ) ;
bind_static_method ( Projection , create_frustum_aspect , sarray ( " size " , " aspect " , " offset " , " z_near " , " z_far " , " flip_fov " ) , varray ( false ) ) ;
bind_static_method ( Projection , create_fit_aabb , sarray ( " aabb " ) , varray ( ) ) ;
bind_method ( Projection , determinant , sarray ( ) , varray ( ) ) ;
bind_method ( Projection , perspective_znear_adjusted , sarray ( " new_znear " ) , varray ( ) ) ;
bind_method ( Projection , get_projection_plane , sarray ( " plane " ) , varray ( ) ) ;
bind_method ( Projection , flipped_y , sarray ( ) , varray ( ) ) ;
bind_method ( Projection , jitter_offseted , sarray ( " offset " ) , varray ( ) ) ;
bind_static_method ( Projection , get_fovy , sarray ( " fovx " , " aspect " ) , varray ( ) ) ;
bind_method ( Projection , get_z_far , sarray ( ) , varray ( ) ) ;
bind_method ( Projection , get_z_near , sarray ( ) , varray ( ) ) ;
bind_method ( Projection , get_aspect , sarray ( ) , varray ( ) ) ;
bind_method ( Projection , get_fov , sarray ( ) , varray ( ) ) ;
bind_method ( Projection , is_orthogonal , sarray ( ) , varray ( ) ) ;
bind_method ( Projection , get_viewport_half_extents , sarray ( ) , varray ( ) ) ;
bind_method ( Projection , get_far_plane_half_extents , sarray ( ) , varray ( ) ) ;
bind_method ( Projection , inverse , sarray ( ) , varray ( ) ) ;
bind_method ( Projection , get_pixels_per_meter , sarray ( " for_pixel_width " ) , varray ( ) ) ;
bind_method ( Projection , get_lod_multiplier , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
/* Dictionary */
bind_method ( Dictionary , size , sarray ( ) , varray ( ) ) ;
2020-12-15 13:04:21 +01:00
bind_method ( Dictionary , is_empty , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Dictionary , clear , sarray ( ) , varray ( ) ) ;
2022-04-04 18:46:55 +02:00
bind_method ( Dictionary , merge , sarray ( " dictionary " , " overwrite " ) , varray ( false ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Dictionary , has , sarray ( " key " ) , varray ( ) ) ;
bind_method ( Dictionary , has_all , sarray ( " keys " ) , varray ( ) ) ;
2022-08-05 19:08:27 +02:00
bind_method ( Dictionary , find_key , sarray ( " value " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Dictionary , erase , sarray ( " key " ) , varray ( ) ) ;
bind_method ( Dictionary , hash , sarray ( ) , varray ( ) ) ;
bind_method ( Dictionary , keys , sarray ( ) , varray ( ) ) ;
bind_method ( Dictionary , values , sarray ( ) , varray ( ) ) ;
2020-10-15 17:29:59 +02:00
bind_method ( Dictionary , duplicate , sarray ( " deep " ) , varray ( false ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Dictionary , get , sarray ( " key " , " default " ) , varray ( Variant ( ) ) ) ;
/* Array */
bind_method ( Array , size , sarray ( ) , varray ( ) ) ;
2020-12-15 13:04:21 +01:00
bind_method ( Array , is_empty , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Array , clear , sarray ( ) , varray ( ) ) ;
bind_method ( Array , hash , sarray ( ) , varray ( ) ) ;
bind_method ( Array , push_back , sarray ( " value " ) , varray ( ) ) ;
bind_method ( Array , push_front , sarray ( " value " ) , varray ( ) ) ;
bind_method ( Array , append , sarray ( " value " ) , varray ( ) ) ;
2020-11-08 21:09:45 +01:00
bind_method ( Array , append_array , sarray ( " array " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Array , resize , sarray ( " size " ) , varray ( ) ) ;
bind_method ( Array , insert , sarray ( " position " , " value " ) , varray ( ) ) ;
2021-07-04 00:17:03 +02:00
bind_method ( Array , remove_at , sarray ( " position " ) , varray ( ) ) ;
2021-02-25 15:10:39 +01:00
bind_method ( Array , fill , sarray ( " value " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Array , erase , sarray ( " value " ) , varray ( ) ) ;
bind_method ( Array , front , sarray ( ) , varray ( ) ) ;
bind_method ( Array , back , sarray ( ) , varray ( ) ) ;
2022-10-15 14:43:16 +02:00
bind_method ( Array , pick_random , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Array , find , sarray ( " what " , " from " ) , varray ( 0 ) ) ;
bind_method ( Array , rfind , sarray ( " what " , " from " ) , varray ( - 1 ) ) ;
bind_method ( Array , find_last , sarray ( " value " ) , varray ( ) ) ;
bind_method ( Array , count , sarray ( " value " ) , varray ( ) ) ;
bind_method ( Array , has , sarray ( " value " ) , varray ( ) ) ;
bind_method ( Array , pop_back , sarray ( ) , varray ( ) ) ;
bind_method ( Array , pop_front , sarray ( ) , varray ( ) ) ;
2021-08-27 00:51:17 +02:00
bind_method ( Array , pop_at , sarray ( " position " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Array , sort , sarray ( ) , varray ( ) ) ;
2021-02-04 02:02:06 +01:00
bind_method ( Array , sort_custom , sarray ( " func " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Array , shuffle , sarray ( ) , varray ( ) ) ;
bind_method ( Array , bsearch , sarray ( " value " , " before " ) , varray ( true ) ) ;
2021-02-04 02:02:06 +01:00
bind_method ( Array , bsearch_custom , sarray ( " value " , " func " , " before " ) , varray ( true ) ) ;
2021-03-14 08:21:32 +01:00
bind_method ( Array , reverse , sarray ( ) , varray ( ) ) ;
2020-10-15 17:29:59 +02:00
bind_method ( Array , duplicate , sarray ( " deep " ) , varray ( false ) ) ;
2022-01-10 13:56:55 +01:00
bind_method ( Array , slice , sarray ( " begin " , " end " , " step " , " deep " ) , varray ( INT_MAX , 1 , false ) ) ;
2020-10-19 21:21:16 +02:00
bind_method ( Array , filter , sarray ( " method " ) , varray ( ) ) ;
bind_method ( Array , map , sarray ( " method " ) , varray ( ) ) ;
bind_method ( Array , reduce , sarray ( " method " , " accum " ) , varray ( Variant ( ) ) ) ;
2021-07-10 20:19:47 +02:00
bind_method ( Array , any , sarray ( " method " ) , varray ( ) ) ;
bind_method ( Array , all , sarray ( " method " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( Array , max , sarray ( ) , varray ( ) ) ;
bind_method ( Array , min , sarray ( ) , varray ( ) ) ;
2022-08-25 11:35:30 +02:00
bind_method ( Array , typed_assign , sarray ( " array " ) , varray ( ) ) ;
bind_method ( Array , set_typed , sarray ( " type " , " class_name " , " script " ) , varray ( ) ) ;
bind_method ( Array , is_typed , sarray ( ) , varray ( ) ) ;
bind_method ( Array , get_typed_builtin , sarray ( ) , varray ( ) ) ;
bind_method ( Array , get_typed_class_name , sarray ( ) , varray ( ) ) ;
bind_method ( Array , get_typed_script , sarray ( ) , varray ( ) ) ;
bind_method ( Array , set_read_only , sarray ( " enable " ) , varray ( ) ) ;
bind_method ( Array , is_read_only , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
/* Byte Array */
bind_method ( PackedByteArray , size , sarray ( ) , varray ( ) ) ;
2020-12-15 13:04:21 +01:00
bind_method ( PackedByteArray , is_empty , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedByteArray , set , sarray ( " index " , " value " ) , varray ( ) ) ;
bind_method ( PackedByteArray , push_back , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedByteArray , append , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedByteArray , append_array , sarray ( " array " ) , varray ( ) ) ;
2021-07-04 00:17:03 +02:00
bind_method ( PackedByteArray , remove_at , sarray ( " index " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedByteArray , insert , sarray ( " at_index " , " value " ) , varray ( ) ) ;
2021-02-25 15:10:39 +01:00
bind_method ( PackedByteArray , fill , sarray ( " value " ) , varray ( ) ) ;
2022-07-04 16:43:49 +02:00
bind_methodv ( PackedByteArray , resize , & PackedByteArray : : resize_zeroed , sarray ( " new_size " ) , varray ( ) ) ;
2022-08-10 11:12:20 +02:00
bind_method ( PackedByteArray , clear , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedByteArray , has , sarray ( " value " ) , varray ( ) ) ;
2021-03-14 08:21:32 +01:00
bind_method ( PackedByteArray , reverse , sarray ( ) , varray ( ) ) ;
2022-01-10 13:56:55 +01:00
bind_method ( PackedByteArray , slice , sarray ( " begin " , " end " ) , varray ( INT_MAX ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedByteArray , sort , sarray ( ) , varray ( ) ) ;
2021-09-19 20:13:09 +02:00
bind_method ( PackedByteArray , bsearch , sarray ( " value " , " before " ) , varray ( true ) ) ;
2020-12-17 21:26:05 +01:00
bind_method ( PackedByteArray , duplicate , sarray ( ) , varray ( ) ) ;
2022-05-07 14:16:11 +02:00
bind_method ( PackedByteArray , find , sarray ( " value " , " from " ) , varray ( 0 ) ) ;
bind_method ( PackedByteArray , rfind , sarray ( " value " , " from " ) , varray ( - 1 ) ) ;
bind_method ( PackedByteArray , count , sarray ( " value " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
2020-11-11 17:16:08 +01:00
bind_function ( PackedByteArray , get_string_from_ascii , _VariantCall : : func_PackedByteArray_get_string_from_ascii , sarray ( ) , varray ( ) ) ;
bind_function ( PackedByteArray , get_string_from_utf8 , _VariantCall : : func_PackedByteArray_get_string_from_utf8 , sarray ( ) , varray ( ) ) ;
bind_function ( PackedByteArray , get_string_from_utf16 , _VariantCall : : func_PackedByteArray_get_string_from_utf16 , sarray ( ) , varray ( ) ) ;
bind_function ( PackedByteArray , get_string_from_utf32 , _VariantCall : : func_PackedByteArray_get_string_from_utf32 , sarray ( ) , varray ( ) ) ;
bind_function ( PackedByteArray , hex_encode , _VariantCall : : func_PackedByteArray_hex_encode , sarray ( ) , varray ( ) ) ;
bind_function ( PackedByteArray , compress , _VariantCall : : func_PackedByteArray_compress , sarray ( " compression_mode " ) , varray ( 0 ) ) ;
bind_function ( PackedByteArray , decompress , _VariantCall : : func_PackedByteArray_decompress , sarray ( " buffer_size " , " compression_mode " ) , varray ( 0 ) ) ;
bind_function ( PackedByteArray , decompress_dynamic , _VariantCall : : func_PackedByteArray_decompress_dynamic , sarray ( " max_output_size " , " compression_mode " ) , varray ( 0 ) ) ;
2020-10-13 20:59:37 +02:00
Add marshalling to PackedByteArray
-Decode/Encode functions for u8,s8,u16,s16,u32,s32,u64,s64,half,float,double,variant
-Improved binder template to allow this
Given in Godot 4.0 PackedByteArray is passed as reference, it is now possible to have these functions there, which makes the most sense.
2021-04-09 22:57:37 +02:00
bind_function ( PackedByteArray , decode_u8 , _VariantCall : : func_PackedByteArray_decode_u8 , sarray ( " byte_offset " ) , varray ( ) ) ;
bind_function ( PackedByteArray , decode_s8 , _VariantCall : : func_PackedByteArray_decode_s8 , sarray ( " byte_offset " ) , varray ( ) ) ;
bind_function ( PackedByteArray , decode_u16 , _VariantCall : : func_PackedByteArray_decode_u16 , sarray ( " byte_offset " ) , varray ( ) ) ;
bind_function ( PackedByteArray , decode_s16 , _VariantCall : : func_PackedByteArray_decode_s16 , sarray ( " byte_offset " ) , varray ( ) ) ;
bind_function ( PackedByteArray , decode_u32 , _VariantCall : : func_PackedByteArray_decode_u32 , sarray ( " byte_offset " ) , varray ( ) ) ;
bind_function ( PackedByteArray , decode_s32 , _VariantCall : : func_PackedByteArray_decode_s32 , sarray ( " byte_offset " ) , varray ( ) ) ;
bind_function ( PackedByteArray , decode_u64 , _VariantCall : : func_PackedByteArray_decode_u64 , sarray ( " byte_offset " ) , varray ( ) ) ;
bind_function ( PackedByteArray , decode_s64 , _VariantCall : : func_PackedByteArray_decode_s64 , sarray ( " byte_offset " ) , varray ( ) ) ;
bind_function ( PackedByteArray , decode_half , _VariantCall : : func_PackedByteArray_decode_half , sarray ( " byte_offset " ) , varray ( ) ) ;
bind_function ( PackedByteArray , decode_float , _VariantCall : : func_PackedByteArray_decode_float , sarray ( " byte_offset " ) , varray ( ) ) ;
bind_function ( PackedByteArray , decode_double , _VariantCall : : func_PackedByteArray_decode_double , sarray ( " byte_offset " ) , varray ( ) ) ;
bind_function ( PackedByteArray , has_encoded_var , _VariantCall : : func_PackedByteArray_has_encoded_var , sarray ( " byte_offset " , " allow_objects " ) , varray ( false ) ) ;
bind_function ( PackedByteArray , decode_var , _VariantCall : : func_PackedByteArray_decode_var , sarray ( " byte_offset " , " allow_objects " ) , varray ( false ) ) ;
bind_function ( PackedByteArray , decode_var_size , _VariantCall : : func_PackedByteArray_decode_var_size , sarray ( " byte_offset " , " allow_objects " ) , varray ( false ) ) ;
2021-07-17 00:36:45 +02:00
bind_function ( PackedByteArray , to_int32_array , _VariantCall : : func_PackedByteArray_decode_s32_array , sarray ( ) , varray ( ) ) ;
bind_function ( PackedByteArray , to_int64_array , _VariantCall : : func_PackedByteArray_decode_s64_array , sarray ( ) , varray ( ) ) ;
bind_function ( PackedByteArray , to_float32_array , _VariantCall : : func_PackedByteArray_decode_float_array , sarray ( ) , varray ( ) ) ;
bind_function ( PackedByteArray , to_float64_array , _VariantCall : : func_PackedByteArray_decode_double_array , sarray ( ) , varray ( ) ) ;
Add marshalling to PackedByteArray
-Decode/Encode functions for u8,s8,u16,s16,u32,s32,u64,s64,half,float,double,variant
-Improved binder template to allow this
Given in Godot 4.0 PackedByteArray is passed as reference, it is now possible to have these functions there, which makes the most sense.
2021-04-09 22:57:37 +02:00
bind_functionnc ( PackedByteArray , encode_u8 , _VariantCall : : func_PackedByteArray_encode_u8 , sarray ( " byte_offset " , " value " ) , varray ( ) ) ;
bind_functionnc ( PackedByteArray , encode_s8 , _VariantCall : : func_PackedByteArray_encode_s8 , sarray ( " byte_offset " , " value " ) , varray ( ) ) ;
bind_functionnc ( PackedByteArray , encode_u16 , _VariantCall : : func_PackedByteArray_encode_u16 , sarray ( " byte_offset " , " value " ) , varray ( ) ) ;
bind_functionnc ( PackedByteArray , encode_s16 , _VariantCall : : func_PackedByteArray_encode_s16 , sarray ( " byte_offset " , " value " ) , varray ( ) ) ;
bind_functionnc ( PackedByteArray , encode_u32 , _VariantCall : : func_PackedByteArray_encode_u32 , sarray ( " byte_offset " , " value " ) , varray ( ) ) ;
bind_functionnc ( PackedByteArray , encode_s32 , _VariantCall : : func_PackedByteArray_encode_s32 , sarray ( " byte_offset " , " value " ) , varray ( ) ) ;
bind_functionnc ( PackedByteArray , encode_u64 , _VariantCall : : func_PackedByteArray_encode_u64 , sarray ( " byte_offset " , " value " ) , varray ( ) ) ;
bind_functionnc ( PackedByteArray , encode_s64 , _VariantCall : : func_PackedByteArray_encode_s64 , sarray ( " byte_offset " , " value " ) , varray ( ) ) ;
bind_functionnc ( PackedByteArray , encode_half , _VariantCall : : func_PackedByteArray_encode_half , sarray ( " byte_offset " , " value " ) , varray ( ) ) ;
bind_functionnc ( PackedByteArray , encode_float , _VariantCall : : func_PackedByteArray_encode_float , sarray ( " byte_offset " , " value " ) , varray ( ) ) ;
bind_functionnc ( PackedByteArray , encode_double , _VariantCall : : func_PackedByteArray_encode_double , sarray ( " byte_offset " , " value " ) , varray ( ) ) ;
bind_functionnc ( PackedByteArray , encode_var , _VariantCall : : func_PackedByteArray_encode_var , sarray ( " byte_offset " , " value " , " allow_objects " ) , varray ( false ) ) ;
2020-10-13 20:59:37 +02:00
/* Int32 Array */
bind_method ( PackedInt32Array , size , sarray ( ) , varray ( ) ) ;
2020-12-15 13:04:21 +01:00
bind_method ( PackedInt32Array , is_empty , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedInt32Array , set , sarray ( " index " , " value " ) , varray ( ) ) ;
bind_method ( PackedInt32Array , push_back , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedInt32Array , append , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedInt32Array , append_array , sarray ( " array " ) , varray ( ) ) ;
2021-07-04 00:17:03 +02:00
bind_method ( PackedInt32Array , remove_at , sarray ( " index " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedInt32Array , insert , sarray ( " at_index " , " value " ) , varray ( ) ) ;
2021-02-25 15:10:39 +01:00
bind_method ( PackedInt32Array , fill , sarray ( " value " ) , varray ( ) ) ;
2022-07-04 16:43:49 +02:00
bind_methodv ( PackedInt32Array , resize , & PackedInt32Array : : resize_zeroed , sarray ( " new_size " ) , varray ( ) ) ;
2022-08-10 11:12:20 +02:00
bind_method ( PackedInt32Array , clear , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedInt32Array , has , sarray ( " value " ) , varray ( ) ) ;
2021-03-14 08:21:32 +01:00
bind_method ( PackedInt32Array , reverse , sarray ( ) , varray ( ) ) ;
2022-01-10 13:56:55 +01:00
bind_method ( PackedInt32Array , slice , sarray ( " begin " , " end " ) , varray ( INT_MAX ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedInt32Array , to_byte_array , sarray ( ) , varray ( ) ) ;
bind_method ( PackedInt32Array , sort , sarray ( ) , varray ( ) ) ;
2021-09-19 20:13:09 +02:00
bind_method ( PackedInt32Array , bsearch , sarray ( " value " , " before " ) , varray ( true ) ) ;
2020-12-17 21:26:05 +01:00
bind_method ( PackedInt32Array , duplicate , sarray ( ) , varray ( ) ) ;
2022-05-07 14:16:11 +02:00
bind_method ( PackedInt32Array , find , sarray ( " value " , " from " ) , varray ( 0 ) ) ;
bind_method ( PackedInt32Array , rfind , sarray ( " value " , " from " ) , varray ( - 1 ) ) ;
bind_method ( PackedInt32Array , count , sarray ( " value " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
/* Int64 Array */
bind_method ( PackedInt64Array , size , sarray ( ) , varray ( ) ) ;
2020-12-15 13:04:21 +01:00
bind_method ( PackedInt64Array , is_empty , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedInt64Array , set , sarray ( " index " , " value " ) , varray ( ) ) ;
bind_method ( PackedInt64Array , push_back , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedInt64Array , append , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedInt64Array , append_array , sarray ( " array " ) , varray ( ) ) ;
2021-07-04 00:17:03 +02:00
bind_method ( PackedInt64Array , remove_at , sarray ( " index " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedInt64Array , insert , sarray ( " at_index " , " value " ) , varray ( ) ) ;
2021-02-25 15:10:39 +01:00
bind_method ( PackedInt64Array , fill , sarray ( " value " ) , varray ( ) ) ;
2022-07-04 16:43:49 +02:00
bind_methodv ( PackedInt64Array , resize , & PackedInt64Array : : resize_zeroed , sarray ( " new_size " ) , varray ( ) ) ;
2022-08-10 11:12:20 +02:00
bind_method ( PackedInt64Array , clear , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedInt64Array , has , sarray ( " value " ) , varray ( ) ) ;
2021-03-14 08:21:32 +01:00
bind_method ( PackedInt64Array , reverse , sarray ( ) , varray ( ) ) ;
2022-01-10 13:56:55 +01:00
bind_method ( PackedInt64Array , slice , sarray ( " begin " , " end " ) , varray ( INT_MAX ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedInt64Array , to_byte_array , sarray ( ) , varray ( ) ) ;
bind_method ( PackedInt64Array , sort , sarray ( ) , varray ( ) ) ;
2021-09-19 20:13:09 +02:00
bind_method ( PackedInt64Array , bsearch , sarray ( " value " , " before " ) , varray ( true ) ) ;
2020-12-17 21:26:05 +01:00
bind_method ( PackedInt64Array , duplicate , sarray ( ) , varray ( ) ) ;
2022-05-07 14:16:11 +02:00
bind_method ( PackedInt64Array , find , sarray ( " value " , " from " ) , varray ( 0 ) ) ;
bind_method ( PackedInt64Array , rfind , sarray ( " value " , " from " ) , varray ( - 1 ) ) ;
bind_method ( PackedInt64Array , count , sarray ( " value " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
/* Float32 Array */
bind_method ( PackedFloat32Array , size , sarray ( ) , varray ( ) ) ;
2020-12-15 13:04:21 +01:00
bind_method ( PackedFloat32Array , is_empty , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedFloat32Array , set , sarray ( " index " , " value " ) , varray ( ) ) ;
bind_method ( PackedFloat32Array , push_back , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedFloat32Array , append , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedFloat32Array , append_array , sarray ( " array " ) , varray ( ) ) ;
2021-07-04 00:17:03 +02:00
bind_method ( PackedFloat32Array , remove_at , sarray ( " index " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedFloat32Array , insert , sarray ( " at_index " , " value " ) , varray ( ) ) ;
2021-02-25 15:10:39 +01:00
bind_method ( PackedFloat32Array , fill , sarray ( " value " ) , varray ( ) ) ;
2022-07-04 16:43:49 +02:00
bind_methodv ( PackedFloat32Array , resize , & PackedFloat32Array : : resize_zeroed , sarray ( " new_size " ) , varray ( ) ) ;
2022-08-10 11:12:20 +02:00
bind_method ( PackedFloat32Array , clear , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedFloat32Array , has , sarray ( " value " ) , varray ( ) ) ;
2021-03-14 08:21:32 +01:00
bind_method ( PackedFloat32Array , reverse , sarray ( ) , varray ( ) ) ;
2022-01-10 13:56:55 +01:00
bind_method ( PackedFloat32Array , slice , sarray ( " begin " , " end " ) , varray ( INT_MAX ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedFloat32Array , to_byte_array , sarray ( ) , varray ( ) ) ;
bind_method ( PackedFloat32Array , sort , sarray ( ) , varray ( ) ) ;
2021-09-19 20:13:09 +02:00
bind_method ( PackedFloat32Array , bsearch , sarray ( " value " , " before " ) , varray ( true ) ) ;
2020-12-17 21:26:05 +01:00
bind_method ( PackedFloat32Array , duplicate , sarray ( ) , varray ( ) ) ;
2022-05-07 14:16:11 +02:00
bind_method ( PackedFloat32Array , find , sarray ( " value " , " from " ) , varray ( 0 ) ) ;
bind_method ( PackedFloat32Array , rfind , sarray ( " value " , " from " ) , varray ( - 1 ) ) ;
bind_method ( PackedFloat32Array , count , sarray ( " value " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
/* Float64 Array */
bind_method ( PackedFloat64Array , size , sarray ( ) , varray ( ) ) ;
2020-12-15 13:04:21 +01:00
bind_method ( PackedFloat64Array , is_empty , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedFloat64Array , set , sarray ( " index " , " value " ) , varray ( ) ) ;
bind_method ( PackedFloat64Array , push_back , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedFloat64Array , append , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedFloat64Array , append_array , sarray ( " array " ) , varray ( ) ) ;
2021-07-04 00:17:03 +02:00
bind_method ( PackedFloat64Array , remove_at , sarray ( " index " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedFloat64Array , insert , sarray ( " at_index " , " value " ) , varray ( ) ) ;
2021-02-25 15:10:39 +01:00
bind_method ( PackedFloat64Array , fill , sarray ( " value " ) , varray ( ) ) ;
2022-07-04 16:43:49 +02:00
bind_methodv ( PackedFloat64Array , resize , & PackedFloat64Array : : resize_zeroed , sarray ( " new_size " ) , varray ( ) ) ;
2022-08-10 11:12:20 +02:00
bind_method ( PackedFloat64Array , clear , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedFloat64Array , has , sarray ( " value " ) , varray ( ) ) ;
2021-03-14 08:21:32 +01:00
bind_method ( PackedFloat64Array , reverse , sarray ( ) , varray ( ) ) ;
2022-01-10 13:56:55 +01:00
bind_method ( PackedFloat64Array , slice , sarray ( " begin " , " end " ) , varray ( INT_MAX ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedFloat64Array , to_byte_array , sarray ( ) , varray ( ) ) ;
bind_method ( PackedFloat64Array , sort , sarray ( ) , varray ( ) ) ;
2021-09-19 20:13:09 +02:00
bind_method ( PackedFloat64Array , bsearch , sarray ( " value " , " before " ) , varray ( true ) ) ;
2020-12-17 21:26:05 +01:00
bind_method ( PackedFloat64Array , duplicate , sarray ( ) , varray ( ) ) ;
2022-05-07 14:16:11 +02:00
bind_method ( PackedFloat64Array , find , sarray ( " value " , " from " ) , varray ( 0 ) ) ;
bind_method ( PackedFloat64Array , rfind , sarray ( " value " , " from " ) , varray ( - 1 ) ) ;
bind_method ( PackedFloat64Array , count , sarray ( " value " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
/* String Array */
bind_method ( PackedStringArray , size , sarray ( ) , varray ( ) ) ;
2020-12-15 13:04:21 +01:00
bind_method ( PackedStringArray , is_empty , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedStringArray , set , sarray ( " index " , " value " ) , varray ( ) ) ;
bind_method ( PackedStringArray , push_back , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedStringArray , append , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedStringArray , append_array , sarray ( " array " ) , varray ( ) ) ;
2021-07-04 00:17:03 +02:00
bind_method ( PackedStringArray , remove_at , sarray ( " index " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedStringArray , insert , sarray ( " at_index " , " value " ) , varray ( ) ) ;
2021-02-25 15:10:39 +01:00
bind_method ( PackedStringArray , fill , sarray ( " value " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedStringArray , resize , sarray ( " new_size " ) , varray ( ) ) ;
2022-08-10 11:12:20 +02:00
bind_method ( PackedStringArray , clear , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedStringArray , has , sarray ( " value " ) , varray ( ) ) ;
2021-03-14 08:21:32 +01:00
bind_method ( PackedStringArray , reverse , sarray ( ) , varray ( ) ) ;
2022-01-10 13:56:55 +01:00
bind_method ( PackedStringArray , slice , sarray ( " begin " , " end " ) , varray ( INT_MAX ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedStringArray , to_byte_array , sarray ( ) , varray ( ) ) ;
bind_method ( PackedStringArray , sort , sarray ( ) , varray ( ) ) ;
2021-09-19 20:13:09 +02:00
bind_method ( PackedStringArray , bsearch , sarray ( " value " , " before " ) , varray ( true ) ) ;
2020-12-17 21:26:05 +01:00
bind_method ( PackedStringArray , duplicate , sarray ( ) , varray ( ) ) ;
2022-05-07 14:16:11 +02:00
bind_method ( PackedStringArray , find , sarray ( " value " , " from " ) , varray ( 0 ) ) ;
bind_method ( PackedStringArray , rfind , sarray ( " value " , " from " ) , varray ( - 1 ) ) ;
bind_method ( PackedStringArray , count , sarray ( " value " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
/* Vector2 Array */
bind_method ( PackedVector2Array , size , sarray ( ) , varray ( ) ) ;
2020-12-15 13:04:21 +01:00
bind_method ( PackedVector2Array , is_empty , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedVector2Array , set , sarray ( " index " , " value " ) , varray ( ) ) ;
bind_method ( PackedVector2Array , push_back , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedVector2Array , append , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedVector2Array , append_array , sarray ( " array " ) , varray ( ) ) ;
2021-07-04 00:17:03 +02:00
bind_method ( PackedVector2Array , remove_at , sarray ( " index " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedVector2Array , insert , sarray ( " at_index " , " value " ) , varray ( ) ) ;
2021-02-25 15:10:39 +01:00
bind_method ( PackedVector2Array , fill , sarray ( " value " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedVector2Array , resize , sarray ( " new_size " ) , varray ( ) ) ;
2022-08-10 11:12:20 +02:00
bind_method ( PackedVector2Array , clear , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedVector2Array , has , sarray ( " value " ) , varray ( ) ) ;
2021-03-14 08:21:32 +01:00
bind_method ( PackedVector2Array , reverse , sarray ( ) , varray ( ) ) ;
2022-01-10 13:56:55 +01:00
bind_method ( PackedVector2Array , slice , sarray ( " begin " , " end " ) , varray ( INT_MAX ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedVector2Array , to_byte_array , sarray ( ) , varray ( ) ) ;
2020-11-04 15:38:26 +01:00
bind_method ( PackedVector2Array , sort , sarray ( ) , varray ( ) ) ;
2021-09-19 20:13:09 +02:00
bind_method ( PackedVector2Array , bsearch , sarray ( " value " , " before " ) , varray ( true ) ) ;
2020-12-17 21:26:05 +01:00
bind_method ( PackedVector2Array , duplicate , sarray ( ) , varray ( ) ) ;
2022-05-07 14:16:11 +02:00
bind_method ( PackedVector2Array , find , sarray ( " value " , " from " ) , varray ( 0 ) ) ;
bind_method ( PackedVector2Array , rfind , sarray ( " value " , " from " ) , varray ( - 1 ) ) ;
bind_method ( PackedVector2Array , count , sarray ( " value " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
/* Vector3 Array */
bind_method ( PackedVector3Array , size , sarray ( ) , varray ( ) ) ;
2020-12-15 13:04:21 +01:00
bind_method ( PackedVector3Array , is_empty , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedVector3Array , set , sarray ( " index " , " value " ) , varray ( ) ) ;
bind_method ( PackedVector3Array , push_back , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedVector3Array , append , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedVector3Array , append_array , sarray ( " array " ) , varray ( ) ) ;
2021-07-04 00:17:03 +02:00
bind_method ( PackedVector3Array , remove_at , sarray ( " index " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedVector3Array , insert , sarray ( " at_index " , " value " ) , varray ( ) ) ;
2021-02-25 15:10:39 +01:00
bind_method ( PackedVector3Array , fill , sarray ( " value " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedVector3Array , resize , sarray ( " new_size " ) , varray ( ) ) ;
2022-08-10 11:12:20 +02:00
bind_method ( PackedVector3Array , clear , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedVector3Array , has , sarray ( " value " ) , varray ( ) ) ;
2021-03-14 08:21:32 +01:00
bind_method ( PackedVector3Array , reverse , sarray ( ) , varray ( ) ) ;
2022-01-10 13:56:55 +01:00
bind_method ( PackedVector3Array , slice , sarray ( " begin " , " end " ) , varray ( INT_MAX ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedVector3Array , to_byte_array , sarray ( ) , varray ( ) ) ;
2020-11-04 15:38:26 +01:00
bind_method ( PackedVector3Array , sort , sarray ( ) , varray ( ) ) ;
2021-09-19 20:13:09 +02:00
bind_method ( PackedVector3Array , bsearch , sarray ( " value " , " before " ) , varray ( true ) ) ;
2020-12-17 21:26:05 +01:00
bind_method ( PackedVector3Array , duplicate , sarray ( ) , varray ( ) ) ;
2022-05-07 14:16:11 +02:00
bind_method ( PackedVector3Array , find , sarray ( " value " , " from " ) , varray ( 0 ) ) ;
bind_method ( PackedVector3Array , rfind , sarray ( " value " , " from " ) , varray ( - 1 ) ) ;
bind_method ( PackedVector3Array , count , sarray ( " value " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
/* Color Array */
bind_method ( PackedColorArray , size , sarray ( ) , varray ( ) ) ;
2020-12-15 13:04:21 +01:00
bind_method ( PackedColorArray , is_empty , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedColorArray , set , sarray ( " index " , " value " ) , varray ( ) ) ;
bind_method ( PackedColorArray , push_back , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedColorArray , append , sarray ( " value " ) , varray ( ) ) ;
bind_method ( PackedColorArray , append_array , sarray ( " array " ) , varray ( ) ) ;
2021-07-04 00:17:03 +02:00
bind_method ( PackedColorArray , remove_at , sarray ( " index " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedColorArray , insert , sarray ( " at_index " , " value " ) , varray ( ) ) ;
2021-02-25 15:10:39 +01:00
bind_method ( PackedColorArray , fill , sarray ( " value " ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedColorArray , resize , sarray ( " new_size " ) , varray ( ) ) ;
2022-08-10 11:12:20 +02:00
bind_method ( PackedColorArray , clear , sarray ( ) , varray ( ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedColorArray , has , sarray ( " value " ) , varray ( ) ) ;
2021-03-14 08:21:32 +01:00
bind_method ( PackedColorArray , reverse , sarray ( ) , varray ( ) ) ;
2022-01-10 13:56:55 +01:00
bind_method ( PackedColorArray , slice , sarray ( " begin " , " end " ) , varray ( INT_MAX ) ) ;
2020-10-13 20:59:37 +02:00
bind_method ( PackedColorArray , to_byte_array , sarray ( ) , varray ( ) ) ;
2020-11-04 15:38:26 +01:00
bind_method ( PackedColorArray , sort , sarray ( ) , varray ( ) ) ;
2021-09-19 20:13:09 +02:00
bind_method ( PackedColorArray , bsearch , sarray ( " value " , " before " ) , varray ( true ) ) ;
2020-12-17 21:26:05 +01:00
bind_method ( PackedColorArray , duplicate , sarray ( ) , varray ( ) ) ;
2022-05-07 14:16:11 +02:00
bind_method ( PackedColorArray , find , sarray ( " value " , " from " ) , varray ( 0 ) ) ;
bind_method ( PackedColorArray , rfind , sarray ( " value " , " from " ) , varray ( - 1 ) ) ;
bind_method ( PackedColorArray , count , sarray ( " value " ) , varray ( ) ) ;
2014-02-10 02:10:30 +01:00
2020-11-04 15:38:26 +01:00
/* Register constants */
2014-02-10 02:10:30 +01:00
2020-11-07 23:33:38 +01:00
int ncc = Color : : get_named_color_count ( ) ;
for ( int i = 0 ; i < ncc ; i + + ) {
_VariantCall : : add_variant_constant ( Variant : : COLOR , Color : : get_named_color_name ( i ) , Color : : get_named_color ( i ) ) ;
2017-12-15 16:43:27 +01:00
}
2016-07-05 21:57:17 +02:00
_VariantCall : : add_constant ( Variant : : VECTOR3 , " AXIS_X " , Vector3 : : AXIS_X ) ;
_VariantCall : : add_constant ( Variant : : VECTOR3 , " AXIS_Y " , Vector3 : : AXIS_Y ) ;
_VariantCall : : add_constant ( Variant : : VECTOR3 , " AXIS_Z " , Vector3 : : AXIS_Z ) ;
2017-12-15 16:43:27 +01:00
2022-04-18 20:17:03 +02:00
_VariantCall : : add_enum_constant ( Variant : : VECTOR3 , " Axis " , " AXIS_X " , Vector3 : : AXIS_X ) ;
_VariantCall : : add_enum_constant ( Variant : : VECTOR3 , " Axis " , " AXIS_Y " , Vector3 : : AXIS_Y ) ;
_VariantCall : : add_enum_constant ( Variant : : VECTOR3 , " Axis " , " AXIS_Z " , Vector3 : : AXIS_Z ) ;
2017-12-15 16:43:27 +01:00
_VariantCall : : add_variant_constant ( Variant : : VECTOR3 , " ZERO " , Vector3 ( 0 , 0 , 0 ) ) ;
2018-10-06 20:13:41 +02:00
_VariantCall : : add_variant_constant ( Variant : : VECTOR3 , " ONE " , Vector3 ( 1 , 1 , 1 ) ) ;
2021-07-21 10:40:31 +02:00
_VariantCall : : add_variant_constant ( Variant : : VECTOR3 , " INF " , Vector3 ( INFINITY , INFINITY , INFINITY ) ) ;
2017-12-15 16:43:27 +01:00
_VariantCall : : add_variant_constant ( Variant : : VECTOR3 , " LEFT " , Vector3 ( - 1 , 0 , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR3 , " RIGHT " , Vector3 ( 1 , 0 , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR3 , " UP " , Vector3 ( 0 , 1 , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR3 , " DOWN " , Vector3 ( 0 , - 1 , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR3 , " FORWARD " , Vector3 ( 0 , 0 , - 1 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR3 , " BACK " , Vector3 ( 0 , 0 , 1 ) ) ;
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-20 01:11:13 +02:00
_VariantCall : : add_constant ( Variant : : VECTOR4 , " AXIS_X " , Vector4 : : AXIS_X ) ;
_VariantCall : : add_constant ( Variant : : VECTOR4 , " AXIS_Y " , Vector4 : : AXIS_Y ) ;
_VariantCall : : add_constant ( Variant : : VECTOR4 , " AXIS_Z " , Vector4 : : AXIS_Z ) ;
_VariantCall : : add_constant ( Variant : : VECTOR4 , " AXIS_W " , Vector4 : : AXIS_W ) ;
_VariantCall : : add_enum_constant ( Variant : : VECTOR4 , " Axis " , " AXIS_X " , Vector4 : : AXIS_X ) ;
_VariantCall : : add_enum_constant ( Variant : : VECTOR4 , " Axis " , " AXIS_Y " , Vector4 : : AXIS_Y ) ;
_VariantCall : : add_enum_constant ( Variant : : VECTOR4 , " Axis " , " AXIS_Z " , Vector4 : : AXIS_Z ) ;
_VariantCall : : add_enum_constant ( Variant : : VECTOR4 , " Axis " , " AXIS_W " , Vector4 : : AXIS_W ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR4 , " ZERO " , Vector4 ( 0 , 0 , 0 , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR4 , " ONE " , Vector4 ( 1 , 1 , 1 , 1 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR4 , " INF " , Vector4 ( INFINITY , INFINITY , INFINITY , INFINITY ) ) ;
2020-08-05 10:45:28 +02:00
_VariantCall : : add_constant ( Variant : : VECTOR3I , " AXIS_X " , Vector3i : : AXIS_X ) ;
_VariantCall : : add_constant ( Variant : : VECTOR3I , " AXIS_Y " , Vector3i : : AXIS_Y ) ;
_VariantCall : : add_constant ( Variant : : VECTOR3I , " AXIS_Z " , Vector3i : : AXIS_Z ) ;
2020-02-22 04:26:41 +01:00
2022-04-18 20:17:03 +02:00
_VariantCall : : add_enum_constant ( Variant : : VECTOR3I , " Axis " , " AXIS_X " , Vector3i : : AXIS_X ) ;
_VariantCall : : add_enum_constant ( Variant : : VECTOR3I , " Axis " , " AXIS_Y " , Vector3i : : AXIS_Y ) ;
_VariantCall : : add_enum_constant ( Variant : : VECTOR3I , " Axis " , " AXIS_Z " , Vector3i : : AXIS_Z ) ;
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-20 01:11:13 +02:00
_VariantCall : : add_constant ( Variant : : VECTOR4I , " AXIS_X " , Vector4i : : AXIS_X ) ;
_VariantCall : : add_constant ( Variant : : VECTOR4I , " AXIS_Y " , Vector4i : : AXIS_Y ) ;
_VariantCall : : add_constant ( Variant : : VECTOR4I , " AXIS_Z " , Vector4i : : AXIS_Z ) ;
_VariantCall : : add_constant ( Variant : : VECTOR4I , " AXIS_W " , Vector4i : : AXIS_W ) ;
_VariantCall : : add_enum_constant ( Variant : : VECTOR4I , " Axis " , " AXIS_X " , Vector4i : : AXIS_X ) ;
_VariantCall : : add_enum_constant ( Variant : : VECTOR4I , " Axis " , " AXIS_Y " , Vector4i : : AXIS_Y ) ;
_VariantCall : : add_enum_constant ( Variant : : VECTOR4I , " Axis " , " AXIS_Z " , Vector4i : : AXIS_Z ) ;
_VariantCall : : add_enum_constant ( Variant : : VECTOR4I , " Axis " , " AXIS_W " , Vector4i : : AXIS_W ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR4I , " ZERO " , Vector4i ( 0 , 0 , 0 , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR4I , " ONE " , Vector4i ( 1 , 1 , 1 , 1 ) ) ;
2020-02-22 04:26:41 +01:00
_VariantCall : : add_variant_constant ( Variant : : VECTOR3I , " ZERO " , Vector3i ( 0 , 0 , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR3I , " ONE " , Vector3i ( 1 , 1 , 1 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR3I , " LEFT " , Vector3i ( - 1 , 0 , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR3I , " RIGHT " , Vector3i ( 1 , 0 , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR3I , " UP " , Vector3i ( 0 , 1 , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR3I , " DOWN " , Vector3i ( 0 , - 1 , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR3I , " FORWARD " , Vector3i ( 0 , 0 , - 1 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR3I , " BACK " , Vector3i ( 0 , 0 , 1 ) ) ;
2019-08-05 03:50:28 +02:00
_VariantCall : : add_constant ( Variant : : VECTOR2 , " AXIS_X " , Vector2 : : AXIS_X ) ;
_VariantCall : : add_constant ( Variant : : VECTOR2 , " AXIS_Y " , Vector2 : : AXIS_Y ) ;
2022-04-18 20:17:03 +02:00
_VariantCall : : add_enum_constant ( Variant : : VECTOR2 , " Axis " , " AXIS_X " , Vector2 : : AXIS_X ) ;
_VariantCall : : add_enum_constant ( Variant : : VECTOR2 , " Axis " , " AXIS_Y " , Vector2 : : AXIS_Y ) ;
2020-08-05 10:45:28 +02:00
_VariantCall : : add_constant ( Variant : : VECTOR2I , " AXIS_X " , Vector2i : : AXIS_X ) ;
_VariantCall : : add_constant ( Variant : : VECTOR2I , " AXIS_Y " , Vector2i : : AXIS_Y ) ;
2020-02-22 04:26:41 +01:00
2022-04-18 20:17:03 +02:00
_VariantCall : : add_enum_constant ( Variant : : VECTOR2I , " Axis " , " AXIS_X " , Vector2i : : AXIS_X ) ;
_VariantCall : : add_enum_constant ( Variant : : VECTOR2I , " Axis " , " AXIS_Y " , Vector2i : : AXIS_Y ) ;
2017-12-15 16:43:27 +01:00
_VariantCall : : add_variant_constant ( Variant : : VECTOR2 , " ZERO " , Vector2 ( 0 , 0 ) ) ;
2018-10-06 20:13:41 +02:00
_VariantCall : : add_variant_constant ( Variant : : VECTOR2 , " ONE " , Vector2 ( 1 , 1 ) ) ;
2021-07-21 10:40:31 +02:00
_VariantCall : : add_variant_constant ( Variant : : VECTOR2 , " INF " , Vector2 ( INFINITY , INFINITY ) ) ;
2017-12-15 16:43:27 +01:00
_VariantCall : : add_variant_constant ( Variant : : VECTOR2 , " LEFT " , Vector2 ( - 1 , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR2 , " RIGHT " , Vector2 ( 1 , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR2 , " UP " , Vector2 ( 0 , - 1 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR2 , " DOWN " , Vector2 ( 0 , 1 ) ) ;
2020-02-22 04:26:41 +01:00
_VariantCall : : add_variant_constant ( Variant : : VECTOR2I , " ZERO " , Vector2i ( 0 , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR2I , " ONE " , Vector2i ( 1 , 1 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR2I , " LEFT " , Vector2i ( - 1 , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR2I , " RIGHT " , Vector2i ( 1 , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR2I , " UP " , Vector2i ( 0 , - 1 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : VECTOR2I , " DOWN " , Vector2i ( 0 , 1 ) ) ;
2021-10-21 18:38:20 +02:00
_VariantCall : : add_constant ( Variant : : BASIS , " EULER_ORDER_XYZ " , Basis : : EULER_ORDER_XYZ ) ;
_VariantCall : : add_constant ( Variant : : BASIS , " EULER_ORDER_XZY " , Basis : : EULER_ORDER_XZY ) ;
_VariantCall : : add_constant ( Variant : : BASIS , " EULER_ORDER_YXZ " , Basis : : EULER_ORDER_YXZ ) ;
_VariantCall : : add_constant ( Variant : : BASIS , " EULER_ORDER_YZX " , Basis : : EULER_ORDER_YZX ) ;
_VariantCall : : add_constant ( Variant : : BASIS , " EULER_ORDER_ZXY " , Basis : : EULER_ORDER_ZXY ) ;
_VariantCall : : add_constant ( Variant : : BASIS , " EULER_ORDER_ZYX " , Basis : : EULER_ORDER_ZYX ) ;
2022-04-18 20:17:03 +02:00
_VariantCall : : add_enum_constant ( Variant : : BASIS , " EulerOrder " , " EULER_ORDER_XYZ " , Basis : : EULER_ORDER_XYZ ) ;
_VariantCall : : add_enum_constant ( Variant : : BASIS , " EulerOrder " , " EULER_ORDER_XZY " , Basis : : EULER_ORDER_XZY ) ;
_VariantCall : : add_enum_constant ( Variant : : BASIS , " EulerOrder " , " EULER_ORDER_YXZ " , Basis : : EULER_ORDER_YXZ ) ;
_VariantCall : : add_enum_constant ( Variant : : BASIS , " EulerOrder " , " EULER_ORDER_YZX " , Basis : : EULER_ORDER_YZX ) ;
_VariantCall : : add_enum_constant ( Variant : : BASIS , " EulerOrder " , " EULER_ORDER_ZXY " , Basis : : EULER_ORDER_ZXY ) ;
_VariantCall : : add_enum_constant ( Variant : : BASIS , " EulerOrder " , " EULER_ORDER_ZYX " , Basis : : EULER_ORDER_ZYX ) ;
2019-08-09 05:29:45 +02:00
_VariantCall : : add_variant_constant ( Variant : : TRANSFORM2D , " IDENTITY " , Transform2D ( ) ) ;
2017-12-15 16:43:27 +01:00
_VariantCall : : add_variant_constant ( Variant : : TRANSFORM2D , " FLIP_X " , Transform2D ( - 1 , 0 , 0 , 1 , 0 , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : TRANSFORM2D , " FLIP_Y " , Transform2D ( 1 , 0 , 0 , - 1 , 0 , 0 ) ) ;
2020-10-17 07:08:21 +02:00
Transform3D identity_transform = Transform3D ( ) ;
Transform3D flip_x_transform = Transform3D ( - 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 ) ;
Transform3D flip_y_transform = Transform3D ( 1 , 0 , 0 , 0 , - 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 ) ;
Transform3D flip_z_transform = Transform3D ( 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , - 1 , 0 , 0 , 0 ) ;
2021-04-28 09:36:08 +02:00
_VariantCall : : add_variant_constant ( Variant : : TRANSFORM3D , " IDENTITY " , identity_transform ) ;
_VariantCall : : add_variant_constant ( Variant : : TRANSFORM3D , " FLIP_X " , flip_x_transform ) ;
_VariantCall : : add_variant_constant ( Variant : : TRANSFORM3D , " FLIP_Y " , flip_y_transform ) ;
_VariantCall : : add_variant_constant ( Variant : : TRANSFORM3D , " FLIP_Z " , flip_z_transform ) ;
2019-08-09 05:29:45 +02:00
Basis identity_basis = Basis ( ) ;
Basis flip_x_basis = Basis ( - 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 1 ) ;
Basis flip_y_basis = Basis ( 1 , 0 , 0 , 0 , - 1 , 0 , 0 , 0 , 1 ) ;
Basis flip_z_basis = Basis ( 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , - 1 ) ;
_VariantCall : : add_variant_constant ( Variant : : BASIS , " IDENTITY " , identity_basis ) ;
_VariantCall : : add_variant_constant ( Variant : : BASIS , " FLIP_X " , flip_x_basis ) ;
_VariantCall : : add_variant_constant ( Variant : : BASIS , " FLIP_Y " , flip_y_basis ) ;
_VariantCall : : add_variant_constant ( Variant : : BASIS , " FLIP_Z " , flip_z_basis ) ;
2017-12-15 16:43:27 +01:00
2018-08-21 07:34:34 +02:00
_VariantCall : : add_variant_constant ( Variant : : PLANE , " PLANE_YZ " , Plane ( Vector3 ( 1 , 0 , 0 ) , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : PLANE , " PLANE_XZ " , Plane ( Vector3 ( 0 , 1 , 0 ) , 0 ) ) ;
_VariantCall : : add_variant_constant ( Variant : : PLANE , " PLANE_XY " , Plane ( Vector3 ( 0 , 0 , 1 ) , 0 ) ) ;
2017-12-15 16:43:27 +01:00
2021-01-20 08:02:02 +01:00
_VariantCall : : add_variant_constant ( Variant : : QUATERNION , " IDENTITY " , Quaternion ( 0 , 0 , 0 , 1 ) ) ;
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-20 01:11:13 +02:00
_VariantCall : : add_constant ( Variant : : PROJECTION , " PLANE_NEAR " , Projection : : PLANE_NEAR ) ;
_VariantCall : : add_constant ( Variant : : PROJECTION , " PLANE_FAR " , Projection : : PLANE_FAR ) ;
_VariantCall : : add_constant ( Variant : : PROJECTION , " PLANE_LEFT " , Projection : : PLANE_LEFT ) ;
_VariantCall : : add_constant ( Variant : : PROJECTION , " PLANE_TOP " , Projection : : PLANE_TOP ) ;
_VariantCall : : add_constant ( Variant : : PROJECTION , " PLANE_RIGHT " , Projection : : PLANE_RIGHT ) ;
_VariantCall : : add_constant ( Variant : : PROJECTION , " PLANE_BOTTOM " , Projection : : PLANE_BOTTOM ) ;
_VariantCall : : add_enum_constant ( Variant : : PROJECTION , " Planes " , " PLANE_NEAR " , Projection : : PLANE_NEAR ) ;
_VariantCall : : add_enum_constant ( Variant : : PROJECTION , " Planes " , " PLANE_FAR " , Projection : : PLANE_FAR ) ;
_VariantCall : : add_enum_constant ( Variant : : PROJECTION , " Planes " , " PLANE_LEFT " , Projection : : PLANE_LEFT ) ;
_VariantCall : : add_enum_constant ( Variant : : PROJECTION , " Planes " , " PLANE_TOP " , Projection : : PLANE_TOP ) ;
_VariantCall : : add_enum_constant ( Variant : : PROJECTION , " Planes " , " PLANE_RIGHT " , Projection : : PLANE_RIGHT ) ;
_VariantCall : : add_enum_constant ( Variant : : PROJECTION , " Planes " , " PLANE_BOTTOM " , Projection : : PLANE_BOTTOM ) ;
Projection p ;
_VariantCall : : add_variant_constant ( Variant : : PROJECTION , " IDENTITY " , p ) ;
p . set_zero ( ) ;
_VariantCall : : add_variant_constant ( Variant : : PROJECTION , " ZERO " , p ) ;
2014-02-10 02:10:30 +01:00
}
2020-11-11 17:16:08 +01:00
void Variant : : _register_variant_methods ( ) {
_register_variant_builtin_methods ( ) ; //needs to be out due to namespace
}
2020-11-09 04:19:09 +01:00
void Variant : : _unregister_variant_methods ( ) {
2020-10-13 20:59:37 +02:00
//clear methods
2020-11-11 17:16:08 +01:00
memdelete_arr ( builtin_method_names ) ;
memdelete_arr ( builtin_method_info ) ;
2014-02-10 02:10:30 +01:00
memdelete_arr ( _VariantCall : : constant_data ) ;
2022-04-18 20:17:03 +02:00
memdelete_arr ( _VariantCall : : enum_data ) ;
2014-02-10 02:10:30 +01:00
}