Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: mojo/public/python/mojo/bindings/serialization.py

Issue 728553002: Update mojo sdk to rev afb4440fd5a10cba980878c326180b7ad7960480 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/public/python/mojo/bindings/messaging.py ('k') | mojo/public/python/mojo/c_core.pxd » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Utility classes for serialization""" 5 """Utility classes for serialization"""
6 6
7 import struct 7 import struct
8 8
9 9
10 # Format of a header for a struct or an array. 10 # Format of a header for a struct or an array.
11 HEADER_STRUCT = struct.Struct("=II") 11 HEADER_STRUCT = struct.Struct("<II")
12 12
13 13
14 class SerializationException(Exception): 14 class SerializationException(Exception):
15 """Error when strying to serialize a struct.""" 15 """Error when strying to serialize a struct."""
16 pass 16 pass
17 17
18 18
19 class DeserializationException(Exception): 19 class DeserializationException(Exception):
20 """Error when strying to deserialize a struct.""" 20 """Error when strying to deserialize a struct."""
21 pass 21 pass
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 def _GetVersion(groups): 103 def _GetVersion(groups):
104 return sum([len(x.descriptors) for x in groups]) 104 return sum([len(x.descriptors) for x in groups])
105 105
106 106
107 def _FilterGroups(groups, version): 107 def _FilterGroups(groups, version):
108 return [group for group in groups if group.GetVersion() < version] 108 return [group for group in groups if group.GetVersion() < version]
109 109
110 110
111 def _GetStruct(groups): 111 def _GetStruct(groups):
112 index = 0 112 index = 0
113 codes = [ '=' ] 113 codes = [ '<' ]
114 for group in groups: 114 for group in groups:
115 code = group.GetTypeCode() 115 code = group.GetTypeCode()
116 size = group.GetByteSize() 116 size = group.GetByteSize()
117 needed_padding = NeededPaddingForAlignment(index, size) 117 needed_padding = NeededPaddingForAlignment(index, size)
118 if needed_padding: 118 if needed_padding:
119 codes.append('x' * needed_padding) 119 codes.append('x' * needed_padding)
120 index = index + needed_padding 120 index = index + needed_padding
121 codes.append(code) 121 codes.append(code)
122 index = index + size 122 index = index + size
123 alignment_needed = NeededPaddingForAlignment(index) 123 alignment_needed = NeededPaddingForAlignment(index)
124 if alignment_needed: 124 if alignment_needed:
125 codes.append('x' * alignment_needed) 125 codes.append('x' * alignment_needed)
126 return struct.Struct(''.join(codes)) 126 return struct.Struct(''.join(codes))
OLDNEW
« no previous file with comments | « mojo/public/python/mojo/bindings/messaging.py ('k') | mojo/public/python/mojo/c_core.pxd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698