Skip to content

Commit

Permalink
fix visibility in :serialize-*
Browse files Browse the repository at this point in the history
  • Loading branch information
gciatto committed Jun 28, 2020
1 parent 6395d91 commit 0db238c
Show file tree
Hide file tree
Showing 22 changed files with 58 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import it.unibo.tuprolog.core.Term
import it.unibo.tuprolog.core.Var

@Suppress("USELESS_CAST")
class JsTermDeobjectifier : TermDeobjectifier {
internal class JsTermDeobjectifier : TermDeobjectifier {

private val scope: Scope = Scope.empty()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package it.unibo.tuprolog.serialize

import it.unibo.tuprolog.core.Term

class JsTermDeserializer(override val mimeType: MimeType) : TermDeserializer {
internal class JsTermDeserializer(override val mimeType: MimeType) : TermDeserializer {
override fun deserialize(string: String): Term =
JsTermDeobjectifier().deobjectify(parse(string))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package it.unibo.tuprolog.serialize

import it.unibo.tuprolog.core.*

class JsTermObjectifier : TermObjectifier {
internal class JsTermObjectifier : TermObjectifier {
override fun defaultValue(term: Term): Any {
throw IllegalStateException()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package it.unibo.tuprolog.serialize

import it.unibo.tuprolog.core.Term

class JsTermSerializer(override val mimeType: MimeType) : TermSerializer {
internal class JsTermSerializer(override val mimeType: MimeType) : TermSerializer {

private val objectifier = JsTermObjectifier()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package it.unibo.tuprolog.serialize

fun emptyJsObject() = jsObject()

fun jsObject(config: dynamic.() -> Unit): Any {
internal fun jsObject(config: dynamic.() -> Unit): Any {
val obj = object {}
config(obj)
return obj
}

fun jsObject(vararg properties: Pair<String, dynamic>, config: dynamic.() -> Unit = {}): Any {
internal fun jsObject(vararg properties: Pair<String, dynamic>, config: dynamic.() -> Unit = {}): Any {
return jsObject {
for ((k, v) in properties) {
this[k] = v
Expand All @@ -17,7 +15,7 @@ fun jsObject(vararg properties: Pair<String, dynamic>, config: dynamic.() -> Uni
}
}

fun jsObject(properties: Iterable<Pair<String, dynamic>>, config: dynamic.() -> Unit = {}): Any {
internal fun jsObject(properties: Iterable<Pair<String, dynamic>>, config: dynamic.() -> Unit = {}): Any {
return jsObject {
for ((k, v) in properties) {
this[k] = v
Expand All @@ -26,9 +24,5 @@ fun jsObject(properties: Iterable<Pair<String, dynamic>>, config: dynamic.() ->
}
}

fun jsObject(properties: Sequence<Pair<String, dynamic>>, config: dynamic.() -> Unit = {}): Any {
return jsObject(properties.asIterable(), config)
}

fun hasProperty(obj: dynamic, name: String): Boolean =
internal fun hasProperty(obj: dynamic, name: String): Boolean =
obj[name] != undefined
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.math.BigDecimal
import java.math.BigInteger
import it.unibo.tuprolog.core.Integer as LogicInteger

class JvmTermDeobjectifier : TermDeobjectifier {
internal class JvmTermDeobjectifier : TermDeobjectifier {

private val scope: Scope = Scope.empty()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package it.unibo.tuprolog.serialize
import it.unibo.tuprolog.core.Term
import java.io.Reader

class JvmTermDeserializer(override val mimeType: MimeType) : ReadingTermDeserializer {
internal class JvmTermDeserializer(override val mimeType: MimeType) : ReadingTermDeserializer {

private val mapper = mimeType.objectMapper

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import it.unibo.tuprolog.core.*
import it.unibo.tuprolog.core.List
import it.unibo.tuprolog.core.Set

class JvmTermObjectifier : TermObjectifier {
internal class JvmTermObjectifier : TermObjectifier {
override fun defaultValue(term: Term): Any {
throw IllegalStateException()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package it.unibo.tuprolog.serialize
import it.unibo.tuprolog.core.Term
import java.io.Writer

class JvmTermSerializer(override val mimeType: MimeType) : WritingTermSerializer {
internal class JvmTermSerializer(override val mimeType: MimeType) : WritingTermSerializer {

private val mapper = mimeType.objectMapper
private val objectifier = JvmTermObjectifier()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@ package it.unibo.tuprolog.serialize

import it.unibo.tuprolog.core.Term

interface ReadingTermDeserializer : TermDeserializer, ReadingDeserializer<Term>
interface ReadingTermDeserializer : TermDeserializer, ReadingDeserializer<Term> {
companion object {
@JvmStatic
fun of(mimeType: MimeType): ReadingTermDeserializer {
return JvmTermDeserializer(mimeType)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@ package it.unibo.tuprolog.serialize

import it.unibo.tuprolog.core.Term

interface WritingTermSerializer : TermSerializer, WritingSerializer<Term>
interface WritingTermSerializer : TermSerializer, WritingSerializer<Term> {
companion object {
@JvmStatic
fun of(mimeType: MimeType): WritingTermSerializer {
return JvmTermSerializer(mimeType)
}
}
}
6 changes: 6 additions & 0 deletions serialize-theory/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ kotlin {
}
}

val commonTest by getting {
dependencies {
api(project(":solve"))
}
}

jvm {
compilations["main"].defaultSourceSet {
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package it.unibo.tuprolog.serialize
import it.unibo.tuprolog.core.Clause
import it.unibo.tuprolog.theory.Theory

class JsTheoryDeobjectifier : TheoryDeobjectifier {
internal class JsTheoryDeobjectifier : TheoryDeobjectifier {
override fun deobjectify(`object`: Any): Theory {
return Theory.of(
JsTermDeobjectifier().deobjectifyMany(`object`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package it.unibo.tuprolog.serialize

import it.unibo.tuprolog.theory.Theory

class JsTheoryDeserializer(override val mimeType: MimeType) : TheoryDeserializer {
internal class JsTheoryDeserializer(override val mimeType: MimeType) : TheoryDeserializer {
override fun deserialize(string: String): Theory =
JsTheoryDeobjectifier().deobjectify(parse(string))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package it.unibo.tuprolog.serialize

import it.unibo.tuprolog.theory.Theory

class JsTheoryObjectifier : TheoryObjectifier {
internal class JsTheoryObjectifier : TheoryObjectifier {
private val objectifier = JsTermObjectifier()

override fun objectify(value: Theory): Any {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package it.unibo.tuprolog.serialize

import it.unibo.tuprolog.theory.Theory

class JsTheorySerializer(override val mimeType: MimeType) : TheorySerializer {
internal class JsTheorySerializer(override val mimeType: MimeType) : TheorySerializer {

private val objectifier = JsTheoryObjectifier()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package it.unibo.tuprolog.serialize
import it.unibo.tuprolog.core.Clause
import it.unibo.tuprolog.theory.Theory

class JvmTheoryDeobjectifier : TheoryDeobjectifier {
internal class JvmTheoryDeobjectifier : TheoryDeobjectifier {
override fun deobjectify(`object`: Any): Theory {
return Theory.of(
JvmTermDeobjectifier().deobjectifyMany(`object`)
TermDeobjectifier.default.deobjectifyMany(`object`)
.asSequence()
.map { it as Clause }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package it.unibo.tuprolog.serialize
import it.unibo.tuprolog.theory.Theory
import java.io.Reader

class JvmTheoryDeserializer(override val mimeType: MimeType) : ReadingTheoryDeserializer {
internal class JvmTheoryDeserializer(override val mimeType: MimeType) : ReadingTheoryDeserializer {

private val mapper = mimeType.objectMapper

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package it.unibo.tuprolog.serialize

import it.unibo.tuprolog.theory.Theory

class JvmTheoryObjectifier : TheoryObjectifier {
internal class JvmTheoryObjectifier : TheoryObjectifier {

private val objectifier = JvmTermObjectifier()
private val objectifier = TermObjectifier.default

override fun objectify(value: Theory): Any {
return value.map { objectifier.objectify(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package it.unibo.tuprolog.serialize
import it.unibo.tuprolog.theory.Theory
import java.io.Writer

class JvmTheorySerializer(override val mimeType: MimeType) : WritingTheorySerializer {
internal class JvmTheorySerializer(override val mimeType: MimeType) : WritingTheorySerializer {

private val mapper = mimeType.objectMapper
private val objectifier = JvmTheoryObjectifier()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@ package it.unibo.tuprolog.serialize

import it.unibo.tuprolog.theory.Theory

interface ReadingTheoryDeserializer : TheoryDeserializer, ReadingDeserializer<Theory>
interface ReadingTheoryDeserializer : TheoryDeserializer, ReadingDeserializer<Theory> {
companion object {
@JvmStatic
fun of(mimeType: MimeType): ReadingTheoryDeserializer {
return JvmTheoryDeserializer(mimeType)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ package it.unibo.tuprolog.serialize
import it.unibo.tuprolog.theory.Theory

interface WritingTheorySerializer : TheorySerializer, WritingSerializer<Theory> {
companion object {
@JvmStatic
fun of(mimeType: MimeType): WritingTheorySerializer {
return JvmTheorySerializer(mimeType)
}
}
}

0 comments on commit 0db238c

Please sign in to comment.