Skip to content

Commit

Permalink
#53 - build test
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-twiner committed Jan 22, 2024
1 parent 56b63e8 commit acd4382
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 50 deletions.
35 changes: 15 additions & 20 deletions aalto/src/main/scala/scales/xml/parser/pull/aalto/AsyncParser.scala
Expand Up @@ -277,26 +277,21 @@ object AsyncParser {

def step(fromStart: Boolean): Input[DataChunk] => ResumableIter[DataChunk, F, EphemeralStream[PullType]] = s =>
s(el = e => {
if (e eq SuspendData)
done((emptyEphemeralStream, cont(step(false))), Input.Empty[DataChunk])
else {

val r = parser.nextInput(e)

r(el = es => {
done((es,
cont(step(false)))
, Input.Empty[DataChunk])
},
empty = {
//emptyness
cont(step(false))
},
eof = {
EOF
}
)
}
val r = parser.nextInput(e)

r(el = es => {
done((es,
cont(step(false)))
, Input.Empty[DataChunk])
},
empty = {
//emptyness
cont(step(false))
},
eof = {
EOF
}
)
},
empty = {
cont(step(false))
Expand Down
2 changes: 2 additions & 0 deletions docs/Getting_Started/release_notes/0.6.0.md
Expand Up @@ -362,6 +362,8 @@ val p = doSomethingReturningAnFofA
val a: A = p runIt
```

If you are having issues on 2.11/2.12 if the type is Trampoline make sure the import of monadHelpers is "_" or explicitly imports TrampolinePerformer as well (2.13 finds it without issue under Performer).

In order to make re-usable code specify the correct implicits, including the correct monad iteratees:

```scala
Expand Down
25 changes: 2 additions & 23 deletions scales-xml/src/main/scala/scales/utils/io/DataChunk.scala
Expand Up @@ -35,17 +35,6 @@ object EmptyData extends DataChunk {
override val isEmpty = true
}

/**
* Represents a data stream that has had too many empty reads (pretty much only aalto parsing)
*/
object SuspendData extends DataChunk {
val array = Array.empty[Byte]
val offset = -23
val length = 0

override val isEmpty = true
}

/**
* Represents the full array
*/
Expand All @@ -55,16 +44,6 @@ final case class FullChunk( array: Array[Byte] ) extends DataChunk {
}

/**
* A section of a Byte array. Due to Trampolining this cannot be re-used, as such a copy is made. TODO Perhaps this should be optional
* A section of a Byte array.
*/
//final case class Chunk( array: Array[Byte], offset: Int, length: Int) extends DataChunk

object Chunk{
def apply( array: Array[Byte], offset: Int, length: Int): DataChunk =
FullChunk{
val c = Array.ofDim[Byte](length)
Array.copy(array, offset, c, 0, length)
c
}
}

final case class Chunk( array: Array[Byte], offset: Int, length: Int) extends DataChunk
Expand Up @@ -243,12 +243,9 @@ trait ReadableByteChannelWrapperImplicits {
val nextIStep =
if (realChunk.isEOF)
k(Eof[DataChunk])
else if (realChunk.isEmpty) {
if (shouldPause)
k(Element(SuspendData))
else
k(Empty[DataChunk])
} else
else if (realChunk.isEmpty)
k(Empty[DataChunk])
else
k(Element(realChunk))

F.bind(nextIStep.value) { step =>
Expand Down
2 changes: 1 addition & 1 deletion scales-xml/src/test/scala/scales/utils/IterateeTests.scala
Expand Up @@ -18,7 +18,7 @@ import scales.utils._

import scala.annotation.tailrec
import scales.utils.iteratee.functions.IterOps
import scales.utils.iteratee.monadHelpers.Performer
import scales.utils.iteratee.monadHelpers._
object StreamHelpers {

def lTo(lower: Long, upper: Long): EphemeralStream[Long] =
Expand Down

0 comments on commit acd4382

Please sign in to comment.