mbeckerle commented on a change in pull request #273: WIP: Add User Defined Functions Capability URL: https://github.com/apache/incubator-daffodil/pull/273#discussion_r334636127
########## File path: daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala ########## @@ -1871,48 +1870,32 @@ case class FunctionCallExpression(functionQNameString: String, expressions: List case (RefQName(_, "unsignedByte", XSD), args) => XSConverterExpr(functionQNameString, functionQName, args, NodeInfo.UnsignedByte) - case (RefQName(Some(_), _, _), args) => { + case (_: RefQName, args) => { val namespace = functionQName.namespace.toString() val fName = functionQName.local - lazy val udfservice = { - val a = UDFService - a.warnings.map { w => SDW(WarnID.UserDefinedFunction, w) } - val allErrors = a.errors.mkString("\n\n") - SDE(s"Function unknown: fname[${fName}] fnamespace[${namespace}].\n$allErrors") - a - } - - val fcObject = udfservice.udfs.lookupFunctionClass(namespace, fName) - - if (fcObject == null) { - SDE("Function not found: fname[%s] fnamespace[%s]. Currently registered UDFs:\n%s", fName, namespace, udfservice.allFunctionClasses) - } - - val fcClassType = fcObject.getClass - - val paramTypesReturnTypeTuple: Array[(Array[Class[_]], Class[_])] = fcClassType.getMethods.collect { - case p if p.getName == "evaluate" => (p.getParameterTypes, p.getReturnType) - } - - if (paramTypesReturnTypeTuple.isEmpty) { - SDE("Missing evaluate method for function provided: name[%s] namespace[%s]", fName, namespace) - } + val udfCallingInfo = UserDefinedFunctionService.lookupUDFCallingInfo(namespace, fName) - if (paramTypesReturnTypeTuple.length > 1) { - SDE("Only one evaluate method allowed per function class: name[%s] namespace[%s]", fName, namespace) + if (udfCallingInfo.isEmpty) { + SDE(s"Error calling $namespace:$fName") Review comment: Do not use string interpolations for SDEs or any kind of user messaging. The SDE/SDW/PE system is designed to allow internationalization of messages. That requires that the underlying message system NOT get just a string, but an English-language string, and separate arguments for each thing substituted into it. It can then lookup a translation using the English string as a key, substitute in arguments in the right positions as that language requires them. So the style: SDE("Error calling %s:%s", namespace, name) is very much preferred. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services