@@ -34,7 +34,6 @@ import java.net.URISyntaxException
34
34
import org .apache .daffodil .lib .calendar .DFDLDateConversion
35
35
import org .apache .daffodil .lib .calendar .DFDLDateTimeConversion
36
36
import org .apache .daffodil .lib .calendar .DFDLTimeConversion
37
- import org .apache .daffodil .lib .exceptions .Assert
38
37
import org .apache .daffodil .lib .util .Delay
39
38
import org .apache .daffodil .lib .util .Enum
40
39
import org .apache .daffodil .lib .util .MaybeInt
@@ -84,33 +83,15 @@ sealed abstract class TypeNode private (
84
83
childrenDelay : Delay [Seq [NodeInfo .Kind ]]
85
84
) extends Serializable
86
85
with NodeInfo .Kind {
87
-
88
86
def this (parents : => Seq [NodeInfo .Kind ], children : => Seq [NodeInfo .Kind ]) =
89
87
this (Delay (" TypeNode" , parents), Delay (" TypeNode" , children))
90
88
91
- def this (parentArg : NodeInfo .Kind , childrenArg : => Seq [NodeInfo .Kind ]) =
92
- this (Delay (" TypeNode" , Seq (parentArg)), Delay (" TypeNode" , childrenArg))
93
-
94
89
def this (parentArg : => NodeInfo .Kind ) =
95
90
this (
96
91
Delay (" TypeNode" , Seq (parentArg)),
97
92
Delay (" TypeNode" , Seq [NodeInfo .Kind ](NodeInfo .Nothing ))
98
93
)
99
94
100
- /**
101
- * Cyclic structures require an initialization
102
- */
103
- lazy val initialize : Unit = {
104
- parents
105
- children // demand their value
106
- parents.foreach { p =>
107
- // if this fails, it is because cyclic graph construction of the types
108
- // has failed. For some reason, this doesn't cause a stack overflow, but
109
- // you just get null as the value of one of the case object type nodes.
110
- Assert .invariant(p ne null )
111
- }
112
- }
113
-
114
95
final override lazy val parents = parentsDelay.value
115
96
final override lazy val children = childrenDelay.value
116
97
}
@@ -122,12 +103,11 @@ sealed abstract class TypeNode private (
122
103
*/
123
104
sealed abstract class PrimTypeNode (
124
105
val dfdlType : DFDLPrimType ,
125
- parent : NodeInfo .Kind ,
106
+ parent : => NodeInfo .Kind ,
126
107
childrenArg : => Seq [NodeInfo .Kind ]
127
- ) extends TypeNode (parent, childrenArg)
108
+ ) extends TypeNode (Seq ( parent) , childrenArg)
128
109
with NodeInfo .PrimType {
129
-
130
- def this (javaType : DFDLPrimType , parent : NodeInfo .Kind ) =
110
+ def this (javaType : DFDLPrimType , parent : => NodeInfo .Kind ) =
131
111
this (javaType, parent, Seq (NodeInfo .Nothing ))
132
112
133
113
}
@@ -173,16 +153,6 @@ class InvalidPrimitiveDataException(msg: String, cause: Throwable = null)
173
153
*/
174
154
object NodeInfo extends Enum {
175
155
176
- /**
177
- * Cyclic structures require initialization
178
- */
179
- private lazy val initialize : Boolean = {
180
- allTypes.foreach {
181
- _.initialize
182
- }
183
- true
184
- }
185
-
186
156
// Primitives are not "global" because they don't appear in any schema document
187
157
188
158
sealed trait PrimType extends PrimTypeKind {
@@ -256,6 +226,7 @@ object NodeInfo extends Enum {
256
226
case _ => QName .createGlobal(name, NoNamespace , scala.xml.TopScope )
257
227
}
258
228
}
229
+
259
230
val ClassString = classOf [java.lang.String ]
260
231
val ClassIntBoxed = classOf [java.lang.Integer ]
261
232
val ClassIntPrim = classOf [scala.Int ]
@@ -392,14 +363,16 @@ object NodeInfo extends Enum {
392
363
protected sealed trait AnySimpleTypeKind extends AnyType .Kind {
393
364
final def primType : PrimType = optPrimType.get
394
365
}
395
- case object AnySimpleType extends TypeNode (AnyType , Seq (AnyAtomic )) with AnySimpleTypeKind {
366
+ case object AnySimpleType
367
+ extends TypeNode (Seq (AnyType ), Seq (AnyAtomic ))
368
+ with AnySimpleTypeKind {
396
369
type Kind = AnySimpleTypeKind
397
370
}
398
371
399
372
protected sealed trait AnyAtomicKind extends AnySimpleType .Kind
400
373
case object AnyAtomic
401
374
extends TypeNode (
402
- AnySimpleType ,
375
+ Seq ( AnySimpleType ) ,
403
376
Seq (String , Numeric , Boolean , Opaque , AnyDateTime , AnyURI )
404
377
)
405
378
with AnyAtomicKind {
@@ -408,27 +381,27 @@ object NodeInfo extends Enum {
408
381
409
382
protected sealed trait NumericKind extends AnyAtomic .Kind
410
383
case object Numeric
411
- extends TypeNode (AnyAtomic , Seq (SignedNumeric , UnsignedNumeric ))
384
+ extends TypeNode (Seq ( AnyAtomic ) , Seq (SignedNumeric , UnsignedNumeric ))
412
385
with NumericKind {
413
386
type Kind = NumericKind
414
387
}
415
388
416
389
protected sealed trait SignedNumericKind extends Numeric .Kind
417
390
case object SignedNumeric
418
- extends TypeNode (Numeric , Seq (Float , Double , Decimal ))
391
+ extends TypeNode (Seq ( Numeric ) , Seq (Float , Double , Decimal ))
419
392
with SignedNumericKind {
420
393
type Kind = SignedNumericKind
421
394
}
422
395
423
396
protected sealed trait UnsignedNumericKind extends Numeric .Kind
424
397
case object UnsignedNumeric
425
- extends TypeNode (Numeric , Seq (NonNegativeInteger ))
398
+ extends TypeNode (Seq ( Numeric ) , Seq (NonNegativeInteger ))
426
399
with UnsignedNumericKind {
427
400
type Kind = UnsignedNumericKind
428
401
}
429
402
430
403
protected sealed trait OpaqueKind extends AnyAtomic .Kind
431
- case object Opaque extends TypeNode (AnyAtomic , Seq (HexBinary )) with OpaqueKind {
404
+ case object Opaque extends TypeNode (Seq ( AnyAtomic ) , Seq (HexBinary )) with OpaqueKind {
432
405
type Kind = OpaqueKind
433
406
}
434
407
@@ -452,33 +425,33 @@ object NodeInfo extends Enum {
452
425
453
426
protected sealed trait AnyDateTimeKind extends AnyAtomicKind
454
427
case object AnyDateTime
455
- extends TypeNode (AnyAtomic , Seq (Date , Time , DateTime ))
428
+ extends TypeNode (Seq ( AnyAtomic ) , Seq (Date , Time , DateTime ))
456
429
with AnyDateTimeKind {
457
430
type Kind = AnyDateTimeKind
458
431
}
459
432
460
433
// One might think these can be def, but scala insists on "stable identifier"
461
434
// where these are used in case matching.
462
- val String = PrimType .String
463
- val Int = PrimType .Int
464
- val Byte = PrimType .Byte
465
- val Short = PrimType .Short
466
- val Long = PrimType .Long
467
- val Integer = PrimType .Integer
468
- val Decimal = PrimType .Decimal
469
- val UnsignedInt = PrimType .UnsignedInt
470
- val UnsignedByte = PrimType .UnsignedByte
471
- val UnsignedShort = PrimType .UnsignedShort
472
- val UnsignedLong = PrimType .UnsignedLong
473
- val NonNegativeInteger = PrimType .NonNegativeInteger
474
- val Double = PrimType .Double
475
- val Float = PrimType .Float
476
- val HexBinary = PrimType .HexBinary
477
- val AnyURI = PrimType .AnyURI
478
- val Boolean = PrimType .Boolean
479
- val DateTime = PrimType .DateTime
480
- val Date = PrimType .Date
481
- val Time = PrimType .Time
435
+ lazy val String = PrimType .String
436
+ lazy val Int = PrimType .Int
437
+ lazy val Byte = PrimType .Byte
438
+ lazy val Short = PrimType .Short
439
+ lazy val Long = PrimType .Long
440
+ lazy val Integer = PrimType .Integer
441
+ lazy val Decimal = PrimType .Decimal
442
+ lazy val UnsignedInt = PrimType .UnsignedInt
443
+ lazy val UnsignedByte = PrimType .UnsignedByte
444
+ lazy val UnsignedShort = PrimType .UnsignedShort
445
+ lazy val UnsignedLong = PrimType .UnsignedLong
446
+ lazy val NonNegativeInteger = PrimType .NonNegativeInteger
447
+ lazy val Double = PrimType .Double
448
+ lazy val Float = PrimType .Float
449
+ lazy val HexBinary = PrimType .HexBinary
450
+ lazy val AnyURI = PrimType .AnyURI
451
+ lazy val Boolean = PrimType .Boolean
452
+ lazy val DateTime = PrimType .DateTime
453
+ lazy val Date = PrimType .Date
454
+ lazy val Time = PrimType .Time
482
455
483
456
protected sealed trait PrimTypeKind extends AnyAtomic .Kind
484
457
@@ -1048,6 +1021,4 @@ object NodeInfo extends Enum {
1048
1021
NonEmptyString ,
1049
1022
Nothing
1050
1023
) ++ allAbstractTypes
1051
-
1052
- initialize // initialize self - creates all cyclic structures
1053
1024
}
0 commit comments