mirror of
https://github.com/Anime-Game-Servers/anime-game-multi-proto.git
synced 2024-11-23 04:29:41 +00:00
[Refactoring] Moved the base interfaces from the gi module into a new core module
* Also updated the kotlin version to 1.9.24 * Made resource folder detection a little bit less hacky * Updated .gitignore
This commit is contained in:
parent
b342ff34df
commit
09d642b2eb
3
.gitignore
vendored
3
.gitignore
vendored
@ -5,8 +5,11 @@
|
||||
##gradle
|
||||
.gradle
|
||||
|
||||
.kotlin
|
||||
|
||||
## protos
|
||||
/protos
|
||||
/gi/src/commonMain/kotlin/protos
|
||||
|
||||
## build stuff
|
||||
build
|
||||
|
@ -2,7 +2,7 @@ group = "org.anime_game_servers.multi_proto"
|
||||
version = "0.2"
|
||||
plugins {
|
||||
id("maven-publish")
|
||||
kotlin("multiplatform") version "1.9.22" apply false
|
||||
kotlin("multiplatform") version "1.9.24" apply false
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,8 @@ plugins {
|
||||
group = "org.anime_game_servers.multi_proto"
|
||||
version = "0.1"
|
||||
kotlin {
|
||||
jvm {
|
||||
jvmToolchain(17)
|
||||
jvm {
|
||||
withJava()
|
||||
testRuns["test"].executionTask.configure {
|
||||
useJUnitPlatform()
|
||||
@ -15,7 +15,8 @@ kotlin {
|
||||
sourceSets {
|
||||
val jvmMain by getting {
|
||||
dependencies {
|
||||
implementation("com.google.devtools.ksp:symbol-processing-api:1.9.21-1.0.16")
|
||||
implementation("com.google.devtools.ksp:symbol-processing-api:1.9.24-1.0.20")
|
||||
implementation(project(":core"))
|
||||
}
|
||||
}
|
||||
val jvmTest by getting
|
||||
|
@ -1,4 +1,4 @@
|
||||
import BaseGenerator.Companion.snakeToLowerCamelCase
|
||||
|
||||
import com.google.devtools.ksp.KspExperimental
|
||||
import com.google.devtools.ksp.getDeclaredProperties
|
||||
import com.google.devtools.ksp.getKotlinClassByName
|
||||
|
@ -1,6 +1,8 @@
|
||||
import com.google.devtools.ksp.processing.KSPLogger
|
||||
import com.google.devtools.ksp.processing.Resolver
|
||||
import com.google.devtools.ksp.symbol.KSType
|
||||
import org.anime_game_servers.multi_proto.core.interfaces.ProtoModel
|
||||
import org.anime_game_servers.multi_proto.core.interfaces.ProtoModelDecoder
|
||||
import java.io.OutputStream
|
||||
|
||||
open class DataGenerator(
|
||||
@ -10,8 +12,8 @@ open class DataGenerator(
|
||||
) : BaseGenerator(logger, resolver, classInfoCache) {
|
||||
override fun addImports(file: OutputStream, classInfo: ClassInfo) {
|
||||
super.addImports(file, classInfo)
|
||||
file += "import interfaces.ProtoModel\n" +
|
||||
"import interfaces.ProtoModelDecoder\n" +
|
||||
file += "import ${ProtoModel::class.java.canonicalName}\n" +
|
||||
"import ${ProtoModelDecoder::class.java.canonicalName}\n" +
|
||||
"import pbandk.decodeFromByteArray\n"+
|
||||
"import pbandk.encodeToByteArray\n"+
|
||||
"import $PROTO_ONE_OF_ANNOTATION\n"
|
||||
@ -32,7 +34,7 @@ open class DataGenerator(
|
||||
}
|
||||
|
||||
open fun getImplementedModels(classInfo:ClassInfo):String{
|
||||
return "ProtoModel"
|
||||
return ProtoModel::class.java.simpleName
|
||||
}
|
||||
|
||||
override fun addBody(file: OutputStream, classInfo: ClassInfo) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import com.google.devtools.ksp.*
|
||||
import com.google.devtools.ksp.processing.*
|
||||
import com.google.devtools.ksp.symbol.*
|
||||
import org.anime_game_servers.multi_proto.core.annotations.ModuleMetaData
|
||||
import java.io.File
|
||||
import java.io.OutputStream
|
||||
|
||||
@ -207,7 +208,7 @@ class FunctionProcessor(
|
||||
|
||||
val compiledProtos = resolver.getClassSymbolsByAnnotation(COMPILED_PROTO_ANNOTATION)
|
||||
|
||||
val versionClassWorkaround = resolver.getClassSymbolsByAnnotation(PROTO_VERSION_ENUM_ANNOTATION).firstOrNull()
|
||||
val versionClassWorkaround = resolver.getClassSymbolsByAnnotation(ModuleMetaData::class.java.canonicalName).firstOrNull()
|
||||
val versionClass = resolver.getClassDeclarationByName(VERSION_ENUM_CLASS) ?: run {
|
||||
logger.error("[resources] Unable to find version class $VERSION_ENUM_CLASS")
|
||||
return emptyList()
|
||||
@ -215,7 +216,7 @@ class FunctionProcessor(
|
||||
|
||||
val resourcesPath = versionClassWorkaround?.let {
|
||||
it.containingFile?.let { file ->
|
||||
val basePath = file.filePath.removeSuffix("kotlin/messages/VERSION.kt")
|
||||
val basePath = file.filePath.removeSuffix("kotlin/${file.fileName}")
|
||||
logger.warn("[resources] BasePath: $basePath")
|
||||
basePath+"resources"
|
||||
}?: run {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import com.google.devtools.ksp.processing.KSPLogger
|
||||
import com.google.devtools.ksp.symbol.*
|
||||
import org.anime_game_servers.multi_proto.core.interfaces.PacketIdProvider
|
||||
import java.io.OutputStream
|
||||
import java.util.*
|
||||
|
||||
@ -14,7 +15,7 @@ class PacketIdGenerator(
|
||||
}
|
||||
|
||||
fun addImports(file: OutputStream) {
|
||||
file += "import interfaces.PacketIdProvider\n"
|
||||
file += "import ${PacketIdProvider::class.java.canonicalName}\n"
|
||||
}
|
||||
|
||||
fun addBody(file: OutputStream, className: String, packetIdMap: PacketIdResult) {
|
||||
|
59
core/build.gradle.kts
Normal file
59
core/build.gradle.kts
Normal file
@ -0,0 +1,59 @@
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
group = "org.anime_game_servers.multi_proto"
|
||||
version = "0.2"
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(17)
|
||||
jvm {
|
||||
withJava()
|
||||
testRuns["test"].executionTask.configure {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
}
|
||||
js(IR) {
|
||||
browser {
|
||||
commonWebpackConfig {
|
||||
cssSupport {
|
||||
enabled.set(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// mingwX64() not supported by pbandk-runtime 0.14.2
|
||||
linuxX64()
|
||||
linuxArm64()
|
||||
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies{
|
||||
implementation("org.anime_game_servers.core:gi:0.1")
|
||||
}
|
||||
}
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test"))
|
||||
}
|
||||
}
|
||||
val jvmMain by getting {
|
||||
getTasksByName("jvmJar", true).forEach{
|
||||
it.setProperty("zip64", true)
|
||||
}
|
||||
}
|
||||
val jvmTest by getting
|
||||
val jsMain by getting
|
||||
val jsTest by getting
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
from(components["kotlin"])
|
||||
artifactId = "core"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
package org.anime_game_servers.multi_proto.core.annotations
|
||||
|
||||
annotation class ModuleMetaData(val relativeResourcesPath:String)
|
@ -1,4 +1,4 @@
|
||||
package interfaces
|
||||
package org.anime_game_servers.multi_proto.core.interfaces
|
||||
|
||||
interface PacketIdProvider {
|
||||
fun getPacketId(packageName:String) : Int
|
@ -1,7 +1,7 @@
|
||||
package interfaces
|
||||
package org.anime_game_servers.multi_proto.core.interfaces
|
||||
|
||||
import org.anime_game_servers.core.base.Version
|
||||
|
||||
interface ProtoModel {
|
||||
fun interface ProtoModel {
|
||||
fun encodeToByteArray(version: Version) : ByteArray?
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package interfaces
|
||||
package org.anime_game_servers.multi_proto.core.interfaces
|
||||
|
||||
import org.anime_game_servers.core.base.Version
|
||||
|
||||
interface ProtoModelDecoder<T> {
|
||||
fun interface ProtoModelDecoder<T> {
|
||||
fun parseBy(data: ByteArray, version: Version): T
|
||||
}
|
2052
core/src/commonMain/resources/package_ids/GI_3_2_0.csv
Normal file
2052
core/src/commonMain/resources/package_ids/GI_3_2_0.csv
Normal file
File diff suppressed because it is too large
Load Diff
@ -9,8 +9,8 @@ group = "org.anime_game_servers.multi_proto"
|
||||
version = "0.2.$protoVersion"
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
jvmToolchain(17)
|
||||
jvm {
|
||||
withJava()
|
||||
testRuns["test"].executionTask.configure {
|
||||
useJUnitPlatform()
|
||||
@ -33,6 +33,7 @@ kotlin {
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
implementation(project(":core"))
|
||||
implementation("pro.streem.pbandk:pbandk-runtime:0.14.2")
|
||||
implementation("org.anime_game_servers.core:gi:0.1")
|
||||
}
|
||||
|
5
gi/src/commonMain/kotlin/MPGIMetaData.kt
Normal file
5
gi/src/commonMain/kotlin/MPGIMetaData.kt
Normal file
@ -0,0 +1,5 @@
|
||||
import org.anime_game_servers.multi_proto.core.annotations.ModuleMetaData
|
||||
|
||||
@ModuleMetaData("../resources")
|
||||
class MPGIMetaData {
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package messages
|
||||
import interfaces.ProtoModel
|
||||
import interfaces.ProtoModelDecoder
|
||||
import messages.activity.music_game.MusicGameActivityDetailInfo
|
||||
import messages.activity.summer_time.SummerTimeDetailInfo
|
||||
import org.anime_game_servers.core.base.Version
|
||||
import org.anime_game_servers.multi_proto.core.interfaces.ProtoModel
|
||||
import org.anime_game_servers.multi_proto.core.interfaces.ProtoModelDecoder
|
||||
import pbandk.decodeFromByteArray
|
||||
import pbandk.encodeToByteArray
|
||||
import protos.V3_2.ActivityInfo
|
||||
|
@ -1,12 +1,14 @@
|
||||
package messages
|
||||
|
||||
import org.anime_game_servers.core.base.Version
|
||||
|
||||
enum class ActivityPushTipsStateTest {
|
||||
ACTIVITY_PUSH_TIPS_STATE_NONE,
|
||||
ACTIVITY_PUSH_TIPS_STATE_START,
|
||||
ACTIVITY_PUSH_TIPS_STATE_READ,
|
||||
UNRECOGNISED;
|
||||
|
||||
fun encodeToByteArray(version: VERSION): Int?{
|
||||
fun encodeToByteArray(version: Version): Int?{
|
||||
return when (version.namespace) {
|
||||
"V3_2" -> encodeToV3_2().value
|
||||
else -> null
|
||||
@ -18,7 +20,7 @@ enum class ActivityPushTipsStateTest {
|
||||
}
|
||||
|
||||
companion object{
|
||||
fun parseBy(value:Int, version: VERSION): ActivityPushTipsStateTest {
|
||||
fun parseBy(value:Int, version: Version): ActivityPushTipsStateTest {
|
||||
return when(version.namespace) {
|
||||
"V3_2" -> {
|
||||
parseByV3_2(value)
|
||||
|
@ -18,9 +18,9 @@ data class SummerTimeV2BoatStageInfoTest(
|
||||
|
||||
|
||||
companion object {
|
||||
fun parseBy(data:ByteArray,version: VERSION) : SummerTimeV2BoatStageInfoTest?{
|
||||
fun parseBy(data:ByteArray,version: Version) : SummerTimeV2BoatStageInfoTest?{
|
||||
return when (version.namespace) {
|
||||
VERSION.V3_2_0.namespace -> parseV3_2(data)
|
||||
Version.GI_3_2_0.namespace -> parseV3_2(data)
|
||||
//VERSION.V3_3_0.namespace -> parseV3_3(data)
|
||||
else -> return SummerTimeV2BoatStageInfoTest()
|
||||
}
|
||||
@ -39,9 +39,9 @@ data class SummerTimeV2BoatStageInfoTest(
|
||||
}*/
|
||||
}
|
||||
|
||||
fun encodeToByteArray(version: VERSION): ByteArray? {
|
||||
fun encodeToByteArray(version: Version): ByteArray? {
|
||||
return when (version.namespace) {
|
||||
VERSION.V3_2_0.namespace -> protos.V3_2.SummerTimeV2BoatStageInfo(openTime, isOpen, stageId, bestScore).encodeToByteArray()
|
||||
Version.GI_3_2_0.namespace -> protos.V3_2.SummerTimeV2BoatStageInfo(openTime, isOpen, stageId, bestScore).encodeToByteArray()
|
||||
//VERSION.V3_3_0.namespace -> protos.V3_3.SummerTimeV2BoatStageInfo(openTime, isOpen, stageId, bestScore).encodeToByteArray()
|
||||
else -> null
|
||||
}
|
||||
|
@ -1,57 +0,0 @@
|
||||
package messages
|
||||
|
||||
import org.anime_game_servers.core.base.annotations.proto.ProtoVersionEnum
|
||||
import kotlin.jvm.JvmStatic
|
||||
|
||||
@ProtoVersionEnum
|
||||
enum class VERSION(val id:Int, val namespace:String) {
|
||||
VCB1(700,"VCB1"),
|
||||
VCB2(800,"VCB2"),
|
||||
V0_9_0(900,"V0_9"),
|
||||
V1_0_0(1000,"V1_0"),
|
||||
V1_1_0(1100,"V1_1"),
|
||||
V1_2_0(1200,"V1_2"),
|
||||
V1_3_0(1300,"V1_3"),
|
||||
V1_4_0(1400,"V1_4"),
|
||||
V1_5_0(1500,"V1_5"),
|
||||
V1_6_0(1600,"V1_6"),
|
||||
V2_0_0(2000,"V2_0"),
|
||||
V2_1_0(2100,"V2_1"),
|
||||
V2_2_0(2200,"V2_2"),
|
||||
V2_3_0(2300,"V2_3"),
|
||||
V2_4_0(2400,"V2_4"),
|
||||
V2_5_0(2500,"V2_5"),
|
||||
V2_6_0(2600,"V2_6"),
|
||||
V2_7_0(2700, "V2.7"),
|
||||
V2_8_0(2800, "V2_8"),
|
||||
V3_0_0(3000, "V3_0"),
|
||||
V3_1_0(3100, "V3_2"),
|
||||
V3_2_0(3200, "V3_2"),
|
||||
V3_3_0(3300, "V3_3"),
|
||||
V3_4_0(3400, "V3_4"),
|
||||
V3_5_0(3500, "V3_5"),
|
||||
V3_6_0(3600, "V3_6"),
|
||||
V3_7_0(3700, "V3_7"),
|
||||
V3_8_0(3800, "V3_8"),
|
||||
V4_0_0(4000, "V4_0"),
|
||||
V4_0_1(4001, "V4_0"),
|
||||
V4_1_0(4100, "V4_1"),
|
||||
V4_2_0(4200, "V4_2"),;
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun fromId(id:Int):VERSION?{
|
||||
return entries.firstOrNull { it.id == id }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun fromVersion(major: Int, minor: Int, fix:Int):VERSION?{
|
||||
val versionId = idFromVersion(major, minor, fix)
|
||||
return entries.firstOrNull { it.id == versionId }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun idFromVersion(major: Int, minor: Int, fix:Int):Int{
|
||||
return major*1000 + minor*100 +fix;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
|
||||
pluginManagement {
|
||||
plugins {
|
||||
id("com.google.devtools.ksp") version "1.9.22-1.0.16"
|
||||
id("com.google.devtools.ksp") version "1.9.24-1.0.20"
|
||||
//kotlin("jvm") version "1.9.22" apply false
|
||||
kotlin("multiplatform") version "1.9.22" apply false
|
||||
kotlin("multiplatform") version "1.9.24" apply false
|
||||
}
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
@ -17,6 +17,7 @@ plugins {
|
||||
rootProject.name = "multi-proto"
|
||||
|
||||
include(":processor")
|
||||
include(":core")
|
||||
include(":gi")
|
||||
|
||||
project(":processor").projectDir = File("codeGenerator/processor")
|
||||
|
Loading…
Reference in New Issue
Block a user