Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update libraries to new versions #246

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.9
0.11.13
23 changes: 10 additions & 13 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import contrib.jmh.JmhModule

val sjsonnetVersion = "0.4.14"

val scalaVersions = Seq("2.12.20", "2.13.15")
val scalaVersions = Seq("2.12.20", "2.13.15", "3.3.4")

trait SjsonnetCrossModule extends CrossScalaModule with PublishModule {
def crossValue: String
def artifactName = "sjsonnet"

def ivyDeps = Agg(
ivy"com.lihaoyi::fastparse::2.3.3",
ivy"com.lihaoyi::pprint::0.6.6",
ivy"com.lihaoyi::ujson::1.3.15",
ivy"com.lihaoyi::scalatags::0.9.4",
ivy"org.scala-lang.modules::scala-collection-compat::2.11.0"
ivy"com.lihaoyi::fastparse::3.1.1",
ivy"com.lihaoyi::pprint::0.9.0",
ivy"com.lihaoyi::ujson::4.0.2",
ivy"com.lihaoyi::scalatags::0.13.1",
ivy"org.scala-lang.modules::scala-collection-compat::2.12.0"
)
def publishVersion = sjsonnetVersion

Expand All @@ -41,14 +41,14 @@ trait SjsonnetCrossModule extends CrossScalaModule with PublishModule {
)
)
trait CrossTests extends ScalaModule with TestModule.Utest {
def ivyDeps = Agg(ivy"com.lihaoyi::utest::0.8.2")
def ivyDeps = Agg(ivy"com.lihaoyi::utest::0.8.4")
}
}

trait SjsonnetJvmNative extends ScalaModule {
def ivyDeps = super.ivyDeps() ++ Agg(
ivy"com.lihaoyi::os-lib::0.7.8",
ivy"com.lihaoyi::mainargs::0.2.5"
ivy"com.lihaoyi::os-lib::0.11.3",
ivy"com.lihaoyi::mainargs::0.7.6"
)
}

Expand All @@ -74,17 +74,14 @@ object sjsonnet extends Module {
object native extends Cross[SjsonnetNativeModule](scalaVersions)
trait SjsonnetNativeModule extends SjsonnetCrossModule with ScalaNativeModule with SjsonnetJvmNative {
def millSourcePath = super.millSourcePath / os.up
def scalaNativeVersion = "0.4.17"
def scalaNativeVersion = "0.5.6"
def sources = T.sources(
this.millSourcePath / "src",
this.millSourcePath / "src-native",
this.millSourcePath / "src-jvm-native"
)
def releaseMode = ReleaseMode.ReleaseFast
def nativeLTO = LTO.Thin

object test extends ScalaNativeTests with CrossTests {
def releaseMode = ReleaseMode.Debug
def scalaNativeVersion = SjsonnetNativeModule.this.scalaNativeVersion
def nativeLTO = LTO.None
def sources = T.sources(
Expand Down
6 changes: 3 additions & 3 deletions sjsonnet/src-jvm-native/sjsonnet/CachedResolvedFile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ class CachedResolvedFile(val resolvedImportPath: OsPath, memoryLimitBytes: Long,
}
}

override lazy val contentHash: String = {
private lazy val contentHashImpl: String = {
if (resolvedImportContent == null) {
// If the file is too large, then we will just read it from disk
Platform.hashFile(jFile)
} else {
resolvedImportContent.contentHash
resolvedImportContent.contentHash()
}
}
override def contentHash(): String = contentHashImpl
}

2 changes: 1 addition & 1 deletion sjsonnet/src-jvm-native/sjsonnet/OsPath.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ case class OsPath(p: os.Path) extends Path{
":" + Util.prettyIndex(lineStarts, offset)
}

p.relativeTo(os.pwd) + offsetStr
s"${p.relativeTo(os.pwd)}${offsetStr}"
}
}
6 changes: 3 additions & 3 deletions sjsonnet/src-jvm-native/sjsonnet/SjsonnetMain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ object SjsonnetMain {
importer = importer match{
case Some(i) => new Importer {
def resolve(docBase: Path, importName: String): Option[Path] =
i(docBase, importName).map(OsPath)
i(docBase, importName).map(OsPath.apply)
def read(path: Path): Option[ResolvedFile] = {
readPath(path)
}
}
case None => resolveImport(config.jpaths.map(os.Path(_, wd)).map(OsPath), allowedInputs)
case None => resolveImport(config.jpaths.map(os.Path(_, wd)).map(OsPath.apply), allowedInputs)
},
parseCache,
settings = new Settings(
Expand Down Expand Up @@ -242,7 +242,7 @@ object SjsonnetMain {
Right(writer.toString)
}
}
relPath = os.FilePath(multiPath) / os.RelPath(f)
relPath = os.RelPath(multiPath) / f
_ <- writeFile(config, relPath.resolveFrom(wd), rendered)
} yield relPath
}
Expand Down
10 changes: 7 additions & 3 deletions sjsonnet/src/sjsonnet/BaseCharRenderer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class BaseCharRenderer[T <: upickle.core.CharOps.Output]
(out: T,
indent: Int = -1,
escapeUnicode: Boolean = false,
newline: Array[Char] = Array('\n')) extends JsVisitor[T, T]{
newline: Array[Char] = Array('\n'),
wrapQuotes: Boolean = true) extends JsVisitor[T, T]{
protected[this] val elemBuilder = new upickle.core.CharBuilder
def flushCharBuilder(): Unit = {
elemBuilder.writeOutToIfLongerThan(out, if (depth == 0) 0 else 1000)
Expand Down Expand Up @@ -54,7 +55,10 @@ class BaseCharRenderer[T <: upickle.core.CharOps.Output]
}
}

def visitObject(length: Int, index: Int): ObjVisitor[T, T] = new ObjVisitor[T, T] {
def visitJsonableObject(length: Int, index: Int): ObjVisitor[T, T] =
throw new RuntimeException("jsonable objects are not supported. This should never be called")

override def visitObject(length: Int, jsonableKeys: Boolean, index: Int): ObjVisitor[T, T] = new ObjVisitor[T, T] {
flushBuffer()
elemBuilder.append('{')
depth += 1
Expand Down Expand Up @@ -154,7 +158,7 @@ class BaseCharRenderer[T <: upickle.core.CharOps.Output]

private def visitNonNullString(s: CharSequence, index: Int) = {
flushBuffer()
upickle.core.RenderUtils.escapeChar(null, elemBuilder, s, escapeUnicode)
upickle.core.RenderUtils.escapeChar(null, elemBuilder, s, escapeUnicode, wrapQuotes)
flushCharBuilder()
out
}
Expand Down
6 changes: 5 additions & 1 deletion sjsonnet/src/sjsonnet/BaseRenderer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class BaseRenderer[T <: java.io.Writer]
renderIndent()
}
}

def visitJsonableObject(length: Int, index: Int): ObjVisitor[T, T] =
throw new RuntimeException("jsonable objects are not supported. This should never be called")

def visitArray(length: Int, index: Int) = new ArrVisitor[T, T] {
flushBuffer()
out.append('[')
Expand All @@ -47,7 +51,7 @@ class BaseRenderer[T <: java.io.Writer]
}
}

def visitObject(length: Int, index: Int) = new ObjVisitor[T, T] {
override def visitObject(length: Int, jsonableKeys: Boolean, index: Int) = new ObjVisitor[T, T] {
flushBuffer()
out.append('{')
depth += 1
Expand Down
18 changes: 9 additions & 9 deletions sjsonnet/src/sjsonnet/Format.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ object Format{
precision: Option[Int],
conversion: Char)
import fastparse._, NoWhitespace._
def integer[_: P] = P( CharIn("1-9") ~ CharsWhileIn("0-9", 0) | "0" )
def label[_: P] = P( ("(" ~ CharsWhile(_ != ')').! ~ ")").? )
def flags[_: P] = P( CharsWhileIn("#0\\- +", 0).! )
def width[_: P] = P( (integer | "*").!.? )
def precision[_: P] = P( ("." ~/ integer.!).? )
def conversion[_: P] = P( CharIn("diouxXeEfFgGcrsa%").! )
def formatSpec[_: P] = P( label ~ flags ~ width ~ precision ~ CharIn("hlL").? ~ conversion ).map{
def integer[$: P] = P( CharIn("1-9") ~ CharsWhileIn("0-9", 0) | "0" )
def label[$: P] = P( ("(" ~ CharsWhile(_ != ')').! ~ ")").? )
def flags[$: P] = P( CharsWhileIn("#0\\- +", 0).! )
def width[$: P] = P( (integer | "*").!.? )
def precision[$: P] = P( ("." ~/ integer.!).? )
def conversion[$: P] = P( CharIn("diouxXeEfFgGcrsa%").! )
def formatSpec[$: P] = P( label ~ flags ~ width ~ precision ~ CharIn("hlL").? ~ conversion ).map{
case (label, flags, width, precision, conversion) =>
FormatSpec(
label,
Expand All @@ -44,8 +44,8 @@ object Format{
}


def plain[_: P] = P( CharsWhile(_ != '%', 0).! )
def format[_: P] = P( plain ~ (("%" ~/ formatSpec) ~ plain).rep ~ End)
def plain[$: P] = P( CharsWhile(_ != '%', 0).! )
def format[$: P] = P( plain ~ (("%" ~/ formatSpec) ~ plain).rep ~ End)



Expand Down
4 changes: 2 additions & 2 deletions sjsonnet/src/sjsonnet/Importer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ case class StaticResolvedFile(content: String) extends ResolvedFile {
def readString(): String = content

// We just cheat, the content hash can be the content itself for static imports
lazy val contentHash: String = content
def contentHash(): String = content
}

class CachedImporter(parent: Importer) extends Importer {
Expand All @@ -184,7 +184,7 @@ class CachedResolver(
internedStaticFieldSets: mutable.HashMap[Val.StaticObjectFieldSet, java.util.LinkedHashMap[String, java.lang.Boolean]]) extends CachedImporter(parentImporter) {

def parse(path: Path, content: ResolvedFile)(implicit ev: EvalErrorScope): Either[Error, (Expr, FileScope)] = {
parseCache.getOrElseUpdate((path, content.contentHash.toString), {
parseCache.getOrElseUpdate((path, content.contentHash().toString), {
val parsed = fastparse.parse(content.getParserInput(), new Parser(path, strictImportSyntax, internedStrings, internedStaticFieldSets).document(_)) match {
case f @ Parsed.Failure(_, _, _) =>
val traced = f.trace()
Expand Down
2 changes: 1 addition & 1 deletion sjsonnet/src/sjsonnet/Materializer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class Materializer {
case obj: Val.Obj =>
storePos(obj.pos)
obj.triggerAllAsserts(obj)
val objVisitor = visitor.visitObject(obj.visibleKeyNames.length , -1)
val objVisitor = visitor.visitObject(obj.visibleKeyNames.length, jsonableKeys = false, -1)
val sort = !evaluator.settings.preserveOrder
var prevKey: String = null
obj.foreachElement(sort, evaluator.emptyMaterializeFileScopePos) { (k, v) =>
Expand Down
Loading
Loading