瀏覽代碼

interrogate: do not wrap methods with rvalue arguments

This could in theory be supported, but this is not really intuitive from a Python user's point of view.
rdb 7 年之前
父節點
當前提交
9441c28f61

+ 4 - 0
dtool/src/interrogate/interfaceMakerPythonNative.cxx

@@ -7298,6 +7298,10 @@ is_cpp_type_legal(CPPType *in_ctype) {
 
   // bool answer = false;
   CPPType *type = TypeManager::resolve_type(in_ctype);
+  if (TypeManager::is_rvalue_reference(type)) {
+    return false;
+  }
+
   type = TypeManager::unwrap(type);
 
   if (TypeManager::is_void(type)) {

+ 20 - 0
dtool/src/interrogate/typeManager.cxx

@@ -124,6 +124,26 @@ is_reference(CPPType *type) {
   }
 }
 
+/**
+ * Returns true if the indicated type is some kind of an rvalue reference.
+ */
+bool TypeManager::
+is_rvalue_reference(CPPType *type) {
+  switch (type->get_subtype()) {
+  case CPPDeclaration::ST_const:
+    return is_rvalue_reference(type->as_const_type()->_wrapped_around);
+
+  case CPPDeclaration::ST_reference:
+    return type->as_reference_type()->_value_category == CPPReferenceType::VC_rvalue;
+
+  case CPPDeclaration::ST_typedef:
+    return is_rvalue_reference(type->as_typedef_type()->_type);
+
+  default:
+    return false;
+  }
+}
+
 /**
  * Returns true if the indicated type is some kind of a reference or const
  * reference type at all, false otherwise.

+ 1 - 0
dtool/src/interrogate/typeManager.h

@@ -44,6 +44,7 @@ public:
   static bool is_assignable(CPPType *type);
 
   static bool is_reference(CPPType *type);
+  static bool is_rvalue_reference(CPPType *type);
   static bool is_ref_to_anything(CPPType *type);
   static bool is_const_ref_to_anything(CPPType *type);
   static bool is_const_pointer_to_anything(CPPType *type);