Commit bd587ae5 authored by Lisandro Dalcin's avatar Lisandro Dalcin

casting to typedef pointer/array types (ticket #518)

parent f9d5e812
......@@ -228,8 +228,9 @@ class CTypedefType(BaseType):
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)
......
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)
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; }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment