瀏覽代碼

Fix "const" NativePtr binds.

bruvzg 3 年之前
父節點
當前提交
a8cd21ac07
共有 2 個文件被更改,包括 25 次插入21 次删除
  1. 4 0
      binding_generator.py
  2. 21 21
      include/godot_cpp/core/method_ptrcall.hpp

+ 4 - 0
binding_generator.py

@@ -789,6 +789,8 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
                 if "arguments" in method:
                 if "arguments" in method:
                     for argument in method["arguments"]:
                     for argument in method["arguments"]:
                         type_name = argument["type"]
                         type_name = argument["type"]
+                        if type_name.startswith("const "):
+                            type_name = type_name[6:]
                         if type_name.endswith("*"):
                         if type_name.endswith("*"):
                             type_name = type_name[:-1]
                             type_name = type_name[:-1]
                         if is_included(type_name, class_name):
                         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")
                                 fully_used_classes.add("Ref")
                 if "return_value" in method:
                 if "return_value" in method:
                     type_name = method["return_value"]["type"]
                     type_name = method["return_value"]["type"]
+                    if type_name.startswith("const "):
+                        type_name = type_name[6:]
                     if type_name.endswith("*"):
                     if type_name.endswith("*"):
                         type_name = type_name[:-1]
                         type_name = type_name[:-1]
                     if is_included(type_name, class_name):
                     if is_included(type_name, class_name):

+ 21 - 21
include/godot_cpp/core/method_ptrcall.hpp

@@ -185,27 +185,27 @@ struct PtrToArg<const T *> {
 };
 };
 
 
 // Pointers.
 // Pointers.
-#define GDVIRTUAL_NATIVE_PTR(m_type)                                     \
-	template <>                                                          \
-	struct PtrToArg<m_type *> {                                          \
-		_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<const m_type *> {                                    \
-		_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<m_type *> {                                                     \
+		_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<const m_type *> {                                               \
+		_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);
 GDVIRTUAL_NATIVE_PTR(bool);