MCPcopy Create free account
hub / github.com/borndotcom/react-native-godot / CPPCallable

Class CPPCallable

android/src/main/cpp/GodotModule.cpp:531–569  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

529}
530
531class CPPCallable : public godot::CallableCustom {
532 // friend bool javascript_callable_compare_equal_func(const godot::CallableCustom *p_a, const godot::CallableCustom *p_b) {
533 // if (p_a == p_b) return true;
534 // const JavascriptCallable *a = static_cast<const JavascriptCallable *>(p_a);
535 // const JavascriptCallable *b = static_cast<const JavascriptCallable *>(p_b);
536 // return jsi::Function::strictEquals(a->_rt, a->_func, b->_func);
537 // };
538
539 std::function<void(const godot::Variant **, int, godot::Variant &, GDExtensionCallError &)> _func;
540
541public:
542 CPPCallable(std::function<void(const godot::Variant **, int, godot::Variant &, GDExtensionCallError &)> f) :
543 _func(f) {}
544
545 uint32_t hash() const override {
546 return 0; // Use default hash function
547 }
548 godot::String get_as_text() const override {
549 return godot::String("CPPCallable");
550 }
551 CompareEqualFunc get_compare_equal_func() const override {
552 return nullptr;
553 }
554
555 CompareLessFunc get_compare_less_func() const override {
556 return nullptr;
557 }
558
559 bool is_valid() const override {
560 return true;
561 }
562 godot::ObjectID get_object() const override {
563 return godot::ObjectID();
564 }
565 void call(const godot::Variant **p_arguments, int p_argcount, godot::Variant &r_return_value, GDExtensionCallError &r_call_error) const override {
566 _func(p_arguments, p_argcount, r_return_value, r_call_error);
567 r_call_error.error = GDEXTENSION_CALL_OK;
568 }
569};
570
571godot::Callable GodotModule::create_callable(std::function<void(const godot::Variant **, int, godot::Variant &, GDExtensionCallError &)> f) {
572 return godot::Callable(memnew(CPPCallable(f)));

Callers 1

create_callableMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected