Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61033 - in branches/release: boost/python boost/python/detail boost/python/object libs/python libs/python/build libs/python/doc/v2 libs/python/src libs/python/src/object libs/python/test
From: rwgk_at_[hidden]
Date: 2010-04-04 01:19:59


Author: rwgk
Date: 2010-04-04 01:19:57 EDT (Sun, 04 Apr 2010)
New Revision: 61033
URL: http://svn.boost.org/trac/boost/changeset/61033

Log:
merging current boost/python and libs/python from trunk into release branch
Added:
   branches/release/libs/python/test/calling_conventions.cpp
      - copied unchanged from r61007, /trunk/libs/python/test/calling_conventions.cpp
   branches/release/libs/python/test/calling_conventions.py
      - copied unchanged from r61007, /trunk/libs/python/test/calling_conventions.py
   branches/release/libs/python/test/calling_conventions_mf.cpp
      - copied unchanged from r61007, /trunk/libs/python/test/calling_conventions_mf.cpp
   branches/release/libs/python/test/calling_conventions_mf.py
      - copied unchanged from r61007, /trunk/libs/python/test/calling_conventions_mf.py
Properties modified:
   branches/release/boost/python/ (props changed)
   branches/release/libs/python/ (props changed)
Text files modified:
   branches/release/boost/python/detail/destroy.hpp | 2
   branches/release/boost/python/object/make_instance.hpp | 3
   branches/release/boost/python/object/pointer_holder.hpp | 11 +++-
   branches/release/boost/python/object_core.hpp | 11 ++++
   branches/release/boost/python/signature.hpp | 83 ++++++++++++++++++++++++++++++++++++---
   branches/release/libs/python/build/Jamfile.v2 | 20 +++++++++
   branches/release/libs/python/doc/v2/configuration.html | 27 +++++++++++++
   branches/release/libs/python/doc/v2/object.html | 12 +++++
   branches/release/libs/python/src/exec.cpp | 20 +++-----
   branches/release/libs/python/src/object/function.cpp | 6 +-
   branches/release/libs/python/src/object/pickle_support.cpp | 8 +-
   branches/release/libs/python/test/Jamfile.v2 | 3 +
   branches/release/libs/python/test/destroy_test.cpp | 4 +
   13 files changed, 177 insertions(+), 33 deletions(-)

Modified: branches/release/boost/python/detail/destroy.hpp
==============================================================================
--- branches/release/boost/python/detail/destroy.hpp (original)
+++ branches/release/boost/python/detail/destroy.hpp 2010-04-04 01:19:57 EDT (Sun, 04 Apr 2010)
@@ -30,7 +30,7 @@
     template <class T>
     static void execute(T const volatile* p)
     {
- p->T::~T();
+ p->~T();
     }
 };
 

Modified: branches/release/boost/python/object/make_instance.hpp
==============================================================================
--- branches/release/boost/python/object/make_instance.hpp (original)
+++ branches/release/boost/python/object/make_instance.hpp 2010-04-04 01:19:57 EDT (Sun, 04 Apr 2010)
@@ -10,6 +10,7 @@
 # include <boost/python/converter/registered.hpp>
 # include <boost/python/detail/decref_guard.hpp>
 # include <boost/python/detail/none.hpp>
+# include <boost/type_traits/is_union.hpp>
 
 namespace boost { namespace python { namespace objects {
 
@@ -21,7 +22,7 @@
     template <class Arg>
     static inline PyObject* execute(Arg& x)
     {
- BOOST_STATIC_ASSERT(is_class<T>::value);
+ BOOST_MPL_ASSERT((mpl::or_<is_class<T>, is_union<T> >));
 
         PyTypeObject* type = Derived::get_class_object(x);
 

Modified: branches/release/boost/python/object/pointer_holder.hpp
==============================================================================
--- branches/release/boost/python/object/pointer_holder.hpp (original)
+++ branches/release/boost/python/object/pointer_holder.hpp 2010-04-04 01:19:57 EDT (Sun, 04 Apr 2010)
@@ -35,6 +35,8 @@
 
 # include <boost/detail/workaround.hpp>
 
+# include <boost/type_traits/remove_const.hpp>
+
 namespace boost { namespace python {
 
 template <class T> class wrapper;
@@ -122,26 +124,29 @@
 template <class Pointer, class Value>
 void* pointer_holder<Pointer, Value>::holds(type_info dst_t, bool null_ptr_only)
 {
+ typedef typename boost::remove_const< Value >::type non_const_value;
+
     if (dst_t == python::type_id<Pointer>()
         && !(null_ptr_only && get_pointer(this->m_p))
     )
         return &this->m_p;
 
- Value* p
+ Value* p0
 # if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
         = static_cast<Value*>( get_pointer(this->m_p) )
 # else
         = get_pointer(this->m_p)
 # endif
         ;
-
+ non_const_value* p = const_cast<non_const_value*>( p0 );
+
     if (p == 0)
         return 0;
     
     if (void* wrapped = holds_wrapped(dst_t, p, p))
         return wrapped;
     
- type_info src_t = python::type_id<Value>();
+ type_info src_t = python::type_id<non_const_value>();
     return src_t == dst_t ? p : find_dynamic_type(p, src_t, dst_t);
 }
 

Modified: branches/release/boost/python/object_core.hpp
==============================================================================
--- branches/release/boost/python/object_core.hpp (original)
+++ branches/release/boost/python/object_core.hpp 2010-04-04 01:19:57 EDT (Sun, 04 Apr 2010)
@@ -5,6 +5,8 @@
 #ifndef OBJECT_CORE_DWA2002615_HPP
 # define OBJECT_CORE_DWA2002615_HPP
 
+# define BOOST_PYTHON_OBJECT_HAS_IS_NONE // added 2010-03-15 by rwgk
+
 # include <boost/python/detail/prefix.hpp>
 
 # include <boost/type.hpp>
@@ -239,7 +241,9 @@
         
       // Underlying object access -- returns a borrowed reference
       inline PyObject* ptr() const;
-
+
+ inline bool is_none() const;
+
    private:
       PyObject* m_ptr;
   };
@@ -539,6 +543,11 @@
     return m_ptr;
 }
 
+inline bool api::object_base::is_none() const
+{
+ return (m_ptr == Py_None);
+}
+
 //
 // Converter specialization implementations
 //

Modified: branches/release/boost/python/signature.hpp
==============================================================================
--- branches/release/boost/python/signature.hpp (original)
+++ branches/release/boost/python/signature.hpp 2010-04-04 01:19:57 EDT (Sun, 04 Apr 2010)
@@ -52,16 +52,23 @@
 //
 // template <class RT, class T0... class TN>
 // inline mpl::vector<RT, T0...TN>
-// get_signature(RT(*)(T0...TN), void* = 0)
+// get_signature(RT(BOOST_PYTHON_FN_CC *)(T0...TN), void* = 0)
 // {
 // return mpl::list<RT, T0...TN>();
 // }
 //
+// where BOOST_PYTHON_FN_CC is a calling convention keyword, can be
+//
+// empty, for default calling convention
+// __cdecl (if BOOST_PYTHON_ENABLE_CDECL is defined)
+// __stdcall (if BOOST_PYTHON_ENABLE_STDCALL is defined)
+// __fastcall (if BOOST_PYTHON_ENABLE_FASTCALL is defined)
+//
 // And, for an appropriate assortment of cv-qualifications::
 //
 // template <class RT, class ClassT, class T0... class TN>
 // inline mpl::vector<RT, ClassT&, T0...TN>
-// get_signature(RT(ClassT::*)(T0...TN) cv))
+// get_signature(RT(BOOST_PYTHON_FN_CC ClassT::*)(T0...TN) cv))
 // {
 // return mpl::list<RT, ClassT&, T0...TN>();
 // }
@@ -72,7 +79,7 @@
 // , typename most_derived<Target, ClassT>::type&
 // , T0...TN
 // >
-// get_signature(RT(ClassT::*)(T0...TN) cv), Target*)
+// get_signature(RT(BOOST_PYTHON_FN_CC ClassT::*)(T0...TN) cv), Target*)
 // {
 // return mpl::list<RT, ClassT&, T0...TN>();
 // }
@@ -87,7 +94,8 @@
 //
 // These functions extract the return type, class (for member
 // functions) and arguments of the input signature and stuff them in
-// an mpl type sequence. Note that cv-qualification is dropped from
+// an mpl type sequence (the calling convention is dropped).
+// Note that cv-qualification is dropped from
 // the "hidden this" argument of member functions; that is a
 // necessary sacrifice to ensure that an lvalue from_python converter
 // is used. A pointer is not used so that None will be rejected for
@@ -100,10 +108,64 @@
 //
 // @group {
 
+// 'default' calling convention
+
+# define BOOST_PYTHON_FN_CC
+
 # define BOOST_PP_ITERATION_PARAMS_1 \
     (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/signature.hpp>))
 
 # include BOOST_PP_ITERATE()
+
+# undef BOOST_PYTHON_FN_CC
+
+// __cdecl calling convention
+
+# if defined(BOOST_PYTHON_ENABLE_CDECL)
+
+# define BOOST_PYTHON_FN_CC __cdecl
+# define BOOST_PYTHON_FN_CC_IS_CDECL
+
+# define BOOST_PP_ITERATION_PARAMS_1 \
+ (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/signature.hpp>))
+
+# include BOOST_PP_ITERATE()
+
+# undef BOOST_PYTHON_FN_CC
+# undef BOOST_PYTHON_FN_CC_IS_CDECL
+
+# endif // defined(BOOST_PYTHON_ENABLE_CDECL)
+
+// __stdcall calling convention
+
+# if defined(BOOST_PYTHON_ENABLE_STDCALL)
+
+# define BOOST_PYTHON_FN_CC __stdcall
+
+# define BOOST_PP_ITERATION_PARAMS_1 \
+ (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/signature.hpp>))
+
+# include BOOST_PP_ITERATE()
+
+# undef BOOST_PYTHON_FN_CC
+
+# endif // defined(BOOST_PYTHON_ENABLE_STDCALL)
+
+// __fastcall calling convention
+
+# if defined(BOOST_PYTHON_ENABLE_FASTCALL)
+
+# define BOOST_PYTHON_FN_CC __fastcall
+
+# define BOOST_PP_ITERATION_PARAMS_1 \
+ (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/signature.hpp>))
+
+# include BOOST_PP_ITERATE()
+
+# undef BOOST_PYTHON_FN_CC
+
+# endif // defined(BOOST_PYTHON_ENABLE_FASTCALL)
+
 # undef BOOST_PYTHON_LIST_INC
 
 // }
@@ -120,17 +182,24 @@
 
 # define N BOOST_PP_ITERATION()
 
+ // as 'get_signature(RT(*)(T0...TN), void* = 0)' is the same
+ // function as 'get_signature(RT(__cdecl *)(T0...TN), void* = 0)',
+ // we don't define it twice
+# if !defined(BOOST_PYTHON_FN_CC_IS_CDECL)
+
 template <
     class RT BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class T)>
 inline BOOST_PYTHON_LIST_INC(N)<
     RT BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, T)>
-get_signature(RT(*)(BOOST_PP_ENUM_PARAMS_Z(1, N, T)), void* = 0)
+get_signature(RT(BOOST_PYTHON_FN_CC *)(BOOST_PP_ENUM_PARAMS_Z(1, N, T)), void* = 0)
 {
     return BOOST_PYTHON_LIST_INC(N)<
             RT BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, T)
>();
 }
 
+# endif // !defined(BOOST_PYTHON_FN_CC_IS_CDECL)
+
 # undef N
 
 # define BOOST_PP_ITERATION_PARAMS_2 \
@@ -146,7 +215,7 @@
     class RT, class ClassT BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class T)>
 inline BOOST_PYTHON_LIST_INC(BOOST_PP_INC(N))<
     RT, ClassT& BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, T)>
-get_signature(RT(ClassT::*)(BOOST_PP_ENUM_PARAMS_Z(1, N, T)) Q)
+get_signature(RT(BOOST_PYTHON_FN_CC ClassT::*)(BOOST_PP_ENUM_PARAMS_Z(1, N, T)) Q)
 {
     return BOOST_PYTHON_LIST_INC(BOOST_PP_INC(N))<
             RT, ClassT& BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, T)
@@ -165,7 +234,7 @@
     BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, T)
>
 get_signature(
- RT(ClassT::*)(BOOST_PP_ENUM_PARAMS_Z(1, N, T)) Q
+ RT(BOOST_PYTHON_FN_CC ClassT::*)(BOOST_PP_ENUM_PARAMS_Z(1, N, T)) Q
   , Target*
 )
 {

Modified: branches/release/libs/python/build/Jamfile.v2
==============================================================================
--- branches/release/libs/python/build/Jamfile.v2 (original)
+++ branches/release/libs/python/build/Jamfile.v2 2010-04-04 01:19:57 EDT (Sun, 04 Apr 2010)
@@ -3,6 +3,7 @@
 # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 import os ;
+import indirect ;
 import modules ;
 import feature ;
 
@@ -41,8 +42,27 @@
 
 project boost/python
   : source-location ../src
+ : requirements
+ -<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
+ <tag>@$(__name__).tag
   ;
 
+rule tag ( name : type ? : property-set )
+{
+ local result = $(name) ;
+ if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
+ {
+ if $(name) = boost_python && $(PYTHON_ID)
+ {
+ result = $(result)-$(PYTHON_ID) ;
+ }
+ }
+
+ # forward to the boost tagging rule
+ return [ indirect.call $(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
+ $(result) : $(type) : $(property-set) ] ;
+}
+
 rule cond ( test ? : yes * : no * ) { if $(test) { return $(yes) ; } else { return $(no) ; } }
 rule unless ( test ? : yes * : no * ) { if ! $(test) { return $(yes) ; } else { return $(no) ; } }
 

Modified: branches/release/libs/python/doc/v2/configuration.html
==============================================================================
--- branches/release/libs/python/doc/v2/configuration.html (original)
+++ branches/release/libs/python/doc/v2/configuration.html 2010-04-04 01:19:57 EDT (Sun, 04 Apr 2010)
@@ -106,6 +106,33 @@
         function from being treated as an exported symbol on platforms which
         support that distinction in-code</td>
       </tr>
+
+ <tr>
+ <td valign="top"><code>BOOST_PYTHON_ENABLE_CDECL</code></td>
+
+ <td valign="top" align="center"><i>not&nbsp;defined</i></td>
+
+ <td valign="top">If defined, allows functions using the <code>__cdecl
+ </code> calling convention to be wrapped.</td>
+ </tr>
+
+ <tr>
+ <td valign="top"><code>BOOST_PYTHON_ENABLE_STDCALL</code></td>
+
+ <td valign="top" align="center"><i>not&nbsp;defined</i></td>
+
+ <td valign="top">If defined, allows functions using the <code>__stdcall
+ </code> calling convention to be wrapped.</td>
+ </tr>
+
+ <tr>
+ <td valign="top"><code>BOOST_PYTHON_ENABLE_FASTCALL</code></td>
+
+ <td valign="top" align="center"><i>not&nbsp;defined</i></td>
+
+ <td valign="top">If defined, allows functions using the <code>__fastcall
+ </code> calling convention to be wrapped.</td>
+ </tr>
     </table>
 
     <h2><a name="lib-defined-impl"></a>Library Defined Implementation

Modified: branches/release/libs/python/doc/v2/object.html
==============================================================================
--- branches/release/libs/python/doc/v2/object.html (original)
+++ branches/release/libs/python/doc/v2/object.html 2010-04-04 01:19:57 EDT (Sun, 04 Apr 2010)
@@ -835,6 +835,8 @@
       object&amp; operator=(object const&amp;);
 
       PyObject* ptr() const;
+
+ bool is_none() const;
   };
 }}}
 </pre>
@@ -895,6 +897,14 @@
       <dt><b>Returns:</b> a pointer to the internally-held Python
       object.</dt>
     </dl>
+
+<pre>
+bool is_none() const;
+</pre>
+
+ <dl class="function-semantics">
+ <dt><b>Returns:</b> result of (ptr() == Py_None)</dt>
+ </dl>
     <!-- -->
 
     <h3><a name="proxy-spec"></a>Class template <code>proxy</code></h3>
@@ -1101,7 +1111,7 @@
 </pre>
     <p>Revised
     <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
- 27 May, 2008
+ 15 March, 2010
   <!--webbot bot="Timestamp" endspan i-checksum="39359" -->
     </p>
 

Modified: branches/release/libs/python/src/exec.cpp
==============================================================================
--- branches/release/libs/python/src/exec.cpp (original)
+++ branches/release/libs/python/src/exec.cpp 2010-04-04 01:19:57 EDT (Sun, 04 Apr 2010)
@@ -17,15 +17,14 @@
 object BOOST_PYTHON_DECL eval(str string, object global, object local)
 {
   // Set suitable default values for global and local dicts.
- object none;
- if (global.ptr() == none.ptr())
+ if (global.is_none())
   {
     if (PyObject *g = PyEval_GetGlobals())
       global = object(detail::borrowed_reference(g));
     else
       global = dict();
   }
- if (local.ptr() == none.ptr()) local = global;
+ if (local.is_none()) local = global;
   // should be 'char const *' but older python versions don't use 'const' yet.
   char *s = python::extract<char *>(string);
   PyObject* result = PyRun_String(s, Py_eval_input, global.ptr(), local.ptr());
@@ -36,15 +35,14 @@
 object BOOST_PYTHON_DECL exec(str string, object global, object local)
 {
   // Set suitable default values for global and local dicts.
- object none;
- if (global.ptr() == none.ptr())
+ if (global.is_none())
   {
     if (PyObject *g = PyEval_GetGlobals())
       global = object(detail::borrowed_reference(g));
     else
       global = dict();
   }
- if (local.ptr() == none.ptr()) local = global;
+ if (local.is_none()) local = global;
   // should be 'char const *' but older python versions don't use 'const' yet.
   char *s = python::extract<char *>(string);
   PyObject* result = PyRun_String(s, Py_file_input, global.ptr(), local.ptr());
@@ -55,15 +53,14 @@
 object BOOST_PYTHON_DECL exec_statement(str string, object global, object local)
 {
   // Set suitable default values for global and local dicts.
- object none;
- if (global.ptr() == none.ptr())
+ if (global.is_none())
   {
     if (PyObject *g = PyEval_GetGlobals())
       global = object(detail::borrowed_reference(g));
     else
       global = dict();
   }
- if (local.ptr() == none.ptr()) local = global;
+ if (local.is_none()) local = global;
   // should be 'char const *' but older python versions don't use 'const' yet.
   char *s = python::extract<char *>(string);
   PyObject* result = PyRun_String(s, Py_single_input, global.ptr(), local.ptr());
@@ -77,15 +74,14 @@
 object BOOST_PYTHON_DECL exec_file(str filename, object global, object local)
 {
   // Set suitable default values for global and local dicts.
- object none;
- if (global.ptr() == none.ptr())
+ if (global.is_none())
   {
     if (PyObject *g = PyEval_GetGlobals())
       global = object(detail::borrowed_reference(g));
     else
       global = dict();
   }
- if (local.ptr() == none.ptr()) local = global;
+ if (local.is_none()) local = global;
   // should be 'char const *' but older python versions don't use 'const' yet.
   char *f = python::extract<char *>(filename);
 #if PY_VERSION_HEX >= 0x03000000

Modified: branches/release/libs/python/src/object/function.cpp
==============================================================================
--- branches/release/libs/python/src/object/function.cpp (original)
+++ branches/release/libs/python/src/object/function.cpp 2010-04-04 01:19:57 EDT (Sun, 04 Apr 2010)
@@ -144,7 +144,7 @@
             if (n_keyword_actual > 0 // Keyword arguments were supplied
                  || n_actual < min_arity) // or default keyword values are needed
             {
- if (f->m_arg_names.ptr() == Py_None)
+ if (f->m_arg_names.is_none())
                 {
                     // this overload doesn't accept keywords
                     inner_args = handle<>();
@@ -487,7 +487,7 @@
         }
 
         // A function is named the first time it is added to a namespace.
- if (new_func->name().ptr() == Py_None)
+ if (new_func->name().is_none())
             new_func->m_name = name;
 
         handle<> name_space_name(
@@ -653,7 +653,7 @@
     static PyObject* function_get_name(PyObject* op, void*)
     {
         function* f = downcast<function>(op);
- if (f->name().ptr() == Py_None)
+ if (f->name().is_none())
 #if PY_VERSION_HEX >= 0x03000000
             return PyUnicode_InternFromString("<unnamed Boost.Python function>");
 #else

Modified: branches/release/libs/python/src/object/pickle_support.cpp
==============================================================================
--- branches/release/libs/python/src/object/pickle_support.cpp (original)
+++ branches/release/libs/python/src/object/pickle_support.cpp 2010-04-04 01:19:57 EDT (Sun, 04 Apr 2010)
@@ -38,21 +38,21 @@
       }
       object getinitargs = getattr(instance_obj, "__getinitargs__", none);
       tuple initargs;
- if (getinitargs.ptr() != none.ptr()) {
+ if (!getinitargs.is_none()) {
           initargs = tuple(getinitargs());
       }
       result.append(initargs);
       object getstate = getattr(instance_obj, "__getstate__", none);
       object instance_dict = getattr(instance_obj, "__dict__", none);
       long len_instance_dict = 0;
- if (instance_dict.ptr() != none.ptr()) {
+ if (!instance_dict.is_none()) {
           len_instance_dict = len(instance_dict);
       }
- if (getstate.ptr() != none.ptr()) {
+ if (!getstate.is_none()) {
           if (len_instance_dict > 0) {
               object getstate_manages_dict = getattr(
                 instance_obj, "__getstate_manages_dict__", none);
- if (getstate_manages_dict.ptr() == none.ptr()) {
+ if (getstate_manages_dict.is_none()) {
                   PyErr_SetString(PyExc_RuntimeError,
                     "Incomplete pickle support"
                     " (__getstate_manages_dict__ not set)");

Modified: branches/release/libs/python/test/Jamfile.v2
==============================================================================
--- branches/release/libs/python/test/Jamfile.v2 (original)
+++ branches/release/libs/python/test/Jamfile.v2 2010-04-04 01:19:57 EDT (Sun, 04 Apr 2010)
@@ -184,6 +184,9 @@
 # bpl-test bienstman5 ;
 # }
 
+[ bpl-test calling_conventions ]
+[ bpl-test calling_conventions_mf ]
+
 # --- unit tests of library components ---
 
 [ compile indirect_traits_test.cpp ]

Modified: branches/release/libs/python/test/destroy_test.cpp
==============================================================================
--- branches/release/libs/python/test/destroy_test.cpp (original)
+++ branches/release/libs/python/test/destroy_test.cpp 2010-04-04 01:19:57 EDT (Sun, 04 Apr 2010)
@@ -22,6 +22,10 @@
         *kills++ = n;
     }
     int n;
+
+ // This used to cause compiler errors with MSVC 9.0.
+ foo& operator~();
+ foo& T();
 };
 
 void assert_destructions(int n)


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk