From aed148838f42d7856f6a6fc15f033382b23b1580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ullrich=20K=C3=B6the?= Date: Fri, 10 Nov 2000 13:37:53 +0000 Subject: [PATCH] added to from_python() functions to gen_extclass.py (these were formerly only present on extclass.h and thus overwritten) [SVN r8164] --- extclass.h | 10 +++++++++- gen_extclass.py | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/extclass.h b/extclass.h index 66e8bbe0..f338f29d 100644 --- a/extclass.h +++ b/extclass.h @@ -82,7 +82,7 @@ class ExtensionClassBase : public Class void* try_base_class_conversions(InstanceHolderBase*) const; void* try_derived_class_conversions(InstanceHolderBase*) const; - void set_attribute(const char* name, PyObject* x_); + void set_attribute(const char* name, PyObject* x); void set_attribute(const char* name, Ptr x); private: @@ -234,6 +234,14 @@ class PyExtensionClassConverters friend const T* from_python(PyObject* p, py::Type) { return from_python(p, py::Type()); } + // Convert to const T* const& + friend const T* from_python(PyObject* p, py::Type) + { return from_python(p, py::Type()); } + + // Convert to T* const& + friend T* from_python(PyObject* p, py::Type) + { return from_python(p, py::Type()); } + // Convert to T& friend T& from_python(PyObject* p, py::Type) { return *py::check_non_null(from_python(p, py::Type())); } diff --git a/gen_extclass.py b/gen_extclass.py index 3569dc68..64363ce9 100644 --- a/gen_extclass.py +++ b/gen_extclass.py @@ -87,7 +87,7 @@ class ExtensionClassBase : public Class void* try_base_class_conversions(InstanceHolderBase*) const; void* try_derived_class_conversions(InstanceHolderBase*) const; - void set_attribute(const char* name, PyObject* x_); + void set_attribute(const char* name, PyObject* x); void set_attribute(const char* name, Ptr x); private: @@ -239,6 +239,14 @@ class PyExtensionClassConverters friend const T* from_python(PyObject* p, py::Type) { return from_python(p, py::Type()); } + // Convert to const T* const& + friend const T* from_python(PyObject* p, py::Type) + { return from_python(p, py::Type()); } + + // Convert to T* const& + friend T* from_python(PyObject* p, py::Type) + { return from_python(p, py::Type()); } + // Convert to T& friend T& from_python(PyObject* p, py::Type) { return *py::check_non_null(from_python(p, py::Type())); }