Commit 07aaffae authored by mattip's avatar mattip

BUG: fix test to use correct macros, functions for c-level getters

parent a6ec7fb9
...@@ -38,23 +38,23 @@ typedef struct { ...@@ -38,23 +38,23 @@ typedef struct {
} FooStructOpaque; } FooStructOpaque;
#define PyFoo_GET0(a) a.f0 #define PyFoo_GET0M(a) ((FooStructNominal*)a)->f0
#define PyFoo_GET1(a) a.f1 #define PyFoo_GET1M(a) ((FooStructNominal*)a)->f1
#define PyFoo_GET2(a) a.f2 #define PyFoo_GET2M(a) ((FooStructNominal*)a)->f2
int PyFoo_Get0(FooStructNominal f) int PyFoo_Get0F(FooStructOpaque *f)
{ {
return f.f0; return ((FooStructNominal*)f)->f0;
} }
int PyFoo_Get1(FooStructNominal f) int PyFoo_Get1F(FooStructOpaque *f)
{ {
return f.f1; return ((FooStructNominal*)f)->f1;
} }
int PyFoo_Get2(FooStructNominal f) int PyFoo_Get2F(FooStructOpaque *f)
{ {
return f.f2; return ((FooStructNominal*)f)->f2;
} }
#ifdef __cplusplus #ifdef __cplusplus
...@@ -124,19 +124,19 @@ cdef extern from "foo.h": ...@@ -124,19 +124,19 @@ cdef extern from "foo.h":
ctypedef class foo_extension.Foo [object FooStructOpaque, check_size ignore]: ctypedef class foo_extension.Foo [object FooStructOpaque, check_size ignore]:
@property @property
cdef int field0(self): cdef int field0(self):
return PyFoo_GET0(self) return PyFoo_GET0M(self)
@property @property
cdef int field1(self): cdef int field1(self):
return PyFoo_Get1(self) return PyFoo_Get1F(self)
@property @property
cdef int field2(self): cdef int field2(self):
return PyFoo_GET2(self) return PyFoo_GET2M(self)
int PyFoo_GET0(Foo); # this is actually a macro ! int PyFoo_GET0M(Foo); # this is actually a macro !
int PyFoo_Get1(Foo); int PyFoo_Get1F(Foo);
int PyFoo_GET2(Foo); # this is actually a macro ! int PyFoo_GET2M(Foo); # this is actually a macro !
def sum(Foo f): def sum(Foo f):
# Note - not a cdef function but compiling the f.__getattr__('field0') # Note - not a cdef function but compiling the f.__getattr__('field0')
......
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