diff options
author | George Marques <george@gmarqu.es> | 2020-11-20 15:51:28 -0300 |
---|---|---|
committer | George Marques <george@gmarqu.es> | 2020-11-20 15:55:17 -0300 |
commit | 8a9e3524a9128d71b78718d2ba1081d5ad34a050 (patch) | |
tree | e29e3861c800c26cfd9c368dc8bbec71c6b98674 /core/variant/variant_call.cpp | |
parent | 48049b8d9e3830ddea5c6844997d928871c16d27 (diff) |
Fix variant getters not setting return type
The validated getters were only setting the value without changing the
type, leading to wrong results. This uses the same path used for
methods to the same purpose.
Diffstat (limited to 'core/variant/variant_call.cpp')
-rw-r--r-- | core/variant/variant_call.cpp | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index f6fe642493..13514b7b9f 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -42,27 +42,6 @@ typedef void (*VariantFunc)(Variant &r_ret, Variant &p_self, const Variant **p_args); typedef void (*VariantConstructFunc)(Variant &r_ret, const Variant **p_args); -template <class T> -struct TypeAdjust { - _FORCE_INLINE_ static void adjust(Variant *r_ret) { - VariantTypeChanger<typename GetSimpleTypeT<T>::type_t>::change(r_ret); - } -}; - -template <> //do nothing for variant -struct TypeAdjust<Variant> { - _FORCE_INLINE_ static void adjust(Variant *r_ret) { - } -}; - -template <> //do nothing for variant -struct TypeAdjust<Object *> { - _FORCE_INLINE_ static void adjust(Variant *r_ret) { - VariantInternal::clear(r_ret); - *r_ret = (Object *)nullptr; - } -}; - 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); @@ -124,12 +103,12 @@ static _FORCE_INLINE_ void vc_ptrcall(void (T::*method)(P...) const, void *p_bas template <class R, class T, class... P> static _FORCE_INLINE_ void vc_change_return_type(R (T::*method)(P...), Variant *v) { - TypeAdjust<R>::adjust(v); + VariantTypeAdjust<R>::adjust(v); } template <class R, class T, class... P> static _FORCE_INLINE_ void vc_change_return_type(R (T::*method)(P...) const, Variant *v) { - TypeAdjust<R>::adjust(v); + VariantTypeAdjust<R>::adjust(v); } template <class T, class... P> @@ -144,7 +123,7 @@ static _FORCE_INLINE_ void vc_change_return_type(void (T::*method)(P...) const, template <class R, class... P> static _FORCE_INLINE_ void vc_change_return_type(R (*method)(P...), Variant *v) { - TypeAdjust<R>::adjust(v); + VariantTypeAdjust<R>::adjust(v); } template <class R, class T, class... P> |