Skip to content

Commit

Permalink
refixing #192
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Jul 18, 2013
1 parent cae80b2 commit 3f813cf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions cli/src/main/scala/scalaxb/compiler/xsd2/Generator.scala
Expand Up @@ -169,7 +169,7 @@ class Generator(val schema: ReferenceSchema,
)
else if (decl.hasSimpleContent) simpleContentTree(decl.base)
else if (particles.isEmpty) NIL
else if (particles.size == 1) PAREN(buildXMLTree(Param(particles(0))))
else if (particles.size == 1) PAREN(buildXMLTree(Param(particles(0), 0)))
else (SeqClass DOT "concat")(Param.fromSeq(particles) map { x => buildXMLTree(x) })

Some(DEF("writesChildNodes", TYPE_SEQ(NodeClass)) withParams(PARAM("__obj", sym),
Expand Down Expand Up @@ -472,7 +472,7 @@ class Generator(val schema: ReferenceSchema,
case compositor if compositor.particles.isEmpty => EmptyTree
case compositor =>
val fmt = formatterSymbol(sym)
val param = Param(compositor)
val param = Param(compositor, 0)
val parser = buildKeyedGroupParser(compositor, Occurrence.SingleNotNillable(), false, false)
val (wrapperParam, wrapperParser) = compositor match {
case x: TaggedKeyedGroup if x.key == ChoiceTag => (param, parser)
Expand Down
23 changes: 13 additions & 10 deletions cli/src/main/scala/scalaxb/compiler/xsd2/Params.scala
Expand Up @@ -2,6 +2,7 @@ package scalaxb.compiler.xsd2

import scalaxb._
import xmlschema._
import scalaxb.compiler.Module.camelCase
import scalaxb.compiler.xsd.{XsAnyType, XsNillableAny, BuiltInSimpleTypeSymbol, XsTypeSymbol, XsInt}
import Defs._
import Occurrence._
Expand Down Expand Up @@ -84,15 +85,15 @@ trait Params { self: Namer with Lookup with Splitter =>
}

object Param {
def apply(tagged: Tagged[Any]): Param = buildParam(tagged, 0)
def apply(tagged: Tagged[Any], postfix: Int): Param = buildParam(tagged, postfix)

def fromSeq(particles: Seq[Tagged[Any]]): Seq[Param] = {
var anyNumber: Int = 0
particles map { tagged => tagged.value match {
particles.zipWithIndex map { case (tagged, i) => tagged.value match {
case any: XAny =>
anyNumber += 1
buildParam(tagged, anyNumber)
case _ => buildParam(tagged, 0)
case _ => buildParam(tagged, i + 1)
}}
}

Expand All @@ -107,14 +108,14 @@ trait Params { self: Namer with Lookup with Splitter =>
case TaggedSimpleType(decl, tag) => Param(tagged.tag.namespace, "value", tagged, SingleNotNillable(), false, false, false)
case TaggedSymbol(symbol, tag) => Param(tagged.tag.namespace, "value", tagged, SingleNotNillable(), false, false, false)
case x: TaggedLocalElement => buildElementParam(x)
case x: TaggedGroupRef => buildGroupRefParam(x)
case x: TaggedGroupRef => buildGroupRefParam(x, postfix)
case x: TaggedKeyedGroup if x.key == AllTag => buildDataRecordMapParam(ALL_PARAM, x)
case x: TaggedKeyedGroup if x.key == ChoiceTag => buildChoiceParam(x)
case x: TaggedKeyedGroup => buildCompositorParam(x)
case x: TaggedWildCard => buildWildCardParam(x, postfix)
case x: TaggedAttributeSeqParam => buildDataRecordMapParam(ATTRS_PARAM, x)
case x: TaggedMixedSeqParam => buildMixedParam(x)
case _ => error("buildParam: " + tagged)
case _ => sys.error("buildParam: " + tagged)
}

private def buildElementParam(tagged: Tagged[XLocalElementable]): Param = {
Expand All @@ -134,7 +135,7 @@ trait Params { self: Namer with Lookup with Splitter =>
}

private def buildChoiceParam(tagged: TaggedParticle[KeyedGroup]): Param = {
val name = getName(tagged).toLowerCase
val name = camelCase(getName(tagged))
val particles = tagged.particles
val o = Occurrence(tagged)

Expand Down Expand Up @@ -168,18 +169,20 @@ trait Params { self: Namer with Lookup with Splitter =>
}

private def buildCompositorParam(tagged: TaggedParticle[KeyedGroup]): Param = {
val name = getName(tagged).toLowerCase
val name = camelCase(getName(tagged))
val typeSymbol = tagged
val retval = Param(tagged.tag.namespace, name, typeSymbol, Occurrence(tagged), false, false, false)
logger.debug("buildCompositorParam: " + retval.toString)
retval
}

private def buildGroupRefParam(tagged: TaggedParticle[XGroupRef]): Param = {
private def buildGroupRefParam(tagged: TaggedParticle[XGroupRef], postfix: Int): Param = {
val group = resolveNamedGroup(tagged)
val name = getName(group).toLowerCase
val name = camelCase(getName(group)) +
(if (postfix <= 1) ""
else postfix.toString)
val retval = Param(group.tag.namespace, name, tagged, Occurrence(tagged), false, false, false)
logger.debug("buildGroupRefParam: " + retval.toString)
logger.debug("buildGroupRefParam: " + postfix.toString + ": " + retval.toString)
retval
}

Expand Down
8 changes: 4 additions & 4 deletions cli/src/main/scala/scalaxb/compiler/xsd2/args.scala
Expand Up @@ -106,21 +106,21 @@ trait Args { self: Namer with Lookup with Params with Symbols =>
buildTypeSymbolArg(buildType(tagged), selector, o, elem.default, elem.fixed, wrapForLongAll)
}
case x: TaggedGroupRef =>
val param = Param(x)
val param = Param(x, 0)
param.occurrence match {
case Multiple(_) => selector DOT "toSeq"
case OptionalNillable(_) => selector INFIX("getOrElse") APPLY BLOCK(NONE)
case _ => selector
}
case x: TaggedKeyedGroup =>
val param = Param(x)
val param = Param(x, 0)
param.occurrence match {
case Multiple(_) => selector DOT "toSeq"
case OptionalNillable(_) => selector INFIX("getOrElse") APPLY BLOCK(NONE)
case _ => selector
}
case AnyLike(x) =>
val param = Param(x)
val param = Param(x, 0)
buildTypeSymbolArg(buildType(x), selector, param.occurrence, None, None, wrapForLongAll)
case _ => sys.error("Args#buildArg: " + tagged.toString)
}
Expand All @@ -146,7 +146,7 @@ trait Args { self: Namer with Lookup with Params with Symbols =>
def buildArgForMixed(tagged: Tagged[Any], selector: Tree): Tree = {
import Occurrence._

val occcurrence = Param(tagged).occurrence
val occcurrence = Param(tagged, 0).occurrence
val isCompositor = tagged match {
case x: TaggedWildCard => true
case x: TaggedKeyedGroup => true
Expand Down
2 changes: 1 addition & 1 deletion integration/src/test/scala/GeneralTest.scala
Expand Up @@ -7,7 +7,7 @@ object GeneralTest extends TestBase {
import scalaxb.compiler.xsd.Driver
import scalaxb.compiler.xsd2.{Driver => Driver2}

// Log.configureLogger(true)
Log.configureLogger(true)
override val module: Module = new Driver2

val inFile = new File("integration/src/test/resources/general.xsd")
Expand Down

0 comments on commit 3f813cf

Please sign in to comment.