From 9441c28f61f622dbc7db9bc662914cc7d984e31e Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 30 Jun 2018 17:34:54 +0200 Subject: [PATCH] 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. --- .../interfaceMakerPythonNative.cxx | 4 ++++ dtool/src/interrogate/typeManager.cxx | 20 +++++++++++++++++++ dtool/src/interrogate/typeManager.h | 1 + 3 files changed, 25 insertions(+) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 6f300eed03..c3611fb4df 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/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)) { diff --git a/dtool/src/interrogate/typeManager.cxx b/dtool/src/interrogate/typeManager.cxx index f12541111d..ab1fbffce3 100644 --- a/dtool/src/interrogate/typeManager.cxx +++ b/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. diff --git a/dtool/src/interrogate/typeManager.h b/dtool/src/interrogate/typeManager.h index db831cdafc..f1aa2908b1 100644 --- a/dtool/src/interrogate/typeManager.h +++ b/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);