diff options
Diffstat (limited to 'modules/gdnative/godot/godot_dictionary.cpp')
-rw-r--r-- | modules/gdnative/godot/godot_dictionary.cpp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/modules/gdnative/godot/godot_dictionary.cpp b/modules/gdnative/godot/godot_dictionary.cpp index deec5f8ffb..12c40f0564 100644 --- a/modules/gdnative/godot/godot_dictionary.cpp +++ b/modules/gdnative/godot/godot_dictionary.cpp @@ -44,9 +44,9 @@ void GDAPI godot_dictionary_new(godot_dictionary *r_dest) { memnew_placement(dest, Dictionary); } -void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *r_src) { +void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src) { Dictionary *dest = (Dictionary *)r_dest; - const Dictionary *src = (const Dictionary *)r_src; + const Dictionary *src = (const Dictionary *)p_src; memnew_placement(dest, Dictionary(*src)); } @@ -107,10 +107,26 @@ godot_array GDAPI godot_dictionary_values(const godot_dictionary *p_self) { return dest; } -godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_dict, const godot_variant *p_key) { - Dictionary *dict = (Dictionary *)p_dict; +godot_variant GDAPI godot_dictionary_get(const godot_dictionary *p_self, const godot_variant *p_key) { + godot_variant raw_dest; + Variant *dest = (Variant *)&raw_dest; + const Dictionary *self = (const Dictionary *)p_self; + const Variant *key = (const Variant *)p_key; + memnew_placement(dest, Variant(self->operator[](*key))); + return raw_dest; +} + +void GDAPI godot_dictionary_set(godot_dictionary *p_self, const godot_variant *p_key, const godot_variant *p_value) { + Dictionary *self = (Dictionary *)p_self; const Variant *key = (const Variant *)p_key; - return (godot_variant *)&dict->operator[](*key); + const Variant *value = (const Variant *)p_value; + self->operator[](*key) = *value; +} + +godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, const godot_variant *p_key) { + Array *self = (Array *)p_self; + const Variant *key = (const Variant *)p_key; + return (godot_variant *)&self->operator[](*key); } godot_bool GDAPI godot_dictionary_operator_equal(const godot_dictionary *p_self, const godot_dictionary *p_b) { @@ -119,11 +135,11 @@ godot_bool GDAPI godot_dictionary_operator_equal(const godot_dictionary *p_self, return *self == *b; } -godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_dict) { +godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_self) { godot_string raw_dest; String *dest = (String *)&raw_dest; - const Dictionary *dict = (const Dictionary *)p_dict; - memnew_placement(dest, String(JSON::print(Variant(*dict)))); + const Dictionary *self = (const Dictionary *)p_self; + memnew_placement(dest, String(JSON::print(Variant(*self)))); return raw_dest; } |