mirror of
https://github.com/Smallhacker/disbrowser.git
synced 2025-01-14 01:29:58 +00:00
Moving to multitarget Gradle project
This commit is contained in:
parent
19424abe28
commit
f0bd8d5170
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
/.idea
|
||||
/target
|
||||
/src/main/resources/public/disbrowser.*
|
||||
/src/jvmMain/resources/public/disbrowser.*
|
57
build.gradle
Normal file
57
build.gradle
Normal file
@ -0,0 +1,57 @@
|
||||
plugins {
|
||||
id 'kotlin-multiplatform' version '1.3.11'
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
kotlin {
|
||||
targets {
|
||||
fromPreset(presets.jvm, 'jvm')
|
||||
fromPreset(presets.js, 'js')
|
||||
}
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-common'
|
||||
}
|
||||
}
|
||||
commonTest {
|
||||
dependencies {
|
||||
implementation 'org.jetbrains.kotlin:kotlin-test-common'
|
||||
implementation 'org.jetbrains.kotlin:kotlin-test-annotations-common'
|
||||
}
|
||||
}
|
||||
jvmMain {
|
||||
dependencies {
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-core:2.9.8'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.8'
|
||||
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.9.8'
|
||||
implementation 'org.glassfish.jersey.containers:jersey-container-grizzly2-http:2.27'
|
||||
implementation 'org.glassfish.jersey.inject:jersey-hk2:2.27'
|
||||
|
||||
}
|
||||
languageSettings {
|
||||
enableLanguageFeature('InlineClasses')
|
||||
useExperimentalAnnotation('kotlin.ExperimentalUnsignedTypes')
|
||||
}
|
||||
}
|
||||
jvmTest {
|
||||
dependencies {
|
||||
implementation 'org.jetbrains.kotlin:kotlin-test'
|
||||
implementation 'org.jetbrains.kotlin:kotlin-test-junit'
|
||||
}
|
||||
}
|
||||
jsMain {
|
||||
dependencies {
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-js'
|
||||
}
|
||||
}
|
||||
jsTest {
|
||||
dependencies {
|
||||
implementation 'org.jetbrains.kotlin:kotlin-test-js'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1
gradle.properties
Normal file
1
gradle.properties
Normal file
@ -0,0 +1 @@
|
||||
kotlin.code.style=official
|
159
pom.xml
159
pom.xml
@ -1,159 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.smallhacker.disbrowser</groupId>
|
||||
<artifactId>disbrowser</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>disbrowser</name>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey</groupId>
|
||||
<artifactId>jersey-bom</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
<artifactId>jackson-module-kotlin</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<artifactId>jersey-container-grizzly2-http</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.inject</groupId>
|
||||
<artifactId>jersey-hk2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- uncomment this to get JSON support:
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-json-binding</artifactId>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.9</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>java</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<mainClass>com.smallhacker.disbrowser.Main</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<jvmTarget>1.8</jvmTarget>
|
||||
<args>
|
||||
<arg>-XXLanguage:+InlineClasses</arg>
|
||||
<arg>-Xexperimental=kotlin.ExperimentalUnsignedTypes</arg>
|
||||
</args>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>testCompile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<inherited>true</inherited>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<jersey.version>2.27</jersey.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<kotlin.version>1.3.11</kotlin.version>
|
||||
<jackson.version>2.9.8</jackson.version>
|
||||
</properties>
|
||||
</project>
|
11
settings.gradle
Normal file
11
settings.gradle
Normal file
@ -0,0 +1,11 @@
|
||||
pluginManagement {
|
||||
resolutionStrategy {
|
||||
eachPlugin {
|
||||
if (requested.id.id == "kotlin-multiplatform") {
|
||||
useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${requested.version}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rootProject.name = 'disbrowser'
|
||||
|
@ -81,47 +81,47 @@ class Grid {
|
||||
= ins.print(gameData)
|
||||
|
||||
add(y, ins.address,
|
||||
htmlFragment {
|
||||
text(address ?: "")
|
||||
},
|
||||
htmlFragment {
|
||||
text(bytes)
|
||||
},
|
||||
htmlFragment {
|
||||
text(address ?: "")
|
||||
},
|
||||
htmlFragment {
|
||||
text(bytes)
|
||||
},
|
||||
editableField(game, indicativeAddress, "label", label),
|
||||
htmlFragment {
|
||||
if (secondaryMnemonic == null) {
|
||||
htmlFragment {
|
||||
if (secondaryMnemonic == null) {
|
||||
text(primaryMnemonic)
|
||||
} else {
|
||||
span {
|
||||
text(primaryMnemonic)
|
||||
}.attr("title", secondaryMnemonic).addClass("opcode-info")
|
||||
}
|
||||
text(suffix ?: "")
|
||||
text(" ")
|
||||
val link = ins.linkedState
|
||||
if (link == null) {
|
||||
if (labelAddress == null) {
|
||||
text(operands ?: "")
|
||||
} else {
|
||||
span {
|
||||
text(primaryMnemonic)
|
||||
}.attr("title", secondaryMnemonic).addClass("opcode-info")
|
||||
val currentLabel = gameData[labelAddress]?.label
|
||||
editablePopupField(game, labelAddress, "label", operands, currentLabel)
|
||||
}
|
||||
text(suffix ?: "")
|
||||
text(" ")
|
||||
val link = ins.linkedState
|
||||
if (link == null) {
|
||||
if (labelAddress == null) {
|
||||
text(operands ?: "")
|
||||
} else {
|
||||
val currentLabel = gameData[labelAddress]?.label
|
||||
editablePopupField(game, labelAddress, "label", operands, currentLabel)
|
||||
}
|
||||
} else {
|
||||
val local = link.address in disassembly
|
||||
} else {
|
||||
val local = link.address in disassembly
|
||||
|
||||
val url = when {
|
||||
local -> "#${link.address.toSimpleString()}"
|
||||
else -> "/${game.id}/${link.address.toSimpleString()}/${link.urlString}"
|
||||
}
|
||||
|
||||
a {
|
||||
text(operands ?: "")
|
||||
}.attr("href", url)
|
||||
val url = when {
|
||||
local -> "#${link.address.toSimpleString()}"
|
||||
else -> "/${game.id}/${link.address.toSimpleString()}/${link.urlString}"
|
||||
}
|
||||
},
|
||||
htmlFragment {
|
||||
text(state ?: "")
|
||||
},
|
||||
|
||||
a {
|
||||
text(operands ?: "")
|
||||
}.attr("href", url)
|
||||
}
|
||||
},
|
||||
htmlFragment {
|
||||
text(state ?: "")
|
||||
},
|
||||
editableField(game, indicativeAddress, "comment", comment)
|
||||
)
|
||||
|
||||
@ -135,12 +135,12 @@ class Grid {
|
||||
private fun editableField(game: Game, address: SnesAddress, type: String, value: String?): HtmlNode {
|
||||
return htmlFragment {
|
||||
input.attr("value", value ?: "")
|
||||
.attr("type", "text")
|
||||
.addClass("field-$type")
|
||||
.addClass("field-editable")
|
||||
.attr("data-field", type)
|
||||
.attr("data-game", game.id)
|
||||
.attr("data-address", address.toSimpleString())
|
||||
.attr("type", "text")
|
||||
.addClass("field-$type")
|
||||
.addClass("field-editable")
|
||||
.attr("data-field", type)
|
||||
.attr("data-game", game.id)
|
||||
.attr("data-address", address.toSimpleString())
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,9 +164,9 @@ class Grid {
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
htmlFragment {
|
||||
text("...")
|
||||
},
|
||||
htmlFragment {
|
||||
text("...")
|
||||
},
|
||||
null,
|
||||
null
|
||||
)
|
||||
@ -220,8 +220,8 @@ class Grid {
|
||||
}.addClass(cssClass)
|
||||
}
|
||||
}.addClass(rowClasses[y])
|
||||
.attr("id", rowId[y])
|
||||
.attr("row-certainty", rowCertainties[y])
|
||||
.attr("id", rowId[y])
|
||||
.attr("row-certainty", rowCertainties[y])
|
||||
}
|
||||
}
|
||||
}
|
@ -66,10 +66,14 @@ private class HtmlTextNode(private val text: String): HtmlNode {
|
||||
}
|
||||
|
||||
private object ParentBuilder {
|
||||
operator fun getValue(a: HtmlArea, b: KProperty<*>) = ParentHtmlElement(b.name).appendTo(a.parent)
|
||||
operator fun getValue(a: HtmlArea, b: KProperty<*>) = ParentHtmlElement(
|
||||
b.name
|
||||
).appendTo(a.parent)
|
||||
}
|
||||
private object LeafBuilder {
|
||||
operator fun getValue(a: HtmlArea, b: KProperty<*>) = HtmlElement(b.name).appendTo(a.parent)
|
||||
operator fun getValue(a: HtmlArea, b: KProperty<*>) = HtmlElement(
|
||||
b.name
|
||||
).appendTo(a.parent)
|
||||
}
|
||||
|
||||
fun htmlFragment(inner: InnerHtml = {}) = object : HtmlNode {
|
||||
@ -108,7 +112,9 @@ val HtmlArea.button by ParentBuilder
|
||||
fun HtmlNode.appendTo(node: HtmlNode) = apply { node.append(this) }
|
||||
fun HtmlNode.addClass(c: String?) = attrAdd("class", c)
|
||||
val HtmlNode.inner get() = this
|
||||
operator fun HtmlNode.invoke(inner: InnerHtml): HtmlNode = append(htmlFragment(inner))
|
||||
operator fun HtmlNode.invoke(inner: InnerHtml): HtmlNode = append(
|
||||
htmlFragment(inner)
|
||||
)
|
||||
|
||||
fun HtmlNode.attr(key: String, value: String?, inner: InnerHtml) = attr(key, value).inner(inner)
|
||||
fun HtmlNode.addClass(c: String?, inner: InnerHtml) = addClass(c).inner(inner)
|
@ -15,7 +15,8 @@ fun <T> immStack(): ImmStack<T> {
|
||||
return EmptyImmStack as ImmStack<T>
|
||||
}
|
||||
|
||||
private class ImmStackImpl<E>(private val parent: ImmStack<E>, override val top: E): ImmStack<E> {
|
||||
private class ImmStackImpl<E>(private val parent: ImmStack<E>, override val top: E):
|
||||
ImmStack<E> {
|
||||
override fun isEmpty() = false
|
||||
|
||||
override fun pop(): ImmStack<E> = parent
|
@ -111,7 +111,7 @@ object Disassembler {
|
||||
.forEach { tryAddFatal(it.address) }
|
||||
|
||||
while (fatalQueue.isNotEmpty()) {
|
||||
val badAddress = fatalQueue.removeNext()!!
|
||||
val badAddress = fatalQueue.removeNext()
|
||||
val instruction = instructionMap[badAddress] ?: continue
|
||||
val mnemonic = instruction.opcode.mnemonic
|
||||
if (mnemonic == Mnemonic.JSL || mnemonic == Mnemonic.JSR) continue
|
@ -101,28 +101,28 @@ class DisassemblyResource {
|
||||
?: return Response.status(404).build()
|
||||
|
||||
val html =
|
||||
htmlFragment {
|
||||
html {
|
||||
head {
|
||||
title { text("Disassembly Browser") }
|
||||
link.attr("rel", "stylesheet").attr("href", "/resources/style.css")
|
||||
meta.attr("charset", "UTF-8")
|
||||
htmlFragment {
|
||||
html {
|
||||
head {
|
||||
title { text("Disassembly Browser") }
|
||||
link.attr("rel", "stylesheet").attr("href", "/resources/style.css")
|
||||
meta.attr("charset", "UTF-8")
|
||||
}
|
||||
body {
|
||||
main {
|
||||
output.appendTo(parent)
|
||||
}
|
||||
body {
|
||||
main {
|
||||
output.appendTo(parent)
|
||||
}
|
||||
|
||||
aside.addClass("sidebar") {
|
||||
button.attr("id", "btn-dark-mode") {
|
||||
text("Dark Mode")
|
||||
}
|
||||
aside.addClass("sidebar") {
|
||||
button.attr("id", "btn-dark-mode") {
|
||||
text("Dark Mode")
|
||||
}
|
||||
|
||||
script.attr("src", "/resources/disbrowser.js")
|
||||
}
|
||||
|
||||
script.attr("src", "/resources/disbrowser.js")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Response.ok(html.toString().toByteArray(StandardCharsets.UTF_8))
|
||||
.encoding("UTF-8")
|
@ -3,7 +3,6 @@ package com.smallhacker.disbrowser.resource
|
||||
import com.smallhacker.disbrowser.Service
|
||||
import com.smallhacker.disbrowser.asm.SnesAddress
|
||||
import com.smallhacker.disbrowser.asm.MetadataLine
|
||||
import com.smallhacker.disbrowser.game.GameSource
|
||||
import com.smallhacker.disbrowser.game.getGameSource
|
||||
import javax.ws.rs.Consumes
|
||||
import javax.ws.rs.POST
|
Loading…
x
Reference in New Issue
Block a user