def detect_custom_layout(w_ctype, sflags, cdef_value, compiler_value, msg1, msg2="", msg3=""): if compiler_value != cdef_value: if sflags & SF_STD_FIELD_POS: from pypy.module._cffi_backend.ffi_obj import get_ffi_error w_FFIError = get_ffi_error(w_ctype.space) raise oefmt(w_FFIError, '%s: %s%s%s (cdef says %d, but C compiler says %d).' ' fix it or use "...;" in the cdef for %s to ' 'make it flexible', w_ctype.name, msg1, msg2, msg3, cdef_value, compiler_value, w_ctype.name) w_ctype._custom_field_pos = True
def detect_custom_layout(w_ctype, sflags, cdef_value, compiler_value, msg1, msg2="", msg3=""): if compiler_value != cdef_value: if sflags & SF_STD_FIELD_POS: from pypy.module._cffi_backend.ffi_obj import get_ffi_error w_FFIError = get_ffi_error(w_ctype.space) raise oefmt( w_FFIError, '%s: %s%s%s (cdef says %d, but C compiler says %d).' ' fix it or use "...;" in the cdef for %s to ' 'make it flexible', w_ctype.name, msg1, msg2, msg3, cdef_value, compiler_value, w_ctype.name) w_ctype._custom_field_pos = True
def fetch_global_var_addr(self): if self.ptr: result = self.ptr else: if not we_are_translated(): FNPTR = rffi.CCallback([], rffi.VOIDP) fetch_addr = rffi.cast(FNPTR, self.fetch_addr) result = fetch_addr() else: # careful in translated versions: we need to call fetch_addr, # but in a GIL-releasing way. The easiest is to invoke a # llexternal() helper. result = pypy__cffi_fetch_var(self.fetch_addr) result = rffi.cast(rffi.CCHARP, result) if not result: from pypy.module._cffi_backend import ffi_obj ffierror = ffi_obj.get_ffi_error(self.space) raise oefmt(ffierror, "global variable '%s' is at address NULL", self.name) return result
def fetch_global_var_addr(self): if self.ptr: result = self.ptr else: if not we_are_translated(): FNPTR = rffi.CCallback([], rffi.VOIDP) fetch_addr = rffi.cast(FNPTR, self.fetch_addr) rgil.release() result = fetch_addr() rgil.acquire() else: # careful in translated versions: we need to call fetch_addr, # but in a GIL-releasing way. The easiest is to invoke a # llexternal() helper. result = pypy__cffi_fetch_var(self.fetch_addr) result = rffi.cast(rffi.CCHARP, result) if not result: from pypy.module._cffi_backend import ffi_obj ffierror = ffi_obj.get_ffi_error(self.space) raise oefmt(ffierror, "global variable '%s' is at address NULL", self.name) return result