Author: Maciej Fijalkowski <fij...@gmail.com> Branch: Changeset: r50284:bc01389b6c4c Date: 2011-12-07 21:29 +0200 http://bitbucket.org/pypy/pypy/changeset/bc01389b6c4c/
Log: add a simple wrapper and some tests diff --git a/pypy/rpython/tool/rffi_platform.py b/pypy/rpython/tool/rffi_platform.py --- a/pypy/rpython/tool/rffi_platform.py +++ b/pypy/rpython/tool/rffi_platform.py @@ -56,6 +56,12 @@ DEFINED = DefinedConstantDouble(macro) return configure(CConfig)['DEFINED'] +def getdefinedinteger(macro, c_header_source): + class CConfig: + _compilation_info_ = eci_from_header(c_header_source) + DEFINED = DefinedConstantInteger(macro) + return configure(CConfig)['DEFINED'] + def has(name, c_header_source, include_dirs=None): class CConfig: _compilation_info_ = eci_from_header(c_header_source, include_dirs) diff --git a/pypy/rpython/tool/test/test_rffi_platform.py b/pypy/rpython/tool/test/test_rffi_platform.py --- a/pypy/rpython/tool/test/test_rffi_platform.py +++ b/pypy/rpython/tool/test/test_rffi_platform.py @@ -108,6 +108,12 @@ '#define ALFKJLKJFLKJFKLEJDLKEWMECEE') assert res +def test_defined_constant(): + res = rffi_platform.getdefineddouble('ABCDFGH', '#define ABCDFGH 2.0') + assert res == 2.0 + res = rffi_platform.getdefinedinteger('ABCDFGH', '#define ABCDFGH 2') + assert res == 2 + def test_defined_constant_float(): value = rffi_platform.getdefineddouble('BLAH', '#define BLAH 1.0') assert value == 1.0 _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit