All Samples(1001) | Call(915) | Derive(0) | Import(86)
sizeof(C type) -> integer sizeof(C instance) -> integer Return the size in bytes of a C instance
src/q/t/qtaste-HEAD/trunk/demo/pywinauto-0.3.8/pywinauto/win32structures.py qtaste(Download)
from win32defines import LF_FACESIZE, NMTTDISPINFOW_V1_SIZE, HDITEMW_V1_SIZE
import ctypes
from ctypes import \
c_int, c_uint, c_long, c_ulong, c_void_p, c_wchar, c_char, \
c_ubyte, c_ushort, c_wchar_p, \
POINTER, sizeof, alignment, Union
('x', LONG),
('y', LONG),
]
assert sizeof(POINT) == 8, sizeof(POINT)
assert alignment(POINT) == 4, alignment(POINT)
RECT.__reduce__ = _reduce assert sizeof(RECT) == 16, sizeof(RECT) assert alignment(RECT) == 4, alignment(RECT)
('lParam', LPARAM),
('iIndent', c_int),
]
assert sizeof(LVITEMW) == 40, sizeof(LVITEMW)
assert alignment(LVITEMW) == 1, alignment(LVITEMW)
('cChildren', c_int),
('lParam', LPARAM),
]
assert sizeof(TVITEMW) == 40, sizeof(TVITEMW)
assert alignment(TVITEMW) == 1, alignment(TVITEMW)
('idFrom', UINT),
('code', UINT),
]
assert sizeof(NMHDR) == 12, sizeof(NMHDR)
assert alignment(NMHDR) == 4, alignment(NMHDR)
('hdr', NMHDR),
('item', TVITEMW),
]
assert sizeof(NMTVDISPINFOW) == 52, sizeof(NMTVDISPINFOW)
assert alignment(NMTVDISPINFOW) == 1, alignment(NMTVDISPINFOW)
LOGFONTW.__reduce__ = _reduce assert sizeof(LOGFONTW) == 92, sizeof(LOGFONTW) assert alignment(LOGFONTW) == 4, alignment(LOGFONTW)
('tmPitchAndFamily', BYTE),
('tmCharSet', BYTE),
]
assert sizeof(TEXTMETRICW) == 58, sizeof(TEXTMETRICW)
assert alignment(TEXTMETRICW) == 2, alignment(TEXTMETRICW)
('lfMessageFont', LOGFONTW),
]
assert sizeof(NONCLIENTMETRICSW) == 500, sizeof(NONCLIENTMETRICSW)
assert alignment(NONCLIENTMETRICSW) == 2, alignment(NONCLIENTMETRICSW)
('lbColor', COLORREF),
('lbHatch', LONG),
]
assert sizeof(LOGBRUSH) == 12, sizeof(LOGBRUSH)
assert alignment(LOGBRUSH) == 4, alignment(LOGBRUSH)
# C:/PROGRA~1/MIAF9D~1/VC98/Include/winuser.h 5147
('dwTypeData', c_wchar_p), #LPWSTR),
('cch', UINT),
]
assert sizeof(MENUITEMINFOW) == 44, sizeof(MENUITEMINFOW)
assert alignment(MENUITEMINFOW) == 2, alignment(MENUITEMINFOW)
class MENUBARINFO(Structure):
('pt', POINT),
]
assert sizeof(MSG) == 28, sizeof(MSG)
assert alignment(MSG) == 4, alignment(MSG)
('lpszText', c_long),#LPWSTR),
('lParam', LPARAM),
]
assert sizeof(TOOLINFOW) == 44, sizeof(TOOLINFOW)
assert alignment(TOOLINFOW) == 1, alignment(TOOLINFOW)
('lParam', LPARAM),
]
assert sizeof(NMTTDISPINFOW) == 188, sizeof(NMTTDISPINFOW)
assert alignment(NMTTDISPINFOW) == 1, alignment(NMTTDISPINFOW)
('iImage', c_int),
('iOrder', c_int),
]
assert sizeof(HDITEMW) == 36, sizeof(HDITEMW)
assert alignment(HDITEMW) == 1, alignment(HDITEMW)
('iIndent', c_int),
('lParam', LPARAM),
]
assert sizeof(COMBOBOXEXITEMW) == 36, sizeof(COMBOBOXEXITEMW)
assert alignment(COMBOBOXEXITEMW) == 1, alignment(COMBOBOXEXITEMW)
('iImage', c_int),
]
assert sizeof(TCITEMHEADERW) == 24, sizeof(TCITEMHEADERW)
assert alignment(TCITEMHEADERW) == 1, alignment(TCITEMHEADERW)
# C:/PROGRA~1/MICROS~4/VC98/Include/commctrl.h 4804
('iImage', c_int),
('lParam', LPARAM),
]
assert sizeof(TCITEMW) == 28, sizeof(TCITEMW)
assert alignment(TCITEMW) == 1, alignment(TCITEMW)
('pszText', LPWSTR),
('cchText', c_int),
]
assert sizeof(TBBUTTONINFOW) == 32, sizeof(TBBUTTONINFOW)
assert alignment(TBBUTTONINFOW) == 1, alignment(TBBUTTONINFOW)
# C:/PROGRA~1/MICROS~4/VC98/Include/commctrl.h 953
('dwData', DWORD),
('iString', c_int),
]
assert sizeof(TBBUTTON) == 20, sizeof(TBBUTTON)
assert alignment(TBBUTTON) == 1, alignment(TBBUTTON)
('lParam', LPARAM),
('cxHeader', UINT),
]
assert sizeof(REBARBANDINFOW) == 80, sizeof(REBARBANDINFOW)
assert alignment(REBARBANDINFOW) == 1, alignment(REBARBANDINFOW)
('lpSecurityDescriptor', LPVOID),
('bInheritHandle', BOOL),
]
assert sizeof(SECURITY_ATTRIBUTES) == 12, sizeof(SECURITY_ATTRIBUTES)
assert alignment(SECURITY_ATTRIBUTES) == 4, alignment(SECURITY_ATTRIBUTES)
# C:/PROGRA~1/MICROS~4/VC98/Include/winbase.h 3794
('hStdOutput', HANDLE),
('hStdError', HANDLE),
]
assert sizeof(STARTUPINFOW) == 68, sizeof(STARTUPINFOW)
assert alignment(STARTUPINFOW) == 4, alignment(STARTUPINFOW)
# C:/PROGRA~1/MICROS~4/VC98/Include/winbase.h 229
('dwProcessId', DWORD),
('dwThreadId', DWORD),
]
assert sizeof(PROCESS_INFORMATION) == 16, sizeof(PROCESS_INFORMATION)
assert alignment(PROCESS_INFORMATION) == 4, alignment(PROCESS_INFORMATION)
('ptAction', POINT),
('lParam', LPARAM),
]
assert sizeof(NMLISTVIEW) == 44, sizeof(NMLISTVIEW)
assert alignment(NMLISTVIEW) == 1, alignment(NMLISTVIEW)
('pt', POINT),
('dwHitInfo', DWORD),
]
assert sizeof(NMMOUSE) == 32, sizeof(NMMOUSE)
assert alignment(NMMOUSE) == 1, alignment(NMMOUSE)
('time', DWORD),
('dwExtraInfo', DWORD),
]
assert sizeof(MOUSEINPUT) == 24, sizeof(MOUSEINPUT)
assert alignment(MOUSEINPUT) == 2, alignment(MOUSEINPUT)
# C:/PROGRA~1/MICROS~4/VC98/Include/winuser.h 4292
('time', DWORD),
('dwExtraInfo', DWORD),
]
assert sizeof(KEYBDINPUT) == 16, sizeof(KEYBDINPUT)
assert alignment(KEYBDINPUT) == 2, alignment(KEYBDINPUT)
('wParamL', WORD),
('wParamH', WORD),
]
assert sizeof(HARDWAREINPUT) == 8, sizeof(HARDWAREINPUT)
assert alignment(HARDWAREINPUT) == 2, alignment(HARDWAREINPUT)
('ki', KEYBDINPUT),
('hi', HARDWAREINPUT),
]
assert sizeof(UNION_INPUT_STRUCTS) == 24, sizeof(UNION_INPUT_STRUCTS)
assert alignment(UNION_INPUT_STRUCTS) == 2, alignment(UNION_INPUT_STRUCTS)
# C:/PROGRA~1/MICROS~4/VC98/Include/winuser.h 4310
# Unnamed field renamed to '_'
('_', UNION_INPUT_STRUCTS),
]
assert sizeof(INPUT) == 28, sizeof(INPUT)
assert alignment(INPUT) == 2, alignment(INPUT)
('iPos', c_int),
('iDelta', c_int),
]
assert sizeof(NMUPDOWN) == 20, sizeof(NMUPDOWN)
assert alignment(NMUPDOWN) == 1, alignment(NMUPDOWN)
('hwndCaret', HWND),
('rcCaret', RECT),
]
assert sizeof(GUITHREADINFO) == 48, sizeof(GUITHREADINFO)
assert alignment(GUITHREADINFO) == 2, alignment(GUITHREADINFO)
('dwContextHelpID', DWORD),
('dwMenuData', DWORD),
]
assert sizeof(MENUINFO) == 28, sizeof(MENUINFO)
assert alignment(MENUINFO) == 2, alignment(MENUINFO)
('uFlags', UINT),
('lParam', LPARAM),
]
assert sizeof(NMTTDISPINFOW) == 188, sizeof(NMTTDISPINFOW)
assert alignment(NMTTDISPINFOW) == 1, alignment(NMTTDISPINFOW)
('ptMaxPosition', POINT),
('rcNormalPosition', RECT),
]
assert sizeof(WINDOWPLACEMENT) == 44, sizeof(WINDOWPLACEMENT)
assert alignment(WINDOWPLACEMENT) == 4, alignment(WINDOWPLACEMENT)
('flags', UINT),
('hItem', HTREEITEM),
]
assert sizeof(TVHITTESTINFO) == 16, sizeof(TVHITTESTINFO)
assert alignment(TVHITTESTINFO) == 1, alignment(TVHITTESTINFO)
src/p/y/python-ptrace-0.6.2/ptrace/pydistorm.py python-ptrace(Download)
Python binding of diStorm64 library written by Victor Stinner
"""
from ctypes import cdll, c_long, c_ulong, c_int, c_uint, c_char, POINTER, Structure, addressof, byref, c_void_p, create_string_buffer, sizeof, cast
# Define (u)int32_t and (u)int64_t types
int32_t = c_int
uint32_t = c_uint
if sizeof(c_ulong) == 8:
int64_t = c_long
uint64_t = c_ulong
else:
from ctypes import c_longlong, c_ulonglong
assert sizeof(c_longlong) == 8
else:
from ctypes import c_longlong, c_ulonglong
assert sizeof(c_longlong) == 8
assert sizeof(c_ulonglong) == 8
int64_t = c_longlong
uint64_t = c_ulonglong
# Allocate memory for decoder
code_buffer = create_string_buffer(code)
decodedInstructionsCount = c_uint()
result = create_string_buffer(sizeof(_DecodedInst)*MAX_INSTRUCTIONS)
# Prepare arguments
codeLen = len(code)
src/q/t/qtaste-HEAD/demo/pywinauto-0.3.8/pywinauto/win32structures.py qtaste(Download)
from win32defines import LF_FACESIZE, NMTTDISPINFOW_V1_SIZE, HDITEMW_V1_SIZE
import ctypes
from ctypes import \
c_int, c_uint, c_long, c_ulong, c_void_p, c_wchar, c_char, \
c_ubyte, c_ushort, c_wchar_p, \
POINTER, sizeof, alignment, Union
('x', LONG),
('y', LONG),
]
assert sizeof(POINT) == 8, sizeof(POINT)
assert alignment(POINT) == 4, alignment(POINT)
RECT.__reduce__ = _reduce assert sizeof(RECT) == 16, sizeof(RECT) assert alignment(RECT) == 4, alignment(RECT)
('lParam', LPARAM),
('iIndent', c_int),
]
assert sizeof(LVITEMW) == 40, sizeof(LVITEMW)
assert alignment(LVITEMW) == 1, alignment(LVITEMW)
('cChildren', c_int),
('lParam', LPARAM),
]
assert sizeof(TVITEMW) == 40, sizeof(TVITEMW)
assert alignment(TVITEMW) == 1, alignment(TVITEMW)
('idFrom', UINT),
('code', UINT),
]
assert sizeof(NMHDR) == 12, sizeof(NMHDR)
assert alignment(NMHDR) == 4, alignment(NMHDR)
('hdr', NMHDR),
('item', TVITEMW),
]
assert sizeof(NMTVDISPINFOW) == 52, sizeof(NMTVDISPINFOW)
assert alignment(NMTVDISPINFOW) == 1, alignment(NMTVDISPINFOW)
LOGFONTW.__reduce__ = _reduce assert sizeof(LOGFONTW) == 92, sizeof(LOGFONTW) assert alignment(LOGFONTW) == 4, alignment(LOGFONTW)
('tmPitchAndFamily', BYTE),
('tmCharSet', BYTE),
]
assert sizeof(TEXTMETRICW) == 58, sizeof(TEXTMETRICW)
assert alignment(TEXTMETRICW) == 2, alignment(TEXTMETRICW)
('lfMessageFont', LOGFONTW),
]
assert sizeof(NONCLIENTMETRICSW) == 500, sizeof(NONCLIENTMETRICSW)
assert alignment(NONCLIENTMETRICSW) == 2, alignment(NONCLIENTMETRICSW)
('lbColor', COLORREF),
('lbHatch', LONG),
]
assert sizeof(LOGBRUSH) == 12, sizeof(LOGBRUSH)
assert alignment(LOGBRUSH) == 4, alignment(LOGBRUSH)
# C:/PROGRA~1/MIAF9D~1/VC98/Include/winuser.h 5147
('dwTypeData', c_wchar_p), #LPWSTR),
('cch', UINT),
]
assert sizeof(MENUITEMINFOW) == 44, sizeof(MENUITEMINFOW)
assert alignment(MENUITEMINFOW) == 2, alignment(MENUITEMINFOW)
class MENUBARINFO(Structure):
('pt', POINT),
]
assert sizeof(MSG) == 28, sizeof(MSG)
assert alignment(MSG) == 4, alignment(MSG)
('lpszText', c_long),#LPWSTR),
('lParam', LPARAM),
]
assert sizeof(TOOLINFOW) == 44, sizeof(TOOLINFOW)
assert alignment(TOOLINFOW) == 1, alignment(TOOLINFOW)
('lParam', LPARAM),
]
assert sizeof(NMTTDISPINFOW) == 188, sizeof(NMTTDISPINFOW)
assert alignment(NMTTDISPINFOW) == 1, alignment(NMTTDISPINFOW)
('iImage', c_int),
('iOrder', c_int),
]
assert sizeof(HDITEMW) == 36, sizeof(HDITEMW)
assert alignment(HDITEMW) == 1, alignment(HDITEMW)
('iIndent', c_int),
('lParam', LPARAM),
]
assert sizeof(COMBOBOXEXITEMW) == 36, sizeof(COMBOBOXEXITEMW)
assert alignment(COMBOBOXEXITEMW) == 1, alignment(COMBOBOXEXITEMW)
('iImage', c_int),
]
assert sizeof(TCITEMHEADERW) == 24, sizeof(TCITEMHEADERW)
assert alignment(TCITEMHEADERW) == 1, alignment(TCITEMHEADERW)
# C:/PROGRA~1/MICROS~4/VC98/Include/commctrl.h 4804
('iImage', c_int),
('lParam', LPARAM),
]
assert sizeof(TCITEMW) == 28, sizeof(TCITEMW)
assert alignment(TCITEMW) == 1, alignment(TCITEMW)
('pszText', LPWSTR),
('cchText', c_int),
]
assert sizeof(TBBUTTONINFOW) == 32, sizeof(TBBUTTONINFOW)
assert alignment(TBBUTTONINFOW) == 1, alignment(TBBUTTONINFOW)
# C:/PROGRA~1/MICROS~4/VC98/Include/commctrl.h 953
('dwData', DWORD),
('iString', c_int),
]
assert sizeof(TBBUTTON) == 20, sizeof(TBBUTTON)
assert alignment(TBBUTTON) == 1, alignment(TBBUTTON)
('lParam', LPARAM),
('cxHeader', UINT),
]
assert sizeof(REBARBANDINFOW) == 80, sizeof(REBARBANDINFOW)
assert alignment(REBARBANDINFOW) == 1, alignment(REBARBANDINFOW)
('lpSecurityDescriptor', LPVOID),
('bInheritHandle', BOOL),
]
assert sizeof(SECURITY_ATTRIBUTES) == 12, sizeof(SECURITY_ATTRIBUTES)
assert alignment(SECURITY_ATTRIBUTES) == 4, alignment(SECURITY_ATTRIBUTES)
# C:/PROGRA~1/MICROS~4/VC98/Include/winbase.h 3794
('hStdOutput', HANDLE),
('hStdError', HANDLE),
]
assert sizeof(STARTUPINFOW) == 68, sizeof(STARTUPINFOW)
assert alignment(STARTUPINFOW) == 4, alignment(STARTUPINFOW)
# C:/PROGRA~1/MICROS~4/VC98/Include/winbase.h 229
('dwProcessId', DWORD),
('dwThreadId', DWORD),
]
assert sizeof(PROCESS_INFORMATION) == 16, sizeof(PROCESS_INFORMATION)
assert alignment(PROCESS_INFORMATION) == 4, alignment(PROCESS_INFORMATION)
('ptAction', POINT),
('lParam', LPARAM),
]
assert sizeof(NMLISTVIEW) == 44, sizeof(NMLISTVIEW)
assert alignment(NMLISTVIEW) == 1, alignment(NMLISTVIEW)
('pt', POINT),
('dwHitInfo', DWORD),
]
assert sizeof(NMMOUSE) == 32, sizeof(NMMOUSE)
assert alignment(NMMOUSE) == 1, alignment(NMMOUSE)
('time', DWORD),
('dwExtraInfo', DWORD),
]
assert sizeof(MOUSEINPUT) == 24, sizeof(MOUSEINPUT)
assert alignment(MOUSEINPUT) == 2, alignment(MOUSEINPUT)
# C:/PROGRA~1/MICROS~4/VC98/Include/winuser.h 4292
('time', DWORD),
('dwExtraInfo', DWORD),
]
assert sizeof(KEYBDINPUT) == 16, sizeof(KEYBDINPUT)
assert alignment(KEYBDINPUT) == 2, alignment(KEYBDINPUT)
('wParamL', WORD),
('wParamH', WORD),
]
assert sizeof(HARDWAREINPUT) == 8, sizeof(HARDWAREINPUT)
assert alignment(HARDWAREINPUT) == 2, alignment(HARDWAREINPUT)
('ki', KEYBDINPUT),
('hi', HARDWAREINPUT),
]
assert sizeof(UNION_INPUT_STRUCTS) == 24, sizeof(UNION_INPUT_STRUCTS)
assert alignment(UNION_INPUT_STRUCTS) == 2, alignment(UNION_INPUT_STRUCTS)
# C:/PROGRA~1/MICROS~4/VC98/Include/winuser.h 4310
# Unnamed field renamed to '_'
('_', UNION_INPUT_STRUCTS),
]
assert sizeof(INPUT) == 28, sizeof(INPUT)
assert alignment(INPUT) == 2, alignment(INPUT)
('iPos', c_int),
('iDelta', c_int),
]
assert sizeof(NMUPDOWN) == 20, sizeof(NMUPDOWN)
assert alignment(NMUPDOWN) == 1, alignment(NMUPDOWN)
('hwndCaret', HWND),
('rcCaret', RECT),
]
assert sizeof(GUITHREADINFO) == 48, sizeof(GUITHREADINFO)
assert alignment(GUITHREADINFO) == 2, alignment(GUITHREADINFO)
('dwContextHelpID', DWORD),
('dwMenuData', DWORD),
]
assert sizeof(MENUINFO) == 28, sizeof(MENUINFO)
assert alignment(MENUINFO) == 2, alignment(MENUINFO)
('uFlags', UINT),
('lParam', LPARAM),
]
assert sizeof(NMTTDISPINFOW) == 188, sizeof(NMTTDISPINFOW)
assert alignment(NMTTDISPINFOW) == 1, alignment(NMTTDISPINFOW)
('ptMaxPosition', POINT),
('rcNormalPosition', RECT),
]
assert sizeof(WINDOWPLACEMENT) == 44, sizeof(WINDOWPLACEMENT)
assert alignment(WINDOWPLACEMENT) == 4, alignment(WINDOWPLACEMENT)
('flags', UINT),
('hItem', HTREEITEM),
]
assert sizeof(TVHITTESTINFO) == 16, sizeof(TVHITTESTINFO)
assert alignment(TVHITTESTINFO) == 1, alignment(TVHITTESTINFO)
src/p/y/python-ptrace-0.6.2/ptrace/ctypes_stdint.py python-ptrace(Download)
- uint64_t
"""
from ctypes import sizeof, \
c_byte, c_ubyte, \
c_short, c_ushort, \
c_int, c_uint, \
int8_t = c_byte # 16-bit integers assert sizeof(c_short) == 2 assert sizeof(c_ushort) == 2 int16_t = c_short uint16_t = c_ushort # 32-bit integers assert sizeof(c_int) == 4 assert sizeof(c_uint) == 4
uint32_t = c_uint
# 64-bit integers
if sizeof(c_long) == 8:
int64_t = c_long
else:
assert sizeof(c_longlong) == 8
int64_t = c_longlong
if sizeof(c_ulong) == 8:
uint64_t = c_ulong
else:
assert sizeof(c_ulonglong) == 8
src/p/y/pynetfilter_conntrack-0.4.2/pynetfilter_conntrack/ctypes_stdint.py pynetfilter_conntrack(Download)
from ctypes import sizeof, \
c_byte, c_ubyte, \
c_short, c_ushort, \
c_int, c_uint, \
c_long, c_ulong, \
c_longlong, c_ulonglong
int8_t = c_byte # 16-bit integers assert sizeof(c_short) == 2 assert sizeof(c_ushort) == 2 int16_t = c_short uint16_t = c_ushort # 32-bit integers assert sizeof(c_int) == 4 assert sizeof(c_uint) == 4
uint32_t = c_uint
# 64-bit integers
if sizeof(c_long) == 8:
int64_t = c_long
else:
assert sizeof(c_longlong) == 8
int64_t = c_longlong
if sizeof(c_ulong) == 8:
uint64_t = c_ulong
else:
assert sizeof(c_ulonglong) == 8
src/c/o/cogen-0.2.1/cogen/core/proactors/ctypes_iocp_impl/api_wrappers.py cogen(Download)
from ctypes import WINFUNCTYPE, GetLastError, \
windll, pythonapi, cast, WinError, create_string_buffer, \
c_ushort, c_ubyte, c_char, WINFUNCTYPE, c_short, c_ubyte, \
c_int, c_uint, c_long, c_ulong, c_void_p, byref, c_char_p, \
Structure, Union, py_object, POINTER, pointer, sizeof, string_at
from ctypes.wintypes import HANDLE, ULONG, DWORD, BOOL, LPCSTR, LPCWSTR, WinError
('sa_data', c_char * 14)
]
ACCEPT_BUFF_SZ = 2*sizeof(sockaddr)
class in_addr(Structure):
_fields_ = [
def _GetConnectExPtr(given_socket=None):
from socket import socket
bogus_sock = given_socket or socket()
bogus_bytes = DWORD()
ConnectEx = ConnectExType(0)
ret = WSAIoctl(
bogus_sock.fileno(), SIO_GET_EXTENSION_FUNCTION_POINTER, byref(WSAID_CONNECTEX), sizeof(WSAID_CONNECTEX),
byref(ConnectEx), sizeof(ConnectEx), byref(bogus_bytes), None, None
def _GetTransmitFilePtr(given_socket=None):
from socket import socket
bogus_sock = given_socket or socket()
bogus_bytes = DWORD()
TransmitFile = TransmitFileType(0)
ret = WSAIoctl(
bogus_sock.fileno(), SIO_GET_EXTENSION_FUNCTION_POINTER, byref(WSAID_TRANSMITFILE), sizeof(WSAID_TRANSMITFILE),
byref(TransmitFile), sizeof(TransmitFile), byref(bogus_bytes), None, None
src/p/y/python-libusb1-HEAD/usb1.py python-libusb1(Download)
"""
import libusb1
from ctypes import byref, create_string_buffer, c_int, sizeof, POINTER, \
create_unicode_buffer, c_wchar, cast, c_uint16, c_ubyte, string_at, \
addressof, c_void_p
from cStringIO import StringIO
raise ValueError('Cannot alter a submitted transfer')
string_buffer = create_binary_buffer(buffer_or_len)
libusb1.libusb_fill_bulk_transfer(self.__transfer, self.__handle,
endpoint, string_buffer, sizeof(string_buffer),
self.__ctypesCallbackWrapper, user_data, timeout)
self.__callback = callback
self.__initialized = True
raise ValueError('Cannot alter a submitted transfer')
string_buffer = create_binary_buffer(buffer_or_len)
libusb1.libusb_fill_interrupt_transfer(self.__transfer, self.__handle,
endpoint, string_buffer, sizeof(string_buffer),
self.__ctypesCallbackWrapper, user_data, timeout)
self.__callback = callback
self.__initialized = True
'setControl')
buff = create_binary_buffer(buffer_or_len)
transfer.buffer = cast(buff, c_void_p)
transfer.length = sizeof(buff)
def isSubmitted(self):
"""
"""
descriptor_string = create_string_buffer(STRING_LENGTH)
result = libusb1.libusb_get_string_descriptor(self.__handle,
0, 0, descriptor_string, sizeof(descriptor_string))
if result < 0:
if result == libusb1.LIBUSB_ERROR_PIPE:
# From libusb_control_transfer doc:
Return None if there is no such descriptor on device.
"""
descriptor_string = create_unicode_buffer(
STRING_LENGTH / sizeof(c_wchar))
result = libusb1.libusb_get_string_descriptor(self.__handle,
descriptor, lang_id, descriptor_string, sizeof(descriptor_string))
if result == libusb1.LIBUSB_ERROR_NOT_FOUND:
"""
descriptor_string = create_string_buffer(STRING_LENGTH)
result = libusb1.libusb_get_string_descriptor_ascii(self.__handle,
descriptor, descriptor_string, sizeof(descriptor_string))
if result == libusb1.LIBUSB_ERROR_NOT_FOUND:
return None
if result < 0:
src/p/y/pywinusb-0.2.4/pywinusb/hid/core.py pywinusb(Download)
import threading import time from ctypes import c_ubyte, c_ulong, c_ushort, c_wchar, byref, sizeof #local modules from winapi import *
try:
# retrieve all the available interface information.
device_interface = SP_DEVICE_INTERFACE_DATA()
device_interface.cb_size = sizeof(device_interface)
dev_inter_detail_data = SP_DEVICE_INTERFACE_DETAIL_DATA()
dev_inter_detail_data.cb_size = sizeof(dev_inter_detail_data) - \
(sizeof(c_tchar)*(MAX_SP_DEV_INTERF_DETAIL_SIZE-1))
required_size.value = 0
SetupDiGetDeviceInterfaceDetail(h_info, byref(device_interface),
None, 0, byref(required_size), None)
if required_size.value > sizeof(dev_inter_detail_data):
sys.stderr.write("Error getting HID device info.\n")
continue
try:
# retrieve all the available interface information.
dev_interface_data = SP_DEVICE_INTERFACE_DATA()
dev_interface_data.cb_size = sizeof(dev_interface_data)
dev_inter_detail_data = SP_DEVICE_INTERFACE_DETAIL_DATA()
dev_inter_detail_data.cb_size = sizeof(dev_inter_detail_data) - \
(sizeof(c_tchar)*(MAX_SP_DEV_INTERF_DETAIL_SIZE-1))
dev_info_data = SP_DEVINFO_DATA()
dev_info_data.cb_size = sizeof(dev_info_data)
required_size.value = 0
SetupDiGetDeviceInterfaceDetail(h_info, byref(dev_interface_data),
None, 0, byref(required_size), None)
if required_size.value > sizeof(dev_inter_detail_data):
sys.stderr.write("Error getting HID device info.\n")
continue
try:
# get device attributes
hidd_attributes = HIDD_ATTRIBUTES()
hidd_attributes.cb_size = sizeof(hidd_attributes)
if not hid_dll.HidD_GetAttributes(int(h_hid),
byref(hidd_attributes) ):
return #can't read attributes
vendor_name = vendor_string_type()
if not hid_dll.HidD_GetManufacturerString(int(h_hid),
byref(vendor_name),
sizeof(vendor_name)) or not len(vendor_name.value):
# would be any possibility to get a vendor id table?,
# maybe not worth it
self.vendor_name = "Unknown manufacturer"
product_name = product_name_type()
if not hid_dll.HidD_GetProductString(int(h_hid),
byref(product_name),
sizeof(product_name)) or not len(product_name.value):
# alternate methode, refer to windows registry for product
# information
path_parts = device_path[len("\\\\.\\"):].split("#")
#reduce the spare buffers queue
empty_report = self.used_queue.pop(0)
self.used_lock.release()
ctypes.memset(empty_report, 0, sizeof(empty_report))
else:
self.used_lock.release()
#create brand new storage
src/a/s/assimp-HEAD/port/PyAssimp/pyassimp/pyassimp.py assimp(Download)
def aiGetMaterialFloatArray(material, key):
AI_SUCCESS = 0
from ctypes import byref, pointer, cast, c_float, POINTER, sizeof, c_uint
out = structs.Color4D()
max = c_uint(sizeof(structs.Color4D))
r=_assimp_lib.dll.aiGetMaterialFloatArray(pointer(material),
key[0],
def aiGetMaterialString(material, key):
AI_SUCCESS = 0
from ctypes import byref, pointer, cast, c_float, POINTER, sizeof, c_uint
out = structs.String()
r=_assimp_lib.dll.aiGetMaterialString(pointer(material),
key[0],
key[1],
key = p.mKey.data
#the data
from ctypes import POINTER, cast, c_int, c_float, sizeof
if p.mType == 1:
arr = cast(p.mData, POINTER(c_float*(p.mDataLength/sizeof(c_float)) )).contents
value = [x for x in arr]
src/e/v/eventghost-HEAD/trunk/plugins/PS3/__init__.py eventghost(Download)
import wx.lib.mixins.listctrl as listmix from ctypes import Structure, Union, c_byte, c_ubyte, c_char, c_int, c_long, c_ulong, c_ushort, c_wchar from ctypes import pointer, byref, sizeof, POINTER from ctypes.wintypes import ULONG, BOOLEAN, BOOL class Ps3Remote:
#prepare Interfacedata
interfaceInfo = SP_DEVICE_INTERFACE_DATA()
interfaceInfo.cbSize = sizeof(interfaceInfo)
#prepare InterfaceDetailData Structure
interfaceDetailData = SP_DEVICE_INTERFACE_DETAIL_DATA_A()
interfaceDetailData.cbSize = 5
#prepare HIDD_ATTRIBUTES
hiddAttributes = HIDD_ATTRIBUTES()
hiddAttributes.cbSize = sizeof(hiddAttributes)
#getting manufacturer
result = hidDLL.HidD_GetManufacturerString(
int(hidHandle), byref(infoStr), ctypes.sizeof(infoStr))
if not result or len(infoStr.value) == 0:
#build a generic ManufacturerString with the vendor ID
device[VENDOR_STRING] = self.text.vendorID + str(hiddAttributes.VendorID)
else:
device[VENDOR_STRING] = infoStr.value
#getting device name
result = hidDLL.HidD_GetProductString(
int(hidHandle), byref(infoStr), ctypes.sizeof(infoStr))
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 Next