Mojo: Expose generated serialization functions through public API |
|||
Issue descriptionIt is useful to be able to capture serialized structs without necessarily pushing them over a pipe right away. For a concrete example, mash wm stores generic window properties as array<uint8>. Currently there are custom TypeConverters to go between real types and vector<uint8_t>, which is unfortunate. Ideally you could just say something like: mojom::RectPtr r = ...; mojo::Array<uint8_t> bytes; r->Serialize(&bytes); and mojo::Array<uint8_t> bytes = ...; mojom::RectPtr r = mojom::Rect::Deserialize(bytes); We could trivially generate implementations of Serialize and Deserialize for all mojom structs using the generated Serialize_ and Deserialize_ functions. It would be worth considering this (though IMHO less obviously a good idea) for interface messages too since they are in practice just structs themselves.
,
Jun 16 2016
The API should actually be bool mojom::Rect::Deserialize(mojo::Array<uint8_t> bytes, mojom::RectPtr* out)
,
Jun 16 2016
Also static. And really, it should just be static bool mojom::Rect::Deserialize(const uint8_t* bytes, mojom::RectPtr* out) for maximum flexibility
,
Jun 16 2016
,
Jun 17 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/9abf5980f6324f6bceccab2ee27b98daffed8aec commit 9abf5980f6324f6bceccab2ee27b98daffed8aec Author: yzshen <yzshen@chromium.org> Date: Fri Jun 17 23:16:20 2016 Mojo C++ bindings: expose serialization public API for mojo structs. BUG= 597115 Review-Url: https://codereview.chromium.org/2076313002 Cr-Commit-Position: refs/heads/master@{#400537} [modify] https://crrev.com/9abf5980f6324f6bceccab2ee27b98daffed8aec/mojo/public/cpp/bindings/lib/serialization.h [modify] https://crrev.com/9abf5980f6324f6bceccab2ee27b98daffed8aec/mojo/public/cpp/bindings/struct_ptr.h [modify] https://crrev.com/9abf5980f6324f6bceccab2ee27b98daffed8aec/mojo/public/cpp/bindings/tests/struct_traits_unittest.cc [modify] https://crrev.com/9abf5980f6324f6bceccab2ee27b98daffed8aec/mojo/public/cpp/bindings/tests/struct_unittest.cc [modify] https://crrev.com/9abf5980f6324f6bceccab2ee27b98daffed8aec/mojo/public/cpp/bindings/tests/wtf_types_unittest.cc [modify] https://crrev.com/9abf5980f6324f6bceccab2ee27b98daffed8aec/mojo/public/interfaces/bindings/tests/test_wtf_types.mojom [modify] https://crrev.com/9abf5980f6324f6bceccab2ee27b98daffed8aec/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl
,
Aug 26 2016
|
|||
►
Sign in to add a comment |
|||
Comment 1 by dcheng@chromium.org
, Jun 16 2016