[C++-sig] additional files for pickle support

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Sun Jul 21 12:13:02 CEST 2002


--- "Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com> wrote:
> The new files have been tested with gcc 3.0.4, cxx 6.5 (tru64) and VC6. I am
> about to experiment with an idea for hiding the entire implementation except
> for the one new member function of class_<> (.pickle_support(); not currently
> in cvs). Having the current, functional implementation in cvs will allow me
> to
> work most efficiently (I can easily back up or look at diffs if necessary).

OK, done experimenting. David, now would be a good time to criticize the new
files. Three additional patches are attached for your reference. The only other
changes are trivial additions to the Jamfiles.

Locally I am currently working with
#include <boost/python/detail/api_placeholder.hpp>
This file implements len() and getattr(). I don't think you want this in cvs.
So before I can check in the patches that complete the integration of the
pickle support there need to be replacements for my len() and getattr().

Ralf

P.S.: I noticed that class_::setattr() still deals with handle<> .
Is this going to change?


Index: class.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/python/class.hpp,v
retrieving revision 1.27
diff -r1.27 class.hpp
27a28
> # include <boost/python/object/pickle_support.hpp>
196a198,210
> 
>     // Pickle support
>     template <typename PickleSupport>
>     self& pickle_support(PickleSupport)
>     {
>       detail::pickle_support_finalize<PickleSupport>::register_(
>         *this,
>         &PickleSupport::getinitargs,
>         &PickleSupport::getstate,
>         &PickleSupport::setstate,
>         PickleSupport::getstate_manages_dict());
>       return *this;
>     }


Index: object/class.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/python/object/class.hpp,v
retrieving revision 1.22
diff -r1.22 class.hpp
41a42
>     void enable_pickle_support(bool getstate_manages_dict);


Index: src/object/class.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/python/src/object/class.cpp,v
retrieving revision 1.31
diff -r1.31 class.cpp
8a9
> #include <boost/python/object/pickle_support.hpp>
304a306,315
>   }
> 
>   void class_base::enable_pickle_support(bool getstate_manages_dict)
>   {
>       setattr("__reduce__", make_instance_reduce_function());
>       handle<> one(PyInt_FromLong(1));
>       setattr("__safe_for_unpickling__", one);
>       if (getstate_manages_dict) {
>         setattr("__getstate_manages_dict__", one);
>       }


__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com





More information about the Cplusplus-sig mailing list