| 1952 | } |
| 1953 | |
| 1954 | string CGenerator::getFunctionServerCall(Function *fn, bool isCCall) |
| 1955 | { |
| 1956 | string proto = ""; |
| 1957 | if (!isCCall) |
| 1958 | { |
| 1959 | if (!fn->getReturnType()->isVoid()) |
| 1960 | { |
| 1961 | proto += "result = "; |
| 1962 | } |
| 1963 | proto += "m_handler->"; |
| 1964 | } |
| 1965 | proto += getOutputName(fn); |
| 1966 | proto += "("; |
| 1967 | |
| 1968 | FunctionType *funcType = fn->getFunctionType(); |
| 1969 | |
| 1970 | auto params = (funcType) ? funcType->getParameters().getMembers() : fn->getParameters().getMembers(); |
| 1971 | |
| 1972 | if (params.size()) |
| 1973 | { |
| 1974 | unsigned int n = 0; |
| 1975 | for (auto it : params) |
| 1976 | { |
| 1977 | bool isLast = (n == params.size() - 1); |
| 1978 | DataType *trueDataType = it->getDataType()->getTrueDataType(); |
| 1979 | |
| 1980 | /* Builtin types and function types. */ |
| 1981 | if (((trueDataType->isScalar()) || trueDataType->isEnum() || trueDataType->isFunction()) && |
| 1982 | it->getDirection() != param_direction_t::kInDirection && findAnnotation(it, NULLABLE_ANNOTATION)) |
| 1983 | { |
| 1984 | // On server side is created new variable for handle null : "_" + name |
| 1985 | proto += "_"; |
| 1986 | } |
| 1987 | else if ((it->getDirection() != param_direction_t::kInDirection) && |
| 1988 | (((trueDataType->isScalar()) || trueDataType->isEnum() || trueDataType->isFunction()) || |
| 1989 | (findAnnotation(it, SHARED_ANNOTATION)))) |
| 1990 | |
| 1991 | { |
| 1992 | if (!isCCall) |
| 1993 | { |
| 1994 | proto += "&"; |
| 1995 | } |
| 1996 | } |
| 1997 | std::string paramName = getOutputName(fn->getParameters().getMembers()[n]); |
| 1998 | if ((paramName.empty()) || (funcType && funcType->getCallbackFuns().size() > 1)) |
| 1999 | { |
| 2000 | paramName = getOutputName(it); |
| 2001 | } |
| 2002 | proto += paramName; |
| 2003 | |
| 2004 | if (!isLast) |
| 2005 | { |
| 2006 | proto += ", "; |
| 2007 | } |
| 2008 | ++n; |
| 2009 | } |
| 2010 | } |
| 2011 | return proto + ");"; |
nothing calls this directly
no test coverage detected