// Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package seq implements the machine-dependent seq serialization format. // // Implementations of Transact and FinalizeRef are provided by a // specific foreign language binding package, e.g. go.mobile/bind/java. // // Designed only for use by the code generated by gobind. Don't try to // use this directly. package seq // import "golang.org/x/mobile/bind/seq" // TODO(crawshaw): // There is opportunity for optimizing these language // bindings which requires deconstructing seq into something // gnarly. So don't get too attached to the design. import ( "fmt" _ "golang.org/x/mobile/internal/mobileinit" ) // Transact calls a method on a foreign object instance. // It blocks until the call is complete. var Transact func(ref *Ref, code int, in *Buffer) (out *Buffer) // FinalizeRef is the finalizer used on foreign objects. var FinalizeRef func(ref *Ref) // A Func can be registered and called by a foreign language. type Func func(out, in *Buffer) // Registry holds functions callable from gobind generated bindings. // Functions are keyed by descriptor and function code. var Registry = make(map[string]map[int]Func) // Register registers a function in the Registry. func Register(descriptor string, code int, fn Func) { m := Registry[descriptor] if m == nil { m = make(map[int]Func) Registry[descriptor] = m } if m[code] != nil { panic(fmt.Sprintf("registry.Register: %q/%d already registered", descriptor, code)) } m[code] = fn } // DecString decodes a string encoded in the Buffer. var DecString func(in *Buffer) string // EncString encodes a Go string into the Buffer. var EncString func(out *Buffer, v string)