> On Fri, Feb 11, 2011 at 4:51 AM, Wichert Akkerman<wich
...@wiggy.net> wrote:
>> On 2/11/11 13:37 , Dag Sverre Seljebotn wrote:
>>> On 02/11/2011 01:27 PM, Wichert Akkerman wrote:
>>>> I have a C++ API which looks like this:
>>>> class Region {
>>>> public:
>>>> enum region_type { west, east };
>>>> void setRegion(region_type region);
>>>> }
>>>> the cython wrapper looks like this:
>>>> cdef:
>>> Should have:
>>> cdef extern from "region.hh":
>>> As it is, you made Cython recreate a (different) enum type.
>> That's certainly an improvement and an obvious mistake om my side.
>> Unfortunately that assumes a global enum, while I have an enum inside the
>> class. Some quick experiments suggest that cython does not support nested
>> types inside classes other than other classes. For example:
>> // C++ source
>> class Foo {
>> public:
>> enum my_enum { one, two };
>> type std::vector<int> int_vector;
>> };
>> # Cython source
>> from libcpp.vector import vector
>> cdef extern from "foo.hh":
>> cdef cppclass Foo:
>> enum my_enum:
>> one
>> two
>> ctypedef vector[int_vector]
>> results in syntax errors both for the enum and the ctypedef lines. Is that
>> analysis correct, or am I making another mistake here?
> You are correct, it's not supported yet. You may be able to get the
> behavior you want by specifying
> cdef extern from "foo.hh":
> enum my_enum "Foo::my_enum":
> one "Foo::one"
> ...
> I've created http://trac.cython.org/cython_trac/ticket/659
ctypedef for a template type. This code:
Results in a syntax error for the ctypedef statement.
Wichert.