Revision: 664
http://svn.sourceforge.net/pygccxml/?rev=664&view=rev
Author: roman_yakovenko
Date: 2006-10-16 11:47:03 -0700 (Mon, 16 Oct 2006)
Log Message:
-----------
change ssize_t to index_type
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_repository/convenience.py
Modified: pyplusplus_dev/pyplusplus/code_repository/convenience.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_repository/convenience.py 2006-10-16 17:14:55 UTC (rev 663)
+++ pyplusplus_dev/pyplusplus/code_repository/convenience.py 2006-10-16 18:47:03 UTC (rev 664)
@@ -25,6 +25,10 @@
namespace pyplusplus{ namespace convenience{
+//TODO: Replace index_type with Boost.Python defined ssize_t type.
+// This should be done by checking Python and Boost.Python version.
+typedef int index_type;
+
inline void
raise_error( PyObject *exception, const char *message ){
PyErr_SetString(exception, message);
@@ -32,14 +36,14 @@
}
inline void
-ensure_sequence( boost::python::object seq, boost::python::ssize_t expected_length=-1 ){
+ensure_sequence( boost::python::object seq, index_type expected_length=-1 ){
PyObject* seq_impl = seq.ptr();
if( !PySequence_Check( seq_impl ) ){
raise_error( PyExc_TypeError, "Sequence expected" );
}
- boost::python::ssize_t length = PySequence_Length( seq_impl );
+ index_type length = PySequence_Length( seq_impl );
if( expected_length != -1 && length != expected_length ){
std::stringstream err;
err << "Expected sequence length is " << expected_length << ". "
@@ -49,11 +53,11 @@
}
template< class ExpectedType >
-void ensure_uniform_sequence( boost::python::object seq, boost::python::ssize_t expected_length=-1 ){
+void ensure_uniform_sequence( boost::python::object seq, index_type expected_length=-1 ){
ensure_sequence( seq, expected_length );
- boost::python::ssize_t length = boost::python::len( seq );
- for( boost::python::ssize_t index = 0; index < length; ++index ){
+ index_type length = boost::python::len( seq );
+ for( index_type index = 0; index < length; ++index ){
boost::python::object item = seq[index];
boost::python::extract<ExpectedType> type_checker( item );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|