Beispiel #1
0
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)
}
Beispiel #2
0
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()
}