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

Side by Side Diff: mojo/public/bindings/pylib/generate/mojom_pack.py

Issue 221663004: mojo: add handle<shared_buffer> support to generator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months 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 | Annotate | Revision Log
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 import mojom 5 import mojom
6 6
7 # mojom_pack provides a mechanism for determining the packed order and offsets 7 # mojom_pack provides a mechanism for determining the packed order and offsets
8 # of a mojom.Struct. 8 # of a mojom.Struct.
9 # 9 #
10 # ps = mojom_pack.PackedStruct(struct) 10 # ps = mojom_pack.PackedStruct(struct)
11 # ps.packed_fields will access a list of PackedField objects, each of which 11 # ps.packed_fields will access a list of PackedField objects, each of which
12 # will have an offset, a size and a bit (for mojom.BOOLs). 12 # will have an offset, a size and a bit (for mojom.BOOLs).
13 13
14 class PackedField(object): 14 class PackedField(object):
15 kind_to_size = { 15 kind_to_size = {
16 mojom.BOOL: 1, 16 mojom.BOOL: 1,
17 mojom.INT8: 1, 17 mojom.INT8: 1,
18 mojom.UINT8: 1, 18 mojom.UINT8: 1,
19 mojom.INT16: 2, 19 mojom.INT16: 2,
20 mojom.UINT16: 2, 20 mojom.UINT16: 2,
21 mojom.INT32: 4, 21 mojom.INT32: 4,
22 mojom.UINT32: 4, 22 mojom.UINT32: 4,
23 mojom.FLOAT: 4, 23 mojom.FLOAT: 4,
24 mojom.HANDLE: 4, 24 mojom.HANDLE: 4,
25 mojom.MSGPIPE: 4, 25 mojom.MSGPIPE: 4,
26 mojom.DCPIPE: 4, 26 mojom.SHAREDBUFFER: 4,
27 mojom.DPPIPE: 4, 27 mojom.DCPIPE: 4,
28 mojom.INT64: 8, 28 mojom.DPPIPE: 4,
29 mojom.UINT64: 8, 29 mojom.INT64: 8,
30 mojom.DOUBLE: 8, 30 mojom.UINT64: 8,
31 mojom.STRING: 8 31 mojom.DOUBLE: 8,
32 mojom.STRING: 8
32 } 33 }
33 34
34 @classmethod 35 @classmethod
35 def GetSizeForKind(cls, kind): 36 def GetSizeForKind(cls, kind):
36 if isinstance(kind, mojom.Array) or isinstance(kind, mojom.Struct): 37 if isinstance(kind, mojom.Array) or isinstance(kind, mojom.Struct):
37 return 8 38 return 8
38 if isinstance(kind, mojom.Interface): 39 if isinstance(kind, mojom.Interface):
39 kind = mojom.MSGPIPE 40 kind = mojom.MSGPIPE
40 if isinstance(kind, mojom.Enum): 41 if isinstance(kind, mojom.Enum):
41 # TODO(mpcomplete): what about big enums? 42 # TODO(mpcomplete): what about big enums?
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 limit_of_previous_field = packed_field.offset + packed_field.size 140 limit_of_previous_field = packed_field.offset + packed_field.size
140 141
141 for i in xrange(limit_of_previous_field, len(bytes)): 142 for i in xrange(limit_of_previous_field, len(bytes)):
142 bytes[i].is_padding = True 143 bytes[i].is_padding = True
143 144
144 for byte in bytes: 145 for byte in bytes:
145 # A given byte cannot both be padding and have a fields packed into it. 146 # A given byte cannot both be padding and have a fields packed into it.
146 assert not (byte.is_padding and byte.packed_fields) 147 assert not (byte.is_padding and byte.packed_fields)
147 148
148 return bytes 149 return bytes
OLDNEW
« no previous file with comments | « mojo/public/bindings/pylib/generate/mojom.py ('k') | mojo/public/bindings/pylib/parse/mojo_lexer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698