Permalink
Browse files

fixes varg parameters in wsdl generated file. fixes #125

  • Loading branch information...
1 parent dccae78 commit 838db8b8975ffe6e7cbdf085bc1b81f6236e1c48 @eed3si9n committed Nov 29, 2011
Showing with 30 additions and 11 deletions.
  1. +27 −10 cli/src/main/scala/scalaxb/compiler/wsdl11/GenSource.scala
  2. +3 −1 notes/0.6.7.markdown
@@ -122,7 +122,7 @@ trait GenSource {
def makeOperationWrapperParams(op: XOperationType, headers: Seq[HeaderBinding],
symbol: XsTypeSymbol): Seq[ParamCache] = {
- val param = ParamCache("value", xsdgenerator.buildTypeName(symbol))
+ val param = ParamCache("value", xsdgenerator.buildTypeName(symbol), false)
val headerParams = headers flatMap { header =>
val message = context.messages(splitTypeName(header.message))
message.part find {_.name == Some(header.part)} map {toParamCache}
@@ -317,7 +317,8 @@ trait GenSource {
case AnyType(_) => (buildIRIStyleArgs(input) map {_.toParamName}).head
case symbol: BuiltInSimpleTypeSymbol => (buildIRIStyleArgs(input) map {_.toParamName}).head
case ReferenceTypeSymbol(decl: SimpleTypeDecl) => (buildIRIStyleArgs(input) map {_.toParamName}).head
- case _ => "%s(%s)".format(paramTypeName(input), buildIRIStyleArgs(input) map {_.toParamName} mkString(", "))
+ case _ =>
+ "%s(%s)".format(paramTypeName(input), buildIRIStyleArgs(input) map {_.toVarg} mkString(", "))
}
lazy val opLabel = "\"%s\"".format(op.name)
@@ -394,32 +395,48 @@ trait GenSource {
def paramMessage(input: XParamType): XMessageType = context.messages(splitTypeName(input.message))
- case class ParamCache(toParamName: String, typeName: String) {
+ case class ParamCache(toParamName: String, typeName: String, seqParam: Boolean) {
def toScalaCode: String = "%s: %s" format(toParamName, typeName)
+ def toVarg: String =
+ if (seqParam) toParamName + ": _*"
+ else toParamName
}
def buildRPCStyleArg(part: XPartType): ParamCache =
- ParamCache(part.name getOrElse {"in"}, xsdgenerator.buildTypeName(toTypeSymbol(part)))
+ ParamCache(part.name getOrElse {"in"}, xsdgenerator.buildTypeName(toTypeSymbol(part)), false)
def buildRPCStyleArgs(input: XParamType): List[ParamCache] = paramMessage(input).part.toList map {buildRPCStyleArg}
def buildIRIStyleArgs(input: XParamType): List[ParamCache] = paramMessage(input).part.headOption map { part =>
val paramName = part.name getOrElse {"in"}
toTypeSymbol(part) match {
case symbol: BuiltInSimpleTypeSymbol =>
- List(ParamCache(paramName, xsdgenerator.buildTypeName(symbol)))
+ List(ParamCache(paramName, xsdgenerator.buildTypeName(symbol), false))
case symbol@ReferenceTypeSymbol(decl: SimpleTypeDecl) =>
- List(ParamCache(paramName, xsdgenerator.buildTypeName(symbol)))
+ List(ParamCache(paramName, xsdgenerator.buildTypeName(symbol), false))
case ReferenceTypeSymbol(decl: ComplexTypeDecl) =>
+ import scalaxb.compiler.xsd.{Multiple, AllDecl, ComplexContentDecl, CompContRestrictionDecl, CompContExtensionDecl}
val flatParticles = xsdgenerator.flattenElements(decl, 0)
val attributes = xsdgenerator.flattenAttributes(decl)
val list = List.concat(flatParticles, attributes)
+ val primary = decl.content match {
+ case ComplexContentDecl(CompContRestrictionDecl(_, x, _)) => x
+ case ComplexContentDecl(CompContExtensionDecl(_, x, _)) => x
+ case _ => None
+ }
+ val longAll: Boolean = primary match {
+ case Some(all: AllDecl) if xsdgenerator.isLongAll(all, decl.namespace, decl.family) => true
+ case _ => false
+ }
+
list map { x =>
val param = xsdgenerator.buildParam(x) map {camelCase}
- ParamCache(param.toParamName, param.typeName)
+ val seqParam = (list.size == 1) && (param.cardinality == Multiple) &
+ (attributes.size == 0) && (!decl.mixed) && (!longAll)
+ ParamCache(param.toParamName, param.typeName, seqParam)
}
case AnyType(symbol) =>
- List(ParamCache(paramName, xsdgenerator.buildTypeName(symbol)))
+ List(ParamCache(paramName, xsdgenerator.buildTypeName(symbol), false))
case x => error("unexpected type: " + x)
}
} getOrElse {error("unexpected input: " + input)}
@@ -438,11 +455,11 @@ trait GenSource {
def toParamCache(part: XPartType): ParamCache =
part.typeValue map { typeValue =>
val name = camelCase(part.name.get)
- ParamCache(name, xsdgenerator.buildTypeName(toTypeSymbol(typeValue)))
+ ParamCache(name, xsdgenerator.buildTypeName(toTypeSymbol(typeValue)), false)
} getOrElse {
part.element map { element =>
val param = xsdgenerator.buildParam(xsdgenerator.elements(splitTypeName(element))) map {camelCase}
- ParamCache(param.toParamName, param.typeName)
+ ParamCache(param.toParamName, param.typeName, false)
} getOrElse {error("part does not have either type or element: " + part.toString)}
}
View
@@ -1,13 +1,15 @@
## bug fixes and minor enhancements
- Adds support for merging duplicate simple types. [#116][#116] reported by [@OlegYch][@OlegYch]
-- Fixes package name of wsdl generated file. [#117][#117] reported by [@hedefalk][@hedefalk] and [@OlegYch][@OlegYch]
- Fixes substitution group parsing. [#119][#119] reported by [@bmjsmith][@bmjsmith]
- Fixes `DataRecord` equality. [#120][#120] reported by [@deanhiller][@deanhiller]
+- Fixes package name of wsdl generated file. [#117][#117] reported by [@hedefalk][@hedefalk] and [@OlegYch][@OlegYch]
+- Fixes varg parameters in wsdl generated file. [#125][#125] reported by [@hedefalk][@hedefalk]
[#116]: https://github.com/eed3si9n/scalaxb/issues/116
[#117]: https://github.com/eed3si9n/scalaxb/issues/117
[#119]: https://github.com/eed3si9n/scalaxb/issues/119
[#120]: https://github.com/eed3si9n/scalaxb/issues/120
+ [#125]: https://github.com/eed3si9n/scalaxb/issues/125
[@OlegYch]: https://github.com/OlegYch
[@hedefalk]: https://github.com/hedefalk
[@bmjsmith]: https://github.com/bmjsmith

0 comments on commit 838db8b

Please sign in to comment.