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

Unified Diff: third_party/mojo/src/mojo/public/go/bindings/encoder.go

Issue 1142043005: Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix type conversion errors on win64 for some msvs Created 5 years, 7 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/go/bindings/encoder.go
diff --git a/third_party/mojo/src/mojo/public/go/bindings/encoder.go b/third_party/mojo/src/mojo/public/go/bindings/encoder.go
index 822aaa477d4eac32ebff104bd0fba2187ef2d2ad..918c883f9d23bf4a9434639761a0f4bc9b9211b6 100644
--- a/third_party/mojo/src/mojo/public/go/bindings/encoder.go
+++ b/third_party/mojo/src/mojo/public/go/bindings/encoder.go
@@ -163,6 +163,12 @@ func (e *Encoder) StartStruct(size, version uint32) {
e.pushState(header, 0)
}
+// StartUnion starts encoding a union and writes its data header.
+func (e *Encoder) StartUnion(tag uint32) {
+ header := DataHeader{uint32(16), tag}
+ e.pushState(header, 0)
+}
+
func (e *Encoder) writeDataHeader(header DataHeader) {
binary.LittleEndian.PutUint32(e.buf[e.state().offset:], header.Size)
binary.LittleEndian.PutUint32(e.buf[e.state().offset+4:], header.ElementsOrVersion)
@@ -285,6 +291,22 @@ func (e *Encoder) WriteFloat64(value float64) error {
return e.WriteUint64(math.Float64bits(value))
}
+// WriteNullUnion writes a null union.
+func (e *Encoder) WriteNullUnion() error {
+ if err := ensureElementBitSizeAndCapacity(e.state(), 128); err != nil {
+ return err
+ }
+ e.state().alignOffsetToBytes()
+ e.state().offset = align(e.state().offset, 16)
+ binary.LittleEndian.PutUint64(e.buf[e.state().offset:], 0)
+ e.state().skipBytes(8)
+ binary.LittleEndian.PutUint64(e.buf[e.state().offset:], 0)
+ e.state().skipBytes(8)
+ e.state().elementsProcessed++
+
+ return nil
+}
+
// WriteNullPointer writes a null pointer.
func (e *Encoder) WriteNullPointer() error {
return e.WriteUint64(0)

Powered by Google App Engine
This is Rietveld 408576698