def cast_code(self, expr_code):
# If self is really an array (rather than pointer), we can't cast.
# For example, the gmp mpz_t.
- if self.typedef_base_type.is_ptr:
- return self.typedef_base_type.cast_code(expr_code)
+ if self.typedef_base_type.is_array:
+ base_type = self.typedef_base_type.base_type
+ return CPtrType(base_type).cast_code(expr_code)
else:
return BaseType.cast_code(self, expr_code)
--- /dev/null
+cdef extern from "cast_ctypedef_array_T518_helper.h":
+ cdef struct __foo_struct:
+ int i, j
+ ctypedef __foo_struct foo_t[1]
+
+ void foo_init(foo_t)
+ void foo_clear(foo_t)
+
+cdef foo_t value
+foo_init(value)
+foo_clear(value)
+
+cdef void *pointer = <void*> value
+foo_init(<foo_t>pointer)
+foo_clear(<foo_t>pointer)
--- /dev/null
+struct __foo_struct { int i, j; };
+typedef struct __foo_struct foo_t[1];
+
+static void foo_init (foo_t v) { v[0].i = 0; v[0].j = 0; }
+static void foo_clear (foo_t v) { v[0].i = 0; v[0].j = 0; }