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

Side by Side Diff: third_party/mojo/src/mojo/public/go/bindings/encoder.go

Issue 1058033002: NOT TO COMMITTED: Update mojo sdk to rev 0018e6a91b75bcb941c867f8a7aa1753c3b53a13 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 package bindings 5 package bindings
6 6
7 import ( 7 import (
8 "encoding/binary" 8 "encoding/binary"
9 "fmt" 9 "fmt"
10 "math" 10 "math"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 for _, b := range bytes { 298 for _, b := range bytes {
299 if err := e.WriteUint8(b); err != nil { 299 if err := e.WriteUint8(b); err != nil {
300 return err 300 return err
301 } 301 }
302 } 302 }
303 return e.Finish() 303 return e.Finish()
304 } 304 }
305 305
306 // WritePointer writes a pointer to first unclaimed byte index. 306 // WritePointer writes a pointer to first unclaimed byte index.
307 func (e *Encoder) WritePointer() error { 307 func (e *Encoder) WritePointer() error {
308 e.state().alignOffsetToBytes()
309 e.state().offset = align(e.state().offset, 8)
308 return e.WriteUint64(uint64(e.end - e.state().offset)) 310 return e.WriteUint64(uint64(e.end - e.state().offset))
309 } 311 }
310 312
311 // WriteInvalidHandle an invalid handle. 313 // WriteInvalidHandle an invalid handle.
312 func (e *Encoder) WriteInvalidHandle() error { 314 func (e *Encoder) WriteInvalidHandle() error {
313 return e.WriteInt32(-1) 315 return e.WriteInt32(-1)
314 } 316 }
315 317
316 // WriteHandle writes a handle and invalidates the passed handle object. 318 // WriteHandle writes a handle and invalidates the passed handle object.
317 func (e *Encoder) WriteHandle(handle system.Handle) error { 319 func (e *Encoder) WriteHandle(handle system.Handle) error {
318 if !handle.IsValid() { 320 if !handle.IsValid() {
319 return fmt.Errorf("can't write an invalid handle") 321 return fmt.Errorf("can't write an invalid handle")
320 } 322 }
321 UntypedHandle := handle.ToUntypedHandle() 323 UntypedHandle := handle.ToUntypedHandle()
322 e.handles = append(e.handles, UntypedHandle) 324 e.handles = append(e.handles, UntypedHandle)
323 return e.WriteUint32(uint32(len(e.handles) - 1)) 325 return e.WriteUint32(uint32(len(e.handles) - 1))
324 } 326 }
OLDNEW
« no previous file with comments | « third_party/mojo/src/mojo/public/go/bindings/decoder.go ('k') | third_party/mojo/src/mojo/public/go/system/message_pipe.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698