/
usr
/
include
/
boost
/
python
/
/usr/include/boost/python
mkdir
upload
Name
Size
Mode
Actions
converter/
-
0755
rm
detail/
-
0755
rm
numpy/
-
0755
rm
object/
-
0755
rm
suite/
-
0755
rm
args.hpp
4194
0644
edit
dl
rm
args_fwd.hpp
1186
0644
edit
dl
rm
arg_from_python.hpp
2000
0644
edit
dl
rm
back_reference.hpp
1463
0644
edit
dl
rm
bases.hpp
1481
0644
edit
dl
rm
base_type_traits.hpp
878
0644
edit
dl
rm
borrowed.hpp
568
0644
edit
dl
rm
call.hpp
2749
0644
edit
dl
rm
call_method.hpp
2859
0644
edit
dl
rm
cast.hpp
2954
0644
edit
dl
rm
class.hpp
17866
0644
edit
dl
rm
class_fwd.hpp
772
0644
edit
dl
rm
copy_const_reference.hpp
1101
0644
edit
dl
rm
copy_non_const_reference.hpp
1141
0644
edit
dl
rm
data_members.hpp
9593
0644
edit
dl
rm
def.hpp
3187
0644
edit
dl
rm
default_call_policies.hpp
2279
0644
edit
dl
rm
def_visitor.hpp
2483
0644
edit
dl
rm
dict.hpp
3866
0644
edit
dl
rm
docstring_options.hpp
3505
0644
edit
dl
rm
enum.hpp
2999
0644
edit
dl
rm
errors.hpp
1397
0644
edit
dl
rm
exception_translator.hpp
939
0644
edit
dl
rm
exec.hpp
1756
0644
edit
dl
rm
extract.hpp
5988
0644
edit
dl
rm
handle.hpp
4503
0644
edit
dl
rm
handle_fwd.hpp
455
0644
edit
dl
rm
has_back_reference.hpp
654
0644
edit
dl
rm
implicit.hpp
1111
0644
edit
dl
rm
import.hpp
476
0644
edit
dl
rm
init.hpp
11490
0644
edit
dl
rm
instance_holder.hpp
2063
0644
edit
dl
rm
iterator.hpp
4308
0644
edit
dl
rm
list.hpp
3611
0644
edit
dl
rm
long.hpp
1637
0644
edit
dl
rm
lvalue_from_pytype.hpp
3614
0644
edit
dl
rm
make_constructor.hpp
8579
0644
edit
dl
rm
make_function.hpp
4482
0644
edit
dl
rm
manage_new_object.hpp
1087
0644
edit
dl
rm
module.hpp
425
0644
edit
dl
rm
module_init.hpp
2173
0644
edit
dl
rm
numpy.hpp
1120
0644
edit
dl
rm
object.hpp
851
0644
edit
dl
rm
object_attributes.hpp
3019
0644
edit
dl
rm
object_call.hpp
810
0644
edit
dl
rm
object_core.hpp
13329
0644
edit
dl
rm
object_fwd.hpp
462
0644
edit
dl
rm
object_items.hpp
1974
0644
edit
dl
rm
object_operators.hpp
4494
0644
edit
dl
rm
object_protocol.hpp
2730
0644
edit
dl
rm
object_protocol_core.hpp
2080
0644
edit
dl
rm
object_slices.hpp
4090
0644
edit
dl
rm
opaque_pointer_converter.hpp
5929
0644
edit
dl
rm
operators.hpp
14278
0644
edit
dl
rm
other.hpp
901
0644
edit
dl
rm
overloads.hpp
437
0644
edit
dl
rm
override.hpp
3538
0644
edit
dl
rm
pointee.hpp
892
0644
edit
dl
rm
proxy.hpp
2653
0644
edit
dl
rm
ptr.hpp
1239
0644
edit
dl
rm
pure_virtual.hpp
3655
0644
edit
dl
rm
raw_function.hpp
1483
0644
edit
dl
rm
refcount.hpp
960
0644
edit
dl
rm
reference_existing_object.hpp
1310
0644
edit
dl
rm
register_ptr_to_python.hpp
769
0644
edit
dl
rm
return_arg.hpp
2799
0644
edit
dl
rm
return_by_value.hpp
724
0644
edit
dl
rm
return_internal_reference.hpp
1285
0644
edit
dl
rm
return_opaque_pointer.hpp
1290
0644
edit
dl
rm
return_value_policy.hpp
675
0644
edit
dl
rm
scope.hpp
1878
0644
edit
dl
rm
self.hpp
889
0644
edit
dl
rm
signature.hpp
7579
0644
edit
dl
rm
slice.hpp
10643
0644
edit
dl
rm
slice_nil.hpp
912
0644
edit
dl
rm
ssize_t.hpp
735
0644
edit
dl
rm
stl_iterator.hpp
1325
0644
edit
dl
rm
str.hpp
10765
0644
edit
dl
rm
tag.hpp
538
0644
edit
dl
rm
to_python_converter.hpp
2431
0644
edit
dl
rm
to_python_indirect.hpp
2973
0644
edit
dl
rm
to_python_value.hpp
5574
0644
edit
dl
rm
tuple.hpp
1758
0644
edit
dl
rm
type_id.hpp
5262
0644
edit
dl
rm
with_custodian_and_ward.hpp
3546
0644
edit
dl
rm
wrapper.hpp
1023
0644
edit
dl
rm
Edit:
/usr/include/boost/python/make_constructor.hpp
(8579B)
// Copyright David Abrahams 2001. // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef MAKE_CONSTRUCTOR_DWA20011221_HPP # define MAKE_CONSTRUCTOR_DWA20011221_HPP # include <boost/python/detail/prefix.hpp> # include <boost/python/default_call_policies.hpp> # include <boost/python/args.hpp> # include <boost/python/object_fwd.hpp> # include <boost/python/object/function_object.hpp> # include <boost/python/object/make_holder.hpp> # include <boost/python/object/pointer_holder.hpp> # include <boost/python/converter/context_result_converter.hpp> # include <boost/python/detail/caller.hpp> # include <boost/python/detail/none.hpp> # include <boost/mpl/size.hpp> # include <boost/mpl/int.hpp> # include <boost/mpl/push_front.hpp> # include <boost/mpl/pop_front.hpp> # include <boost/mpl/assert.hpp> namespace boost { namespace python { namespace detail { template <class T> struct install_holder : converter::context_result_converter { install_holder(PyObject* args_) : m_self(PyTuple_GetItem(args_, 0)) {} PyObject* operator()(T x) const { dispatch(x, is_pointer<T>()); return none(); } private: template <class U> void dispatch(U* x, detail::true_) const { #if defined(BOOST_NO_CXX11_SMART_PTR) std::auto_ptr<U> owner(x); dispatch(owner, detail::false_()); #else std::unique_ptr<U> owner(x); dispatch(std::move(owner), detail::false_()); #endif } template <class Ptr> void dispatch(Ptr x, detail::false_) const { typedef typename pointee<Ptr>::type value_type; typedef objects::pointer_holder<Ptr,value_type> holder; typedef objects::instance<holder> instance_t; void* memory = holder::allocate(this->m_self, offsetof(instance_t, storage), sizeof(holder)); try { #if defined(BOOST_NO_CXX11_SMART_PTR) (new (memory) holder(x))->install(this->m_self); #else (new (memory) holder(std::move(x)))->install(this->m_self); #endif } catch(...) { holder::deallocate(this->m_self, memory); throw; } } PyObject* m_self; }; struct constructor_result_converter { template <class T> struct apply { typedef install_holder<T> type; }; }; template <class BaseArgs, class Offset> struct offset_args { offset_args(BaseArgs base_) : base(base_) {} BaseArgs base; }; template <int N, class BaseArgs, class Offset> inline PyObject* get(mpl::int_<N>, offset_args<BaseArgs,Offset> const& args_) { return get(mpl::int_<(N+Offset::value)>(), args_.base); } template <class BaseArgs, class Offset> inline unsigned arity(offset_args<BaseArgs,Offset> const& args_) { return arity(args_.base) - Offset::value; } template <class BasePolicy_ = default_call_policies> struct constructor_policy : BasePolicy_ { constructor_policy(BasePolicy_ base) : BasePolicy_(base) {} // If the BasePolicy_ supplied a result converter it would be // ignored; issue an error if it's not the default. BOOST_MPL_ASSERT_MSG( (is_same< typename BasePolicy_::result_converter , default_result_converter >::value) , MAKE_CONSTRUCTOR_SUPPLIES_ITS_OWN_RESULT_CONVERTER_THAT_WOULD_OVERRIDE_YOURS , (typename BasePolicy_::result_converter) ); typedef constructor_result_converter result_converter; typedef offset_args<typename BasePolicy_::argument_package, mpl::int_<1> > argument_package; }; template <class InnerSignature> struct outer_constructor_signature { typedef typename mpl::pop_front<InnerSignature>::type inner_args; typedef typename mpl::push_front<inner_args,object>::type outer_args; typedef typename mpl::push_front<outer_args,void>::type type; }; // ETI workaround template <> struct outer_constructor_signature<int> { typedef int type; }; // // These helper functions for make_constructor (below) do the raw work // of constructing a Python object from some invokable entity. See // <boost/python/detail/caller.hpp> for more information about how // the Sig arguments is used. // // @group make_constructor_aux { template <class F, class CallPolicies, class Sig> object make_constructor_aux( F f // An object that can be invoked by detail::invoke() , CallPolicies const& p // CallPolicies to use in the invocation , Sig const& // An MPL sequence of argument types expected by F ) { typedef typename outer_constructor_signature<Sig>::type outer_signature; typedef constructor_policy<CallPolicies> inner_policy; return objects::function_object( objects::py_function( detail::caller<F,inner_policy,Sig>(f, inner_policy(p)) , outer_signature() ) ); } // As above, except that it accepts argument keywords. NumKeywords // is used only for a compile-time assertion to make sure the user // doesn't pass more keywords than the function can accept. To // disable all checking, pass mpl::int_<0> for NumKeywords. template <class F, class CallPolicies, class Sig, class NumKeywords> object make_constructor_aux( F f , CallPolicies const& p , Sig const& , detail::keyword_range const& kw // a [begin,end) pair of iterators over keyword names , NumKeywords // An MPL integral type wrapper: the size of kw ) { enum { arity = mpl::size<Sig>::value - 1 }; typedef typename detail::error::more_keywords_than_function_arguments< NumKeywords::value, arity >::too_many_keywords assertion BOOST_ATTRIBUTE_UNUSED; typedef typename outer_constructor_signature<Sig>::type outer_signature; typedef constructor_policy<CallPolicies> inner_policy; return objects::function_object( objects::py_function( detail::caller<F,inner_policy,Sig>(f, inner_policy(p)) , outer_signature() ) , kw ); } // } // // These dispatch functions are used to discriminate between the // cases when the 3rd argument is keywords or when it is a // signature. // // @group Helpers for make_constructor when called with 3 arguments. { // template <class F, class CallPolicies, class Keywords> object make_constructor_dispatch(F f, CallPolicies const& policies, Keywords const& kw, mpl::true_) { return detail::make_constructor_aux( f , policies , detail::get_signature(f) , kw.range() , mpl::int_<Keywords::size>() ); } template <class F, class CallPolicies, class Signature> object make_constructor_dispatch(F f, CallPolicies const& policies, Signature const& sig, mpl::false_) { return detail::make_constructor_aux( f , policies , sig ); } // } } // These overloaded functions wrap a function or member function // pointer as a Python object, using optional CallPolicies, // Keywords, and/or Signature. @group { // template <class F> object make_constructor(F f) { return detail::make_constructor_aux( f,default_call_policies(), detail::get_signature(f)); } template <class F, class CallPolicies> object make_constructor(F f, CallPolicies const& policies) { return detail::make_constructor_aux( f, policies, detail::get_signature(f)); } template <class F, class CallPolicies, class KeywordsOrSignature> object make_constructor( F f , CallPolicies const& policies , KeywordsOrSignature const& keywords_or_signature) { typedef typename detail::is_reference_to_keywords<KeywordsOrSignature&>::type is_kw; return detail::make_constructor_dispatch( f , policies , keywords_or_signature , is_kw() ); } template <class F, class CallPolicies, class Keywords, class Signature> object make_constructor( F f , CallPolicies const& policies , Keywords const& kw , Signature const& sig ) { return detail::make_constructor_aux( f , policies , sig , kw.range() , mpl::int_<Keywords::size>() ); } // } }} #endif // MAKE_CONSTRUCTOR_DWA20011221_HPP
Save
cmd:
run