本文整理汇总了Golang中tritium/proto.Function.Stub方法的典型用法代码示例。如果您正苦于以下问题:Golang Function.Stub方法的具体用法?Golang Function.Stub怎么用?Golang Function.Stub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tritium/proto.Function
的用法示例。
在下文中一共展示了Function.Stub方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: resolveNativeDeclaration
// can't re-use the legacy native function resolver because it's a method of a
// type that provides its own helpers and contextual data, all of which would
// be too hard to reproduce
func (pkgr *Packager) resolveNativeDeclaration(f *tp.Function, path string) {
// first we should check that the signature refers to something that actually exists
sigStr := strings.Replace(f.Stub(pkgr.Package), ",", ".", -1)
if whale.LookupBuiltIn(sigStr) == nil {
panic(fmt.Sprintf("attempt to provide signature for nonexistent native function `%s` in `%s`", sigStr, path))
}
// now turn the type names into the appropriate numeric ids
if returnType := f.GetReturnType(); len(returnType) > 0 {
f.ReturnTypeId = proto.Int32(int32(pkgr.TypeMap[returnType]))
f.ReturnType = nil
}
if scopeType := f.GetScopeType(); len(scopeType) > 0 {
f.ScopeTypeId = proto.Int32(int32(pkgr.TypeMap[scopeType]))
f.ScopeType = nil
}
if opensType := f.GetOpensType(); len(opensType) > 0 {
f.OpensTypeId = proto.Int32(int32(pkgr.TypeMap[opensType]))
f.OpensType = nil
}
for _, arg := range f.Args {
if typeName := arg.GetTypeString(); len(typeName) > 0 {
arg.TypeId = proto.Int32(int32(pkgr.TypeMap[typeName]))
arg.TypeString = nil
}
}
}