[Cython] Bug: compilation failure with "Template parameter not a type" for pointer & reference types

2016-02-10 Thread Yury V. Zaytsev

Hi,

I came across the following bug, while trying to implement iterator 
versions of std::string members, for which a simple reproducer is below.


If the return type of a function is a normal type, then everything is 
fine, but if it's a pointer or reference type, then Cython refuses to 
compile it.


Could something please be done about that? Many thanks!

Error compiling Cython file:

...
cdef extern from * nogil:
cdef cppclass test:
void assign[input_iterator](input_iterator, input_iterator)
char assign[input_iterator](input_iterator, input_iterator)
char* assign[input_iterator](input_iterator, input_iterator)
char& assign[input_iterator](input_iterator, input_iterator)
  ^


notatype.pyx:6:35: Template parameter not a type

--
Sincerely yours,
Yury V. Zaytsev
___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Bug: compilation failure with "Template parameter not a type" for pointer & reference types

2016-02-10 Thread Yury V. Zaytsev

On Wed, 10 Feb 2016, Yury V. Zaytsev wrote:

If the return type of a function is a normal type, then everything is 
fine, but if it's a pointer or reference type, then Cython refuses to 
compile it.


I've just found out that apparently this happens because Cython misparses 
function definition as an array declaration, but luckily a safety check 
kicks in.


An obvious workaround is:

ctypedef char* r1
ctypedef char& r2

cdef extern from * nogil:
cdef cppclass test:
r1 assign[input_iterator](input_iterator, input_iterator)
r2 assign[input_iterator](input_iterator, input_iterator)

which compiles just fine. Unfortunately, I'm not well-versed enough with 
the parser to provide a patch...


Hope that helps to fix the problem for good though!

--
Sincerely yours,
Yury V. Zaytsev
___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Bug: compilation failure with "Template parameter not a type" for pointer & reference types

2016-02-10 Thread Yury V. Zaytsev

On Wed, 10 Feb 2016, Yury V. Zaytsev wrote:


Hope that helps to fix the problem for good though!


Apparently a separate, but related bug: when C++ class constructor is 
templated, Cython fails to compile the code.


However, if I specify a return type (irrespectively of what type is), it 
seems to work and some meaningful code is generated:


cdef extern from * nogil:
cdef cppclass test:
test test()
test test[input_iterator](input_iterator, input_iterator)

Original error messages below:

Error compiling Cython file:

...


cdef extern from * nogil:
cdef cppclass test:
test()
test[input_iterator](input_iterator, input_iterator)
  ^


notatype.pyx:9:27: undeclared name not builtin: input_iterator

Error compiling Cython file:

...


cdef extern from * nogil:
cdef cppclass test:
test()
test[input_iterator](input_iterator, input_iterator)
  ^


notatype.pyx:9:27: Array dimension not integer

Error compiling Cython file:

...


cdef extern from * nogil:
cdef cppclass test:
test()
test[input_iterator](input_iterator, input_iterator)
   ^


notatype.pyx:9:28: Missing name in declaration.


--
Sincerely yours,
Yury V. Zaytsev

___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel