Package ctypes
[hide private]
[frames] | no frames]

Package ctypes

create and manipulate C data types in Python


Version: 1.0.1

Submodules [hide private]

Classes [hide private]
ArgumentError
CDLL
An instance of this class represents a loaded dll/shared library, exporting functions using the standard C calling convention (named 'cdecl' on Windows).
HRESULT
LibraryLoader
OleDLL
This class represents a dll exporting functions using the Windows stdcall calling convention, and returning HRESULT.
PyDLL
This class represents the Python library itself.
WinDLL
This class represents a dll exporting functions using the Windows stdcall calling convention.
c_byte
c_char
c_char_p
c_double
c_float
c_int
c_int16
c_int32
c_int64
c_int8
c_long
c_longlong
c_short
c_size_t
c_ubyte
c_uint
c_uint16
c_uint32
c_uint64
c_uint8
c_ulong
c_ulonglong
c_ushort
c_void_p
c_voidp
c_wchar
c_wchar_p
py_object
Functions [hide private]
 
ARRAY(typ, len)
function prototype
CFUNCTYPE(restype, *argtypes)
restype: the result type argtypes: a sequence specifying the argument types
 
DllCanUnloadNow()
 
DllGetClassObject(rclsid, riid, ppv)
 
POINTER(cls)
 
PYFUNCTYPE(restype, *argtypes)
 
SetPointerType(pointer, cls)
 
WINFUNCTYPE(restype, *argtypes)
 
WinError(code=None, descr=None)
 
c_buffer(init, size=None)
 
cast(obj, typ)
character array
create_string_buffer(aString)
create_string_buffer(anInteger) -> character array create_string_buffer(aString, anInteger) -> character array
character array
create_unicode_buffer(aString)
create_unicode_buffer(anInteger) -> character array create_unicode_buffer(aString, anInteger) -> character array
 
pointer(inst)
string
string_at(addr, size=...)
Return the string at addr.
string
wstring_at(addr, size=...)
Return the string at addr.
Variables [hide private]
  DEFAULT_MODE = 0
  GetLastError = windll.coredll.GetLastError
  _FUNCFLAG_STDCALL = _FUNCFLAG_CDECL
  _c_functype_cache = {(<class 'ctypes.py_object'>, (<class 'cty...
  _cast = PYFUNCTYPE(py_object, c_void_p, py_object, py_object)(...
  _pointer_type_cache = {None: <class 'ctypes.c_void_p'>, <class...
  _string_at = CFUNCTYPE(py_object, c_void_p, c_int)(_string_at_...
  _win_functype_cache = {}
  _wstring_at = CFUNCTYPE(py_object, c_void_p, c_int)(_wstring_a...
  cdll = LibraryLoader(CDLL)
  memmove = CFUNCTYPE(c_void_p, c_void_p, c_void_p, c_size_t)(_m...
  memset = CFUNCTYPE(c_void_p, c_void_p, c_int, c_size_t)(_memse...
  oledll = LibraryLoader(OleDLL)
  pydll = LibraryLoader(PyDLL)
  pythonapi = <PyDLL 'None', handle 400164f8 at 409d3aac>
  windll = LibraryLoader(WinDLL)

Imports: util, Array, BigEndianStructure, FormatError, LittleEndianStructure, RTLD_GLOBAL, RTLD_LOCAL, Structure, Union, _CFuncPtr, _FUNCFLAG_CDECL, _FUNCFLAG_PYTHONAPI, _Pointer, _SimpleCData, _calcsize, _cast_addr, _check_HRESULT, _ctypes_version, _dlopen, _endian, _memmove_addr, _memset_addr, _os, _string_at_addr, _sys, _wstring_at_addr, addressof, alignment, byref, gestalt, macholib, resize, set_conversion_mode, sizeof


Function Details [hide private]

CFUNCTYPE(restype, *argtypes)

 

restype: the result type argtypes: a sequence specifying the argument types

The function prototype can be called in different ways to create a callable object:

prototype(integer address) -> foreign function prototype(callable) -> create and return a C callable function from callable prototype(integer index, method name[, paramflags]) -> foreign function calling a COM method prototype((ordinal number, dll object)[, paramflags]) -> foreign function exported by ordinal prototype((function name, dll object)[, paramflags]) -> foreign function exported by name

Returns: function prototype

Variables Details [hide private]

_c_functype_cache

Value:
{(<class 'ctypes.py_object'>,
  (<class 'ctypes.c_void_p'>, <class 'ctypes.c_long'>)): <class 'ctype\
s.CFunctionType'>,
 (<class 'ctypes.c_void_p'>,
  (<class 'ctypes.c_void_p'>,
   <class 'ctypes.c_long'>,
   <class 'ctypes.c_ulong'>)): <class 'ctypes.CFunctionType'>,
 (<class 'ctypes.c_void_p'>, (<class 'ctypes.c_void_p'>, <class 'ctype\
...

_cast

Value:
PYFUNCTYPE(py_object, c_void_p, py_object, py_object)(_cast_addr)

_pointer_type_cache

Value:
{None: <class 'ctypes.c_void_p'>,
 <class 'ctypes.c_char'>: <class 'ctypes.LP_c_char'>,
 <class 'ctypes.c_wchar'>: <class 'ctypes.LP_c_wchar'>}

_string_at

Value:
CFUNCTYPE(py_object, c_void_p, c_int)(_string_at_addr)

_wstring_at

Value:
CFUNCTYPE(py_object, c_void_p, c_int)(_wstring_at_addr)

memmove

Value:
CFUNCTYPE(c_void_p, c_void_p, c_void_p, c_size_t)(_memmove_addr)

memset

Value:
CFUNCTYPE(c_void_p, c_void_p, c_int, c_size_t)(_memset_addr)