Beispiel #1
0
 def __init__(self,
              argtypes,
              restype,
              func,
              additional_arg=0,
              flags=FUNCFLAG_CDECL,
              variadic_args=0):
     AbstractFuncPtr.__init__(self, "callback", argtypes, restype, flags,
                              variadic_args)
     self.ll_code = lltype.malloc(rffi.VOIDPP.TO, 1, flavor='raw')
     self.ll_closure = rffi.cast(
         FFI_CLOSUREP,
         c_ffi_closure_alloc(
             rffi.cast(rffi.SIZE_T, rffi.sizeof(FFI_CLOSUREP.TO)),
             self.ll_code))
     self.ll_userdata = lltype.malloc(USERDATA_P.TO,
                                      flavor='raw',
                                      track_allocation=False)
     self.ll_userdata.callback = rffi.llhelper(CALLBACK_TP, func)
     self.ll_userdata.addarg = additional_arg
     res = c_ffi_prep_closure_loc(self.ll_closure, self.ll_cif, ll_callback,
                                  rffi.cast(rffi.VOIDP, self.ll_userdata),
                                  self.ll_code[0])
     if not res == FFI_OK:
         raise LibFFIError
Beispiel #2
0
 def __init__(self, argtypes, restype, func, additional_arg=0,
              flags=FUNCFLAG_CDECL):
     AbstractFuncPtr.__init__(self, "callback", argtypes, restype, flags)
     self.ll_closure = closureHeap.alloc()
     self.ll_userdata = lltype.malloc(USERDATA_P.TO, flavor='raw',
                                      track_allocation=False)
     self.ll_userdata.callback = rffi.llhelper(CALLBACK_TP, func)
     self.ll_userdata.addarg = additional_arg
     res = c_ffi_prep_closure(self.ll_closure, self.ll_cif,
                              ll_callback, rffi.cast(rffi.VOIDP,
                                                     self.ll_userdata))
     if not res == FFI_OK:
         raise LibFFIError
Beispiel #3
0
 def __init__(self, argtypes, restype, func, additional_arg=0,
              flags=FUNCFLAG_CDECL):
     AbstractFuncPtr.__init__(self, "callback", argtypes, restype, flags)
     self.ll_closure = closureHeap.alloc()
     self.ll_userdata = lltype.malloc(USERDATA_P.TO, flavor='raw',
                                      track_allocation=False)
     self.ll_userdata.callback = rffi.llhelper(CALLBACK_TP, func)
     self.ll_userdata.addarg = additional_arg
     res = c_ffi_prep_closure(self.ll_closure, self.ll_cif,
                              ll_callback, rffi.cast(rffi.VOIDP,
                                                     self.ll_userdata))
     if not res == FFI_OK:
         raise LibFFIError
Beispiel #4
0
 def __init__(self, w_iteratee, space):
     self.w_iteratee = w_iteratee
     self.space = space
     self.keys_w = []
     self.idx = -1
     ll_callback = rffi.llhelper(support.CALLBACK_V_TP, _gather_callback)
     dataptr = rffi.cast(rffi.VOIDP, 0)
     _gather_callback_self.instance = self
     try:
         with _unwrap_handle(space, w_iteratee) as h_iteratee:
             self._gather_keys(h_iteratee, ll_callback, dataptr)
     finally:
         _gather_callback_self.instance = None
     self.space = None
Beispiel #5
0
def _make_callback(space, w_callback, wants_this, args):
    callback = Callback(space, w_callback, wants_this, args)
    dataptr = rffi.cast(rffi.VOIDP, callback.id)
    ll_dispatch_callback = rffi.llhelper(support.CALLBACK_TP,
                                         dispatch_callback)
    return support.emjs_make_callback(ll_dispatch_callback, dataptr), callback
Beispiel #6
0
def _make_callback(space, w_callback, wants_this, args):
    callback = Callback(space, w_callback, wants_this, args)
    dataptr = rffi.cast(rffi.VOIDP, callback.id)
    ll_dispatch_callback = rffi.llhelper(support.CALLBACK_TP, dispatch_callback)
    return support.emjs_make_callback(ll_dispatch_callback, dataptr), callback