How to override set/get with GDExtension

In GDScript we can override _set and _get .

How to achieve the same in a GDExtension / C++ (godot-cpp)?

extends Node

class_name FooClass

func _set(name: StringName, val: Variant) -> bool:
	print("set called with ", val)
	return true

func _get(name: StringName):
	print("get called")

I tried to implement:

protected:
	Variant _get(const StringName &p_property);

but no workie. What’s the signature?

In C++ I am also inheriting from Node:

class BarClass : public Node {
	GDCLASS(BarClass, Node)

Godot 4.4

Seems like the function signature is different.

Both must return bool, _get is const with a reference out-value

bool _get(const StringName &p_name, Variant &r_value) const;
bool _set(const StringName &p_name, const Variant &p_value);

Seems like I did try that earlier but my problem is something else. Without ClassDb registration, Godot complains:

ERROR: Can't open dynamic library: /home/bla/godot/gd-bla/output/demo/addons/bla/libgdbla-0.0.1.linux.release.x86_64.so. Error: /home/bla/godot/gd-bla/output/demo/addons/bla/libgdbla-0.0.1.linux.release.x86_64.so: undefined symbol: _ZNK5godot7BarClass4_getERKNS_10StringNameERNS_7VariantE.

So undefined symbol for _get(), I add a ClassDB registration, the full .cpp file:

#include "bar.h"
#include <godot_cpp/core/class_db.hpp>

using namespace godot;

BarClass::BarClass() {
  print_debug("BarClass constructor");
}

void BarClass::_bind_methods() {
	ClassDB::bind_method(D_METHOD("_get", "p_name", "r_value"), &BarClass::_get);
}

bool _get(const StringName &p_name, Variant &r_value) {
  printf("bla\n");
  return false;
}

BarClass::~BarClass() {
  print_debug("BarClass destructor");
}

.h

#pragma once

#include <godot_cpp/classes/sprite2d.hpp>
#include <godot_cpp/classes/node.hpp>

#include <godot_cpp/variant/variant.hpp>
#include <godot_cpp/variant/string.hpp>
#include <godot_cpp/variant/string_name.hpp>
#include <godot_cpp/variant/vector2i.hpp>
#include <godot_cpp/classes/node3d.hpp>
#include <godot_cpp/variant/utility_functions.hpp>
#include <godot_cpp/classes/timer.hpp>
#include <godot_cpp/classes/engine.hpp>
#include <godot_cpp/classes/scene_tree.hpp>

namespace godot {

class BarClass : public Node {
	GDCLASS(BarClass, Node)

protected:
	static void _bind_methods();

public:
	BarClass();
	~BarClass();

protected:
	bool _get(const StringName &p_name, Variant &r_value) const;
};

}

Error:

Compiling shared src/bla.cpp ...
In file included from godot-cpp/include/godot_cpp/core/method_bind.hpp:34,
                 from godot-cpp/include/godot_cpp/core/class_db.hpp:38,
                 from godot-cpp/gen/include/godot_cpp/classes/ref_counted.hpp:39,
                 from godot-cpp/include/godot_cpp/classes/ref.hpp:37,
                 from godot-cpp/gen/include/godot_cpp/classes/node.hpp:37,
                 from godot-cpp/gen/include/godot_cpp/classes/canvas_item.hpp:37,
                 from godot-cpp/gen/include/godot_cpp/classes/node2d.hpp:36,
                 from godot-cpp/gen/include/godot_cpp/classes/sprite2d.hpp:36,
                 from src/bla.h:5,
                 from src/bla.cpp:1:
godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_get_argument_type_helper(int, int&, GDExtensionVariantType&) [with Q = Variant&]':
godot-cpp/include/godot_cpp/core/binder_common.hpp:494:53:   required from 'GDExtensionVariantType godot::call_get_argument_type(int) [with P = {const StringName&, Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:532:39:   required from 'GDExtensionVariantType godot::MethodBindTRC<R, P>::gen_argument_type(int) const [with R = bool; P = {const godot::StringName&, godot::Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:530:33:   required from here
godot-cpp/include/godot_cpp/core/binder_common.hpp:483:63: error: incomplete type 'godot::GetTypeInfo<godot::Variant&, void>' used in nested name specifier
  483 |                 type = GDExtensionVariantType(GetTypeInfo<Q>::VARIANT_TYPE);
      |                                                               ^~~~~~~~~~~~
godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_get_argument_type_info_helper(int, int&, PropertyInfo&) [with Q = Variant&]':
godot-cpp/include/godot_cpp/core/binder_common.hpp:513:58:   required from 'void godot::call_get_argument_type_info(int, PropertyInfo&) [with P = {const StringName&, Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:541:37:   required from 'godot::PropertyInfo godot::MethodBindTRC<R, P>::gen_argument_type_info(int) const [with R = bool; P = {const godot::StringName&, godot::Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:538:23:   required from here
godot-cpp/include/godot_cpp/core/binder_common.hpp:503:54: error: incomplete type 'godot::GetTypeInfo<godot::Variant&, void>' used in nested name specifier
  503 |                 info = GetTypeInfo<Q>::get_class_info();
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_get_argument_metadata_helper(int, int&, GDExtensionClassMethodArgumentMetadata&) [with Q = Variant&]':
godot-cpp/include/godot_cpp/core/binder_common.hpp:533:57:   required from 'GDExtensionClassMethodArgumentMetadata godot::call_get_argument_metadata(int) [with P = {const StringName&, Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:554:43:   required from 'GDExtensionClassMethodArgumentMetadata godot::MethodBindTRC<R, P>::get_argument_metadata(int) const [with R = bool; P = {const godot::StringName&, godot::Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:552:49:   required from here
godot-cpp/include/godot_cpp/core/binder_common.hpp:521:38: error: incomplete type 'godot::GetTypeInfo<godot::Variant&, void>' used in nested name specifier
  521 |                 md = GetTypeInfo<Q>::METADATA;
      |                                      ^~~~~~~~
godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_with_variant_args_retc_helper(T*, R (T::*)(P ...) const, const Variant**, Variant&, GDExtensionCallError&, IndexSequence<Is ...>) [with T = _gde_UnexistingClass; R = bool; P = {const StringName&, Variant&}; long unsigned int ...Is = {0, 1}]':
godot-cpp/include/godot_cpp/core/binder_common.hpp:470:36:   required from 'void godot::call_with_variant_args_retc_dv(T*, R (T::*)(P ...) const, const void* const*, int, Variant&, GDExtensionCallError&, const std::vector<Variant>&) [with T = _gde_UnexistingClass; R = bool; P = {const StringName&, Variant&}; GDExtensionConstVariantPtr = const void*]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:565:33:   required from 'godot::Variant godot::MethodBindTRC<R, P>::call(GDExtensionClassInstancePtr, const void* const*, GDExtensionInt, GDExtensionCallError&) const [with R = bool; P = {const godot::StringName&, godot::Variant&}; GDExtensionClassInstancePtr = void*; GDExtensionConstVariantPtr = const void*; GDExtensionInt = long int]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:560:18:   required from here
godot-cpp/include/godot_cpp/core/binder_common.hpp:274:40: error: cannot bind non-const lvalue reference of type 'godot::Variant&' to an rvalue of type 'godot::Variant'
  274 |    _ret = (p_instance->*p_method)(VariantCaster<P>::cast(*p_args[Is])...);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_with_ptr_args_retc_helper(T*, R (T::*)(P ...) const, const void* const*, void*, IndexSequence<Is ...>) [with T = _gde_UnexistingClass; R = bool; P = {const StringName&, Variant&}; long unsigned int ...Is = {0, 1}; GDExtensionConstTypePtr = const void*]':
godot-cpp/include/godot_cpp/core/binder_common.hpp:229:44:   required from 'void godot::call_with_ptr_args(T*, R (T::*)(P ...) const, const void* const*, void*) [with T = _gde_UnexistingClass; R = bool; P = {const StringName&, Variant&}; GDExtensionConstTypePtr = const void*]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:573:36:   required from 'void godot::MethodBindTRC<R, P>::ptrcall(GDExtensionClassInstancePtr, const void* const*, GDExtensionTypePtr) const [with R = bool; P = {const godot::StringName&, godot::Variant&}; GDExtensionClassInstancePtr = void*; GDExtensionConstTypePtr = const void*; GDExtensionTypePtr = void*]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:569:15:   required from here
godot-cpp/include/godot_cpp/core/binder_common.hpp:209:73: error: 'convert' is not a member of 'godot::PtrToArg<godot::Variant&>'
  209 |         PtrToArg<R>::encode((p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...), r_ret);
      |                                                     ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
scons: *** [src/bla.os] Error 1
scons: building terminated because of errors.
     r

Needs the class name.

bool BarClass::_get(const StringName &p_name, Variant &r_value) {

yes, in addition the impl. should be marked const too so it becomes

bool WebBind::_get(const StringName &p_name, Variant &r_value) const {
[...]

Unfortunately the issue persists:

Compiling shared src/bla.cpp ...
In file included from godot-cpp/include/godot_cpp/core/method_bind.hpp:34,
                 from godot-cpp/include/godot_cpp/core/class_db.hpp:38,
                 from src/bla.h:5,
                 from src/bla.cpp:1:
godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_get_argument_type_helper(int, int&, GDExtensionVariantType&) [with Q = Variant&]':
godot-cpp/include/godot_cpp/core/binder_common.hpp:494:53:   required from 'GDExtensionVariantType godot::call_get_argument_type(int) [with P = {const StringName&, Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:532:39:   required from 'GDExtensionVariantType godot::MethodBindTRC<R, P>::gen_argument_type(int) const [with R = bool; P = {const godot::StringName&, godot::Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:530:33:   required from here
godot-cpp/include/godot_cpp/core/binder_common.hpp:483:63: error: incomplete type 'godot::GetTypeInfo<godot::Variant&, void>' used in nested name specifier
  483 |                 type = GDExtensionVariantType(GetTypeInfo<Q>::VARIANT_TYPE);
      |                                                               ^~~~~~~~~~~~
godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_get_argument_type_info_helper(int, int&, PropertyInfo&) [with Q = Variant&]':
godot-cpp/include/godot_cpp/core/binder_common.hpp:513:58:   required from 'void godot::call_get_argument_type_info(int, PropertyInfo&) [with P = {const StringName&, Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:541:37:   required from 'godot::PropertyInfo godot::MethodBindTRC<R, P>::gen_argument_type_info(int) const [with R = bool; P = {const godot::StringName&, godot::Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:538:23:   required from here
godot-cpp/include/godot_cpp/core/binder_common.hpp:503:54: error: incomplete type 'godot::GetTypeInfo<godot::Variant&, void>' used in nested name specifier
  503 |                 info = GetTypeInfo<Q>::get_class_info();
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_get_argument_metadata_helper(int, int&, GDExtensionClassMethodArgumentMetadata&) [with Q = Variant&]':
godot-cpp/include/godot_cpp/core/binder_common.hpp:533:57:   required from 'GDExtensionClassMethodArgumentMetadata godot::call_get_argument_metadata(int) [with P = {const StringName&, Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:554:43:   required from 'GDExtensionClassMethodArgumentMetadata godot::MethodBindTRC<R, P>::get_argument_metadata(int) const [with R = bool; P = {const godot::StringName&, godot::Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:552:49:   required from here
godot-cpp/include/godot_cpp/core/binder_common.hpp:521:38: error: incomplete type 'godot::GetTypeInfo<godot::Variant&, void>' used in nested name specifier
  521 |                 md = GetTypeInfo<Q>::METADATA;
      |                                      ^~~~~~~~
godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_with_variant_args_retc_helper(T*, R (T::*)(P ...) const, const Variant**, Variant&, GDExtensionCallError&, IndexSequence<Is ...>) [with T = _gde_UnexistingClass; R = bool; P = {const StringName&, Variant&}; long unsigned int ...Is = {0, 1}]':
godot-cpp/include/godot_cpp/core/binder_common.hpp:470:36:   required from 'void godot::call_with_variant_args_retc_dv(T*, R (T::*)(P ...) const, const void* const*, int, Variant&, GDExtensionCallError&, const std::vector<Variant>&) [with T = _gde_UnexistingClass; R = bool; P = {const StringName&, Variant&}; GDExtensionConstVariantPtr = const void*]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:565:33:   required from 'godot::Variant godot::MethodBindTRC<R, P>::call(GDExtensionClassInstancePtr, const void* const*, GDExtensionInt, GDExtensionCallError&) const [with R = bool; P = {const godot::StringName&, godot::Variant&}; GDExtensionClassInstancePtr = void*; GDExtensionConstVariantPtr = const void*; GDExtensionInt = long int]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:560:18:   required from here
godot-cpp/include/godot_cpp/core/binder_common.hpp:274:40: error: cannot bind non-const lvalue reference of type 'godot::Variant&' to an rvalue of type 'godot::Variant'
  274 |         r_ret = (p_instance->*p_method)(VariantCaster<P>::cast(*p_args[Is])...);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_with_ptr_args_retc_helper(T*, R (T::*)(P ...) const, const void* const*, void*, IndexSequence<Is ...>) [with T = _gde_UnexistingClass; R = bool; P = {const StringName&, Variant&}; long unsigned int ...Is = {0, 1}; GDExtensionConstTypePtr = const void*]':
godot-cpp/include/godot_cpp/core/binder_common.hpp:229:44:   required from 'void godot::call_with_ptr_args(T*, R (T::*)(P ...) const, const void* const*, void*) [with T = _gde_UnexistingClass; R = bool; P = {const StringName&, Variant&}; GDExtensionConstTypePtr = const void*]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:573:36:   required from 'void godot::MethodBindTRC<R, P>::ptrcall(GDExtensionClassInstancePtr, const void* const*, GDExtensionTypePtr) const [with R = bool; P = {const godot::StringName&, godot::Variant&}; GDExtensionClassInstancePtr = void*; GDExtensionConstTypePtr = const void*; GDExtensionTypePtr = void*]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:569:15:   required from here
godot-cpp/include/godot_cpp/core/binder_common.hpp:209:73: error: 'convert' is not a member of 'godot::PtrToArg<godot::Variant&>'
  209 |         PtrToArg<R>::encode((p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...), r_ret);
      |                                                     ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
scons: *** [src/bla.os] Error 1
scons: building terminated because of errors.

so its error: incomplete type ? am I missing an include? Perhaps the error is error: 'convert' is not a member of 'godot::PtrToArg<godot::Variant&>'

or perhaps I need to update godot-cpp, I’m on d47758910428242169ebe59329b449edf16036e0 from 27 Aug, in combination with Godot 4.4 dev2

Try including godot_cpp/core/type_info.hpp?

With that as top include in the header I get:

Compiling shared src/bla.cpp ...
In file included from src/bla.h:5,
                 from src/bla.cpp:1:
godot-cpp/include/godot_cpp/core/type_info.hpp:310:8: error: 'PtrToArg' is not a class template
  310 | struct PtrToArg<TypedArray<T>> {
      |        ^~~~~~~~
In file included from godot-cpp/include/godot_cpp/core/binder_common.hpp:36,
                 from godot-cpp/include/godot_cpp/core/method_bind.hpp:34,
                 from godot-cpp/include/godot_cpp/core/class_db.hpp:38,
                 from src/bla.h:6:
godot-cpp/include/godot_cpp/core/method_ptrcall.hpp:43:8: error: redefinition of 'struct godot::PtrToArg<T>'
   43 | struct PtrToArg {};
      |        ^~~~~~~~
godot-cpp/include/godot_cpp/core/type_info.hpp:310:8: note: previous definition of 'struct godot::PtrToArg<T>'
  310 | struct PtrToArg<TypedArray<T>> {
      |        ^~~~~~~~
godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_get_argument_type_helper(int, int&, GDExtensionVariantType&) [with Q = Variant&]':
godot-cpp/include/godot_cpp/core/binder_common.hpp:494:53:   required from 'GDExtensionVariantType godot::call_get_argument_type(int) [with P = {const StringName&, Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:532:39:   required from 'GDExtensionVariantType godot::MethodBindTRC<R, P>::gen_argument_type(int) const [with R = bool; P = {const godot::StringName&, godot::Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:530:33:   required from here
godot-cpp/include/godot_cpp/core/binder_common.hpp:483:63: error: incomplete type 'godot::GetTypeInfo<godot::Variant&, void>' used in nested name specifier
  483 |                 type = GDExtensionVariantType(GetTypeInfo<Q>::VARIANT_TYPE);
      |                                                               ^~~~~~~~~~~~
godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_get_argument_type_info_helper(int, int&, PropertyInfo&) [with Q = Variant&]':
godot-cpp/include/godot_cpp/core/binder_common.hpp:513:58:   required from 'void godot::call_get_argument_type_info(int, PropertyInfo&) [with P = {const StringName&, Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:541:37:   required from 'godot::PropertyInfo godot::MethodBindTRC<R, P>::gen_argument_type_info(int) const [with R = bool; P = {const godot::StringName&, godot::Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:538:23:   required from here
godot-cpp/include/godot_cpp/core/binder_common.hpp:503:54: error: incomplete type 'godot::GetTypeInfo<godot::Variant&, void>' used in nested name specifier
  503 |                 info = GetTypeInfo<Q>::get_class_info();
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_get_argument_metadata_helper(int, int&, GDExtensionClassMethodArgumentMetadata&) [with Q = Variant&]':
godot-cpp/include/godot_cpp/core/binder_common.hpp:533:57:   required from 'GDExtensionClassMethodArgumentMetadata godot::call_get_argument_metadata(int) [with P = {const StringName&, Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:554:43:   required from 'GDExtensionClassMethodArgumentMetadata godot::MethodBindTRC<R, P>::get_argument_metadata(int) const [with R = bool; P = {const godot::StringName&, godot::Variant&}]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:552:49:   required from here
godot-cpp/include/godot_cpp/core/binder_common.hpp:521:38: error: incomplete type 'godot::GetTypeInfo<godot::Variant&, void>' used in nested name specifier
  521 |                 md = GetTypeInfo<Q>::METADATA;
      |                                      ^~~~~~~~
godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_with_variant_args_retc_helper(T*, R (T::*)(P ...) const, const Variant**, Variant&, GDExtensionCallError&, IndexSequence<Is ...>) [with T = _gde_UnexistingClass; R = bool; P = {const StringName&, Variant&}; long unsigned int ...Is = {0, 1}]':
godot-cpp/include/godot_cpp/core/binder_common.hpp:470:36:   required from 'void godot::call_with_variant_args_retc_dv(T*, R (T::*)(P ...) const, const void* const*, int, Variant&, GDExtensionCallError&, const std::vector<Variant>&) [with T = _gde_UnexistingClass; R = bool; P = {const StringName&, Variant&}; GDExtensionConstVariantPtr = const void*]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:565:33:   required from 'godot::Variant godot::MethodBindTRC<R, P>::call(GDExtensionClassInstancePtr, const void* const*, GDExtensionInt, GDExtensionCallError&) const [with R = bool; P = {const godot::StringName&, godot::Variant&}; GDExtensionClassInstancePtr = void*; GDExtensionConstVariantPtr = const void*; GDExtensionInt = long int]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:560:18:   required from here
godot-cpp/include/godot_cpp/core/binder_common.hpp:274:40: error: cannot bind non-const lvalue reference of type 'godot::Variant&' to an rvalue of type 'godot::Variant'
  274 |         r_ret = (p_instance->*p_method)(VariantCaster<P>::cast(*p_args[Is])...);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_with_ptr_args_retc_helper(T*, R (T::*)(P ...) const, const void* const*, void*, IndexSequence<Is ...>) [with T = _gde_UnexistingClass; R = bool; P = {const StringName&, Variant&}; long unsigned int ...Is = {0, 1}; GDExtensionConstTypePtr = const void*]':
godot-cpp/include/godot_cpp/core/binder_common.hpp:229:44:   required from 'void godot::call_with_ptr_args(T*, R (T::*)(P ...) const, const void* const*, void*) [with T = _gde_UnexistingClass; R = bool; P = {const StringName&, Variant&}; GDExtensionConstTypePtr = const void*]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:573:36:   required from 'void godot::MethodBindTRC<R, P>::ptrcall(GDExtensionClassInstancePtr, const void* const*, GDExtensionTypePtr) const [with R = bool; P = {const godot::StringName&, godot::Variant&}; GDExtensionClassInstancePtr = void*; GDExtensionConstTypePtr = const void*; GDExtensionTypePtr = void*]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:569:15:   required from here
godot-cpp/include/godot_cpp/core/binder_common.hpp:209:52: error: cannot bind non-const lvalue reference of type 'godot::Variant&' to an rvalue of type 'godot::Variant'
  209 |         PtrToArg<R>::encode((p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...), r_ret);
      |                             ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from godot-cpp/include/godot_cpp/core/property_info.hpp:38,
                 from godot-cpp/include/godot_cpp/core/object.hpp:38,
                 from godot-cpp/include/godot_cpp/core/type_info.hpp:34:
godot-cpp/include/godot_cpp/variant/variant.hpp:206:9: note:   after user-defined conversion: 'godot::Variant::Variant(const godot::Array&)'
  206 |         Variant(const Array &v);
      |         ^~~~~~~
In file included from godot-cpp/gen/include/godot_cpp/classes/object.hpp:42,
                 from godot-cpp/include/godot_cpp/core/object.hpp:42:
godot-cpp/include/godot_cpp/variant/typed_array.hpp: In instantiation of 'godot::TypedArray<T>::TypedArray(const godot::Array&) [with T = godot::Variant&]':
godot-cpp/include/godot_cpp/core/type_info.hpp:312:10:   required from 'static godot::TypedArray<T> godot::PtrToArg<T>::convert(const void*) [with T = godot::Variant&]'
godot-cpp/include/godot_cpp/core/binder_common.hpp:209:66:   required from 'void godot::call_with_ptr_args_retc_helper(T*, R (T::*)(P ...) const, const void* const*, void*, IndexSequence<Is ...>) [with T = _gde_UnexistingClass; R = bool; P = {const StringName&, Variant&}; long unsigned int ...Is = {0, 1}; GDExtensionConstTypePtr = const void*]'
godot-cpp/include/godot_cpp/core/binder_common.hpp:229:44:   required from 'void godot::call_with_ptr_args(T*, R (T::*)(P ...) const, const void* const*, void*) [with T = _gde_UnexistingClass; R = bool; P = {const StringName&, Variant&}; GDExtensionConstTypePtr = const void*]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:573:36:   required from 'void godot::MethodBindTRC<R, P>::ptrcall(GDExtensionClassInstancePtr, const void* const*, GDExtensionTypePtr) const [with R = bool; P = {const godot::StringName&, godot::Variant&}; GDExtensionClassInstancePtr = void*; GDExtensionConstTypePtr = const void*; GDExtensionTypePtr = void*]'
godot-cpp/include/godot_cpp/core/method_bind.hpp:569:15:   required from here
godot-cpp/include/godot_cpp/variant/typed_array.hpp:50:63: error: 'get_class_static' is not a member of 'godot::Variant&'
   50 |                 set_typed(Variant::OBJECT, T::get_class_static(), Variant());
      |                                            ~~~~~~~~~~~~~~~~~~~^~

ill try with a newer version of godot-cpp and make sure my dev env. is fresh.

1 Like

Solution:

  1. Do not use ClassDB::bind_method for _set and _get
  2. _set will not be called for variables that are already defined!
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.