summaryrefslogtreecommitdiffstats
path: root/core/variant/variant_setget.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_setget.cpp
parentd55e335026e4848d4d2ec21db8f334a9429c8cc8 (diff)
downloadredot-engine-d66a58a4d48fcc44334a870190176a4a1278c390.tar.gz
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_setget.cpp')
-rw-r--r--core/variant/variant_setget.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp
index 28cf8ef967..dd3e70fc6a 100644
--- a/core/variant/variant_setget.cpp
+++ b/core/variant/variant_setget.cpp
@@ -437,6 +437,11 @@ void Variant::get_member_list(Variant::Type p_type, List<StringName> *r_members)
}
}
+int Variant::get_member_count(Type p_type) {
+ ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, -1);
+ return variant_setters_getters_names[p_type].size();
+}
+
Variant::ValidatedSetter Variant::get_member_validated_setter(Variant::Type p_type, const StringName &p_member) {
ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, nullptr);