All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.utopiarise.serialization.godot.core.Declarations.kt Maven / Gradle / Ivy

The newest version!
package com.utopiarise.serialization.godot.core

sealed class Declaration(val identifierToken: IdentifierToken?, vararg val values: Any)

class NumberDeclaration(token: IdentifierToken?, value: Double) : Declaration(token, value) {
    infix fun getValueToType(type: Class<*>): Any {
        return when (type) {
            Double::class.java -> values[0]
            Long::class.java -> (values[0] as Double).toLong()
            Float::class.java -> (values[0] as Double).toFloat()
            Int::class.java -> (values[0] as Double).toInt()
            Integer::class.java -> (values[0] as Double).toInt()
            Short::class.java -> (values[0] as Double).toInt().toShort()
            Byte::class.java -> (values[0] as Double).toInt().toByte()
            else -> throw NotImplementedError("No conversion of ${values[0]} to type $type is implemented")
        }
    }
}

class StringDeclaration(token: IdentifierToken?, value: String) : Declaration(token, value)
class BooleanDeclaration(token: IdentifierToken?, value: Boolean) : Declaration(token, value)
class NullDeclaration(token: IdentifierToken?) : Declaration(token)
class ArrayDeclaration(token: IdentifierToken?, vararg values: Declaration) : Declaration(token, *values)
class DictionaryDeclaration(token: IdentifierToken?, vararg values: Pair) : Declaration(token, *values)

class ResourceDeclaration : Declaration(null), StandaloneDeclaration
class GdResourceDeclaration(vararg values: Declaration) : Declaration(null, *values), StandaloneDeclaration
class GdSceneDeclaration(vararg values: Declaration) : Declaration(null, *values), StandaloneDeclaration
class ExternalResourceDeclaration(vararg values: Declaration) : Declaration(null, *values), StandaloneDeclaration
class SubResourceDeclaration(vararg values: Declaration) : Declaration(null, *values), StandaloneDeclaration
class NodeDeclaration(vararg values: Declaration) : Declaration(null, *values), StandaloneDeclaration
class SignalConnectionDeclaration(vararg values: Declaration) : Declaration(null, *values), StandaloneDeclaration

abstract class CallToResourceDeclaration(identifierToken: IdentifierToken?, values: Any) : Declaration(identifierToken, values)
class CallExternalResourceDeclaration(token: IdentifierToken?, id: Int) : CallToResourceDeclaration(token, id)
class CallSubResourceDeclaration(token: IdentifierToken?, id: Int) : CallToResourceDeclaration(token, id)

class ScriptDeclaration(token: ScriptToken, callToResourceDeclaration: CallToResourceDeclaration) : Declaration(token, callToResourceDeclaration)

class ConstructorDeclaration(token: IdentifierToken?, className: String, vararg values: Any) : Declaration(token, className, *values)

interface StandaloneDeclaration




© 2015 - 2024 Weber Informatics LLC | Privacy Policy