Signal from Godot native with custom object

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mikekulasinski

Hi

I am trying to send a signal from C++ using native plugin. I have managed to send a signal with any of the defined data classes like int, string, color etc however I cannot figure out a way to send signal with a custom object.

I have realised that it is possible to send a signal of any Variant, and Variant constructor accepts type Object but I cannot find any example how to do it.

class MyData : public Object {
}

class Simple : public GodotScript<Reference> {
GODOT_CLASS(Simple); 
public:
    void _init() override {
         owner->add_user_signal("mySignal");
    }
    void say() {
         owner->emit_signal("mySignal", new MyData());
    }
    static void _register_methods() {
         register_method("say", &Simple::say);
    }
}

extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {
    Godot::gdnative_init(o);
}

extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) {
    Godot::gdnative_terminate(o);
}

extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
    Godot::nativescript_init(handle);
    register_class<Simple>();
}

I have tried to wrap MyData object in GodotScript, use macros GODOT_CLASS , GODOT_SUBCLASS. When I run the code I either have null instance when called “.new” so something is wrong with library or object from signal is null or its just “Object” with no way to cast it to my object.

Additionally is there anyway to see more detailed log of error in godot for loaded libraries?