From: David Barnett Date: Sat, 15 May 2010 20:47:40 +0000 (-0700) Subject: C++ failures / tests X-Git-Tag: 0.13.beta0~77^2~2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=57fe4a6eba35cf4a35bcfa101b832bd4d9545ab5;p=cython.git C++ failures / tests I noticed two failures to compile that I think are bugs: - "ctypedef Foo[int] Bar" gives a syntax error (i.e., there doesn't seem to be any way to typedef a templated type). - Defining a struct in a namespace and trying to convert it to a Python dict doesn't work. Instead you get nasty "__pyx_convert__to_py_THENAMESPACE" errors from the C++ compiler (it doesn't mangle the cname properly and tries to define __pyx_convert__to_py_THENAMESPACE::THESTRUCT). I made a patch to *add tests* for the two bugs (not fix them). --- diff --git a/tests/compile/cpp_structs.pyx b/tests/compile/cpp_structs.pyx new file mode 100644 index 00000000..c7b86935 --- /dev/null +++ b/tests/compile/cpp_structs.pyx @@ -0,0 +1,9 @@ +cdef extern from "point.h" namespace "geometry": + + cdef struct Point: + double x + double y + int color + +cdef Point p = Point(0.0, 0.0, 0) +the_point = p diff --git a/tests/compile/cpp_templated_ctypedef.pyx b/tests/compile/cpp_templated_ctypedef.pyx new file mode 100644 index 00000000..634b46f5 --- /dev/null +++ b/tests/compile/cpp_templated_ctypedef.pyx @@ -0,0 +1,4 @@ +cdef extern from *: + cdef cppclass Foo[T]: + pass + ctypedef Foo[int] IntFoo diff --git a/tests/compile/point.h b/tests/compile/point.h new file mode 100644 index 00000000..866807c3 --- /dev/null +++ b/tests/compile/point.h @@ -0,0 +1,14 @@ +#ifndef POINT_H +#define POINT_H + +namespace geometry { + + struct Point + { + double x; + double y; + int color; + }; +} + +#endif