summaryrefslogtreecommitdiff
path: root/core/bind
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-04-09 17:46:35 +0200
committerGitHub <noreply@github.com>2017-04-09 17:46:35 +0200
commitf29dc079dcf10865f5373f7b3d4ed23772c85737 (patch)
tree004cbc54625d8bb20e812da4a963ac21d9c3bd4e /core/bind
parent769bec26a76dfbaf4bd83e2c11dec467d24eb3cf (diff)
parent42eba57badd70432093d8114a0e8e1fabe184e5c (diff)
Merge pull request #8333 from touilleMan/classdb-class_sget_property-binding
Add _ClassDB.class_[g|s]et_property to ClassDB exposed methods
Diffstat (limited to 'core/bind')
-rw-r--r--core/bind/core_bind.cpp19
-rw-r--r--core/bind/core_bind.h2
2 files changed, 21 insertions, 0 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 8c57f49069..7523d30e18 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -2367,6 +2367,23 @@ Array _ClassDB::get_property_list(StringName p_class, bool p_no_inheritance) con
return ret;
}
+Variant _ClassDB::get_property(Object *p_object, const StringName &p_property) const {
+ Variant ret;
+ ClassDB::get_property(p_object, p_property, ret);
+ return ret;
+}
+
+Error _ClassDB::set_property(Object *p_object, const StringName &p_property, const Variant &p_value) const {
+ Variant ret;
+ bool valid;
+ if (!ClassDB::set_property(p_object, p_property, p_value, &valid)) {
+ return ERR_UNAVAILABLE;
+ } else if (!valid) {
+ return ERR_INVALID_DATA;
+ }
+ return OK;
+}
+
bool _ClassDB::has_method(StringName p_class, StringName p_method, bool p_no_inheritance) const {
return ClassDB::has_method(p_class, p_method, p_no_inheritance);
@@ -2439,6 +2456,8 @@ void _ClassDB::_bind_methods() {
ClassDB::bind_method(D_METHOD("class_get_signal_list", "class", "no_inheritance"), &_ClassDB::get_signal_list, DEFVAL(false));
ClassDB::bind_method(D_METHOD("class_get_property_list", "class", "no_inheritance"), &_ClassDB::get_property_list, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("class_get_property:Variant", "object", "property"), &_ClassDB::get_property);
+ ClassDB::bind_method(D_METHOD("class_set_property:Error", "object", "property", "value"), &_ClassDB::set_property);
ClassDB::bind_method(D_METHOD("class_has_method", "class", "method", "no_inheritance"), &_ClassDB::has_method, DEFVAL(false));
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 13956c3373..ab27296b27 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -587,6 +587,8 @@ public:
Array get_signal_list(StringName p_class, bool p_no_inheritance = false) const;
Array get_property_list(StringName p_class, bool p_no_inheritance = false) const;
+ Variant get_property(Object *p_object, const StringName &p_property) const;
+ Error set_property(Object *p_object, const StringName &p_property, const Variant &p_value) const;
bool has_method(StringName p_class, StringName p_method, bool p_no_inheritance = false) const;