[pypy-svn] r75529 - in pypy/branch/fast-ctypes/pypy: module/jitffi rlib
getxsick at codespeak.net
getxsick at codespeak.net
Wed Jun 23 18:43:28 CEST 2010
Author: getxsick
Date: Wed Jun 23 18:43:26 2010
New Revision: 75529
Modified:
pypy/branch/fast-ctypes/pypy/module/jitffi/interp_jitffi.py
pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py
Log:
add a new class pypy.rlib.rjitffi._LibHandler
update W_LibHandler to intherit from the provided class
this is a better version of in r75508
Modified: pypy/branch/fast-ctypes/pypy/module/jitffi/interp_jitffi.py
==============================================================================
--- pypy/branch/fast-ctypes/pypy/module/jitffi/interp_jitffi.py (original)
+++ pypy/branch/fast-ctypes/pypy/module/jitffi/interp_jitffi.py Wed Jun 23 18:43:26 2010
@@ -1,18 +1,16 @@
-from pypy.rlib import rdynload
from pypy.rlib import rjitffi
from pypy.interpreter.baseobjspace import ObjSpace, W_Root, Wrappable
from pypy.interpreter.error import OperationError, wrap_oserror
from pypy.interpreter.gateway import interp2app
from pypy.interpreter.typedef import TypeDef
-class W_LibHandler(Wrappable):
+class W_LibHandler(Wrappable, rjitffi._LibHandler):
def __init__(self, space, name):
- try:
- self.handler = rdynload.dlopen(name)
- except rdynload.DLOpenError, e:
- raise OSError('%s: %s', name, e.msg or 'unspecified error')
-
self.space = space
+ try:
+ rjitffi._LibHandler.__init__(self, name)
+ except OSError, e:
+ raise OperationError(space.w_OSError, space.wrap(str(e)))
def W_LibHandler___new__(space, w_type, name):
try:
Modified: pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py
==============================================================================
--- pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py (original)
+++ pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py Wed Jun 23 18:43:26 2010
@@ -9,10 +9,7 @@
class CDLL(object):
def __init__(self, name, load=True):
if load:
- try:
- self.lib = rdynload.dlopen(name)
- except rdynload.DLOpenError, e:
- raise OSError('%s: %s', name, e.msg or 'unspecified error')
+ self.lib = _LibHandler(name)
else:
self.lib = None
@@ -22,17 +19,20 @@
def get(self, func, args_type, res_type='void'):
return _Get(self.cpu, self.lib, func, args_type, res_type)
+class _LibHandler(object):
+ def __init__(self, name):
+ try:
+ self.handler = rdynload.dlopen(name)
+ except rdynload.DLOpenError, e:
+ raise OSError('%s: %s', name, e.msg or 'unspecified error')
+
class _Get(object):
def __init__(self, cpu, lib, func, args_type, res_type='void'):
assert isinstance(args_type, list)
self.args_type = args_type
self.res_type = res_type
self.cpu = cpu
-
- if hasattr(lib, 'handler'): # XXX dirty hack for pypy.module.jitffi
- self.lib = lib.handler
- else:
- self.lib = lib
+ self.lib = lib.handler
if self.res_type == 'int':
self.bres = BoxInt()
More information about the Pypy-commit
mailing list