How to bind a C++ method with pointer argument?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Zylann
:warning: Old Version Published before Godot 3 was released.

I am binding a C++ library to Godot as a module, but I wonder how to bind this method the right way:

class Noise : public Reference {
//...
    // TODO Q: how can I do that properly?
    //void set_cellular_noise_lookup(Noise * other_noise);

In order to do this in GDScript:

var A = Noise.new()
# Configure A...
var B = Noise.new()
# Configure B...
B.set_cellular_noise_lookup(A)
# Then have fun generating noise :)

Should I add a ref count? Will the binding work for GDScript?
Also, how do I return a Noise reference as well?

I’m inexperienced in this case. But, I guess you should be helped once inspecting this module:

GitHub - dbsGen/my_godot_modules: My godot modules

KelinciFX | 2016-04-30 07:02

Ok, so a Ref, then :slight_smile:

_FORCE_INLINE_ Ref<HitStatus> get_hit_status() {return hit_status;}
_FORCE_INLINE_ void set_hit_status(Ref<HitStatus> p_status) {hit_status=p_status;}

Zylann | 2016-04-30 16:16