File: ctypeslib.1

package info (click to toggle)
python-ctypeslib 0.0.0%2Bsvn20100125-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 332 kB
  • ctags: 398
  • sloc: python: 2,845; makefile: 38
file content (231 lines) | stat: -rw-r--r-- 5,116 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
.\" This file was originally generated by help2man 1.36, but
.\" hand-edited to combine the pages for h2xml and xml2py together.
.TH ctypeslib 1 "March 2010" "ctypeslib" "User Commands"

.SH NAME
.B h2xml
- convert header files to XML intermediates
.br
.B xml2py
- convert XML intermediates to Python ctypes interface


.SH SYNOPSIS
.B h2xml
.I includefile\fR ... [\fIoptions\fR]
.B -o
.I outputxmlfile
.br
.B xml2py
.I xmlfile\fR ... [\fIoptions\fR]
.B -o
.I outputpyfile

.SH DESCRIPTION

.B
ctypeslib
is a Python code generator capable of converting C header files
into xml files (using gccxml), and then converting the xmlfiles into
Python modules which define a ctypes interface to the corresponding C
library.

Ctypeslib is not ctypes.  Ctypes is included in Python 2.5+ and as an
add-on for lower versions, while ctypeslib is a lesser known add-on
written by the ctypes author.  If you use ctypes a lot and are tired
of setting argtypes and restype of the called functions, you should
look into ctypeslib.  Ctypeslib can also set up data types and
structures from C header files automatically.

.B h2xml
and
.B xml2py
are the user interface scripts to ctypeslib. 
.B h2xml
converts C header files into xml intermediates (using \fBgccxml\fR) and
.B xml2py
converts these intermediates to Python files.  At the minimum, you can
get automatic construction of the C types (structures, etc) in ctypes
definitions.  With extra options, macro definitions can be expanded
and the output Python file can be automatically linked (using ctypes)
to the corresponding C library.

The briefest example is:

.RS
.B h2xml \fIheader.h\fR -o \fIout_c.xml\fR
.br
.B xml2py \fIout_c.xml\fR -o \fIout_c.py\fR
.RE

Key options are 
.B -c
(include C preprocessor headers) to
.B h2xml
and
.B -l
.I library.so
(automatically link to the C library using ctypes) to
.B xml2py\fR.



.SH OPTIONS

.B h2xml
options:
.RS

.TP
\fB\-h\fR, \fB\-\-help\fR
show brief help message
.HP
\fB\-q\fR, \fB\-\-quiet\fR

.TP
\fB\-D\fR NAME[=VALUE]
macros to define
.TP
\fB\-U\fR NAME
macros to undefine
.TP
\fB\-I\fR DIRECTORY
additional include directories
.TP
\fB\-o\fR XMLFILE
XML output filename
.TP
\fB\-c\fR, \fB\-\-cpp\-symbols\fR
try to find #define symbols \- this may give compiler
errors, so it's off by default.
.TP
\fB\-k\fR
don't delete the temporary files created (useful for
finding problems)
.RE



.B xml2py
options:
.RS
.TP
\fB\-h\fR, \fB\-\-help\fR
show this help message and exit
.TP
\fB\-c\fR
include source file location in comments
.TP
\fB\-d\fR
include docstrings containing C prototype and source file
location
.TP
\fB\-k\fR TYPEKIND
kind of type descriptions to include: d = #defines, e =
enumerations, f = functions, s = structures, t = typedefs
.TP
\fB\-l\fR DLLS
libraries to search for exported functions
.TP
\fB\-o\fR OUTPUT
output filename (if not specified, standard output will be
used)
.TP
\fB\-r\fR EXPRESSION
regular expression for symbols to include (if neither symbols
nor expressions are specified,everything will be included)
.TP
\fB\-s\fR SYMBOL
symbol to include (if neither symbols nor expressions are
specified,everything will be included)
.TP
\fB\-v\fR
verbose output
.TP
\fB\-w\fR
add all standard windows dlls to the searched dlls list
.TP
\fB\-m\fR module
Python module(s) containing symbols which will be imported
instead of generated
.TP
\fB\-\-preload\fR=\fIDLL\fR
dlls to be loaded before all others (to resolve symbols)
.TP
\fB\-h\fR, \fB\-\-help\fR
show this help message and exit
.TP
\fB\-c\fR
include source file location in comments
.TP
\fB\-d\fR
include docstrings containing C prototype and source file
location
.TP
\fB\-k\fR TYPEKIND
kind of type descriptions to include: d = #defines, e =
enumerations, f = functions, s = structures, t = typedefs
.TP
\fB\-l\fR DLLS
libraries to search for exported functions
.TP
\fB\-o\fR OUTPUT
output filename (if not specified, standard output will be
used)
.TP
\fB\-r\fR EXPRESSION
regular expression for symbols to include (if neither symbols
nor expressions are specified,everything will be included)
.TP
\fB\-s\fR SYMBOL
symbol to include (if neither symbols nor expressions are
specified,everything will be included)
.TP
\fB\-v\fR
verbose output
.TP
\fB\-w\fR
add all standard windows dlls to the searched dlls list
.TP
\fB\-m\fR module
Python module(s) containing symbols which will be imported
instead of generated
.TP
\fB\-\-preload\fR=\fIDLL\fR
dlls to be loaded before all others (to resolve symbols)

.RE




.SH "EXAMPLES"

Please see
.I /usr/share/doc/python-ctypeslib/examples.Debian
for examples and explanation.




.SH "SEE ALSO"
.I /usr/share/doc/python-ctypeslib/examples.Debian
contains a brief tutorial on some key features

Python docstrings (\fBpydoc ctypeslib\fR)

Ctypeslib upstream is
.I http://python.net/crew/theller/ctypes/
(see "Related Projects").

For ctypes information, see
.I http://docs.python.org/library/ctypes.html



.SH "AUTHOR"
.B ctypeslib
was written by Thomas Heller <theller@ctypes.org>.
.PP
This manual page was written by Richard Darst <rkd@zgib.net>,
for the Debian project (and may be used by others).