diff options
Diffstat (limited to 'test/src/example.cpp')
-rw-r--r-- | test/src/example.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/src/example.cpp b/test/src/example.cpp index dd58f37..2b8bef6 100644 --- a/test/src/example.cpp +++ b/test/src/example.cpp @@ -15,6 +15,46 @@ using namespace godot; +class MyCallableCustom : public CallableCustom { +public: + virtual uint32_t hash() const { + return 27; + } + + virtual String get_as_text() const { + return "<MyCallableCustom>"; + } + + static bool compare_equal_func(const CallableCustom *p_a, const CallableCustom *p_b) { + return p_a == p_b; + } + + virtual CompareEqualFunc get_compare_equal_func() const { + return &MyCallableCustom::compare_equal_func; + } + + static bool compare_less_func(const CallableCustom *p_a, const CallableCustom *p_b) { + return (void *)p_a < (void *)p_b; + } + + virtual CompareLessFunc get_compare_less_func() const { + return &MyCallableCustom::compare_less_func; + } + + bool is_valid() const { + return true; + } + + virtual ObjectID get_object() const { + return ObjectID(); + } + + virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, GDExtensionCallError &r_call_error) const { + r_return_value = "Hi"; + r_call_error.error = GDEXTENSION_CALL_OK; + } +}; + void ExampleRef::set_id(int p_id) { id = p_id; } @@ -168,6 +208,7 @@ void Example::_bind_methods() { 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_custom_callable"), &Example::test_custom_callable); ClassDB::bind_method(D_METHOD("test_bitfield", "flags"), &Example::test_bitfield); @@ -378,6 +419,10 @@ Callable Example::test_callable_mp_static_ret() const { return callable_mp_static(&Example::unbound_static_method2); } +Callable Example::test_custom_callable() const { + return Callable(memnew(MyCallableCustom)); +} + void Example::unbound_method1(Object *p_object, String p_string, int p_int) { String test = "unbound_method1: "; test += p_object->get_class(); |