Skip to content

Commit 1c5a50d

Browse files
author
Ralf W. Grosse-Kunstleve
committed
pickle support implementation details hidden in namespace detail
[SVN r14550]
1 parent 4ef5f77 commit 1c5a50d

1 file changed

Lines changed: 27 additions & 11 deletions

File tree

include/boost/python/object/pickle_support.hpp

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,34 @@ namespace error_messages {
2020

2121
}
2222

23-
class pickle_support_base
23+
namespace detail { struct pickle_support_registration; }
24+
25+
struct pickle_support_base
2426
{
2527
private:
26-
struct dummy_return_type_ {};
27-
28+
struct inaccessible {};
29+
friend struct detail::pickle_support_registration;
2830
public:
31+
static inaccessible* getinitargs() { return 0; }
32+
static inaccessible* getstate() { return 0; }
33+
static inaccessible* setstate() { return 0; }
34+
static bool getstate_manages_dict() { return false; }
35+
};
36+
37+
namespace detail {
38+
39+
struct pickle_support_registration
40+
{
41+
typedef pickle_support_base::inaccessible inaccessible;
42+
2943
template <class Class_, class Tgetinitargs>
3044
static
3145
void
3246
register_(
3347
Class_& cl,
3448
tuple (*getinitargs_fn)(Tgetinitargs),
35-
dummy_return_type_* (*getstate_fn)(),
36-
dummy_return_type_* (*setstate_fn)(),
49+
inaccessible* (*getstate_fn)(),
50+
inaccessible* (*setstate_fn)(),
3751
bool)
3852
{
3953
cl.enable_pickle_support(false);
@@ -45,7 +59,7 @@ class pickle_support_base
4559
void
4660
register_(
4761
Class_& cl,
48-
dummy_return_type_* (*getinitargs_fn)(),
62+
inaccessible* (*getinitargs_fn)(),
4963
tuple (*getstate_fn)(Tgetstate),
5064
void (*setstate_fn)(Tsetstate, object),
5165
bool getstate_manages_dict)
@@ -83,13 +97,15 @@ class pickle_support_base
8397
error_messages::missing_pickle_support_function_or_incorrect_signature<
8498
Class_>::error_type error_type;
8599
}
100+
};
86101

87-
static dummy_return_type_* getinitargs() { return 0; }
88-
static dummy_return_type_* getstate() { return 0; }
89-
static dummy_return_type_* setstate() { return 0; }
102+
template <typename UserPickleSupportType>
103+
struct pickle_support_finalize
104+
: UserPickleSupportType,
105+
pickle_support_registration
106+
{};
90107

91-
static bool getstate_manages_dict() { return false; }
92-
};
108+
} // namespace detail
93109

94110
}} // namespace boost::python
95111

0 commit comments

Comments
 (0)