Add type validations when setting basic type
This commit is contained in:
parent
3e2bb415a9
commit
d9c4d75e31
|
@ -1390,45 +1390,41 @@ bool Variant::has_method(const StringName &p_method) const {
|
|||
}
|
||||
|
||||
Vector<Variant::Type> Variant::get_method_argument_types(Variant::Type p_type, const StringName &p_method) {
|
||||
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, Vector<Variant::Type>());
|
||||
const _VariantCall::TypeFunc &tf = _VariantCall::type_funcs[p_type];
|
||||
|
||||
const Map<StringName, _VariantCall::FuncData>::Element *E = tf.functions.find(p_method);
|
||||
if (!E) {
|
||||
return Vector<Variant::Type>();
|
||||
}
|
||||
ERR_FAIL_COND_V(!E, Vector<Variant::Type>());
|
||||
|
||||
return E->get().arg_types;
|
||||
}
|
||||
|
||||
bool Variant::is_method_const(Variant::Type p_type, const StringName &p_method) {
|
||||
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false);
|
||||
const _VariantCall::TypeFunc &tf = _VariantCall::type_funcs[p_type];
|
||||
|
||||
const Map<StringName, _VariantCall::FuncData>::Element *E = tf.functions.find(p_method);
|
||||
if (!E) {
|
||||
return false;
|
||||
}
|
||||
ERR_FAIL_COND_V(!E, false);
|
||||
|
||||
return E->get()._const;
|
||||
}
|
||||
|
||||
Vector<StringName> Variant::get_method_argument_names(Variant::Type p_type, const StringName &p_method) {
|
||||
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, Vector<StringName>());
|
||||
const _VariantCall::TypeFunc &tf = _VariantCall::type_funcs[p_type];
|
||||
|
||||
const Map<StringName, _VariantCall::FuncData>::Element *E = tf.functions.find(p_method);
|
||||
if (!E) {
|
||||
return Vector<StringName>();
|
||||
}
|
||||
ERR_FAIL_COND_V(!E, Vector<StringName>());
|
||||
|
||||
return E->get().arg_names;
|
||||
}
|
||||
|
||||
Variant::Type Variant::get_method_return_type(Variant::Type p_type, const StringName &p_method, bool *r_has_return) {
|
||||
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, Variant::NIL);
|
||||
const _VariantCall::TypeFunc &tf = _VariantCall::type_funcs[p_type];
|
||||
|
||||
const Map<StringName, _VariantCall::FuncData>::Element *E = tf.functions.find(p_method);
|
||||
if (!E) {
|
||||
return Variant::NIL;
|
||||
}
|
||||
ERR_FAIL_COND_V(!E, Variant::NIL);
|
||||
|
||||
if (r_has_return) {
|
||||
*r_has_return = E->get().returns;
|
||||
|
|
|
@ -282,6 +282,7 @@ String VisualScriptFunctionCall::get_text() const {
|
|||
}
|
||||
|
||||
void VisualScriptFunctionCall::set_basic_type(Variant::Type p_type) {
|
||||
ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX);
|
||||
if (basic_type == p_type) {
|
||||
return;
|
||||
}
|
||||
|
@ -1068,6 +1069,7 @@ void VisualScriptPropertySet::_update_base_type() {
|
|||
}
|
||||
}
|
||||
void VisualScriptPropertySet::set_basic_type(Variant::Type p_type) {
|
||||
ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX);
|
||||
if (basic_type == p_type) {
|
||||
return;
|
||||
}
|
||||
|
@ -1916,6 +1918,7 @@ VisualScriptPropertyGet::CallMode VisualScriptPropertyGet::get_call_mode() const
|
|||
}
|
||||
|
||||
void VisualScriptPropertyGet::set_basic_type(Variant::Type p_type) {
|
||||
ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX);
|
||||
if (basic_type == p_type) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1950,6 +1950,7 @@ StringName VisualScriptBasicTypeConstant::get_basic_type_constant() const {
|
|||
}
|
||||
|
||||
void VisualScriptBasicTypeConstant::set_basic_type(Variant::Type p_which) {
|
||||
ERR_FAIL_INDEX(p_which, Variant::VARIANT_MAX);
|
||||
type = p_which;
|
||||
|
||||
List<StringName> constants;
|
||||
|
|
Loading…
Reference in a new issue