diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-06-06 20:09:04 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-06-06 20:09:04 -0300 |
commit | 7499fa4507919eb0f1802f01d012d9b88fe714c7 (patch) | |
tree | b21469f0c29680e3ebd830ec39d81322c58cbb73 /core | |
parent | 5aa40704388be838c4fecc9989dd69bc6b5d9077 (diff) | |
parent | dcce477f5e2b6572e3b9579e288986c969f1a816 (diff) |
Merge pull request #5048 from J08nY/dictionary
Added Dictionary.values()
Diffstat (limited to 'core')
-rw-r--r-- | core/dictionary.cpp | 14 | ||||
-rw-r--r-- | core/dictionary.h | 1 | ||||
-rw-r--r-- | core/variant_call.cpp | 2 |
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()); |