overview :: tutorial :: reference :: faq
( Work in progress: COM :: COM sample )
This reference is probably not worth it's name, so incomplete it is.
sizeof(obj) -> integer
Return an integer specifying the number of bytes in the memory
block. This corresponds to the C code
also work for types.
byref(obj) -> cparam-object
&obj in C code, but only usable for passing the
object as a parameter to a C function call.
pointer(obj) -> ctypes instance
&obj in C. Different from
creates a new ctypes object, acting as a pointer to
will be an instance of a pointer class pointing to
instances. The pointer class is created on the fly, if it
does not yet exist.
addressof(obj) -> integer
(int)&obj in C. Returns the address of the internal
memory buffer as an integer.
ctypes types/classes extensively use the new Python type system, so the following may first look unusual to the Pyhon programmer.
POINTER(ctype) -> class
Return a subclass of
ctype. Instances of this class are
ctype. The subclass will be created if it does
not yet exist, otherwise it is returned from a builtin cache.
ctype * num -> array class
ctype class with a positive integer creates a
Array. Instances are arrays holding
ctype.from_address(address) -> ctypes instance
Create a new instance of
ctype from the memory block at the
address. It must no longer be accessed if the memory
block becomes invalid, the programmer must ensure this.
obj._as_parameter_ -> magic
Automatically called when a ctype object is used as a parameter in a C function call by value. Must return something that can be understood by the C function call parameter converter. Currently, it either returns an integer, a string or a unicode string. These are passed as the corresponding C data type to the function call.