Skip to content

Can't bind methods with the native pointer argument. #630

@bruvzg

Description

@bruvzg

godot-cpp: 5826fd52592c5ed9051c7ef5dbfbd9295fb23607
godot: godotengine/godot#52192

Binding native pointer argument (both simple types and custom structure types register in the engine):

virtual void _font_set_data_ptr(const RID &font_rid, const uint8_t *p_data_ptr, uint64_t data_size);
...
virtual void _shaped_text_get_glyphs(const RID &shaped, const Glyph **r_glyphs) const;

Which was defined in the engine as:

virtual void font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) override;
GDVIRTUAL3(_font_set_data_ptr, RID, GDNativeConstPtr<const uint8_t>, uint64_t);
...
virtual const Glyph *shaped_text_get_glyphs(RID p_shaped) const override;
GDVIRTUAL2C(_shaped_text_get_glyphs, RID, GDNativePtr<const Glyph *>);

Fails with the following errors:

Simple type:

In file included from src/register_types.cpp:1:
In file included from ./godot-cpp/include/godot_cpp/core/class_db.hpp:38:
In file included from ./godot-cpp/include/godot_cpp/core/method_bind.hpp:34:
In file included from ./godot-cpp/include/godot_cpp/core/binder_common.hpp:36:
./godot-cpp/include/godot_cpp/core/method_ptrcall.hpp:179:134: error: type 'unsigned char' cannot be used prior to '::' because it has no members
                return reinterpret_cast<const T *>(godot::internal::interface->object_get_instance_binding((void *)p_ptr, godot::internal::token, &T::___binding_callbacks));
                                                                                                                                                   ^
./godot-cpp/include/godot_cpp/core/binder_common.hpp:152:39: note: in instantiation of member function 'godot::PtrToArg<const unsigned char *>::convert' requested here
        (p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...);
                                             ^
./godot-cpp/include/godot_cpp/core/binder_common.hpp:172:2: note: in instantiation of function template specialization 'godot::call_with_ptr_args_helper<godot::TextServerTest, const godot::RID &, const unsigned char *, unsigned long long, 0, 1, 2>' requested here
        call_with_ptr_args_helper<T, P...>(p_instance, p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
        ^
./godot-cpp/gen/include/godot_cpp/classes/text_server_extension.hpp:266:4: note: in instantiation of function template specialization 'godot::call_with_ptr_args<godot::TextServerTest, const godot::RID &, const unsigned char *, unsigned long long>' requested here
                        BIND_VIRTUAL_METHOD(T, _font_set_data_ptr);
                        ^
./godot-cpp/include/godot_cpp/core/class_db.hpp:132:4: note: expanded from macro 'BIND_VIRTUAL_METHOD'
                        call_with_ptr_args(reinterpret_cast<m_class *>(p_instance), &m_class::m_method, p_args, p_ret);                       \
                        ^
src/ts_test.h:20:2: note: in instantiation of function template specialization 'godot::TextServerExtension::register_virtuals<godot::TextServerTest>' requested here
        GDCLASS(TextServerTest, TextServerExtension);
        ^
./godot-cpp/include/godot_cpp/classes/wrapped.hpp:122:16: note: expanded from macro 'GDCLASS'
                        m_inherits::register_virtuals<m_class>();                                                                                                             \
                                    ^
1 error generated.
scons: *** [src/register_types.os] Error 1

Pointer to the custom structure type:

In file included from src/register_types.cpp:1:
In file included from ./godot-cpp/include/godot_cpp/core/class_db.hpp:38:
In file included from ./godot-cpp/include/godot_cpp/core/method_bind.hpp:34:
In file included from ./godot-cpp/include/godot_cpp/core/binder_common.hpp:36:
./godot-cpp/include/godot_cpp/core/method_ptrcall.hpp:168:128: error: type 'const godot::Glyph *' cannot be used prior to '::' because it has no members
                return reinterpret_cast<T *>(godot::internal::interface->object_get_instance_binding((void *)p_ptr, godot::internal::token, &T::___binding_callbacks));
                                                                                                                                             ^
./godot-cpp/include/godot_cpp/core/binder_common.hpp:157:39: note: in instantiation of member function 'godot::PtrToArg<const godot::Glyph **>::convert' requested here
        (p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...);
                                             ^
./godot-cpp/include/godot_cpp/core/binder_common.hpp:177:2: note: in instantiation of function template specialization 'godot::call_with_ptr_argsc_helper<godot::TextServerTest, const godot::RID &, const godot::Glyph **, 0, 1>' requested here
        call_with_ptr_argsc_helper<T, P...>(p_instance, p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
        ^
./godot-cpp/gen/include/godot_cpp/classes/text_server_extension.hpp:581:4: note: in instantiation of function template specialization 'godot::call_with_ptr_args<godot::TextServerTest, const godot::RID &, const godot::Glyph **>' requested here
                        BIND_VIRTUAL_METHOD(T, _shaped_text_get_glyphs);
                        ^
./godot-cpp/include/godot_cpp/core/class_db.hpp:132:4: note: expanded from macro 'BIND_VIRTUAL_METHOD'
                        call_with_ptr_args(reinterpret_cast<m_class *>(p_instance), &m_class::m_method, p_args, p_ret);                       \
                        ^
src/ts_test.h:20:2: note: in instantiation of function template specialization 'godot::TextServerExtension::register_virtuals<godot::TextServerTest>' requested here
        GDCLASS(TextServerTest, TextServerExtension);
        ^
./godot-cpp/include/godot_cpp/classes/wrapped.hpp:122:16: note: expanded from macro 'GDCLASS'
                        m_inherits::register_virtuals<m_class>();                                                                                                             \
                                    ^
1 error generated.
scons: *** [src/register_types.os] Error 1

Similar errors happen if methods are defined with void * pointers (as they are defined in the base TextServerExtension generated header).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis has been identified as a bugtopic:gdextensionThis relates to the new Godot 4 extension implementation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions