summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJ08nY <jancar.jj@gmail.com>2016-06-05 14:20:52 +0200
committerJ08nY <jancar.jj@gmail.com>2016-06-05 14:50:06 +0200
commitdcce477f5e2b6572e3b9579e288986c969f1a816 (patch)
treef35313ae16b39fb1a5bc54597e01872f1440b8a2 /core
parent56348cbbfe82c2f5e2b95875e0687b664cc6e2d8 (diff)
Added Dictionary.values()
Diffstat (limited to 'core')
-rw-r--r--core/dictionary.cpp14
-rw-r--r--core/dictionary.h1
-rw-r--r--core/variant_call.cpp2
3 files changed, 15 insertions, 2 deletions
diff --git a/core/dictionary.cpp b/core/dictionary.cpp
index 75c8531251..6204a87054 100644
--- a/core/dictionary.cpp
+++ b/core/dictionary.cpp
@@ -199,6 +199,18 @@ Array Dictionary::keys() const {
}
+Array Dictionary::values() const {
+
+ Array varr;
+ varr.resize(size());
+ const Variant *key=NULL;
+ int i=0;
+ while((key=next(key))){
+ varr[i++] = _p->variant_map[*key];
+ }
+ return varr;
+}
+
const Variant* Dictionary::next(const Variant* p_key) const {
return _p->variant_map.next(p_key);
@@ -250,5 +262,3 @@ Dictionary::~Dictionary() {
_unref();
}
-
-
diff --git a/core/dictionary.h b/core/dictionary.h
index c854e95ee6..ae79fab9c3 100644
--- a/core/dictionary.h
+++ b/core/dictionary.h
@@ -81,6 +81,7 @@ public:
const Variant* next(const Variant* p_key=NULL) const;
Array keys() const;
+ Array values() const;
Dictionary(const Dictionary& p_from);
Dictionary(bool p_shared=false);
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index f5dcd75691..f9fc54641c 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -445,6 +445,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1(Dictionary,erase);
VCALL_LOCALMEM0R(Dictionary,hash);
VCALL_LOCALMEM0R(Dictionary,keys);
+ VCALL_LOCALMEM0R(Dictionary,values);
VCALL_LOCALMEM1R(Dictionary,parse_json);
VCALL_LOCALMEM0R(Dictionary,to_json);
@@ -1434,6 +1435,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC1(DICTIONARY,NIL,Dictionary,erase,NIL,"value",varray());
ADDFUNC0(DICTIONARY,INT,Dictionary,hash,varray());
ADDFUNC0(DICTIONARY,ARRAY,Dictionary,keys,varray());
+ ADDFUNC0(DICTIONARY,ARRAY,Dictionary,values,varray());
ADDFUNC1(DICTIONARY,INT,Dictionary,parse_json,STRING,"json",varray());
ADDFUNC0(DICTIONARY,STRING,Dictionary,to_json,varray());