本文整理汇总了Golang中github.com/gsrpc/gslang/ast.Method类的典型用法代码示例。如果您正苦于以下问题:Golang Method类的具体用法?Golang Method怎么用?Golang Method使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Method类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: parseExceptions
func (parser *Parser) parseExceptions(method *ast.Method) {
token := parser.peek()
if token.Type != lexer.KeyThrows {
return
}
parser.next()
parser.expectf(lexer.TokenType('('), "method exception table must start with (")
for {
typeDecl := parser.expectTypeDecl("expect exception type")
exception := method.NewException(typeDecl)
start, end := Pos(typeDecl)
_setNodePos(exception, start, end)
token := parser.peek()
if token.Type != lexer.TokenType(',') {
break
}
parser.next()
}
parser.expectf(lexer.TokenType(')'), "method exception table must end with )")
}
开发者ID:gsrpc,项目名称:gslang,代码行数:33,代码来源:parser.go
示例2: methodRPC
func (codegen *_CodeGen) methodRPC(method *ast.Method) string {
var buff bytes.Buffer
if codegen.notVoid(method.Return) {
buff.WriteString(fmt.Sprintf("com.gsrpc.Future<%s> %s(", codegen.objTypeName(method.Return), methodName(method.Name())))
} else {
if gslang.IsAsync(method) {
buff.WriteString(fmt.Sprintf("void %s(", methodName(method.Name())))
} else {
buff.WriteString(fmt.Sprintf("com.gsrpc.Future<Void> %s(", methodName(method.Name())))
}
}
for _, v := range method.Params {
buff.WriteString(fmt.Sprintf("%s arg%d, ", codegen.typeName(v.Type), v.ID))
}
if !gslang.IsAsync(method) {
buff.WriteString("final int timeout)")
} else {
buff.WriteString(")")
}
return strings.Replace(buff.String(), ", )", ")", -1)
}
开发者ID:gsrpc,项目名称:gsrpc,代码行数:27,代码来源:codegen.go
示例3: methodcall
func (codegen *_CodeGen) methodcall(method *ast.Method) string {
var buff bytes.Buffer
if !codegen.notVoid(method.Return) {
buff.WriteString(fmt.Sprintf("this.service.%s(", methodName(method.Name())))
} else {
buff.WriteString(fmt.Sprintf("%s ret = this.service.%s(", codegen.typeName(method.Return), methodName(method.Name())))
}
for i := range method.Params {
buff.WriteString(fmt.Sprintf("arg%d, ", i))
}
buff.WriteString(");")
return strings.Replace(buff.String(), ", );", ");", -1)
}
开发者ID:gsrpc,项目名称:gsrpc,代码行数:18,代码来源:codegen.go
示例4: methodDecl
func (codegen *_CodeGen) methodDecl(method *ast.Method) string {
var stream bytes.Buffer
stream.WriteString(fmt.Sprintf("- (%s)", codegen.typeName(method.Return)))
if len(method.Params) > 0 {
stream.WriteString(fmt.Sprintf(" %s:(%s)arg0", method.Name(), codegen.typeName(method.Params[0].Type)))
for i := 1; i < len(method.Params); i++ {
stream.WriteString(fmt.Sprintf(" withArg%d:(%s)arg%d", i, codegen.typeName(method.Params[i].Type), i))
}
} else {
stream.WriteString(fmt.Sprintf(" %s", method.Name()))
}
return stream.String()
}
开发者ID:gsrpc,项目名称:gsrpc,代码行数:19,代码来源:codegen.go
示例5: parseParams
func (parser *Parser) parseParams(method *ast.Method) {
parser.expectf(lexer.TokenType('('), "method param table must start with (")
for {
token := parser.peek()
if token.Type == lexer.TokenType(')') {
break
}
for parser.parseAnnotation() {
}
typeDecl := parser.expectTypeDecl("expect method param type declare")
nameToken := parser.expectf(lexer.TokenID, "expect method param name")
name := nameToken.Value.(string)
param, ok := method.NewParam(name, typeDecl)
parser.attachAnnotation(param)
if !ok {
parser.errorf(token.Start, "duplicate method(%s) param(%s)", method, name)
}
_setNodePos(param, token.Start, nameToken.End)
token = parser.peek()
if token.Type != lexer.TokenType(',') {
break
}
parser.next()
}
parser.expectf(lexer.TokenType(')'), "method param table must end with )")
}
开发者ID:gsrpc,项目名称:gslang,代码行数:43,代码来源:parser.go
示例6: rpcMethodDecl
func (codegen *_CodeGen) rpcMethodDecl(method *ast.Method) string {
var stream bytes.Buffer
if gslang.IsAsync(method) {
stream.WriteString("- (NSError*)")
} else {
stream.WriteString("- (id<GSPromise>)")
}
if len(method.Params) > 0 {
stream.WriteString(fmt.Sprintf(" %s:(%s) arg0 ", method.Name(), codegen.typeName(method.Params[0].Type)))
for i := 1; i < len(method.Params); i++ {
stream.WriteString(fmt.Sprintf(" withArg%d:(%s) arg%d ", i, codegen.typeName(method.Params[i].Type), i))
}
} else {
stream.WriteString(fmt.Sprintf(" %s", method.Name()))
}
return stream.String()
}
开发者ID:gsrpc,项目名称:gsrpc,代码行数:22,代码来源:codegen.go
示例7: methodCall
func (codegen *_CodeGen) methodCall(method *ast.Method) string {
var stream bytes.Buffer
if codegen.notVoid(method.Return) {
stream.WriteString(fmt.Sprintf("%s ret = ", codegen.typeName(method.Return)))
}
if len(method.Params) > 0 {
stream.WriteString(fmt.Sprintf("[ _service %s: arg0 ", method.Name()))
for i := 1; i < len(method.Params); i++ {
stream.WriteString(fmt.Sprintf(" withArg%d:arg%d ", i, i))
}
} else {
stream.WriteString(fmt.Sprintf(" [ _service %s", method.Name()))
}
stream.WriteString("];")
return stream.String()
}
开发者ID:gsrpc,项目名称:gsrpc,代码行数:23,代码来源:codegen.go
注:本文中的github.com/gsrpc/gslang/ast.Method类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论