[pypy-commit] pypy default: Try to import 'embedding' from __init__(), which might allow us
arigo
pypy.commits at gmail.com
Sat Dec 17 07:27:54 EST 2016
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r89113:be4a524fa746
Date: 2016-12-17 12:45 +0100
http://bitbucket.org/pypy/pypy/changeset/be4a524fa746/
Log: Try to import 'embedding' from __init__(), which might allow us to
check a space flag
diff --git a/pypy/module/_cffi_backend/__init__.py b/pypy/module/_cffi_backend/__init__.py
--- a/pypy/module/_cffi_backend/__init__.py
+++ b/pypy/module/_cffi_backend/__init__.py
@@ -1,6 +1,6 @@
import sys
from pypy.interpreter.mixedmodule import MixedModule
-from rpython.rlib import rdynload, clibffi, entrypoint
+from rpython.rlib import rdynload, clibffi
from rpython.rtyper.lltypesystem import rffi
VERSION = "1.9.1"
@@ -68,7 +68,11 @@
if has_stdcall:
interpleveldefs['FFI_STDCALL'] = 'space.wrap(%d)' % FFI_STDCALL
- def startup(self, space):
+ def __init__(self, space, *args):
+ MixedModule.__init__(self, space, *args)
+ #
+ # import 'embedding', which has the side-effect of registering
+ # the 'pypy_init_embedded_cffi_module' entry point
from pypy.module._cffi_backend import embedding
embedding.glob.space = space
@@ -85,11 +89,3 @@
for _name, _value in get_dict_rtld_constants().items():
Module.interpleveldefs[_name] = 'space.wrap(%d)' % _value
-
-
-# write this entrypoint() here, to make sure it is registered early enough
- at entrypoint.entrypoint_highlevel('main', [rffi.INT, rffi.VOIDP],
- c_name='pypy_init_embedded_cffi_module')
-def pypy_init_embedded_cffi_module(version, init_struct):
- from pypy.module._cffi_backend import embedding
- return embedding.pypy_init_embedded_cffi_module(version, init_struct)
diff --git a/pypy/module/_cffi_backend/embedding.py b/pypy/module/_cffi_backend/embedding.py
--- a/pypy/module/_cffi_backend/embedding.py
+++ b/pypy/module/_cffi_backend/embedding.py
@@ -1,4 +1,5 @@
import os
+from rpython.rlib import entrypoint
from rpython.rtyper.lltypesystem import lltype, rffi
from rpython.translator.tool.cbuild import ExternalCompilationInfo
@@ -46,6 +47,8 @@
glob = Global()
+ at entrypoint.entrypoint_highlevel('main', [rffi.INT, rffi.VOIDP],
+ c_name='pypy_init_embedded_cffi_module')
def pypy_init_embedded_cffi_module(version, init_struct):
# called from __init__.py
name = "?"
More information about the pypy-commit
mailing list