[pypy-svn] r75130 - in pypy/branch/fast-ctypes/pypy/rlib: . test
getxsick at codespeak.net
getxsick at codespeak.net
Sat Jun 5 19:01:12 CEST 2010
Author: getxsick
Date: Sat Jun 5 19:01:10 2010
New Revision: 75130
Modified:
pypy/branch/fast-ctypes/pypy/rlib/jitffi.py
pypy/branch/fast-ctypes/pypy/rlib/test/test_jitffi.py
Log:
kill CDLL.call(), use CDLL.get() instead
Modified: pypy/branch/fast-ctypes/pypy/rlib/jitffi.py
==============================================================================
--- pypy/branch/fast-ctypes/pypy/rlib/jitffi.py (original)
+++ pypy/branch/fast-ctypes/pypy/rlib/jitffi.py Sat Jun 5 19:01:10 2010
@@ -16,64 +16,6 @@
self.name = name
self.cpu = CPU(None, None)
- def call(self, func, func_args, res_type='void'):
- # only integers are supported for now
- assert isinstance(func_args, list)
-
- if res_type == 'int':
- bres = BoxInt()
- elif res_type == 'float':
- bres = BoxFloat()
- elif res_type == 'ref':
- bres = BoxPtr()
- elif res_type == 'void':
- bres = None
- else:
- raise ValueError(res_type)
-
- try:
- addr = rffi.cast(lltype.Signed, rdynload.dlsym(self.lib, func))
- except KeyError:
- raise ValueError("Cannot find symbol %s", func)
- bfuncaddr = BoxInt(addr)
-
- args_type = [ lltype.Signed for i in func_args ]
- FPTR = lltype.Ptr(lltype.FuncType(args_type, lltype.Signed))
- FUNC = deref(FPTR)
- calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT)
-
- bargs = [ BoxInt(x) for x in func_args ]
- inputargs = [bfuncaddr] + bargs
-
- oplist = [ResOperation(rop.CALL, inputargs, bres, descr=calldescr),
- ResOperation(rop.FINISH, [bres], None,
- descr=BasicFailDescr(0))]
- looptoken = LoopToken()
- self.cpu.compile_loop(inputargs, oplist, looptoken)
-
- i = 0
- for box in inputargs:
- self.cpu.set_future_value_int(i, box.getint())
- i += 1
-
- res = self.cpu.execute_token(looptoken)
- if res is oplist[-1].descr:
- self.guard_failed = False
- else:
- self.guard_failed = True
-
- if res_type == 'int':
- r = BoxInt(self.cpu.get_latest_value_int(0)).getint()
- elif res_type == 'float':
- r = BoxFloat(self.cpu.get_latest_value_float(0)).getfloat()
- elif res_type == 'ref':
- r = BoxPtr(self.cpu.get_latest_value_ref(0)).getref()
- elif res_type == 'void':
- r = None
- else:
- raise ValueError(res_type)
- return r
-
def get(self, func, args_type, res_type='void'):
return _Get(self.cpu, self.lib, func, args_type, res_type)
Modified: pypy/branch/fast-ctypes/pypy/rlib/test/test_jitffi.py
==============================================================================
--- pypy/branch/fast-ctypes/pypy/rlib/test/test_jitffi.py (original)
+++ pypy/branch/fast-ctypes/pypy/rlib/test/test_jitffi.py Sat Jun 5 19:01:10 2010
@@ -59,26 +59,6 @@
def test_missing_lib(self):
py.test.raises(OSError, jitffi.CDLL, 'xxxfoo888baryyy')
- def test_call(self):
- lib = jitffi.CDLL(self.lib_name)
-
- res = lib.call('add_integers', [1, 2], 'int')
- assert 3 == res
- assert isinstance(res, int)
- res = lib.call('add_integers', [-1, 2], 'int')
- assert 1 == res
- res = lib.call('add_integers', [0, 0], 'int')
- assert 0 == res
-
- res = lib.call('max3', [2, 8, 3], 'int')
- assert 8 == res
-
- res = lib.call('return_float', [1, 2], 'float')
- assert 3.0 == res
- assert isinstance(res, float)
- #res = lib.call('return_float', [1.5, 1.2], 'float')
- #assert 2.7 == res
-
def test_get(self):
lib = jitffi.CDLL(self.lib_name)
More information about the Pypy-commit
mailing list