From 57fe4a6eba35cf4a35bcfa101b832bd4d9545ab5 Mon Sep 17 00:00:00 2001 From: David Barnett Date: Sat, 15 May 2010 13:47:40 -0700 Subject: [PATCH] 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). --- tests/compile/cpp_structs.pyx | 9 +++++++++ tests/compile/cpp_templated_ctypedef.pyx | 4 ++++ tests/compile/point.h | 14 ++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 tests/compile/cpp_structs.pyx create mode 100644 tests/compile/cpp_templated_ctypedef.pyx create mode 100644 tests/compile/point.h 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 -- 2.26.2