Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cffibuilder/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
from .lock import allocate_lock
from .error import CDefError
from .typeresolver import TypeResolver
import sys

if sys.version_info > (3,):
basestring = str


class FFI(object):
Expand Down
48 changes: 26 additions & 22 deletions cffibuilder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,28 +387,32 @@ def setter(library, value):
type(library)._cffi_dir.append(name)


class FFILibrary(object):
__metaclass__ = FFILibraryMeta

def __init__(self):
# Build FFILibrary instance and call _cffi_setup().
# this will set up some fields like '_cffi_types', and only then
# it will invoke the chained list of functions that will really
# build (notably) the constant objects, as <cdata> if they are
# pointers, and store them as attributes on the 'library' object.
super(FFILibrary, self).__init__()
if _libmodule._cffi_setup(FFILibrary._ctypes_ordered,
ffiplatform.VerificationError,
self):
import warnings
warnings.warn("reimporting %r might overwrite older definitions"
% (_libmodule.__name__))
# finally, call the loaded_cpy_xxx() functions. This will perform
# the final adjustments, like copying the Python->C wrapper
# functions from the module to the 'library' object, and setting
# up the FFILibrary class with properties for the global C variables.
with ffi._lock:
FFILibrary._load('loaded', library=self)
def ffi_library_init(self):
# Build FFILibrary instance and call _cffi_setup().
# this will set up some fields like '_cffi_types', and only then
# it will invoke the chained list of functions that will really
# build (notably) the constant objects, as <cdata> if they are
# pointers, and store them as attributes on the 'library' object.
super(FFILibrary, self).__init__()
if _libmodule._cffi_setup(FFILibrary._ctypes_ordered,
ffiplatform.VerificationError,
self):
import warnings
warnings.warn("reimporting %r might overwrite older definitions"
% (_libmodule.__name__))
# finally, call the loaded_cpy_xxx() functions. This will perform
# the final adjustments, like copying the Python->C wrapper
# functions from the module to the 'library' object, and setting
# up the FFILibrary class with properties for the global C variables.
with ffi._lock:
FFILibrary._load('loaded', library=self)


FFILibrary = FFILibraryMeta(
str('FFILibrary'),
(),
{'__init__': ffi_library_init}
)


lib = FFILibrary()
Expand Down