All Samples(777) | Call(709) | Derive(0) | Import(68)
create_string_buffer(aString) -> character array create_string_buffer(anInteger) -> character array create_string_buffer(aString, anInteger) -> character array
def create_string_buffer(init, size=None):
"""create_string_buffer(aString) -> character array
create_string_buffer(anInteger) -> character array
create_string_buffer(aString, anInteger) -> character array
"""
if isinstance(init, (str, unicode)):
if size is None:
size = len(init)+1
buftype = c_char * size
buf = buftype()
buf.value = init
return buf
elif isinstance(init, (int, long)):
buftype = c_char * init
buf = buftype()
return buf
raise TypeError(init)
#FIXME: stop using POINTER(GLchar) except for buffer construction? #FIXME: possible if c_str(POINTER((GLchar * size)())) is valid from ctypes import c_char_p as c_str from ctypes import POINTER from ctypes import addressof from ctypes import create_string_buffer from ctypes import cast from ctypes import c_char_p as c_str
def _wrapped_get_info_log(self):
log_length = self.info_log_length
log = create_string_buffer('', log_length)
getter(self._object,
GLuint(log_length),
cast(NULL, POINTER(GLuint)),
c_str(addressof(log))
def _get_info(self, index):
namelen = GLsizei(0)
attrib_size = GLint(0)
type = GLenum(0)
name = create_string_buffer('', self._max_name_length())
src/c/y/cygwinreg-1.0/cygwinreg/w32api.py cygwinreg(Download)
from cygwinreg.constants import *
from ctypes import (addressof, byref, cast, pointer, POINTER, sizeof, Structure,
create_string_buffer,
c_char_p, c_long, c_ulong, c_ushort, c_void_p, c_wchar_p)
exception = ValueError("Could not convert the data to the specified type.")
if typ == REG_DWORD:
if value is None:
buf = create_string_buffer(pack('L', 0), sizeof(DWORD))
else:
buf = create_string_buffer(pack('L', value), sizeof(DWORD))
elif typ in (REG_SZ, REG_EXPAND_SZ):
if not isinstance(value, basestring):
raise ValueError("Value must be a string or a unicode object.")
if value is None:
value = u''
buf = create_string_buffer(utf16(value))
count += 1
result.append(utf16(u'')) # Terminate the list with an empty string
result = '\x00\x00'.join(result)
buf = create_string_buffer(result, len(result))
else:
# Handle REG_BINARY and ALSO handle ALL unknown data types
# here. Even if we can't support it natively, we should
# handle the bits.
if value is None:
buf = create_string_buffer(0)
try:
buf = buffer(value)
buf = create_string_buffer(str(buf), len(buf))
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
def create_binary_buffer(string_or_len):
# Prevent ctypes from adding a trailing null char.
if isinstance(string_or_len, basestring):
result = create_string_buffer(string_or_len, len(string_or_len))
else:
result = create_string_buffer(string_or_len)
return result
def getSupportedLanguageList(self):
"""
Return a list of USB language identifiers (as integers) supported by
current device for its string descriptors.
"""
descriptor_string = create_string_buffer(STRING_LENGTH)
result = libusb1.libusb_get_string_descriptor(self.__handle,
Return value is an ASCII string.
Return None if there is no such descriptor on device.
"""
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:
"""
request_type = (request_type & ~libusb1.USB_ENDPOINT_DIR_MASK) | \
libusb1.LIBUSB_ENDPOINT_OUT
data = create_string_buffer(data)
return self._controlTransfer(request_type, request, value, index, data,
len(data)-1, timeout)
"""
request_type = (request_type & ~libusb1.USB_ENDPOINT_DIR_MASK) | \
libusb1.LIBUSB_ENDPOINT_IN
data = create_string_buffer(length)
transferred = self._controlTransfer(request_type, request, value,
index, data, length, timeout)
return data.raw[:transferred]
"""
endpoint = (endpoint & ~libusb1.USB_ENDPOINT_DIR_MASK) | \
libusb1.LIBUSB_ENDPOINT_OUT
data = create_string_buffer(data)
return self._bulkTransfer(endpoint, data, len(data) - 1, timeout)
def bulkRead(self, endpoint, length, timeout=0):
"""
endpoint = (endpoint & ~libusb1.USB_ENDPOINT_DIR_MASK) | \
libusb1.LIBUSB_ENDPOINT_IN
data = create_string_buffer(length)
transferred = self._bulkTransfer(endpoint, data, length, timeout)
return data.raw[:transferred]
"""
endpoint = (endpoint & ~libusb1.USB_ENDPOINT_DIR_MASK) | \
libusb1.LIBUSB_ENDPOINT_OUT
data = create_string_buffer(data)
return self._interruptTransfer(endpoint, data, len(data) - 1, timeout)
def interruptRead(self, endpoint, length, timeout=0):
"""
endpoint = (endpoint & ~libusb1.USB_ENDPOINT_DIR_MASK) | \
libusb1.LIBUSB_ENDPOINT_IN
data = create_string_buffer(length)
transferred = self._interruptTransfer(endpoint, data, length, timeout)
return data.raw[:transferred]
src/p/y/pyvisa-HEAD/trunk/src/vpp43.py pyvisa(Download)
from vpp43_types import *
from vpp43_attributes import attributes
import os
from ctypes import byref, cdll, c_void_p, c_double, c_long, \
create_string_buffer, POINTER
if os.name == 'nt':
from ctypes import windll, WINFUNCTYPE as FUNCTYPE
for i in range(len(byvalue_arguments)):
if isinstance(byvalue_arguments[i], str):
byvalue_arguments[i] = \
create_string_buffer(byvalue_arguments[i],
max(len(byvalue_arguments[i]) + 1,
buffer_length))
converted_arguments.append(byvalue_arguments[i])
def buffer_read(vi, count):
buffer = create_string_buffer(count)
return_count = ViUInt32()
visa_library().viBufRead(vi, buffer, count, byref(return_count))
return buffer.raw[:return_count.value]
def buffer_write(vi, buffer):
def find_next(find_list):
instrument_description = create_string_buffer(VI_FIND_BUFLEN)
visa_library().viFindNext(find_list, instrument_description)
return instrument_description.value
def find_resources(session, regular_expression):
find_list = ViFindList()
return_counter = ViUInt32()
instrument_description = create_string_buffer(VI_FIND_BUFLEN)
def get_attribute(vi, attribute):
# FixMe: How to deal with ViBuf?
datatype = attributes[attribute]
if datatype == ViString:
attribute_state = create_string_buffer(256)
visa_library().viGetAttribute(vi, attribute, attribute_state)
elif datatype == ViAUInt8:
def lock(vi, lock_type, timeout, requested_key = None):
if lock_type == VI_EXCLUSIVE_LOCK:
requested_key = None
access_key = None
else:
access_key = create_string_buffer(256)
visa_library().viLock(vi, lock_type, timeout, requested_key, access_key)
def parse_resource_extended(session, resource_name):
interface_type = ViUInt16()
interface_board_number = ViUInt16()
resource_class = create_string_buffer(VI_FIND_BUFLEN)
unaliased_expanded_resource_name = create_string_buffer(VI_FIND_BUFLEN)
alias_if_exists = create_string_buffer(VI_FIND_BUFLEN)
visa_library().viParseRsrcEx(session, resource_name, byref(interface_type),
def read(vi, count):
buffer = create_string_buffer(count)
return_count = ViUInt32()
visa_library().viRead(vi, buffer, count, byref(return_count))
return buffer.raw[:return_count.value]
def read_asynchronously(vi, count):
buffer = create_string_buffer(count)
def sprintf(vi, write_format, *args, **keyw):
buffer = create_string_buffer(keyw.get("buffer_length", 1024))
visa_library(force_cdecl=True).viSPrintf(vi, buffer, write_format,
*convert_argument_list(args))
return buffer.raw
def sscanf(vi, buffer, read_format, *args, **keyw):
def status_description(vi, status):
description = create_string_buffer(256)
visa_library().viStatusDesc(vi, status, description)
return description.value
def terminate(vi, degree, job_id):
visa_library().viTerminate(vi, degree, job_id)
def usb_control_in(vi, request_type_bitmap_field, request_id, request_value,
index, length = 0):
buffer = create_string_buffer(length)
return_count = ViUInt16()
visa_library().viUsbControlIn(vi, request_type_bitmap_field, request_id,
request_value, index, length, buffer,
byref(return_count))
src/p/y/pyvisa-HEAD/src/vpp43.py pyvisa(Download)
from vpp43_types import *
from vpp43_attributes import attributes
import os
from ctypes import byref, cdll, c_void_p, c_double, c_long, \
create_string_buffer, POINTER
if os.name == 'nt':
from ctypes import windll, WINFUNCTYPE as FUNCTYPE
for i in range(len(byvalue_arguments)):
if isinstance(byvalue_arguments[i], str):
byvalue_arguments[i] = \
create_string_buffer(byvalue_arguments[i],
max(len(byvalue_arguments[i]) + 1,
buffer_length))
converted_arguments.append(byvalue_arguments[i])
def buffer_read(vi, count):
buffer = create_string_buffer(count)
return_count = ViUInt32()
visa_library().viBufRead(vi, buffer, count, byref(return_count))
return buffer.raw[:return_count.value]
def buffer_write(vi, buffer):
def find_next(find_list):
instrument_description = create_string_buffer(VI_FIND_BUFLEN)
visa_library().viFindNext(find_list, instrument_description)
return instrument_description.value
def find_resources(session, regular_expression):
find_list = ViFindList()
return_counter = ViUInt32()
instrument_description = create_string_buffer(VI_FIND_BUFLEN)
def get_attribute(vi, attribute):
# FixMe: How to deal with ViBuf?
datatype = attributes[attribute]
if datatype == ViString:
attribute_state = create_string_buffer(256)
visa_library().viGetAttribute(vi, attribute, attribute_state)
elif datatype == ViAUInt8:
def lock(vi, lock_type, timeout, requested_key = None):
if lock_type == VI_EXCLUSIVE_LOCK:
requested_key = None
access_key = None
else:
access_key = create_string_buffer(256)
visa_library().viLock(vi, lock_type, timeout, requested_key, access_key)
def parse_resource_extended(session, resource_name):
interface_type = ViUInt16()
interface_board_number = ViUInt16()
resource_class = create_string_buffer(VI_FIND_BUFLEN)
unaliased_expanded_resource_name = create_string_buffer(VI_FIND_BUFLEN)
alias_if_exists = create_string_buffer(VI_FIND_BUFLEN)
visa_library().viParseRsrcEx(session, resource_name, byref(interface_type),
def read(vi, count):
buffer = create_string_buffer(count)
return_count = ViUInt32()
visa_library().viRead(vi, buffer, count, byref(return_count))
return buffer.raw[:return_count.value]
def read_asynchronously(vi, count):
buffer = create_string_buffer(count)
def sprintf(vi, write_format, *args, **keyw):
buffer = create_string_buffer(keyw.get("buffer_length", 1024))
visa_library(force_cdecl=True).viSPrintf(vi, buffer, write_format,
*convert_argument_list(args))
return buffer.raw
def sscanf(vi, buffer, read_format, *args, **keyw):
def status_description(vi, status):
description = create_string_buffer(256)
visa_library().viStatusDesc(vi, status, description)
return description.value
def terminate(vi, degree, job_id):
visa_library().viTerminate(vi, degree, job_id)
def usb_control_in(vi, request_type_bitmap_field, request_id, request_value,
index, length = 0):
buffer = create_string_buffer(length)
return_count = ViUInt16()
visa_library().viUsbControlIn(vi, request_type_bitmap_field, request_id,
request_value, index, length, buffer,
byref(return_count))
src/p/y/PyVISA-1.3/src/vpp43.py PyVISA(Download)
from vpp43_types import *
from vpp43_attributes import attributes
import os
from ctypes import byref, cdll, c_void_p, c_double, c_long, \
create_string_buffer, POINTER
if os.name == 'nt':
from ctypes import windll, WINFUNCTYPE as FUNCTYPE
for i in range(len(byvalue_arguments)):
if isinstance(byvalue_arguments[i], str):
byvalue_arguments[i] = \
create_string_buffer(byvalue_arguments[i],
max(len(byvalue_arguments[i]) + 1,
buffer_length))
converted_arguments.append(byvalue_arguments[i])
def buffer_read(vi, count):
buffer = create_string_buffer(count)
return_count = ViUInt32()
visa_library().viBufRead(vi, buffer, count, byref(return_count))
return buffer.raw[:return_count.value]
def buffer_write(vi, buffer):
def find_next(find_list):
instrument_description = create_string_buffer(VI_FIND_BUFLEN)
visa_library().viFindNext(find_list, instrument_description)
return instrument_description.value
def find_resources(session, regular_expression):
find_list = ViFindList()
return_counter = ViUInt32()
instrument_description = create_string_buffer(VI_FIND_BUFLEN)
def get_attribute(vi, attribute):
# FixMe: How to deal with ViBuf?
datatype = attributes[attribute]
if datatype == ViString:
attribute_state = create_string_buffer(256)
visa_library().viGetAttribute(vi, attribute, attribute_state)
elif datatype == ViAUInt8:
def lock(vi, lock_type, timeout, requested_key = None):
if lock_type == VI_EXCLUSIVE_LOCK:
requested_key = None
access_key = None
else:
access_key = create_string_buffer(256)
visa_library().viLock(vi, lock_type, timeout, requested_key, access_key)
def parse_resource_extended(session, resource_name):
interface_type = ViUInt16()
interface_board_number = ViUInt16()
resource_class = create_string_buffer(VI_FIND_BUFLEN)
unaliased_expanded_resource_name = create_string_buffer(VI_FIND_BUFLEN)
alias_if_exists = create_string_buffer(VI_FIND_BUFLEN)
visa_library().viParseRsrcEx(session, resource_name, byref(interface_type),
def read(vi, count):
buffer = create_string_buffer(count)
return_count = ViUInt32()
visa_library().viRead(vi, buffer, count, byref(return_count))
return buffer.raw[:return_count.value]
def read_asynchronously(vi, count):
buffer = create_string_buffer(count)
def sprintf(vi, write_format, *args, **keyw):
buffer = create_string_buffer(keyw.get("buffer_length", 1024))
visa_library(force_cdecl=True).viSPrintf(vi, buffer, write_format,
*convert_argument_list(args))
return buffer.raw
def sscanf(vi, buffer, read_format, *args, **keyw):
def status_description(vi, status):
description = create_string_buffer(256)
visa_library().viStatusDesc(vi, status, description)
return description.value
def terminate(vi, degree, job_id):
visa_library().viTerminate(vi, degree, job_id)
def usb_control_in(vi, request_type_bitmap_field, request_id, request_value,
index, length = 0):
buffer = create_string_buffer(length)
return_count = ViUInt16()
visa_library().viUsbControlIn(vi, request_type_bitmap_field, request_id,
request_value, index, length, buffer,
byref(return_count))
src/r/a/rapid-spring-0.4.3/rapid/unitsync/unitsync.py rapid-spring(Download)
import os, ctypes
from ctypes import c_bool, c_char, c_char_p, c_int, c_uint, c_float, Structure, create_string_buffer, cast, pointer
class StartPos(Structure):
_fields_ = [('x', c_int), ('y', c_int)]
def __str__(self):
return '(%i, %i)' % (self.x, self.y)
class MapInfo(Structure):
def __init__(self):
self.author = cast(create_string_buffer(200), c_char_p) # BUG: author field shows up as empty, probably something to do with the fact it's after the startpos structs
self.description = cast(create_string_buffer(255), c_char_p)
src/u/n/unladen-swallow-HEAD/Lib/urllib.py unladen-swallow(Download)
def _CStringFromCFString(sc, value):
from ctypes import create_string_buffer
length = sc.CFStringGetLength(value) + 1
buff = create_string_buffer(length)
sc.CFStringGetCString(value, buff, length, 0)
return buff.value
src/p/y/python2.6-HEAD/Lib/urllib.py python2.6(Download)
def _CStringFromCFString(sc, value):
from ctypes import create_string_buffer
length = sc.CFStringGetLength(value) + 1
buff = create_string_buffer(length)
sc.CFStringGetCString(value, buff, length, 0)
return buff.value
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
raise IndexError("Decoding-type must be either Decode16Bits, Decode32Bits or Decode64Bits.")
# Allocate memory for decoder
code_buffer = create_string_buffer(code)
decodedInstructionsCount = c_uint()
result = create_string_buffer(sizeof(_DecodedInst)*MAX_INSTRUCTIONS)
1 | 2 | 3 | 4 | 5 | 6 | 7 Next