bsloane1650 commented on a change in pull request #207: Added support for enumerations and TypeValueCalc URL: https://github.com/apache/incubator-daffodil/pull/207#discussion_r278372611
########## File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/DFDLXTypeCalcFunctions.scala ########## @@ -0,0 +1,239 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.daffodil.dpath + +import org.apache.daffodil.xml.QName +import org.apache.daffodil.util.Maybe +import org.apache.daffodil.processors.TypeCalculator +import org.apache.daffodil.processors.SimpleTypeRuntimeData +import org.apache.daffodil.exceptions.Assert +import org.apache.daffodil.dpath.NodeInfo.PrimType.IntegerKind +import org.apache.daffodil.dpath.NodeInfo.PrimType.String +import org.apache.daffodil.dpath.NodeInfo.PrimType.Integer + +trait typeCalculatorNamedDispatch { self: FNTwoArgs => + var srcType: NodeInfo.Kind = null + var dstType: NodeInfo.Kind = null + + override def validateType(srcTypes: Seq[NodeInfo.Kind], dstType: NodeInfo.Kind): Unit = { + //We can't actually verify anything yet, because we need to wait until run() is + //called to know what calculator we are using Review comment: I agree with the naming issue. The original idea was just that I was deferring type-checking to expression nodes themselves, which is a layer of abstraction lower then we normally do, so this function was providing a back door to sneak the type information into the nodes without tearing up too much existing code. If there is a pre-existing way of getting this type information at the layer I need it, I can remove this function entirely The reason I ended up deferring to runtime is that we could, in principle, have expressions like: { dfdl:inputTypeCalcInt(../functionName, ../functionArg) } where the type calculator to be used is determined by the infoset itself. Mike had suggested just not allowing this. If we insist the function name be a constant, we should be able to move the validation back to compile time (along with a handleful of other missing/invalid typeCalculator errors). Even if someone comes along with a reason to need the dynamisism, it might still be worth it to specialize the constant case to provide SDEs at compile time. ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
