summaryrefslogtreecommitdiff
path: root/core/variant/variant_call.cpp
diff options
context:
space:
mode:
authorGeorge Marques <george@gmarqu.es>2020-12-27 11:09:06 -0300
committerGeorge Marques <george@gmarqu.es>2020-12-27 11:14:29 -0300
commitd66a58a4d48fcc44334a870190176a4a1278c390 (patch)
tree19e64a7750435c193ed55976336e1da855500e10 /core/variant/variant_call.cpp
parentd55e335026e4848d4d2ec21db8f334a9429c8cc8 (diff)
Add helper count function to Variant
To get counts of items before getting the list, which is useful for GDNative so users can pre-allocate the buffer with the correct size without having to get the list twice.
Diffstat (limited to 'core/variant/variant_call.cpp')
-rw-r--r--core/variant/variant_call.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index afe4f2702e..854c0c01ef 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -705,6 +705,11 @@ void Variant::get_builtin_method_list(Variant::Type p_type, List<StringName> *p_
}
}
+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();
+}
+
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);
@@ -799,6 +804,13 @@ void Variant::get_constants_for_type(Variant::Type p_type, List<StringName> *p_c
}
}
+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();
+}
+
bool Variant::has_constant(Variant::Type p_type, const StringName &p_value) {
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false);
_VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type];