pyd / examples / misc / ctypes /

from ctypes import *
import ctypes.util;
import os, os.path

from common import reg_fun
import common
common.dll = dll = CDLL(os.path.abspath(""))
dll.test_pyd.restype = py_object
dll.test_long_to_d.restype = py_object
def _type(obj): return type(obj)
def _id(l): 
    print '_id l: ', type(l)
    return l
FUNC2 = CFUNCTYPE(py_object, py_object, py_object)
def get_item(thing, index):
    print 'get_item thing: ', type(thing)
    print 'get_item index: ', type(index)
    return thing[index]
def utf8_to_str(_buffer, _len):
    a = create_string_buffer(_buffer, _len)
    return a.value
LCONV = CFUNCTYPE(py_object, c_longlong)
reg_fun('long_to_python', LCONV(_id))
LUCONV = CFUNCTYPE(py_object, c_ulonglong)
reg_fun('ulong_to_python', LUCONV(_id))
UTF8CONV = CFUNCTYPE(py_object, c_void_p, c_size_t)
reg_fun('utf8_to_python', UTF8CONV(utf8_to_str))
reg_fun('get_item', FUNC2(get_item))
print 'test2 zip'
print dll.test_long_to_d(py_object(1))

a = set()
#z = dll.test_pyd(py_object([1,2,3,a,5,6]))
#print a is z
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.