Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r48209:595bfa0049db Date: 2011-10-18 16:50 +0200 http://bitbucket.org/pypy/pypy/changeset/595bfa0049db/
Log: Add the 'pyexpat.model' module. diff --git a/pypy/module/pyexpat/__init__.py b/pypy/module/pyexpat/__init__.py --- a/pypy/module/pyexpat/__init__.py +++ b/pypy/module/pyexpat/__init__.py @@ -4,12 +4,8 @@ class ErrorsModule(MixedModule): "Definition of pyexpat.errors module." - - appleveldefs = { - } - - interpleveldefs = { - } + appleveldefs = {} + interpleveldefs = {} def setup_after_space_initialization(self): from pypy.module.pyexpat import interp_pyexpat @@ -18,6 +14,18 @@ interp_pyexpat.ErrorString(self.space, getattr(interp_pyexpat, name))) +class ModelModule(MixedModule): + "Definition of pyexpat.model module." + appleveldefs = {} + interpleveldefs = {} + + def setup_after_space_initialization(self): + from pypy.module.pyexpat import interp_pyexpat + space = self.space + for name in interp_pyexpat.xml_model_list: + value = getattr(interp_pyexpat, name) + space.setattr(self, space.wrap(name), space.wrap(value)) + class Module(MixedModule): "Python wrapper for Expat parser." @@ -39,6 +47,7 @@ submodules = { 'errors': ErrorsModule, + 'model': ModelModule, } for name in ['XML_PARAM_ENTITY_PARSING_NEVER', diff --git a/pypy/module/pyexpat/interp_pyexpat.py b/pypy/module/pyexpat/interp_pyexpat.py --- a/pypy/module/pyexpat/interp_pyexpat.py +++ b/pypy/module/pyexpat/interp_pyexpat.py @@ -76,6 +76,18 @@ "XML_ERROR_FINISHED", "XML_ERROR_SUSPEND_PE", ] +xml_model_list = [ + "XML_CTYPE_EMPTY", + "XML_CTYPE_ANY", + "XML_CTYPE_MIXED", + "XML_CTYPE_NAME", + "XML_CTYPE_CHOICE", + "XML_CTYPE_SEQ", + "XML_CQUANT_NONE", + "XML_CQUANT_OPT", + "XML_CQUANT_REP", + "XML_CQUANT_PLUS", + ] class CConfigure: _compilation_info_ = eci @@ -104,6 +116,8 @@ for name in xml_error_list: locals()[name] = rffi_platform.ConstantInteger(name) + for name in xml_model_list: + locals()[name] = rffi_platform.ConstantInteger(name) for k, v in rffi_platform.configure(CConfigure).items(): globals()[k] = v diff --git a/pypy/module/pyexpat/test/test_parser.py b/pypy/module/pyexpat/test/test_parser.py --- a/pypy/module/pyexpat/test/test_parser.py +++ b/pypy/module/pyexpat/test/test_parser.py @@ -131,3 +131,7 @@ 'encoding specified in XML declaration is incorrect') assert (pyexpat.errors.XML_ERROR_XML_DECL == 'XML declaration not well-formed') + + def test_model(self): + import pyexpat + assert isinstance(pyexpat.model.XML_CTYPE_EMPTY, int) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit