Commits

Maciej Fijalkowski  committed bc01389

add a simple wrapper and some tests

  • Participants
  • Parent commits 38243eb

Comments (0)

Files changed (2)

File pypy/rpython/tool/rffi_platform.py

         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)

File pypy/rpython/tool/test/test_rffi_platform.py

                                      '#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