[pypy-svn] r9917 - pypy/dist/pypy/lib

pedronis at codespeak.net pedronis at codespeak.net
Sun Mar 20 02:04:07 CET 2005


Author: pedronis
Date: Sun Mar 20 02:04:07 2005
New Revision: 9917

Modified:
   pypy/dist/pypy/lib/marshal.py
Log:
marshal for bools



Modified: pypy/dist/pypy/lib/marshal.py
==============================================================================
--- pypy/dist/pypy/lib/marshal.py	(original)
+++ pypy/dist/pypy/lib/marshal.py	Sun Mar 20 02:04:07 2005
@@ -27,7 +27,8 @@
 TYPE_DICT     = '{'
 TYPE_CODE     = 'c'
 TYPE_UNKNOWN  = '?'
-
+FALSE_CODE    = 'F'
+TRUE_CODE     = 'T'
 
 class Marshaller:
 
@@ -57,14 +58,22 @@
 
     def dump_none(self, x):
         self.f.write(TYPE_NONE)
-        dispatch[NoneType] = dump_none
+    dispatch[NoneType] = dump_none
+
+    def dump_bool(self, x):
+        if x:
+            self.f.write(TRUE_CODE)
+        else:
+            self.f.write(FALSE_CODE)
+    dispatch[bool] = dump_bool
 
     def dump_ellipsis(self, x):
         self.f.write(TYPE_ELLIPSIS)
-        try:
-            dispatch[EllipsisType] = dump_ellipsis
-        except NameError:
-            pass
+    
+    try:
+        dispatch[EllipsisType] = dump_ellipsis
+    except NameError:
+        pass
 
     def dump_int(self, x):
         y = x>>31
@@ -221,6 +230,14 @@
         return None
     dispatch[TYPE_NONE] = load_none
 
+    def load_true(self):
+        return True
+    dispatch[TRUE_CODE] = load_true
+
+    def load_false(self):
+        return False
+    dispatch[FALSE_CODE] = load_false
+
     def load_ellipsis(self):
         return EllipsisType
     dispatch[TYPE_ELLIPSIS] = load_ellipsis



More information about the Pypy-commit mailing list