[pypy-commit] pypy default: add a simple wrapper and some tests
fijal
noreply at buildbot.pypy.org
Wed Dec 7 20:30:15 CET 2011
Author: Maciej Fijalkowski <fijall at 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
More information about the pypy-commit
mailing list