@@ -0,0 +1,1019 @@
+%22%22%22Extension of standard library's ctypes.%22%22%22%0A%0A__all__ = %5B%0A    'PyBUF_READ',%0A    'PyBUF_WRITE',%0A    'PyMemoryView_FromMemory',%0A    'c_blob',%0A    'deref_py_object_p',%0A    'load_func',%0A    'py_object_p',%0A%5D%0A%0Aimport ctypes%0A%0APyBUF_READ = 0x100%0APyBUF_WRITE = 0x200%0A%0APyMemoryView_FromMemory = ctypes.pythonapi.PyMemoryView_FromMemory%0APyMemoryView_FromMemory.argtypes = (%0A    ctypes.c_void_p,%0A    ctypes.c_ssize_t,%0A    ctypes.c_int,%0A)%0APyMemoryView_FromMemory.restype = ctypes.py_object%0A%0A# Represent not NULL-terminated strings.%0A# See: https://docs.python.org/3/library/ctypes.html#ctypes.c_char_p%0Ac_blob = ctypes.POINTER(ctypes.c_char)%0A%0A%0Adef load_func(library, name, restype, argtypes):%0A    func = library%5Bname%5D%0A    func.argtypes = argtypes%0A    func.restype = restype%0A    return func%0A%0A%0A# %60%60py_object%60%60 itself is a pointer type: %60%60PyObject *%60%60.%0Apy_object_p = ctypes.POINTER(ctypes.py_object)%0A%0A%0Adef deref_py_object_p(addr):%0A    %22%22%22Equivalent to %60%60*(PyObject **)addr%60%60.%22%22%22%0A    return ctypes.cast(addr, py_object_p).contents.value%0A

Add g1.bases.ctypes