• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(708)  |  Call(550)  |  Derive(0)  |  Import(158)
No Document.

        def cast(obj, typ):
    return _cast(obj, obj, typ)
        


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/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('To alter control transfer buffer, use '
                'setControl')
        buff = create_binary_buffer(buffer_or_len)
        transfer.buffer = cast(buff, c_void_p)
        transfer.length = sizeof(buff)
 
    def isSubmitted(self):
                # control request not supported by the device
                return []
            raise libusb1.USBError(result)
        length = cast(descriptor_string, POINTER(c_ubyte))[0]
        langid_list = cast(descriptor_string, POINTER(c_uint16))
        result = []
        append = result.append

src/s/h/shapely-3k-HEAD/shapely/geometry/multipoint.py   shapely-3k(Download)
"""
Multiple points.
"""
 
from ctypes import byref, c_double, c_int, c_void_p, cast, POINTER, pointer
 
from shapely.geos import lgeos
        assert n == 2 or n == 3
 
        # Make pointer to the coordinate array
        cp = cast(array['data'][0], POINTER(c_double))
 
        # Array of pointers to sub-geometries
        subs = (c_void_p * m)()
 
        for i in range(m):
            geom, ndims = geos_point_from_py(cp[n*i:n*i+2])
            subs[i] = cast(geom, c_void_p)
        for i in range(m):
            coords = ob[i]
            geom, ndims = geos_point_from_py(coords)
            subs[i] = cast(geom, c_void_p)
 
    return lgeos.GEOSGeom_createCollection(4, subs, m), n
 

src/s/h/shapely-3k-HEAD/shapely/geometry/multilinestring.py   shapely-3k(Download)
"""
Multi-part collection of linestrings.
"""
 
from ctypes import byref, c_double, c_int, c_void_p, cast, POINTER, pointer
 
from shapely.geos import lgeos
        assert L >= 1
 
        # Make pointer to the coordinate array
        cp = cast(array['data'][0], POINTER(c_double))
 
        # Array of pointers to sub-geometries
        subs = (c_void_p * L)()
 
        for l in range(L):
            geom, ndims = geos_linestring_from_py(array['data'][l])
            subs[i] = cast(geom, c_void_p)
        # add to coordinate sequence
        for l in range(L):
            geom, ndims = geos_linestring_from_py(ob[l])
            subs[l] = cast(geom, c_void_p)
 
    return (lgeos.GEOSGeom_createCollection(5, subs, L), N)
 

src/s/h/shapely-3k-HEAD/shapely/geometry/multipolygon.py   shapely-3k(Download)
"""
Multi-part collection of polygons.
"""
 
from ctypes import byref, c_double, c_int, c_void_p, cast, POINTER, pointer
 
from shapely.geos import lgeos
    subs = (c_void_p * L)()
    for l in range(L):
        geom, ndims = geos_polygon_from_py(ob[l][0], ob[l][1:])
        subs[l] = cast(geom, c_void_p)
 
    return (lgeos.GEOSGeom_createCollection(6, subs, L), N)
 
    subs = (c_void_p * L)()
    for l in range(L):
        geom, ndims = geos_polygon_from_py(ob[l][0], ob[l][1])
        subs[l] = cast(geom, c_void_p)
 
    return (lgeos.GEOSGeom_createCollection(6, subs, L), N)
 

src/s/p/spineless-HEAD/trunk/source/spineless/lib/opengl.py   spineless(Download)
# Copyright 2007 Jussi Lepisto
 
import ctypes
import logging
import sys
from ctypes import byref, cast, create_string_buffer, sizeof, POINTER
from ctypes import (c_char, c_char_p, c_double, c_float, c_int, c_ubyte,
    def UniformMatrix2fv(self, location, *matrices):
        count = len(matrices)
 
        array_type = (c_float * 4) * count
        array = array_type(cast(matrix, POINTER(c_float))
                           for matrix in matrices)
 
        self._UniformMatrix2fv(location, count, cast(array, POINTER(c_float)))
 
    def UniformMatrix3fv(self, location, *matrices):
        count = len(matrices)
 
        array_type = (c_float * 9) * count
        array = array_type(cast(matrix, POINTER(c_float))
    def UniformMatrix4fv(self, location, *matrices):
        count = len(matrices)
 
        array_type = (c_float * 16) * count
        array = array_type(cast(matrix, POINTER(c_float))
                           for matrix in matrices)
 

src/s/h/shapely-3k-HEAD/shapely/geometry/point.py   shapely-3k(Download)
from ctypes import string_at, create_string_buffer, \
    c_char_p, c_double, c_float, c_int, c_uint, c_size_t, c_ubyte, \
    c_void_p, byref
from ctypes import cast, POINTER
 
from shapely.geos import lgeos, DimensionError
from shapely.geometry.base import BaseGeometry, CoordinateSequence
        assert n == 2 or n == 3
 
        cdata = array['data'][0]
        cp = cast(cdata, POINTER(c_double))
        dx = c_double(cp[0])
        dy = c_double(cp[1])
        dz = None

src/s/p/spineless-HEAD/source/spineless/lib/opengl.py   spineless(Download)
# Copyright 2007 Jussi Lepisto
 
import ctypes
import logging
import sys
from ctypes import byref, cast, create_string_buffer, sizeof, POINTER
from ctypes import (c_char, c_char_p, c_double, c_float, c_int, c_ubyte,
    def UniformMatrix2fv(self, location, *matrices):
        count = len(matrices)
 
        array_type = (c_float * 4) * count
        array = array_type(cast(matrix, POINTER(c_float))
                           for matrix in matrices)
 
        self._UniformMatrix2fv(location, count, cast(array, POINTER(c_float)))
 
    def UniformMatrix3fv(self, location, *matrices):
        count = len(matrices)
 
        array_type = (c_float * 9) * count
        array = array_type(cast(matrix, POINTER(c_float))
    def UniformMatrix4fv(self, location, *matrices):
        count = len(matrices)
 
        array_type = (c_float * 16) * count
        array = array_type(cast(matrix, POINTER(c_float))
                           for matrix in matrices)
 

src/s/e/seamcarver-0.1/python/seamcarver.py   seamcarver(Download)
#!/usr/bin/python
 
__all__ = ('SeamCarver', 'retarget_image')
 
from ctypes import create_string_buffer, POINTER, c_ubyte, cast, c_char
from _seamcarver import *
 
class SeamCarver(object):
    def __init__(self, rgb_data, width, height, energy_function):
        rgb_data = cast(create_string_buffer(rgb_data), POINTER(c_ubyte))
    def get_rgb_data(self):
        rgb_data = cast(seamcarver_get_rgb_data(self._sc), POINTER(c_char))
        return rgb_data[:3*self._width*self._height]
    def get_energy_data(self):
        energy = cast(seamcarver_get_energy_data(self._sc), POINTER(c_char))
        return energy[:3*self._width*self._height]
    def retarget(self, new_width, new_height):
        rgb_data = cast(seamcarver_retarget(self._sc, new_width, new_height),

src/p/y/pygl-HEAD/src/pygl/shader.py   pygl(Download)
#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))
        ShaderSource(self._object,
                     len(sources),
                     c_str_array,
                     cast(NULL, POINTER(GLuint))
                    )
        _check_errors()
 

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next