The first part of the .h
file to convert are the
enumerations.
To convert a C enumeration to Pyrex:
typedef enum
with
cdef enum
,}
) to after the
enum
,
,
from the end of each line, and
{}
blocking with a
:
and indenting.For example, consider the following C enumeration, called
xosd_pos
, that is contained in
xosd.h
.
typedef enum { XOSD_top, XOSD_bottom } xosd_pos;
The above enumeration consists of two elements:
XOSD_top
and XOSD_bottom
The Pyrex version of the enumeration looks similar.
cdef enum xosd_pos: XOSD_top XOSD_bottom
The rest of the enumeration is then copied, with
whitespace replacing {}
as the blocking
mechanism and the commas removed.
The XOSD_
could also be removed from the start of
each enumeration value, but I will leave them in to emphasise
the mechanical nature of the conversion!
A further example is the xosd_command
enumeration that is converted from the following C
enumeration.
typedef enum { XOSD_percentage, XOSD_string, XOSD_printf, XOSD_slider } xosd_command;
The Pyrex version is as follows.
cdef enum xosd_command: XOSD_percentage XOSD_string XOSD_printf XOSD_slider
Previous | Contents | Next |