[pypy-svn] r33253 - pypy/dist/pypy/rpython/rctypes/tool
quest at codespeak.net
quest at codespeak.net
Fri Oct 13 16:14:40 CEST 2006
Author: quest
Date: Fri Oct 13 16:14:39 2006
New Revision: 33253
Modified:
pypy/dist/pypy/rpython/rctypes/tool/ctypes_platform.py
Log:
Retreive string constants from include files.
Modified: pypy/dist/pypy/rpython/rctypes/tool/ctypes_platform.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/tool/ctypes_platform.py (original)
+++ pypy/dist/pypy/rpython/rctypes/tool/ctypes_platform.py Fri Oct 13 16:14:39 2006
@@ -282,6 +282,36 @@
return None
+class DefinedConstantString(CConfigEntry):
+ """
+ """
+ def __init__(self, macro):
+ self.macro = macro
+ self.name = macro
+
+ def prepare_code(self):
+ yield '#ifdef %s' % self.macro
+ yield 'int i;'
+ yield 'char *p = %s;' % self.macro
+ yield 'dump("defined", 1);'
+ yield 'for (i = 0; p[i] != 0; i++ ) {'
+ yield ' printf("value_%d: %d\\n", i, (int)(unsigned char)p[i]);'
+ yield '}'
+ yield '#else'
+ yield 'dump("defined", 0);'
+ yield '#endif'
+
+ def build_result(self, info, config_result):
+ if info["defined"]:
+ string = ''
+ d = 0
+ while info.has_key('value_%d' % d):
+ string += chr(info['value_%d' % d])
+ d += 1
+ return string
+ return None
+
+
class Defined(CConfigEntry):
"""A boolean, corresponding to an #ifdef.
"""
More information about the Pypy-commit
mailing list