From 8763fd1c53e4d0dd7e10dee2724b9ac96636f05a Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 25 Jul 2002 14:52:11 +0000 Subject: [PATCH] scope default constructor gets current scope; killed scope::get() [SVN r14599] --- include/boost/python/scope.hpp | 15 +++++++++------ src/module.cpp | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/boost/python/scope.hpp b/include/boost/python/scope.hpp index edcfe02a..298f1eaa 100644 --- a/include/boost/python/scope.hpp +++ b/include/boost/python/scope.hpp @@ -16,8 +16,8 @@ class BOOST_PYTHON_DECL scope : public object, noncopyable { public: inline scope(object const&); + inline scope(); inline ~scope(); - static inline object get(); private: // data members PyObject* m_previous_scope; @@ -35,17 +35,20 @@ inline scope::scope(object const& new_scope) current_scope = python::incref(new_scope.ptr()); } +inline scope::scope() + : object(detail::borrowed_reference( + current_scope + )) + , m_previous_scope(python::incref(current_scope)) +{ +} + inline scope::~scope() { python::decref(current_scope); current_scope = m_previous_scope; } -inline object scope::get() -{ - return object(detail::borrowed_reference(current_scope)); -} - namespace converter { template <> diff --git a/src/module.cpp b/src/module.cpp index 4a30f6f0..b07cfe35 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -19,7 +19,7 @@ namespace boost { namespace python { namespace detail { module_base::module_base(const char* name) : m_module( allow_null(python::borrowed( - scope::get().ptr() + scope().ptr() ))) { } @@ -94,6 +94,6 @@ BOOST_PYTHON_DECL void init_module(char const* name, void(*init_function)()) namespace boost { namespace python { -BOOST_PYTHON_DECL PyObject* scope::current_scope; +BOOST_PYTHON_DECL PyObject* scope::current_scope = Py_None; }}