Skip to content

Commit

Permalink
Merge branch 'master' into documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gciatto committed Jun 9, 2020
2 parents bd36540 + 095cd40 commit d29e091
Show file tree
Hide file tree
Showing 225 changed files with 9,819 additions and 1,615 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Giovanni Ciatto (giovanni.ciatto@unibo.it, giovanni.ciatto@gmail.com)
Enrico Siboni (enrico.siboni3@studio.unibo.it)
Paolo Verdini (paolo.verdini@studio.unibo.it, paolopiano1997@gmail.com)
Manuel Bonarrigo (manuel.bonarrigo@studio.unibo.it)
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ val githubToken = getPropertyOrWarnForAbsence("githubToken")
val npmToken = getPropertyOrWarnForAbsence("npmToken")

val allSubprojects = subprojects.map { it.name }.toSet()
val jvmSubprojects = setOf("parser-jvm")
val jvmSubprojects = setOf("parser-jvm", "examples")
val jsSubprojects = setOf("parser-js")
val docSubprojects = setOf("documentation")

Expand Down Expand Up @@ -173,7 +173,7 @@ ktSubprojects.forEachProject {
configureUploadToBintray("kotlinMultiplatform", "js", "jvm", "metadata")
configureSigning()
configureJsPackage()
configureUploadToGithub({ "jvm" in it })
configureUploadToGithub({ "jvm" in it || "shadow" in it })
}

jvmSubprojects.forEachProject {
Expand Down
36 changes: 23 additions & 13 deletions buildSrc/src/main/kotlin/Libs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,31 +92,41 @@ object Libs {

const val org_danilopianini_git_sensitive_semantic_versioning_gradle_plugin: String =
"org.danilopianini.git-sensitive-semantic-versioning:org.danilopianini.git-sensitive-semantic-versioning.gradle.plugin:" +
Versions.org_danilopianini_git_sensitive_semantic_versioning_gradle_plugin
Versions.org_danilopianini_git_sensitive_semantic_versioning_gradle_plugin

const val com_github_breadmoirai_github_release_gradle_plugin: String =
"com.github.breadmoirai.github-release:com.github.breadmoirai.github-release.gradle.plugin:" +
Versions.com_github_breadmoirai_github_release_gradle_plugin
"com.github.breadmoirai.github-release:com.github.breadmoirai.github-release.gradle.plugin:" +
Versions.com_github_breadmoirai_github_release_gradle_plugin

const val org_jetbrains_kotlin_multiplatform_gradle_plugin: String =
"org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:" +
Versions.org_jetbrains_kotlin_multiplatform_gradle_plugin
"org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:" +
Versions.org_jetbrains_kotlin_multiplatform_gradle_plugin

const val com_github_johnrengelman_shadow_gradle_plugin: String =
"com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:" +
Versions.com_github_johnrengelman_shadow_gradle_plugin

const val de_fayard_buildsrcversions_gradle_plugin: String =
"de.fayard.buildSrcVersions:de.fayard.buildSrcVersions.gradle.plugin:" +
Versions.de_fayard_buildsrcversions_gradle_plugin
"de.fayard.buildSrcVersions:de.fayard.buildSrcVersions.gradle.plugin:" +
Versions.de_fayard_buildsrcversions_gradle_plugin

const val com_eden_orchidplugin_gradle_plugin: String =
"com.eden.orchidPlugin:com.eden.orchidPlugin.gradle.plugin:" +
Versions.com_eden_orchidplugin_gradle_plugin
"com.eden.orchidPlugin:com.eden.orchidPlugin.gradle.plugin:" +
Versions.com_eden_orchidplugin_gradle_plugin

const val org_jetbrains_dokka_gradle_plugin: String =
"org.jetbrains.dokka:org.jetbrains.dokka.gradle.plugin:" +
Versions.org_jetbrains_dokka_gradle_plugin
"org.jetbrains.dokka:org.jetbrains.dokka.gradle.plugin:" +
Versions.org_jetbrains_dokka_gradle_plugin

const val com_jfrog_bintray_gradle_plugin: String =
"com.jfrog.bintray:com.jfrog.bintray.gradle.plugin:" +
Versions.com_jfrog_bintray_gradle_plugin
"com.jfrog.bintray:com.jfrog.bintray.gradle.plugin:" +
Versions.com_jfrog_bintray_gradle_plugin

/**
* 2.7.1
*/
const val clikt_multiplatform: String = "com.github.ajalt:clikt-multiplatform:" +
Versions.clikt_multiplatform

/**
* http://plantuml.sourceforge.net
Expand Down
8 changes: 6 additions & 2 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ object Versions {

const val org_jetbrains_kotlin_multiplatform_gradle_plugin: String = "1.3.72"

const val com_github_johnrengelman_shadow_gradle_plugin: String = "5.2.0"

const val de_fayard_buildsrcversions_gradle_plugin: String = "0.7.0"

const val com_eden_orchidplugin_gradle_plugin: String = "0.20.0"
Expand All @@ -32,16 +34,18 @@ object Versions {

const val com_jfrog_bintray_gradle_plugin: String = "1.8.5"

const val clikt_multiplatform: String = "2.7.1"

const val plantuml: String = "1.2020.2" // available: "8059"

const val kt_math: String = "0.1.3"

/**
* Current version: "6.3"
* Current version: "6.4.1"
* See issue 19: How to update Gradle itself?
* https://github.com/jmfayard/buildSrcVersions/issues/19
*/
const val gradleLatestVersion: String = "6.3"
const val gradleLatestVersion: String = "6.4.1"
}

/**
Expand Down
9 changes: 2 additions & 7 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
api("io.github.gciatto:kt-math:${Versions.kt_math}")
api(Libs.kt_math)
}
}
}
}

//tasks.getByName<KotlinPackageJsonTask>("jsPackageJson") {
// println(this::class.java)
// this.
//}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,12 @@ interface Directive : Clause {
@JsName("of")
fun of(body1: Term, vararg body: Term): Directive =
of(listOf(body1, *body))

@JvmStatic
@JsName("template")
fun template(length: Int = 1): Directive {
require(length > 0)
return of((0 until length).map { Var.anonymous() })
}
}
}
6 changes: 6 additions & 0 deletions core/src/commonMain/kotlin/it/unibo/tuprolog/core/Fact.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,11 @@ interface Fact : Rule {
@JvmStatic
@JsName("of")
fun of(head: Struct): Fact = FactImpl(head)

@JvmStatic
@JsName("template")
fun template(functor: String, arity: Int): Fact {
return of(Struct.template(functor, arity))
}
}
}
10 changes: 10 additions & 0 deletions core/src/commonMain/kotlin/it/unibo/tuprolog/core/List.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ interface List : Collection {
@JsName("ofIterable")
fun of(items: Iterable<Term>): List = from(items.toList(), empty())

@JvmStatic
@JsName("from")
fun from(vararg items: Term, last: Term?): List =
from(items.toList(), last)

@JvmStatic
@JsName("fromNullTerminated")
fun from(vararg items: Term): List =
from(items.toList(), null)

@JvmStatic
@JsName("fromIterable")
fun from(items: Iterable<Term>, last: Term?): List =
Expand Down
6 changes: 6 additions & 0 deletions core/src/commonMain/kotlin/it/unibo/tuprolog/core/Rule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,11 @@ interface Rule : Clause {
body.isEmpty() || body.size == 1 && body[0].isTrue -> Fact.of(head)
else -> RuleImpl(head, Tuple.wrapIfNeeded(*body))
}

@JvmStatic
@JsName("template")
fun template(functor: String, arity: Int): Rule {
return of(Struct.template(functor, arity), Var.anonymous())
}
}
}
7 changes: 6 additions & 1 deletion core/src/commonMain/kotlin/it/unibo/tuprolog/core/Struct.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ interface Struct : Term {
@JsName("functor")
val functor: String


@JsName("isFunctorWellFormed")
val isFunctorWellFormed: Boolean

Expand Down Expand Up @@ -116,6 +115,12 @@ interface Struct : Term {
escapeFunctor(string)
}

@JvmStatic
@JsName("template")
fun template(functor: String, arity: Int): Struct {
return of(functor, (0 until arity).map { Var.anonymous() })
}

@JvmStatic
@JsName("ofList")
fun of(functor: String, args: KtList<Term>): Struct =
Expand Down
34 changes: 34 additions & 0 deletions core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Cached.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package it.unibo.tuprolog.utils

import it.unibo.tuprolog.utils.impl.CachedImpl

interface Cached<T> {
companion object {
fun <T> of(generator: () -> T): Cached<T> {
return CachedImpl(generator)
}
}

val isValid: Boolean

val isInvalid: Boolean

val value: T

fun regenerate()

fun <R> regenerating(consumer: (T) -> R): R {
regenerate()
return value.let(consumer)
}

fun invalidate()

fun <R> ifValid(consumer: (T) -> R): Optional<out R> {
return if (isValid) {
Optional.of(value.let(consumer))
} else {
Optional.none()
}
}
}
9 changes: 9 additions & 0 deletions core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Deque.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package it.unibo.tuprolog.utils

expect fun <T> dequeOf(vararg items: T): MutableList<T>

expect fun <T> dequeOf(items: Iterable<T>): MutableList<T>

expect fun <T> dequeOf(items: Sequence<T>): MutableList<T>

expect fun <T> MutableList<T>.addFirst(item: T)
14 changes: 14 additions & 0 deletions core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Indexed.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package it.unibo.tuprolog.utils

interface Indexed<K, T> {
val index: K

val value: T

operator fun component1(): K = index

operator fun component2(): T = value

fun <R> map(mapper: (T) -> R): Indexed<K, R>
}

19 changes: 19 additions & 0 deletions core/src/commonMain/kotlin/it/unibo/tuprolog/utils/IntIndexed.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package it.unibo.tuprolog.utils

import it.unibo.tuprolog.utils.impl.IntIndexedImpl

interface IntIndexed<T> : Indexed<Int, T>, Comparable<IntIndexed<T>> {

override fun compareTo(other: IntIndexed<T>): Int {
return index - other.index
}

override fun <R> map(mapper: (T) -> R): IntIndexed<R>

companion object {
fun <T> of(index: Int, value: T): IntIndexed<T> {
return IntIndexedImpl(index, value)
}
}
}

Loading

0 comments on commit d29e091

Please sign in to comment.