Skip to content

Commit f9a67b3

Browse files
committed
Roll back most of Dave Hawkes' changes for the time being.
[SVN r14501]
1 parent 6ac5735 commit f9a67b3

File tree

8 files changed

+19
-341
lines changed

8 files changed

+19
-341
lines changed

include/boost/python/class.hpp

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# include <boost/python/type_id.hpp>
1515
# include <boost/python/detail/wrap_function.hpp>
1616
# include <boost/python/detail/member_function_cast.hpp>
17-
# include <boost/python/detail/module_base.hpp>
1817
# include <boost/python/object/class_converters.hpp>
1918
# include <boost/type_traits/ice.hpp>
2019
# include <boost/type_traits/same_traits.hpp>
@@ -87,12 +86,12 @@ class class_ : public objects::class_base
8786
public:
8887
// Automatically derive the class name - only works on some
8988
// compilers because type_info::name is sometimes mangled (gcc)
90-
class_(base const& parent_class = empty_class_base());
89+
class_();
9190

9291
// Construct with the class name. [ Would have used a default
9392
// argument but gcc-2.95.2 choked on typeid(T).name() as a default
9493
// parameter value]
95-
class_(char const* name, base const& parent_class = empty_class_base());
94+
class_(char const* name);
9695

9796

9897
// Wrap a member function or a non-member function which can take
@@ -196,22 +195,6 @@ class class_ : public objects::class_base
196195

197196
self& setattr(char const* name, handle<> const&);
198197

199-
// add to module
200-
self& add(module &m)
201-
{
202-
// redundant
203-
// m.add(*this);
204-
return *this;
205-
}
206-
207-
// add to current module
208-
self& add()
209-
{
210-
// redundant
211-
// boost::python::add(*this);
212-
return *this;
213-
}
214-
215198
private: // types
216199
typedef objects::class_id class_id;
217200

@@ -248,7 +231,7 @@ class class_ : public objects::class_base
248231
// implementations
249232
//
250233
template <class T, class X1, class X2, class X3>
251-
inline class_<T,X1,X2,X3>::class_(base const& parent_class)
234+
inline class_<T,X1,X2,X3>::class_()
252235
: base(typeid(T).name(), id_vector::size, id_vector().ids)
253236
{
254237
// register converters
@@ -258,16 +241,10 @@ inline class_<T,X1,X2,X3>::class_(base const& parent_class)
258241
mpl::bool_t<is_copyable>()
259242
, objects::select_holder<T,held_type>((held_type*)0).get()
260243
, this->object());
261-
262-
// get the context to add the class to
263-
handle<> parent(parent_class.object() ? handle<>(parent_class.object()) :
264-
base::get_class_context_object(typeid(T).name(), object()));
265-
// add the class to the current module
266-
boost::python::detail::module_base::add(object(), parent);
267244
}
268245

269246
template <class T, class X1, class X2, class X3>
270-
inline class_<T,X1,X2,X3>::class_(char const* name, base const& parent_class)
247+
inline class_<T,X1,X2,X3>::class_(char const* name)
271248
: base(name, id_vector::size, id_vector().ids)
272249
{
273250
// register converters
@@ -277,14 +254,9 @@ inline class_<T,X1,X2,X3>::class_(char const* name, base const& parent_class)
277254
mpl::bool_t<is_copyable>()
278255
, objects::select_holder<T,held_type>((held_type*)0).get()
279256
, this->object());
280-
281-
// get the context to add the class to
282-
handle<> parent(parent_class.object() ? handle<>(parent_class.object()) :
283-
base::get_class_context_object(name, object()));
284-
// add the class to the current module
285-
boost::python::detail::module_base::add(object(), parent);
286257
}
287258

259+
288260
template <class T, class X1, class X2, class X3>
289261
inline class_<T,X1,X2,X3>& class_<T,X1,X2,X3>::add_property(char const* name, handle<> const& fget)
290262
{

include/boost/python/detail/module_base.hpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
namespace boost { namespace python { namespace detail {
1212

13-
class module_info;
14-
1513
class BOOST_PYTHON_DECL module_base
1614
{
1715
public:
@@ -23,22 +21,14 @@ class BOOST_PYTHON_DECL module_base
2321
void setattr(const char* name, PyObject*);
2422
void setattr(const char* name, handle<> const&);
2523
void add(type_handle const&); // just use the type's name
26-
static module_info* get_module_info();
27-
static void set_module_info(module_info& mi);
28-
static handle<> get_prior_module();
29-
static void set_prior_module(handle<> const& m);
30-
static void add(type_handle const& class_obj, handle<> const& context);
3124

3225
// Return a reference to the Python module object being built
3326
inline handle<> object() const;
3427

3528
protected:
36-
module_base(handle<> const &m) : m_module(m) {}
3729
void add_class(type_handle const& class_obj);
38-
void add_class(type_handle const& class_obj, handle<> const& context);
3930

4031
private:
41-
static module_info*& get_module_info_ref();
4232
handle<> m_module;
4333
static PyMethodDef initial_methods[1];
4434
};
@@ -51,12 +41,6 @@ inline handle<> module_base::object() const
5141
return m_module;
5242
}
5343

54-
inline void module_base::add(type_handle const& class_obj, handle<> const& context)
55-
{
56-
module_base mb(get_prior_module());
57-
mb.add_class(class_obj, context);
58-
}
59-
6044
}}} // namespace boost::python::detail
6145

6246
#endif // MODULE_BASE_DWA2002227_HPP

include/boost/python/detail/module_init.hpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,50 +8,38 @@
88

99
# ifndef BOOST_PYTHON_MODULE_INIT
1010

11-
# define PRE_INIT_FUNC(name) \
12-
void init_module_base_##name() \
13-
{ \
14-
boost::python::detail::module_info mi(#name); \
15-
boost::python::detail::module_base::set_module_info(mi); \
16-
boost::python::module(); \
17-
init_module_##name(); \
18-
}
19-
2011
# if defined(_WIN32) || defined(__CYGWIN__)
2112

2213
# define BOOST_PYTHON_MODULE_INIT(name) \
2314
void init_module_##name(); \
24-
PRE_INIT_FUNC(name) \
2515
extern "C" __declspec(dllexport) void init##name() \
2616
{ \
27-
boost::python::handle_exception(&init_module_base_##name); \
17+
boost::python::handle_exception(&init_module_##name); \
2818
} \
2919
void init_module_##name()
3020

3121
# elif defined(_AIX)
3222

3323
# include <boost/python/detail/aix_init_module.hpp>
3424
# define BOOST_PYTHON_MODULE_INIT(name) \
35-
PRE_INIT_FUNC(name) \
3625
void init_module_##name(); \
3726
extern "C" \
3827
{ \
3928
extern PyObject* _PyImport_LoadDynamicModule(char*, char*, FILE *); \
4029
void init##name() \
4130
{ \
42-
boost::python::detail::aix_init_module(_PyImport_LoadDynamicModule, &init_module_base_##name); \
31+
boost::python::detail::aix_init_module(_PyImport_LoadDynamicModule, &init_module_##name); \
4332
} \
4433
} \
4534
void init_module_##name()
4635

4736
# else
4837

4938
# define BOOST_PYTHON_MODULE_INIT(name) \
50-
PRE_INIT_FUNC(name) \
5139
void init_module_##name(); \
5240
extern "C" void init##name() \
5341
{ \
54-
boost::python::handle_exception(&init_module_base_##name); \
42+
boost::python::handle_exception(&init_module_##name); \
5543
} \
5644
void init_module_##name()
5745

include/boost/python/module.hpp

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# include <boost/python/class_fwd.hpp>
1414
# include <boost/python/detail/module_base.hpp>
1515
# include <boost/python/detail/module_init.hpp>
16-
# include <boost/python/detail/module_info.hpp>
1716

1817
namespace boost { namespace python {
1918

@@ -22,7 +21,7 @@ class module : public detail::module_base
2221
public:
2322
typedef detail::module_base base;
2423

25-
module(const char* name = "")
24+
module(const char* name)
2625
: base(name) {}
2726

2827
// Add elements to the module
@@ -34,8 +33,7 @@ class module : public detail::module_base
3433
template <class T1, class T2 , class T3, class T4>
3534
module& add(class_<T1,T2,T3,T4> const& c)
3635
{
37-
// redundant
38-
// this->add_class(c.object());
36+
this->add_class(c.object());
3937
return *this;
4038
}
4139

@@ -53,14 +51,6 @@ class module : public detail::module_base
5351
this->setattr(name, boost::python::make_function(fn, handler));
5452
return *this;
5553
}
56-
57-
static module get_prior_module()
58-
{
59-
return module(module_base::get_prior_module());
60-
}
61-
62-
private:
63-
module(handle<> const& m) : base(m) {}
6454
};
6555

6656
//
@@ -90,19 +80,6 @@ inline module& module::add(PyTypeObject* x)
9080
return *this;
9181
}
9282

93-
template <class Fn>
94-
inline void def(char const* name, Fn fn)
95-
{
96-
module::get_prior_module().def(name, fn);
97-
}
98-
99-
100-
template <class Fn, class ResultHandler>
101-
inline void def(char const* name, Fn fn, ResultHandler handler)
102-
{
103-
module::get_prior_module().def(name, fn, handler);
104-
}
105-
10683
}} // namespace boost::python
10784

10885
#endif // MODULE_DWA20011221_HPP

include/boost/python/object/class.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,7 @@ struct BOOST_PYTHON_DECL class_base : private noncopyable
3939
void add_property(char const* name, handle<> const& fget);
4040
void add_property(char const* name, handle<> const& fget, handle<> const& fset);
4141
void setattr(char const* name, handle<> const&);
42-
static handle<> get_class_context_object(const char* name, type_handle const& class_obj);
43-
protected:
44-
static class_base const& empty_class_base();
4542
private:
46-
// construct an empty base class
47-
class_base();
4843
type_handle m_object;
4944
};
5045

0 commit comments

Comments
 (0)