Hi all,
I'm trying to convert my existing C++ wrapper to use Cython 0.13 and am
getting strange error messages.
In pyclical.h I have:
-----
#include "glucat/glucat.h"
typedef glucat::tuning<> Tune_P;
#include "glucat/glucat_imp.h"
#include <iostream>
#include <sstream>
#include <iomanip>
using namespace glucat;
using namespace std;
typedef index_set<DEFAULT_LO,DEFAULT_HI> IndexSet;
typedef double scalar_t;
typedef framed_multi<scalar_t> Clifford;
string index_set_to_repr(const IndexSet& ist)
{
ostringstream os;
os << ist;
return os.str();
}
string index_set_to_str(const IndexSet& ist)
{
ostringstream os;
os << ist;
return os.str();
}
[...]
-----
In glucat/index_set.h I have:
-----
namespace glucat
{
template<const index_t LO, const index_t HI>
class index_set; // forward
/// Symmetric set difference: exclusive or
template<const index_t LO, const index_t HI>
const index_set<LO,HI>
operator^ (const index_set<LO,HI>& lhs,
const index_set<LO,HI>& rhs);
/// Set intersection: and
template<const index_t LO, const index_t HI>
const index_set<LO,HI>
operator& (const index_set<LO,HI>& lhs,
const index_set<LO,HI>& rhs);
/// Set union: or
template<const index_t LO, const index_t HI>
const index_set<LO,HI>
operator| (const index_set<LO,HI>& lhs,
const index_set<LO,HI>& rhs);
/// Index set class based on std::bitset<> in Gnu standard C++ library
template<const index_t LO, const index_t HI>
class index_set :
private std::bitset<HI-LO>
{
private:
BOOST_STATIC_ASSERT((LO <= 0) && (0 <= HI) && (LO < HI) && \
(-LO < _GLUCAT_BITS_PER_ULONG) && \
( HI < _GLUCAT_BITS_PER_ULONG) && \
( HI-LO <= _GLUCAT_BITS_PER_ULONG));
typedef std::bitset<HI-LO> bitset_t;
typedef error<index_set> error_t;
public:
typedef index_set index_set_t;
typedef std::pair<index_t,index_t> index_pair_t;
static const index_t v_lo = LO;
static const index_t v_hi = HI;
static const std::string classname();
/// Default constructor creates an empty set
index_set () { }
/// Constructor from bitset_t
index_set (const bitset_t bst);
/// Constructor from index
index_set (const index_t idx);
[...]
/// Constructor from string
index_set (const std::string& str);
/// Equality
bool operator== (const index_set_t rhs) const;
/// Inequality
bool operator!= (const index_set_t rhs) const;
/// Set complement: not
index_set_t operator~ () const;
/// Symmetric set difference: exclusive or
index_set_t& operator^= (const index_set_t rhs);
/// Set intersection: and
index_set_t& operator&= (const index_set_t rhs);
/// Set union: or
index_set_t& operator|= (const index_set_t rhs);
[...]
-----
In pyclical.pyx I had:
-----
cdef extern from "PyCliCal.h":
[...]
ctypedef struct c_index_set "IndexSet":
int eq "operator=="(c_index_set rhs)
c_index_set invert "operator~"()
c_index_set *new_index_set_from_index_set "new IndexSet" (c_index_set ist)
c_index_set *new_index_set_from_string "new IndexSet" (char* str)
c_index_set *new_index_set_from_int "new IndexSet" (int ndx)
void del_index_set "delete" (c_index_set *mv)
c_index_set c_or "operator|"(c_index_set lhs, c_index_set rhs)
c_index_set c_and "operator&"(c_index_set lhs, c_index_set rhs)
c_index_set c_xor "operator^"(c_index_set lhs, c_index_set rhs)
cpp_string index_set_to_repr(c_index_set ist)
cpp_string index_set_to_str(c_index_set ist)
-----
I now have:
-----
cdef extern from "PyCliCal.h":
[...]
cdef cppclass IndexSet:
int operator==(IndexSet rhs)
IndexSet operator~()
IndexSet (IndexSet ist)
IndexSet (char* str)
IndexSet (int ndx)
IndexSet operator|(IndexSet lhs, IndexSet rhs)
IndexSet operator&(IndexSet lhs, IndexSet rhs)
IndexSet operator^(IndexSet lhs, IndexSet rhs)
cpp_string index_set_to_repr(IndexSet ist)
cpp_string index_set_to_str(IndexSet ist)
void del_index_set "delete" (IndexSet *mv)
-----
The output from cython 0.13 looks like:
-----
cythoning PyCliCal.pyx to PyCliCal.cpp
Error converting Pyrex file to C:
------------------------------------------------------------
...
int operator==(IndexSet rhs)
IndexSet operator~()
IndexSet (IndexSet ist)
IndexSet (char* str)
IndexSet (int ndx)
IndexSet operator|(IndexSet lhs, IndexSet rhs)
^
------------------------------------------------------------
/home/leopardi/src/Working/Working-0.5.1/glucat/pyclical/PyCliCal.pyx:17:4:
'IndexSet' is not a type identifier
Error converting Pyrex file to C:
------------------------------------------------------------
...
int operator==(IndexSet rhs)
IndexSet operator~()
IndexSet (IndexSet ist)
IndexSet (char* str)
IndexSet (int ndx)
IndexSet operator|(IndexSet lhs, IndexSet rhs)
^
------------------------------------------------------------
/home/leopardi/src/Working/Working-0.5.1/glucat/pyclical/PyCliCal.pyx:17:23:
'IndexSet' is not a type identifier
[...]
-----
Why does IndexSet work within cppclass IndexSet but noot outside it? What am I
doing wrong, and how do I fix it?
Thanks, Paul
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev