Exemplo n.º 1
0
 def __init__(self, space, name, flags, klass=None):
     W_Object.__init__(self, space, klass)
     namestr = '[current process]' if name is None else name
     # on my os it's libc.so.6, not just libc.so
     if name == 'libc.so': name = 'libc.so.6'
     try:
         self.cdll = clibffi.CDLL(name, flags)
     except clibffi.DLOpenError:
         raise space.error(space.w_LoadError,
                           "Could not open library %s" % namestr)
     self.set_instance_var(space, '@name', space.newsymbol(namestr))
Exemplo n.º 2
0
 def test_it_creates_the_following_low_level_data(self, space):
     w_function = space.execute(
         typeformat("""
     tan = FFI::DynamicLibrary.open('%s').find_function(:tan)
     FFI::Function.new({float64}, [{float64}], tan, \{\})
     """ % libm))
     w_float64 = space.execute("FFI::Type::FLOAT64")
     assert w_function.w_info.arg_types_w == [w_float64]
     assert w_function.w_info.w_ret_type == w_float64
     tan = clibffi.CDLL(libm).getpointer('tan', [clibffi.ffi_type_double],
                                         clibffi.ffi_type_double)
     assert w_function.ptr == tan.funcsym
Exemplo n.º 3
0
 def test_its_a_wrapper_around_a_function_symbol(self, space):
     exp_ptr = clibffi.CDLL(libm).getaddressindll('exp')
     w_dl_sym = W_DL_SymbolObject(space, exp_ptr)
     assert w_dl_sym.ptr == exp_ptr