I just created tickets for some of the bugs I reported (without the
one that was a mistake from me, as pointed by Sturla Molden, of
course). I did not report previously Bug #550; see the track ticket
for details.

Ticket #549 (http://trac.cython.org/cython_trac/ticket/549) : compiler
crash with non-declared template argument
Test case: crash_non_declared_template_argument_T549.pyx

Ticket #550 (http://trac.cython.org/cython_trac/ticket/550) : Cython
can generate incorrect c++ code when a function uses a reference
argument
Test case: incorrect_code_with_reference_argument_T550.pyx

Ticket #551 (http://trac.cython.org/cython_trac/ticket/551) : Cython
does not allow ctypedef'ing templated types
Test case: ctypedef_of_templated_type_T551.pyx

I attach a diff adding the test cases to tests/run and modifying
tests/bugs.txt accordingly.

I did not submit an enhancement ticket for the "left-value assignment
problems" yet, because I wanted to make some things clear first. To
recap, there are actually two problems, I think:
1-  If foo_iterator is an iterator, operator.dereference(foo_iterator)
is not an l-value for cython. Therefore it is not possible to do the
equivalent of " *foo_iterator=bar "  in cython (except if foo_iterator
is a pointer and not a general iterator)
2-  functions returning references are not l-values for cython.
Therefore, for example, it is not possible to use the ".at" method of
std::vectors to assign a value.

It looks like 1 and 2 could be solved by having a cython operator like
operator.set_lvalue(foo,bar) that would emit " foo=bar" provided foo
is either a function returning a reference or an operator.dereference
call or a standard l-value. Therefore, just in case, I wanted to ask
is such an operator had been already coded but not yet documented
(there seems to be hardly any doc about the operators in
cython.operator, actually).

Secondly, it seems that (1) is both a bit more annoying and a bit
easier (AFAICT without knowing cython internals) to solve than (2).
Therefore, would it be OK to make two different tickets, in the hope
that (1) can be solved earlier? Maybe a possible solution is to
overload operator.dereference so that it can take a second argument?
Thus operator.dereference(foo_iterator ,bar) would produce the c++
code:  " *foo_iterator=bar ".

A related "missing feature" is that it is not possible to take the
address of a dereferenced iterator: "
&operator.dereference(foo_iterator) " is invalid.

cheers,
Toki
# HG changeset patch
# User fab...@laptop
# Date 1278306959 -32400
# Node ID bc8a96e21f2bdec47d904f576715f92639d833d9
# Parent  edef3eed3f00427454993660b00cea4070be9fd6
added test cases for bugs #549, #550 and #551

diff -r edef3eed3f00 -r bc8a96e21f2b tests/bugs.txt
--- a/tests/bugs.txt	Sat Jul 03 18:22:12 2010 +0200
+++ b/tests/bugs.txt	Mon Jul 05 14:15:59 2010 +0900
@@ -13,6 +13,10 @@
 cpp_structs
 with_statement_module_level_T536
 
+ctypedef_of_templated_type_T551
+incorrect_code_with_reference_argument_T550
+crash_non_declared_template_argument_T549
+
 # CPython regression tests that don't current work:
 pyregr.test_threadsignals
 pyregr.test_module
diff -r edef3eed3f00 -r bc8a96e21f2b tests/run/crash_non_declared_template_argument_T549.pyx
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/run/crash_non_declared_template_argument_T549.pyx	Mon Jul 05 14:15:59 2010 +0900
@@ -0,0 +1,2 @@
+from libcpp.vector cimport vector
+cdef vector[x] *vect
diff -r edef3eed3f00 -r bc8a96e21f2b tests/run/ctypedef_of_templated_type_T551.pyx
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/run/ctypedef_of_templated_type_T551.pyx	Mon Jul 05 14:15:59 2010 +0900
@@ -0,0 +1,2 @@
+from libcpp.vector import vector
+ctypedef vector[int] VectOfInt
diff -r edef3eed3f00 -r bc8a96e21f2b tests/run/incorrect_code_with_reference_argument_T550.pyx
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/run/incorrect_code_with_reference_argument_T550.pyx	Mon Jul 05 14:15:59 2010 +0900
@@ -0,0 +1,9 @@
+cdef extern from "<vector>" namespace "std":
+    cdef cppclass vector[T]:
+        vector()
+        void push_back(T&)
+
+cdef void pushInt(value):
+    cdef vector[int] vect
+    vect.push_back(value)
+
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to