Author: Ronan Lamy <ronan.l...@gmail.com> Branch: rffi-parser Changeset: r89120:d8f4db529986 Date: 2016-12-17 17:47 +0000 http://bitbucket.org/pypy/pypy/changeset/d8f4db529986/
Log: Do one configure_types call per ParsedSource instance diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py --- a/pypy/module/cpyext/api.py +++ b/pypy/module/cpyext/api.py @@ -268,8 +268,6 @@ self.gil = gil self.result_borrowed = result_borrowed self.result_is_ll = result_is_ll - if result_is_ll: # means 'returns a low-level PyObject pointer' - assert is_PyObject(restype) # def get_llhelper(space): return llhelper(self.functype, self.get_wrapper(space)) @@ -624,6 +622,7 @@ typedef struct _typeobject PyTypeObject; """) +h.configure_types() Py_ssize_t = h.definitions['Py_ssize_t'] Py_ssize_tP = rffi.CArrayPtr(Py_ssize_t) diff --git a/pypy/module/cpyext/cparser.py b/pypy/module/cpyext/cparser.py --- a/pypy/module/cpyext/cparser.py +++ b/pypy/module/cpyext/cparser.py @@ -671,11 +671,15 @@ class ParsedSource(object): def __init__(self, source, parser, definitions=None, macros=None): + from pypy.module.cpyext.api import CConfig self.source = source self.definitions = definitions if definitions is not None else {} self.macros = macros if macros is not None else {} self.structs = {} self.ctx = parser + self._Config = type('Config', (object,), {}) + self._Config._compilation_info_ = CConfig._compilation_info_ + self._TYPES = {} def add_typedef(self, name, obj): assert name not in self.definitions @@ -701,12 +705,17 @@ def realize_struct(self, struct, type_name): from pypy.module.cpyext.api import CConfig, TYPES configname = type_name.replace(' ', '__') - setattr(CConfig, configname, + setattr(self._Config, configname, rffi_platform.Struct(type_name, struct.fields)) forward = lltype.ForwardReference() - TYPES[configname] = forward + self._TYPES[configname] = forward return forward + def configure_types(self): + for name, TYPE in rffi_platform.configure(self._Config).iteritems(): + if name in self._TYPES: + self._TYPES[name].become(TYPE) + def convert_type(self, obj): if isinstance(obj, model.PrimitiveType): return cname_to_lltype(obj.name) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit