ScriptingProtocol

class ScriptingProtocol(scope: Any, instanceSaver: MutableList<Any?>?)

Implementation of IPC communication protocol specified in Module.md.

Does not handle transmission or reception. Only creates responses and requests. Agnostic to Unciv types. Protocol spec should be generic enough to apply to all Kotlin objects. Uses automatic Kotlin/JVM object tokenization by InstanceTokenizer through TokenizingJson.

Constructors

ScriptingProtocol
Link copied to clipboard
fun ScriptingProtocol(scope: Any, instanceSaver: MutableList<Any?>? = null)

Types

Companion
Link copied to clipboard
object Companion
KnownFlag
Link copied to clipboard
enum KnownFlag : Enum<ScriptingProtocol.KnownFlag>

Enum class of valid items for the flag field in scripting packets.

makeActionRequests
Link copied to clipboard
object makeActionRequests

Functions to generate requests to send to a script interpreter.

parseActionResponses
Link copied to clipboard
object parseActionResponses

Functions to parse a response packet received after a request packet sent to a scripting interpreter.

ScriptingPacketPathedData
Link copied to clipboard
private class ScriptingPacketPathedData(packet: ScriptingPacket)

Functions

equals
Link copied to clipboard
open operator fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
open fun hashCode(): Int
makeActionResponse
Link copied to clipboard
fun makeActionResponse(packet: ScriptingPacket): ScriptingPacket

Return a valid response packet for a request packet from a script interpreter.

toString
Link copied to clipboard
open fun toString(): String
trySaveInstance
Link copied to clipboard
private fun <T> trySaveInstance(obj: T): T

Save an instance in the mutable list cache that prevents generated responses from being garbage-collected before the other end of the protocol can use them.

Properties

instanceSaver
Link copied to clipboard
val instanceSaver: MutableList<Any?>? = null

Mutable list in which to save response values, to prevent created instances from being garbage collected before the other end of the IPC can save or use them. List, not Set, to preserve instance identity and not value. Not automatically cleared. Should be manually cleared when not needed.

scope
Link copied to clipboard
val scope: Any

Kotlin/JVM object that represents the hierarchical root of actions that require recursively resolving a property path through reflection. In practice, this should never be set to anything other than an instance of ScriptingScope. But that's an API-level implementation and use case detail, so the protocol is typed for and should never assume anything more specific than Any.

Sources

jvm source
Link copied to clipboard