From a8cd21ac07ba9f5c67e952524a5c8851be705512 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Wed, 16 Feb 2022 11:35:13 +0200 Subject: [PATCH] Fix "const" NativePtr binds. --- binding_generator.py | 4 +++ include/godot_cpp/core/method_ptrcall.hpp | 42 +++++++++++------------ 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/binding_generator.py b/binding_generator.py index ff59ce74..c389838c 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -789,6 +789,8 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node): if "arguments" in method: for argument in method["arguments"]: type_name = argument["type"] + if type_name.startswith("const "): + type_name = type_name[6:] if type_name.endswith("*"): type_name = type_name[:-1] if is_included(type_name, class_name): @@ -802,6 +804,8 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node): fully_used_classes.add("Ref") if "return_value" in method: type_name = method["return_value"]["type"] + if type_name.startswith("const "): + type_name = type_name[6:] if type_name.endswith("*"): type_name = type_name[:-1] if is_included(type_name, class_name): diff --git a/include/godot_cpp/core/method_ptrcall.hpp b/include/godot_cpp/core/method_ptrcall.hpp index 3e6f060d..5752f7ee 100644 --- a/include/godot_cpp/core/method_ptrcall.hpp +++ b/include/godot_cpp/core/method_ptrcall.hpp @@ -185,27 +185,27 @@ struct PtrToArg { }; // Pointers. -#define GDVIRTUAL_NATIVE_PTR(m_type) \ - template <> \ - struct PtrToArg { \ - _FORCE_INLINE_ static m_type *convert(const void *p_ptr) { \ - return (m_type *)(*(void **)p_ptr); \ - } \ - typedef m_type *EncodeT; \ - _FORCE_INLINE_ static void encode(m_type *p_var, void *p_ptr) { \ - *((void **)p_ptr) = p_var; \ - } \ - }; \ - \ - template <> \ - struct PtrToArg { \ - _FORCE_INLINE_ static const m_type *convert(const void *p_ptr) { \ - return (const m_type *)(*(const void **)p_ptr); \ - } \ - typedef const m_type *EncodeT; \ - _FORCE_INLINE_ static void encode(m_type *p_var, void *p_ptr) { \ - *((void **)p_ptr) = p_var; \ - } \ +#define GDVIRTUAL_NATIVE_PTR(m_type) \ + template <> \ + struct PtrToArg { \ + _FORCE_INLINE_ static m_type *convert(const void *p_ptr) { \ + return (m_type *)(*(void **)p_ptr); \ + } \ + typedef m_type *EncodeT; \ + _FORCE_INLINE_ static void encode(m_type *p_var, void *p_ptr) { \ + *((void **)p_ptr) = p_var; \ + } \ + }; \ + \ + template <> \ + struct PtrToArg { \ + _FORCE_INLINE_ static const m_type *convert(const void *p_ptr) { \ + return (const m_type *)(*(const void **)p_ptr); \ + } \ + typedef const m_type *EncodeT; \ + _FORCE_INLINE_ static void encode(const m_type *p_var, const void *p_ptr) { \ + *((const void **)p_ptr) = p_var; \ + } \ } GDVIRTUAL_NATIVE_PTR(bool);