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

Unified Diff: mojo/public/python/mojo/bindings/reflection.py

Issue 578263003: mojo: Add deserialization to python structs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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: mojo/public/python/mojo/bindings/reflection.py
diff --git a/mojo/public/python/mojo/bindings/reflection.py b/mojo/public/python/mojo/bindings/reflection.py
index d77bdb3abe5b6a86bc67400522a22101f1ff0645..bc8f7a855164b76427680231b899085a34b8b1f3 100644
--- a/mojo/public/python/mojo/bindings/reflection.py
+++ b/mojo/public/python/mojo/bindings/reflection.py
@@ -107,6 +107,14 @@ class MojoStructType(type):
return serialization_object.Serialize(self, handle_offset)
dictionary['Serialize'] = Serialize
+ def Deserialize(cls, data, handles):
+ result = cls.__new__(cls)
+ fields = {}
sdefresne 2014/09/18 12:56:21 Why not just doing result._fields = {} here? Nothi
qsr 2014/09/18 14:16:36 Because pylint is a little dumb... If I try to acc
sdefresne 2014/09/18 15:01:49 Acknowledged. You could do "result._fields = field
+ serialization_object.Deserialize(fields, data, handles)
+ result._fields = fields
+ return result
+ dictionary['Deserialize'] = classmethod(Deserialize)
+
return type.__new__(mcs, name, bases, dictionary)
# Prevent adding new attributes, or mutating constants.

Powered by Google App Engine
This is Rietveld 408576698