Exemplo n.º 1
0
 def finalize_call(self, args, args_w, call_local):
     stride = capi.c_function_arg_sizeof()
     for i in range(len(args_w)):
         conv = self.converters[i]
         arg_i = lltype.direct_ptradd(rffi.cast(rffi.CCHARP, args), i * stride)
         loc_i = self._address_from_local_buffer(call_local, i)
         conv.finalize_call(self.space, args_w[i], loc_i)
         conv.free_argument(self.space, rffi.cast(capi.C_OBJECT, arg_i), loc_i)
     capi.c_deallocate_function_args(args)
Exemplo n.º 2
0
 def prepare_arguments(self, args_w, call_local):
     args = capi.c_allocate_function_args(self.space, len(args_w))
     stride = capi.c_function_arg_sizeof(self.space)
     for i in range(len(args_w)):
         conv = self.converters[i]
         w_arg = args_w[i]
         try:
             arg_i = lltype.direct_ptradd(rffi.cast(rffi.CCHARP, args), i*stride)
             loc_i = self._address_from_local_buffer(call_local, i)
             conv.convert_argument(self.space, w_arg, rffi.cast(capi.C_OBJECT, arg_i), loc_i)
         except:
             # fun :-(
             for j in range(i):
                 conv = self.converters[j]
                 arg_j = lltype.direct_ptradd(rffi.cast(rffi.CCHARP, args), j*stride)
                 loc_j = self._address_from_local_buffer(call_local, j)
                 conv.free_argument(self.space, rffi.cast(capi.C_OBJECT, arg_j), loc_j)
             capi.c_deallocate_function_args(self.space, args)
             raise
     return args