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.
This commit is contained in:
George Marques 2020-11-20 15:51:28 -03:00
parent 48049b8d9e
commit 8a9e3524a9
No known key found for this signature in database
GPG key ID: 046BD46A3201E43D
3 changed files with 37 additions and 24 deletions

View file

@ -1128,4 +1128,26 @@ struct VariantTypeChanger {
}
};
template <class T>
struct VariantTypeAdjust {
_FORCE_INLINE_ static void adjust(Variant *r_ret) {
VariantTypeChanger<typename GetSimpleTypeT<T>::type_t>::change(r_ret);
}
};
template <>
struct VariantTypeAdjust<Variant> {
_FORCE_INLINE_ static void adjust(Variant *r_ret) {
// Do nothing for variant.
}
};
template <>
struct VariantTypeAdjust<Object *> {
_FORCE_INLINE_ static void adjust(Variant *r_ret) {
VariantInternal::clear(r_ret);
*r_ret = (Object *)nullptr;
}
};
#endif // VARIANT_INTERNAL_H