summaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2023-06-28 21:55:04 -0500
committerDavid Snopek <dsnopek@gmail.com>2023-09-21 15:17:50 -0500
commitc18c1916c3f465d00800921d527902f18308fbf4 (patch)
tree5ca066cd3e84799c40defebe7923d7785bc20fe6 /test/src
parent4314f91b7dc23d930506f52d3a3c88fae0f5d57d (diff)
downloadredot-cpp-c18c1916c3f465d00800921d527902f18308fbf4.tar.gz
Implement `callable_mp()` and `callable_mp_static()`
Diffstat (limited to 'test/src')
-rw-r--r--test/src/example.cpp64
-rw-r--r--test/src/example.h12
2 files changed, 76 insertions, 0 deletions
diff --git a/test/src/example.cpp b/test/src/example.cpp
index 800f5ed..759cc4f 100644
--- a/test/src/example.cpp
+++ b/test/src/example.cpp
@@ -163,6 +163,12 @@ void Example::_bind_methods() {
ClassDB::bind_method(D_METHOD("test_variant_call", "variant"), &Example::test_variant_call);
+ ClassDB::bind_method(D_METHOD("test_callable_mp"), &Example::test_callable_mp);
+ ClassDB::bind_method(D_METHOD("test_callable_mp_ret"), &Example::test_callable_mp_ret);
+ ClassDB::bind_method(D_METHOD("test_callable_mp_retc"), &Example::test_callable_mp_retc);
+ ClassDB::bind_method(D_METHOD("test_callable_mp_static"), &Example::test_callable_mp_static);
+ ClassDB::bind_method(D_METHOD("test_callable_mp_static_ret"), &Example::test_callable_mp_static_ret);
+
ClassDB::bind_method(D_METHOD("test_bitfield", "flags"), &Example::test_bitfield);
ClassDB::bind_method(D_METHOD("test_rpc", "value"), &Example::test_rpc);
@@ -349,6 +355,64 @@ int Example::test_vector_ops() const {
return ret;
}
+Callable Example::test_callable_mp() {
+ return callable_mp(this, &Example::unbound_method1);
+}
+
+Callable Example::test_callable_mp_ret() {
+ return callable_mp(this, &Example::unbound_method2);
+}
+
+Callable Example::test_callable_mp_retc() const {
+ return callable_mp(this, &Example::unbound_method3);
+}
+
+Callable Example::test_callable_mp_static() const {
+ return callable_mp_static(&Example::unbound_static_method1);
+}
+
+Callable Example::test_callable_mp_static_ret() const {
+ return callable_mp_static(&Example::unbound_static_method2);
+}
+
+void Example::unbound_method1(Object *p_object, String p_string, int p_int) {
+ String test = "unbound_method1: ";
+ test += p_object->get_class();
+ test += " - " + p_string;
+ emit_custom_signal(test, p_int);
+}
+
+String Example::unbound_method2(Object *p_object, String p_string, int p_int) {
+ String test = "unbound_method2: ";
+ test += p_object->get_class();
+ test += " - " + p_string;
+ test += " - " + itos(p_int);
+ return test;
+}
+
+String Example::unbound_method3(Object *p_object, String p_string, int p_int) const {
+ String test = "unbound_method3: ";
+ test += p_object->get_class();
+ test += " - " + p_string;
+ test += " - " + itos(p_int);
+ return test;
+}
+
+void Example::unbound_static_method1(Example *p_object, String p_string, int p_int) {
+ String test = "unbound_static_method1: ";
+ test += p_object->get_class();
+ test += " - " + p_string;
+ p_object->emit_custom_signal(test, p_int);
+}
+
+String Example::unbound_static_method2(Object *p_object, String p_string, int p_int) {
+ String test = "unbound_static_method2: ";
+ test += p_object->get_class();
+ test += " - " + p_string;
+ test += " - " + itos(p_int);
+ return test;
+}
+
int Example::test_tarray_arg(const TypedArray<int64_t> &p_array) {
int sum = 0;
for (int i = 0; i < p_array.size(); i++) {
diff --git a/test/src/example.h b/test/src/example.h
index 354b7ba..4dfda23 100644
--- a/test/src/example.h
+++ b/test/src/example.h
@@ -138,6 +138,18 @@ public:
Variant test_variant_call(Variant p_variant);
+ Callable test_callable_mp();
+ Callable test_callable_mp_ret();
+ Callable test_callable_mp_retc() const;
+ Callable test_callable_mp_static() const;
+ Callable test_callable_mp_static_ret() const;
+
+ void unbound_method1(Object *p_object, String p_string, int p_int);
+ String unbound_method2(Object *p_object, String p_string, int p_int);
+ String unbound_method3(Object *p_object, String p_string, int p_int) const;
+ static void unbound_static_method1(Example *p_object, String p_string, int p_int);
+ static String unbound_static_method2(Object *p_object, String p_string, int p_int);
+
BitField<Flags> test_bitfield(BitField<Flags> flags);
// RPC