summaryrefslogtreecommitdiff
path: root/src/python
diff options
context:
space:
mode:
Diffstat (limited to 'src/python')
-rw-r--r--src/python/py_commodity.cc2
-rw-r--r--src/python/py_times.cc4
-rw-r--r--src/python/py_utils.cc8
-rw-r--r--src/python/pyutils.h4
-rw-r--r--src/python/tuples.hpp116
5 files changed, 67 insertions, 67 deletions
diff --git a/src/python/py_commodity.cc b/src/python/py_commodity.cc
index f857a448..0dab3cd3 100644
--- a/src/python/py_commodity.cc
+++ b/src/python/py_commodity.cc
@@ -51,7 +51,7 @@ void export_commodity()
scope().attr("COMMODITY_STYLE_BUILTIN") = COMMODITY_STYLE_BUILTIN;
class_< commodity_t, bases<>,
- commodity_t, boost::noncopyable > ("commodity", no_init)
+ commodity_t, boost::noncopyable > ("commodity", no_init)
.def(self == self)
.def("drop_flags", &commodity_t::drop_flags)
diff --git a/src/python/py_times.cc b/src/python/py_times.cc
index f7672dcc..173f21fa 100644
--- a/src/python/py_times.cc
+++ b/src/python/py_times.cc
@@ -56,7 +56,7 @@ struct date_to_python
return PyDate_FromDate(dte.year(), dte.month(), dte.day());
}
};
-
+
struct date_from_python
{
static void* convertible(PyObject* obj_ptr)
@@ -93,7 +93,7 @@ struct datetime_to_python
tod.total_microseconds() % 1000000);
}
};
-
+
struct datetime_from_python
{
static void* convertible(PyObject* obj_ptr)
diff --git a/src/python/py_utils.cc b/src/python/py_utils.cc
index 73961d43..50ce9712 100644
--- a/src/python/py_utils.cc
+++ b/src/python/py_utils.cc
@@ -50,7 +50,7 @@ struct bool_to_python
Py_RETURN_FALSE;
}
};
-
+
struct bool_from_python
{
static void* convertible(PyObject* obj_ptr)
@@ -82,7 +82,7 @@ struct string_to_python
return incref(object(*boost::polymorphic_downcast<const std::string *>(&str)).ptr());
}
};
-
+
struct string_from_python
{
static void* convertible(PyObject* obj_ptr)
@@ -112,7 +112,7 @@ struct istream_to_python
return incref(boost::python::detail::none());
}
};
-
+
struct istream_from_python
{
static void* convertible(PyObject* obj_ptr)
@@ -140,7 +140,7 @@ struct ostream_to_python
return incref(boost::python::detail::none());
}
};
-
+
struct ostream_from_python
{
static void* convertible(PyObject* obj_ptr)
diff --git a/src/python/pyutils.h b/src/python/pyutils.h
index 216af8b7..41bbbfde 100644
--- a/src/python/pyutils.h
+++ b/src/python/pyutils.h
@@ -62,10 +62,10 @@ struct register_optional_to_python : public boost::noncopyable
{
return boost::python::incref
(value ? boost::python::to_python_value<T>()(*value) :
- boost::python::detail::none());
+ boost::python::detail::none());
}
};
-
+
struct optional_from_python
{
static void * convertible(PyObject * source)
diff --git a/src/python/tuples.hpp b/src/python/tuples.hpp
index 18cbdb83..523846a7 100644
--- a/src/python/tuples.hpp
+++ b/src/python/tuples.hpp
@@ -145,11 +145,11 @@ struct to_py_tuple{
typedef mpl::int_< tuples::length< TTuple >::value > length_type;
static PyObject* convert(const TTuple& c_tuple){
- list values;
- //add all c_tuple items to "values" list
- convert_impl( c_tuple, values, mpl::int_< 0 >(), length_type() );
- //create Python tuple from the list
- return incref( python::tuple( values ).ptr() );
+ list values;
+ //add all c_tuple items to "values" list
+ convert_impl( c_tuple, values, mpl::int_< 0 >(), length_type() );
+ //create Python tuple from the list
+ return incref( python::tuple( values ).ptr() );
}
private:
@@ -157,8 +157,8 @@ private:
template< int index, int length >
static void
convert_impl( const TTuple &c_tuple, list& values, mpl::int_< index >, mpl::int_< length > ) {
- values.append( c_tuple.template get< index >() );
- convert_impl( c_tuple, values, details::increment_index<index>(), length_type() );
+ values.append( c_tuple.template get< index >() );
+ convert_impl( c_tuple, values, details::increment_index<index>(), length_type() );
}
template< int length >
@@ -179,48 +179,48 @@ struct from_py_sequence{
static void*
convertible(PyObject* py_obj){
- if( !PySequence_Check( py_obj ) ){
- return 0;
- }
-
- if( !PyObject_HasAttrString( py_obj, "__len__" ) ){
- return 0;
- }
-
- python::object py_sequence( handle<>( borrowed( py_obj ) ) );
-
- if( tuples::length< TTuple >::value != len( py_sequence ) ){
- return 0;
- }
-
- if( convertible_impl( py_sequence, mpl::int_< 0 >(), length_type() ) ){
- return py_obj;
- }
- else{
- return 0;
- }
+ if( !PySequence_Check( py_obj ) ){
+ return 0;
+ }
+
+ if( !PyObject_HasAttrString( py_obj, "__len__" ) ){
+ return 0;
+ }
+
+ python::object py_sequence( handle<>( borrowed( py_obj ) ) );
+
+ if( tuples::length< TTuple >::value != len( py_sequence ) ){
+ return 0;
+ }
+
+ if( convertible_impl( py_sequence, mpl::int_< 0 >(), length_type() ) ){
+ return py_obj;
+ }
+ else{
+ return 0;
+ }
}
static void
construct( PyObject* py_obj, converter::rvalue_from_python_stage1_data* data){
- typedef converter::rvalue_from_python_storage<TTuple> storage_t;
- storage_t* the_storage = reinterpret_cast<storage_t*>( data );
- void* memory_chunk = the_storage->storage.bytes;
- TTuple* c_tuple = new (memory_chunk) TTuple();
- data->convertible = memory_chunk;
-
- python::object py_sequence( handle<>( borrowed( py_obj ) ) );
- construct_impl( py_sequence, *c_tuple, mpl::int_< 0 >(), length_type() );
+ typedef converter::rvalue_from_python_storage<TTuple> storage_t;
+ storage_t* the_storage = reinterpret_cast<storage_t*>( data );
+ void* memory_chunk = the_storage->storage.bytes;
+ TTuple* c_tuple = new (memory_chunk) TTuple();
+ data->convertible = memory_chunk;
+
+ python::object py_sequence( handle<>( borrowed( py_obj ) ) );
+ construct_impl( py_sequence, *c_tuple, mpl::int_< 0 >(), length_type() );
}
static TTuple to_c_tuple( PyObject* py_obj ){
- if( !convertible( py_obj ) ){
- throw std::runtime_error( "Unable to construct boost::tuples::tuple from Python object!" );
- }
- TTuple c_tuple;
- python::object py_sequence( handle<>( borrowed( py_obj ) ) );
- construct_impl( py_sequence, c_tuple, mpl::int_< 0 >(), length_type() );
- return c_tuple;
+ if( !convertible( py_obj ) ){
+ throw std::runtime_error( "Unable to construct boost::tuples::tuple from Python object!" );
+ }
+ TTuple c_tuple;
+ python::object py_sequence( handle<>( borrowed( py_obj ) ) );
+ construct_impl( py_sequence, c_tuple, mpl::int_< 0 >(), length_type() );
+ return c_tuple;
}
private:
@@ -229,34 +229,34 @@ private:
static bool
convertible_impl( const python::object& py_sequence, mpl::int_< index >, mpl::int_< length > ){
- typedef typename tuples::element< index, TTuple>::type element_type;
+ typedef typename tuples::element< index, TTuple>::type element_type;
- object element = py_sequence[index];
- extract<element_type> type_checker( element );
- if( !type_checker.check() ){
- return false;
- }
- else{
- return convertible_impl( py_sequence, details::increment_index<index>(), length_type() );
- }
+ object element = py_sequence[index];
+ extract<element_type> type_checker( element );
+ if( !type_checker.check() ){
+ return false;
+ }
+ else{
+ return convertible_impl( py_sequence, details::increment_index<index>(), length_type() );
+ }
}
template< int length >
static bool
convertible_impl( const python::object& py_sequence, mpl::int_< length >, mpl::int_< length > ){
- return true;
+ return true;
}
template< int index, int length >
static void
construct_impl( const python::object& py_sequence, TTuple& c_tuple, mpl::int_< index >, mpl::int_< length > ){
- typedef typename tuples::element< index, TTuple>::type element_type;
+ typedef typename tuples::element< index, TTuple>::type element_type;
- object element = py_sequence[index];
- c_tuple.template get< index >() = extract<element_type>( element );
+ object element = py_sequence[index];
+ c_tuple.template get< index >() = extract<element_type>( element );
- construct_impl( py_sequence, c_tuple, details::increment_index<index>(), length_type() );
+ construct_impl( py_sequence, c_tuple, details::increment_index<index>(), length_type() );
}
template< int length >
@@ -272,8 +272,8 @@ void register_tuple(){
to_python_converter< TTuple, to_py_tuple<TTuple> >();
converter::registry::push_back( &from_py_sequence<TTuple>::convertible
- , &from_py_sequence<TTuple>::construct
- , type_id<TTuple>() );
+ , &from_py_sequence<TTuple>::construct
+ , type_id<TTuple>() );
};
} } //boost::python