[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pyamf-commits
Subject:    [pyamf-commits] r2940 - pyamf/branches/flash-dict-696/pyamf
From:       SVN commit logs for PyAMF <commits () pyamf ! org>
Date:       2009-10-22 20:20:55
Message-ID: 20091022202055.CC5777BC014 () mail ! collab ! com
[Download RAW message or body]

Author: thijs
Date: 2009-10-22 22:20:55 +0200 (Thu, 22 Oct 2009)
New Revision: 2940

Modified:
   pyamf/branches/flash-dict-696/pyamf/amf3.py
Log:
Apply dict.patch by FunnyMan3595


Modified: pyamf/branches/flash-dict-696/pyamf/amf3.py
===================================================================
--- pyamf/branches/flash-dict-696/pyamf/amf3.py	2009-10-22 20:17:39 UTC (rev 2939)
+++ pyamf/branches/flash-dict-696/pyamf/amf3.py	2009-10-22 20:20:55 UTC (rev 2940)
@@ -108,6 +108,8 @@
 #: <http://osflash.org/documentation/amf3/parsing_byte_arrays>}
 TYPE_BYTEARRAY = '\x0C'
 
+TYPE_DICTIONARY = '\x11'
+
 #: Reference bit.
 REFERENCE_BIT = 0x01
 
@@ -339,8 +341,6 @@
         @param decoder: AMF3 decoder containing the stream.
         @type decoder: L{amf3.Decoder<pyamf.amf3.Decoder>}
         """
-        assert isinstance(decoder, Decoder)
-
         self.decoder = decoder
         self.stream = decoder.stream
 
@@ -514,6 +514,7 @@
         self.context = kwargs.pop('context', Context())
 
         util.BufferedByteStream.__init__(self, *args, **kwargs)
+
         DataInput.__init__(self, Decoder(self, self.context))
         DataOutput.__init__(self, Encoder(self, self.context))
 
@@ -771,6 +772,7 @@
         TYPE_OBJECT:     'readObject',
         TYPE_XMLSTRING:  'readXMLString',
         TYPE_BYTEARRAY:  'readByteArray',
+        TYPE_DICTIONARY: 'readDictionary'
     }
 
     def __init__(self, *args, **kwargs):
@@ -1113,7 +1115,27 @@
 
         return obj
 
+    def readDictionary(self):
+        """
+        """
+        ref = self.readUnsignedInteger()
+        assert self.stream.read_uchar() == 0
 
+        if ref & REFERENCE_BIT == 0:
+            return self.context.getObject(ref >> 1)
+
+        ref >>= 1
+        obj = {}
+
+        self.context.addObject(obj)
+
+        for i in xrange(0, ref):
+            k = self.readElement()
+            obj[k] = self.readElement()
+
+        return obj
+
+
 class Encoder(pyamf.BaseEncoder):
     """
     Encodes an AMF3 data stream.

_______________________________________________
PyAMF commits mailing list - commits@pyamf.org
http://lists.pyamf.org/mailman/listinfo/commits
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic