[pypy-commit] pypy llimpl: Hack the functionptr when passing an llexternal as llimpl in register_external()
rlamy
pypy.commits at gmail.com
Sat Feb 6 21:08:33 EST 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: llimpl
Changeset: r82104:58ecd8c5102c
Date: 2016-02-07 02:00 +0000
http://bitbucket.org/pypy/pypy/changeset/58ecd8c5102c/
Log: Hack the functionptr when passing an llexternal as llimpl in
register_external()
diff --git a/rpython/rtyper/extfunc.py b/rpython/rtyper/extfunc.py
--- a/rpython/rtyper/extfunc.py
+++ b/rpython/rtyper/extfunc.py
@@ -1,10 +1,8 @@
from rpython.rtyper.extregistry import ExtRegistryEntry
-from rpython.rtyper.lltypesystem.lltype import typeOf, FuncType, functionptr
+from rpython.rtyper.lltypesystem.lltype import typeOf, FuncType, functionptr, _ptr
from rpython.annotator.model import unionof
from rpython.annotator.signature import annotation, SignatureError
-import py
-
class ExtFuncEntry(ExtRegistryEntry):
safe_not_sandboxed = False
@@ -52,14 +50,17 @@
make_sandbox_trampoline)
impl = make_sandbox_trampoline(
self.name, signature_args, s_result)
- # store some attributes to the 'impl' function, where
- # the eventual call to rtyper.getcallable() will find them
- # and transfer them to the final lltype.functionptr().
- impl._llfnobjattrs_ = {'_name': self.name}
- if hasattr(self, 'lltypefakeimpl'):
- impl._llfnobjattrs_['_fakeimpl'] = fakeimpl
- obj = rtyper.getannmixlevel().delayedfunction(
- impl, signature_args, hop.s_result)
+ if isinstance(impl, _ptr):
+ obj = impl
+ else:
+ # store some attributes to the 'impl' function, where
+ # the eventual call to rtyper.getcallable() will find them
+ # and transfer them to the final lltype.functionptr().
+ impl._llfnobjattrs_ = {'_name': self.name}
+ if hasattr(self, 'lltypefakeimpl'):
+ impl._llfnobjattrs_['_fakeimpl'] = fakeimpl
+ obj = rtyper.getannmixlevel().delayedfunction(
+ impl, signature_args, hop.s_result)
else:
FT = FuncType(args_ll, ll_result)
obj = functionptr(FT, name, _external_name=self.name,
@@ -84,6 +85,10 @@
if export_name is None:
export_name = function.__name__
+ if isinstance(llimpl, _ptr) and llfakeimpl:
+ llimpl._obj.__dict__['_fakeimpl'] = llfakeimpl
+ llfakeimpl = None
+
class FunEntry(ExtFuncEntry):
_about_ = function
safe_not_sandboxed = sandboxsafe
More information about the pypy-commit
mailing list