[Pyrex] Wrapping nested structs
Greg Ewing
greg at cosc.canterbury.ac.nz
Mon May 5 07:55:54 CEST 2003
"Edward C. Jones" <edcjones at erols.com>:
> How do I wrap the following four snippets of code?
Something like this (untested):
--------------------------------
Snippet 1
--------------------------------
cdef extern from "something.h":
# Embedded structs/unions have to be broken out
# and explicitly named
ctypedef struct Small:
int i
ctypedef struct AAA:
Small sm
cdef Small clone(Small sm);
--------------------------------
Snippet 2
--------------------------------
cdef extern from "something.h":
cdef struct SmallStruct:
int i
ctypedef struct BBB:
SmallStruct Small
--------------------------------
Snippet 3
--------------------------------
cdef extern from "something.h":
cdef union NumUnion:
int i
float x
ctypedef struct CCC:
NumUnion Num
--------------------------------
Snippet 4
--------------------------------
cdef extern from "something.h":
ctypedef struct Point:
# We're lying here, and relying on the fact that
# "something.h" will supply the real definition at
# C compilation time. This will ONLY work inside a
# "cdef extern from" block!
int x
int col
int y
int row
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
greg at cosc.canterbury.ac.nz +--------------------------------------+
More information about the Pyrex
mailing list