本文整理匯總了Golang中github.com/c-darwin/mobile/bind/seq.Buffer類的典型用法代碼示例。如果您正苦於以下問題:Golang Buffer類的具體用法?Golang Buffer怎麽用?Golang Buffer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Buffer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Times
func (p *proxyI) Times(v int32) int64 {
in := new(seq.Buffer)
in.WriteInt32(v)
out := seq.Transact((*seq.Ref)(p), "go.testpkg.I", proxyI_Times_Code, in)
res_0 := out.ReadInt64()
return res_0
}
示例2: proxy_CallSSum
func proxy_CallSSum(out, in *seq.Buffer) {
// Must be a Go object
param_s_ref := in.ReadRef()
param_s := param_s_ref.Get().(*testpkg.S)
res := testpkg.CallSSum(param_s)
out.WriteFloat64(res)
}
示例3: Error
func (p *proxyI) Error(triggerError bool) error {
in := new(seq.Buffer)
in.WriteBool(triggerError)
out := seq.Transact((*seq.Ref)(p), "go.testpkg.I", proxyI_Error_Code, in)
res_0 := out.ReadError()
return res_0
}
示例4: transact
// transact calls a method on an Objective-C object instance.
// It blocks until the call is complete.
//
// Code (>0) is the method id assigned by gobind.
// Code -1 is used to instruct Objective-C to decrement the ref count of
// the Objective-Co object.
func transact(ref *seq.Ref, descriptor string, code int, in *seq.Buffer) *seq.Buffer {
var (
res *C.uint8_t = nil
resLen C.size_t = 0
req *C.uint8_t = nil
reqLen C.size_t = 0
)
if len(in.Data) > 0 {
req = (*C.uint8_t)(unsafe.Pointer(&in.Data[0]))
reqLen = C.size_t(len(in.Data))
}
if debug {
fmt.Printf("transact: ref.Num = %d code = %d\n", ref.Num, code)
}
desc := cstrings.get(descriptor)
C.go_seq_recv(C.int32_t(ref.Num), desc, C.int(code), req, reqLen, &res, &resLen)
if resLen > 0 {
goSlice := (*[maxSliceLen]byte)(unsafe.Pointer(res))[:resLen]
out := new(seq.Buffer)
out.Data = make([]byte, int(resLen))
copy(out.Data, goSlice)
C.free(unsafe.Pointer(res))
// TODO: own or copy []bytes whose addresses were passed in.
return out
}
return nil
}
示例5: proxy_RegisterI
func proxy_RegisterI(out, in *seq.Buffer) {
param_idx := in.ReadInt32()
var param_i testpkg.I
param_i_ref := in.ReadRef()
if param_i_ref.Num < 0 { // go object
param_i = param_i_ref.Get().(testpkg.I)
} else { // foreign object
param_i = (*proxyI)(param_i_ref)
}
testpkg.RegisterI(param_idx, param_i)
}
示例6: proxyS_TryTwoStrings
func proxyS_TryTwoStrings(out, in *seq.Buffer) {
ref := in.ReadRef()
v := ref.Get().(*testpkg.S)
param_first := in.ReadString()
param_second := in.ReadString()
res := v.TryTwoStrings(param_first, param_second)
out.WriteString(res)
}
示例7: proxy_ReturnsError
func proxy_ReturnsError(out, in *seq.Buffer) {
param_b := in.ReadBool()
res, err := testpkg.ReturnsError(param_b)
out.WriteString(res)
if err == nil {
out.WriteString("")
} else {
out.WriteString(err.Error())
}
}
示例8: Send
// Send is called by Java to send a request to run a Go function.
//export Send
func Send(descriptor string, code int, req *C.uint8_t, reqlen C.size_t, res **C.uint8_t, reslen *C.size_t) {
fn := seq.Registry[descriptor][code]
if fn == nil {
panic(fmt.Sprintf("invalid descriptor(%s) and code(0x%x)", descriptor, code))
}
in := new(seq.Buffer)
if reqlen > 0 {
in.Data = (*[maxSliceLen]byte)(unsafe.Pointer(req))[:reqlen]
}
out := new(seq.Buffer)
fn(out, in)
// BUG(hyangah): the function returning a go byte slice (so fn writes a pointer into 'out') is unsafe.
// After fn is complete here, Go runtime is free to collect or move the pointed byte slice
// contents. (Explicitly calling runtime.GC here will surface the problem?)
// Without pinning support from Go side, it will be hard to fix it without extra copying.
seqToBuf(res, reslen, out)
}
示例9: proxyI_Error
func proxyI_Error(out, in *seq.Buffer) {
ref := in.ReadRef()
v := ref.Get().(testpkg.I)
param_triggerError := in.ReadBool()
err := v.Error(param_triggerError)
if err == nil {
out.WriteString("")
} else {
out.WriteString(err.Error())
}
}
示例10: proxyI_Times
func proxyI_Times(out, in *seq.Buffer) {
ref := in.ReadRef()
v := ref.Get().(testpkg.I)
param_v := in.ReadInt32()
res := v.Times(param_v)
out.WriteInt64(res)
}
示例11: proxy_CallIError
func proxy_CallIError(out, in *seq.Buffer) {
var param_i testpkg.I
param_i_ref := in.ReadRef()
if param_i_ref.Num < 0 { // go object
param_i = param_i_ref.Get().(testpkg.I)
} else { // foreign object
param_i = (*proxyI)(param_i_ref)
}
param_triggerError := in.ReadBool()
err := testpkg.CallIError(param_i, param_triggerError)
if err == nil {
out.WriteString("")
} else {
out.WriteString(err.Error())
}
}
示例12: proxyNode_Err_Get
func proxyNode_Err_Get(out, in *seq.Buffer) {
ref := in.ReadRef()
v := ref.Get().(*testpkg.Node).Err
if v == nil {
out.WriteString("")
} else {
out.WriteString(v.Error())
}
}
示例13: proxy_Hello
func proxy_Hello(out, in *seq.Buffer) {
param_s := in.ReadString()
res := testpkg.Hello(param_s)
out.WriteString(res)
}
示例14: proxy_CollectS
func proxy_CollectS(out, in *seq.Buffer) {
param_want := in.ReadInt()
param_timeoutSec := in.ReadInt()
res := testpkg.CollectS(param_want, param_timeoutSec)
out.WriteInt(res)
}
示例15: proxy_BytesAppend
func proxy_BytesAppend(out, in *seq.Buffer) {
param_a := in.ReadByteArray()
param_b := in.ReadByteArray()
res := testpkg.BytesAppend(param_a, param_b)
out.WriteByteArray(res)
}