• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang seq.Buffer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中golang.org/x/mobile/bind/seq.Buffer的典型用法代码示例。如果您正苦于以下问题:Golang Buffer类的具体用法?Golang Buffer怎么用?Golang Buffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Buffer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: 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
}
开发者ID:Christeefym,项目名称:lantern,代码行数:37,代码来源:seq_darwin.go


示例2: 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
}
开发者ID:0x90sled,项目名称:mobile,代码行数:7,代码来源:go_testpkg.go


示例3: 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
}
开发者ID:0x90sled,项目名称:mobile,代码行数:7,代码来源:go_testpkg.go


示例4: 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)
}
开发者ID:0x90sled,项目名称:mobile,代码行数:7,代码来源:go_testpkg.go


示例5: proxy_StopClientProxy

func proxy_StopClientProxy(out, in *seq.Buffer) {
	err := flashlight.StopClientProxy()
	if err == nil {
		out.WriteUTF16("")
	} else {
		out.WriteUTF16(err.Error())
	}
}
开发者ID:dexuter,项目名称:lantern-android,代码行数:8,代码来源:go_bindings.go


示例6: StringError

func (p *proxyI) StringError(s string) (string, error) {
	in := new(seq.Buffer)
	in.WriteString(s)
	out := seq.Transact((*seq.Ref)(p), "go.testpkg.I", proxyI_StringError_Code, in)
	res_0 := out.ReadString()
	res_1 := out.ReadError()
	return res_0, res_1
}
开发者ID:0x90sled,项目名称:mobile,代码行数:8,代码来源:go_testpkg.go


示例7: proxy_CallF

func proxy_CallF(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)
	}
	testpkg.CallF(param_i)
}
开发者ID:Miaque,项目名称:mojo,代码行数:10,代码来源:go_testpkg.go


示例8: var_setInterfaceVar

func var_setInterfaceVar(out, in *seq.Buffer) {
	var v testpkg.I
	v_ref := in.ReadRef()
	if v_ref.Num < 0 { // go object
		v = v_ref.Get().(testpkg.I)
	} else { // foreign object
		v = (*proxyI)(v_ref)
	}
	testpkg.InterfaceVar = v
}
开发者ID:nadiasvertex,项目名称:mobile,代码行数:10,代码来源:go_testpkg.go


示例9: proxy_Keep

func proxy_Keep(out, in *seq.Buffer) {
	var param_i testpkg.I
	param_i_ref := in.ReadRef()
	if param_i_ref.Num < 0 {
		param_i = param_i_ref.Get().(testpkg.I)
	} else {
		param_i = (*proxyI)(param_i_ref)
	}
	testpkg.Keep(param_i)
}
开发者ID:dylanpoe,项目名称:golang.org,代码行数:10,代码来源:go_testpkg.go


示例10: 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]
	in := new(seq.Buffer)
	if reqlen > 0 {
		in.Data = (*[maxSliceLen]byte)(unsafe.Pointer(req))[:reqlen]
	}
	out := new(seq.Buffer)
	fn(out, in)
	seqToBuf(res, reslen, out)
}
开发者ID:TriangleGo,项目名称:golang.org,代码行数:12,代码来源:seq_android.go


示例11: proxyStructThatStartsWithLetterBeforeZ_Value_Set

func proxyStructThatStartsWithLetterBeforeZ_Value_Set(out, in *seq.Buffer) {
	ref := in.ReadRef()
	var v testpkg.Z
	v_ref := in.ReadRef()
	if v_ref.Num < 0 { // go object
		v = v_ref.Get().(testpkg.Z)
	} else { // foreign object
		v = (*proxyZ)(v_ref)
	}
	ref.Get().(*testpkg.StructThatStartsWithLetterBeforeZ).Value = v
}
开发者ID:Christeefym,项目名称:lantern,代码行数:11,代码来源:go_testpkg.go


示例12: 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)
}
开发者ID:0x90sled,项目名称:mobile,代码行数:11,代码来源:go_testpkg.go


示例13: proxyI_StringError

func proxyI_StringError(out, in *seq.Buffer) {
	ref := in.ReadRef()
	v := ref.Get().(testpkg.I)
	param_s := in.ReadString()
	res, err := v.StringError(param_s)
	out.WriteString(res)
	if err == nil {
		out.WriteString("")
	} else {
		out.WriteString(err.Error())
	}
}
开发者ID:0x90sled,项目名称:mobile,代码行数:12,代码来源:go_testpkg.go


示例14: 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)
}
开发者ID:0x90sled,项目名称:mobile,代码行数:8,代码来源:go_testpkg.go


示例15: proxy_CallIStringError

func proxy_CallIStringError(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_s := in.ReadString()
	res, err := testpkg.CallIStringError(param_i, param_s)
	out.WriteString(res)
	if err == nil {
		out.WriteString("")
	} else {
		out.WriteString(err.Error())
	}
}
开发者ID:0x90sled,项目名称:mobile,代码行数:17,代码来源:go_testpkg.go


示例16: 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())
	}
}
开发者ID:0x90sled,项目名称:mobile,代码行数:10,代码来源:go_testpkg.go


示例17: 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)
}
开发者ID:tendermint,项目名称:mobile,代码行数:20,代码来源:seq_android.go


示例18: proxyIVE

func proxyIVE(out, in *seq.Buffer) {
	ref := in.ReadRef()
	v := ref.Get().(testpkg.I)
	res, err := v.VE()
	out.WriteInt(res)
	if err == nil {
		out.WriteUTF16("")
	} else {
		out.WriteUTF16(err.Error())
	}
}
开发者ID:Miaque,项目名称:mojo,代码行数:11,代码来源:go_testpkg.go


示例19: 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())
	}
}
开发者ID:0x90sled,项目名称:mobile,代码行数:11,代码来源:go_testpkg.go


示例20: 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)
}
开发者ID:0x90sled,项目名称:mobile,代码行数:7,代码来源:go_testpkg.go



注:本文中的golang.org/x/mobile/bind/seq.Buffer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang key.Event类代码示例发布时间:2022-05-28
下一篇:
Golang seq.Register函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap