summaryrefslogtreecommitdiff
path: root/modules/gdnative
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-02-22 09:54:20 +0100
committerGitHub <noreply@github.com>2019-02-22 09:54:20 +0100
commitc700d714bb8dad0b6aae525f880d2ee2d679e7b6 (patch)
treebd71f43200fac91482faa7da7ebad6b1507915d9 /modules/gdnative
parentc4b736d7ad1406adbc19bdfc99cd52bd67b27c5e (diff)
parent56bb22c988ce84995a674e3b5f58cc22dfc41a8b (diff)
Merge pull request #26130 from karroffel/gdnative-dictionary-fix
added godot_dictionary_get_with_default to GDNative
Diffstat (limited to 'modules/gdnative')
-rw-r--r--modules/gdnative/gdnative/dictionary.cpp14
-rw-r--r--modules/gdnative/gdnative_api.json25
-rw-r--r--modules/gdnative/include/gdnative/dictionary.h4
3 files changed, 35 insertions, 8 deletions
diff --git a/modules/gdnative/gdnative/dictionary.cpp b/modules/gdnative/gdnative/dictionary.cpp
index a18d221a7c..2c6c9e2de2 100644
--- a/modules/gdnative/gdnative/dictionary.cpp
+++ b/modules/gdnative/gdnative/dictionary.cpp
@@ -155,12 +155,26 @@ godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_self) {
return raw_dest;
}
+// GDNative core 1.1
+
godot_bool GDAPI godot_dictionary_erase_with_return(godot_dictionary *p_self, const godot_variant *p_key) {
Dictionary *self = (Dictionary *)p_self;
const Variant *key = (const Variant *)p_key;
return self->erase(*key);
}
+godot_variant GDAPI godot_dictionary_get_with_default(const godot_dictionary *p_self, const godot_variant *p_key, const godot_variant *p_default) {
+ const Dictionary *self = (const Dictionary *)p_self;
+ const Variant *key = (const Variant *)p_key;
+ const Variant *def = (const Variant *)p_default;
+
+ godot_variant raw_dest;
+ Variant *dest = (Variant *)&raw_dest;
+ memnew_placement(dest, Variant(self->get(*key, *def)));
+
+ return raw_dest;
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index 7680471409..bdcd51085f 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -107,6 +107,23 @@
]
},
{
+ "name": "godot_dictionary_get_with_default",
+ "return_type": "godot_variant",
+ "arguments": [
+ ["const godot_dictionary *", "p_self"],
+ ["const godot_variant *", "p_key"],
+ ["const godot_variant *", "p_default"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_erase_with_return",
+ "return_type": "bool",
+ "arguments": [
+ ["godot_dictionary *", "p_self"],
+ ["const godot_variant *", "p_key"]
+ ]
+ },
+ {
"name": "godot_node_path_get_as_property_path",
"return_type": "godot_node_path",
"arguments": [
@@ -234,14 +251,6 @@
]
},
{
- "name": "godot_dictionary_erase_with_return",
- "return_type": "bool",
- "arguments": [
- ["godot_dictionary *", "p_self"],
- ["const godot_variant *", "p_key"]
- ]
- },
- {
"name": "godot_is_instance_valid",
"return_type": "bool",
"arguments": [
diff --git a/modules/gdnative/include/gdnative/dictionary.h b/modules/gdnative/include/gdnative/dictionary.h
index 7703742899..14e35b4692 100644
--- a/modules/gdnative/include/gdnative/dictionary.h
+++ b/modules/gdnative/include/gdnative/dictionary.h
@@ -94,8 +94,12 @@ godot_bool GDAPI godot_dictionary_operator_equal(const godot_dictionary *p_self,
godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_self);
+// GDNative core 1.1
+
godot_bool GDAPI godot_dictionary_erase_with_return(godot_dictionary *p_self, const godot_variant *p_key);
+godot_variant GDAPI godot_dictionary_get_with_default(const godot_dictionary *p_self, const godot_variant *p_key, const godot_variant *p_default);
+
#ifdef __cplusplus
}
#endif