[pypy-svn] r71855 - in pypy/branch/ctypes-configure-cache-2/pypy/lib: . ctypes_config_cache
arigo at codespeak.net
arigo at codespeak.net
Sat Mar 6 13:01:31 CET 2010
Author: arigo
Date: Sat Mar 6 13:01:29 2010
New Revision: 71855
Added:
pypy/branch/ctypes-configure-cache-2/pypy/lib/ctypes_config_cache/locale.ctc.py (contents, props changed)
Modified:
pypy/branch/ctypes-configure-cache-2/pypy/lib/_locale.py
Log:
Split _locale.py.
Modified: pypy/branch/ctypes-configure-cache-2/pypy/lib/_locale.py
==============================================================================
--- pypy/branch/ctypes-configure-cache-2/pypy/lib/_locale.py (original)
+++ pypy/branch/ctypes-configure-cache-2/pypy/lib/_locale.py Sat Mar 6 13:01:29 2010
@@ -7,48 +7,16 @@
c_ubyte, c_int, c_char_p, c_wchar_p)
from ctypes_support import standard_c_lib as libc
from ctypes_support import get_errno
-from ctypes_configure.configure import (configure, ExternalCompilationInfo,
- ConstantInteger, DefinedConstantInteger, SimpleType)
+
+# load the platform-specific cache made by running locale.ctc.py
+from ctypes_config_cache._locale_cache import *
+
size_t = c_int
# XXX check where this comes from
CHAR_MAX = 127
-_CONSTANTS = (
- 'LC_CTYPE',
- 'LC_NUMERIC',
- 'LC_TIME',
- 'LC_COLLATE',
- 'LC_MONETARY',
- 'LC_MESSAGES',
- 'LC_ALL',
- 'LC_PAPER',
- 'LC_NAME',
- 'LC_ADDRESS',
- 'LC_TELEPHONE',
- 'LC_MEASUREMENT',
- 'LC_IDENTIFICATION',
-)
-
-class LocaleConfigure:
- _compilation_info_ = ExternalCompilationInfo(includes=['locale.h'])
-for key in _CONSTANTS:
- setattr(LocaleConfigure, key, ConstantInteger(key))
-
-try:
- locale_config = configure(LocaleConfigure, noerr=True)
-except Exception, e:
- # should probably be moved into configure()
- # as an optional feature
- raise ImportError("%s: %s" % (e.__class__, e))
-
-for key in _CONSTANTS:
- globals()[key] = locale_config[key]
-del LocaleConfigure
-del locale_config
-
-HAS_LANGINFO = True
# Ubuntu Gusty i386 structure
class lconv(Structure):
@@ -288,29 +256,6 @@
raise NotImplementedError()
if HAS_LANGINFO:
- # this is incomplete list
- langinfo_names = ('CODESET D_T_FMT D_FMT T_FMT RADIXCHAR THOUSEP '
- 'YESEXPR NOEXPR CRNCYSTR').split(" ")
- for i in range(1, 8):
- langinfo_names.append("DAY_%d" % i)
- langinfo_names.append("ABDAY_%d" % i)
- for i in range(1, 13):
- langinfo_names.append("MON_%d" % i)
- langinfo_names.append("ABMON_%d" % i)
-
- class LanginfoConfigure:
- _compilation_info_ = ExternalCompilationInfo(includes=['langinfo.h'])
- nl_item = SimpleType('nl_item')
- for key in langinfo_names:
- setattr(LanginfoConfigure, key, ConstantInteger(key))
-
- config = configure(LanginfoConfigure)
- nl_item = config['nl_item']
- for key in langinfo_names:
- globals()[key] = config[key]
- del LanginfoConfigure
- del config
-
_nl_langinfo = libc.nl_langinfo
_nl_langinfo.argtypes = (nl_item,)
_nl_langinfo.restype = c_char_p
Added: pypy/branch/ctypes-configure-cache-2/pypy/lib/ctypes_config_cache/locale.ctc.py
==============================================================================
--- (empty file)
+++ pypy/branch/ctypes-configure-cache-2/pypy/lib/ctypes_config_cache/locale.ctc.py Sat Mar 6 13:01:29 2010
@@ -0,0 +1,63 @@
+"""
+'ctypes_configure' source for _locale.py.
+Run this to rebuild _locale_cache.py.
+"""
+
+import autopath
+from ctypes_configure.configure import (configure, ExternalCompilationInfo,
+ ConstantInteger, DefinedConstantInteger, SimpleType)
+from ctypes_configure.dumpcache import dumpcache
+
+# ____________________________________________________________
+
+_CONSTANTS = [
+ 'LC_CTYPE',
+ 'LC_NUMERIC',
+ 'LC_TIME',
+ 'LC_COLLATE',
+ 'LC_MONETARY',
+ 'LC_MESSAGES',
+ 'LC_ALL',
+ 'LC_PAPER',
+ 'LC_NAME',
+ 'LC_ADDRESS',
+ 'LC_TELEPHONE',
+ 'LC_MEASUREMENT',
+ 'LC_IDENTIFICATION',
+]
+
+class LocaleConfigure:
+ _compilation_info_ = ExternalCompilationInfo(includes=['locale.h'])
+for key in _CONSTANTS:
+ setattr(LocaleConfigure, key, ConstantInteger(key))
+
+config = configure(LocaleConfigure, noerr=True)
+
+# ____________________________________________________________
+
+HAS_LANGINFO = True # xxx hard-coded to True for now
+
+if HAS_LANGINFO:
+ # this is incomplete list
+ langinfo_names = ('CODESET D_T_FMT D_FMT T_FMT RADIXCHAR THOUSEP '
+ 'YESEXPR NOEXPR CRNCYSTR').split(" ")
+ for i in range(1, 8):
+ langinfo_names.append("DAY_%d" % i)
+ langinfo_names.append("ABDAY_%d" % i)
+ for i in range(1, 13):
+ langinfo_names.append("MON_%d" % i)
+ langinfo_names.append("ABMON_%d" % i)
+
+ class LanginfoConfigure:
+ _compilation_info_ = ExternalCompilationInfo(includes=['langinfo.h'])
+ nl_item = SimpleType('nl_item')
+ for key in langinfo_names:
+ setattr(LanginfoConfigure, key, ConstantInteger(key))
+
+ config.update(configure(LanginfoConfigure))
+
+# ____________________________________________________________
+
+config['_CONSTANTS'] = _CONSTANTS
+config['HAS_LANGINFO'] = HAS_LANGINFO
+dumpcache(__file__, '_locale_cache.py', config)
More information about the Pypy-commit
mailing list