Browse Source

interrogate: Do not write wrappers taking rvalue reference to interrogatedb

These are not actually exported by the Python binding generator anyway
rdb 3 years ago
parent
commit
6ab6acfbaf

+ 7 - 0
dtool/src/interrogate/interrogateBuilder.cxx

@@ -1074,6 +1074,10 @@ scan_function(CPPInstance *function) {
     return;
   }
 
+  if (TypeManager::involves_rvalue_reference(ftype)) {
+    return;
+  }
+
   get_function(function, "",
                nullptr, scope,
                InterrogateFunction::F_global);
@@ -2986,6 +2990,9 @@ define_method(CPPInstance *function, InterrogateType &itype,
     // If it isn't, we should publish this method anyway.
   }
 
+  if (TypeManager::involves_rvalue_reference(ftype)) {
+    return;
+  }
 
   FunctionIndex index = get_function(function, "", struct_type, scope, 0);
   if (index != 0) {

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

@@ -2015,6 +2015,46 @@ involves_protected(CPPType *type) {
   }
 }
 
+/**
+ * Returns true if the type involves an rvalue reference.
+ */
+bool TypeManager::
+involves_rvalue_reference(CPPType *type) {
+  switch (type->get_subtype()) {
+  case CPPDeclaration::ST_const:
+    return involves_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_pointer:
+    return involves_rvalue_reference(type->as_pointer_type()->_pointing_at);
+
+  case CPPDeclaration::ST_function:
+    {
+      CPPFunctionType *ftype = type->as_function_type();
+      if (involves_rvalue_reference(ftype->_return_type)) {
+        return true;
+      }
+      const CPPParameterList::Parameters &params =
+        ftype->_parameters->_parameters;
+      CPPParameterList::Parameters::const_iterator pi;
+      for (pi = params.begin(); pi != params.end(); ++pi) {
+        if (involves_rvalue_reference((*pi)->_type)) {
+          return true;
+        }
+      }
+      return false;
+    }
+
+  case CPPDeclaration::ST_typedef:
+    return involves_rvalue_reference(type->as_typedef_type()->_type);
+
+  default:
+    return false;
+  }
+}
+
 /**
  * Returns the type this pointer type points to.
  */

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

@@ -118,6 +118,7 @@ public:
   static bool is_handle(CPPType *type);
   static bool involves_unpublished(CPPType *type);
   static bool involves_protected(CPPType *type);
+  static bool involves_rvalue_reference(CPPType *type);
 
   static bool is_ostream(CPPType *type);
   static bool is_pointer_to_ostream(CPPType *type);