From 3b4f3a948c12f762d12916499b976a69071682c9 Mon Sep 17 00:00:00 2001 From: Twan van Laarhoven Date: Sat, 18 Apr 2020 19:32:25 +0200 Subject: [PATCH] Fix: length now works correctly for maps --- src/script/to_value.hpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/script/to_value.hpp b/src/script/to_value.hpp index fb89f5d1..2fceb66b 100644 --- a/src/script/to_value.hpp +++ b/src/script/to_value.hpp @@ -225,12 +225,14 @@ class ScriptMap : public ScriptValue { /// Script value containing a custom collection, returned from script functions class ScriptCustomCollection : public ScriptCollectionBase { public: - virtual ScriptValueP getMember(const String& name) const; - virtual ScriptValueP getIndex(int index) const; - virtual ScriptValueP makeIterator(const ScriptValueP& thisP) const; - virtual int itemCount() const { return (int)value.size(); } + ScriptValueP getMember(const String& name) const override; + ScriptValueP getIndex(int index) const override; + ScriptValueP makeIterator(const ScriptValueP& thisP) const override; + int itemCount() const override { + return (int)(value.size() + key_value.size()); + } /// Collections can be compared by comparing pointers - virtual CompareWhat compareAs(String&, void const*& compare_ptr) const { + CompareWhat compareAs(String&, void const*& compare_ptr) const override { compare_ptr = this; return COMPARE_AS_POINTER; }