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

Unified Diff: third_party/mojo/src/mojo/public/python/mojo_bindings/descriptor.py

Issue 1309103002: Revert of Update mojo sdk to rev c02a28868825edfa57ab77947b8cb15e741c5598 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/mojo/src/mojo/public/python/mojo_bindings/descriptor.py
diff --git a/third_party/mojo/src/mojo/public/python/mojo_bindings/descriptor.py b/third_party/mojo/src/mojo/public/python/mojo_bindings/descriptor.py
index c359e446086b5a75d58f2bbec12df9f15dbcc820..efba73de693ab3ac28ea1aadbb8d64a61b5782e2 100644
--- a/third_party/mojo/src/mojo/public/python/mojo_bindings/descriptor.py
+++ b/third_party/mojo/src/mojo/public/python/mojo_bindings/descriptor.py
@@ -33,13 +33,6 @@
This method must be able to correcly handle value being None.
"""
return self.Convert(value)
-
- def IsUnion(self):
- """
- Returns true if the type is a union. This is necessary to be able to
- identify a union when descriptor.py cannot be imported.
- """
- return False
class SerializableType(Type):
@@ -158,47 +151,6 @@
if not isinstance(value, (int, long, float)):
raise TypeError('%r is not a numeric type' % value)
return float(value)
-
-
-class UnionType(SerializableType):
- """Base Type object for union."""
-
- def __init__(self, union_type_getter, nullable=False):
- SerializableType.__init__(self, 'IIQ')
- self.nullable = nullable
- self._union_type_getter = union_type_getter
- self._union_type = None
-
- def IsUnion(self):
- return True
-
- @property
- def union_type(self):
- if not self._union_type:
- self._union_type = self._union_type_getter()
- return self._union_type
-
- def Serialize(self, value, data_offset, data, handle_offset):
- if not value:
- if not self.nullable:
- raise serialization.SerializationException(
- 'Trying to serialize null for non nullable type.')
- return ((0, 0, 0), [])
-
- ((size, tag, entry, new_data), new_handles) = (
- value.SerializeInline(handle_offset))
- if len(new_data) > 0:
- data.extend(new_data)
- entry = data_offset - 8
-
- return ((size, tag, entry), new_handles)
-
- def Deserialize(self, value, context):
- result = self.union_type.Deserialize(context)
- if not result and not self.nullable:
- raise serialization.DeserializationException(
- 'Trying to deserialize null for non nullable type.')
- return result
class PointerType(SerializableType):
@@ -482,19 +434,16 @@
to_pack.extend(serialization.Flatten(new_data))
returned_handles.extend(new_handles)
position = position + self.sub_type.GetByteSize()
-
serialization.HEADER_STRUCT.pack_into(data, data_end, size, len(value))
- # TODO(azani): Refactor so we don't have to create big formatting strings.
- struct.pack_into(('%s' % self.sub_type.GetTypeCode()) * len(value),
+ struct.pack_into('%d%s' % (len(value), self.sub_type.GetTypeCode()),
data,
data_end + serialization.HEADER_STRUCT.size,
*to_pack)
return (data_offset, returned_handles)
def DeserializeArray(self, size, nb_elements, context):
- # TODO(azani): Refactor so the format string isn't so big.
values = struct.unpack_from(
- nb_elements * self.sub_type.GetTypeCode(),
+ '%d%s' % (nb_elements, self.sub_type.GetTypeCode()),
buffer(context.data, serialization.HEADER_STRUCT.size))
values_per_element = len(self.sub_type.GetTypeCode())
assert nb_elements * values_per_element == len(values)

Powered by Google App Engine
This is Rietveld 408576698