Armin Rigo avatar Armin Rigo committed c5c360a

Write a bit more of the app-level interface. Untested so far.

Comments (0)

Files changed (8)

lib_pypy/_codecs_cn.py

+# this getcodec() function supports any multibyte codec, although
+# for compatibility with CPython it should only be used for the
+# codecs from this module, i.e.:
+#
+#     'gb2312', 'gbk', 'gb18030', 'hz'
+
+from _multibytecodec import __getcodec as getcodec

lib_pypy/_codecs_hk.py

+# this getcodec() function supports any multibyte codec, although
+# for compatibility with CPython it should only be used for the
+# codecs from this module, i.e.:
+#
+#    'big5hkscs'
+
+from _multibytecodec import __getcodec as getcodec

lib_pypy/_codecs_iso2022.py

+# this getcodec() function supports any multibyte codec, although
+# for compatibility with CPython it should only be used for the
+# codecs from this module, i.e.:
+#
+#    'iso2022_kr', 'iso2022_jp', 'iso2022_jp_1', 'iso2022_jp_2',
+#    'iso2022_jp_2004', 'iso2022_jp_3', 'iso2022_jp_ext'
+
+from _multibytecodec import __getcodec as getcodec

lib_pypy/_codecs_jp.py

+# this getcodec() function supports any multibyte codec, although
+# for compatibility with CPython it should only be used for the
+# codecs from this module, i.e.:
+#
+#    'shift_jis', 'cp932', 'euc_jp', 'shift_jis_2004',
+#    'euc_jis_2004', 'euc_jisx0213', 'shift_jisx0213'
+
+from _multibytecodec import __getcodec as getcodec

lib_pypy/_codecs_kr.py

+# this getcodec() function supports any multibyte codec, although
+# for compatibility with CPython it should only be used for the
+# codecs from this module, i.e.:
+#
+#    'euc_kr', 'cp949', 'johab'
+
+from _multibytecodec import __getcodec as getcodec

lib_pypy/_codecs_tw.py

+# this getcodec() function supports any multibyte codec, although
+# for compatibility with CPython it should only be used for the
+# codecs from this module, i.e.:
+#
+#    'big5', 'cp950'
+
+from _multibytecodec import __getcodec as getcodec

pypy/module/_multibytecodec/__init__.py

 class Module(MixedModule):
 
     interpleveldefs = {
+        # for compatibility this name is obscured, and should be called
+        # via the _codecs_*.py modules written in lib_pypy.
+        '__getcodec': 'interp_multibytecodec.getcodec',
     }
 
     appleveldefs = {
+        'MultibyteIncrementalEncoder':
+            'app_multibytecodec.MultibyteIncrementalEncoder',
+        'MultibyteIncrementalDecoder':
+            'app_multibytecodec.MultibyteIncrementalDecoder',
+        'MultibyteStreamReader':
+            'app_multibytecodec.MultibyteStreamReader',
+        'MultibyteStreamWriter':
+            'app_multibytecodec.MultibyteStreamWriter',
     }

pypy/module/_multibytecodec/app_multibytecodec.py

+#
+# These classes are not supported so far.
+#
+# My theory is that they are not widely used on CPython either, because
+# I found two bugs just by looking at their .c source: they always call
+# encreset() after a piece of data, even though I think it's wrong ---
+# it should be called only once at the end; and mbiencoder_reset() calls
+# decreset() instead of encreset().
+#
+
+class MultibyteIncrementalEncoder(object):
+    def __init__(self, *args, **kwds):
+        raise NotImplementedError(
+            "MultibyteIncrementalEncoder not supported; "
+            "see pypy/module/_multibytecodec/app_multibytecodec.py")
+
+class MultibyteIncrementalDecoder(object):
+    def __init__(self, *args, **kwds):
+        raise NotImplementedError(
+            "MultibyteIncrementalDecoder not supported; "
+            "see pypy/module/_multibytecodec/app_multibytecodec.py")
+
+class MultibyteStreamReader(object):
+    def __init__(self, *args, **kwds):
+        raise NotImplementedError(
+            "MultibyteStreamReader not supported; "
+            "see pypy/module/_multibytecodec/app_multibytecodec.py")
+
+class MultibyteStreamWriter(object):
+    def __init__(self, *args, **kwds):
+        raise NotImplementedError(
+            "MultibyteStreamWriter not supported; "
+            "see pypy/module/_multibytecodec/app_multibytecodec.py")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.