improved type inference in plugin
This commit is contained in:
1 parent
f6deabaa38
commit
1efa96a990
12 files changed
+276
-125
No files matched your search
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com
|
||||
* Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,10 +18,7 @@
|
||||
package net.sergeych.lynon
|
||||
|
||||
import net.sergeych.lyng.Scope
|
||||
import net.sergeych.lyng.obj.Obj
|
||||
import net.sergeych.lyng.obj.ObjBitBuffer
|
||||
import net.sergeych.lyng.obj.ObjClass
|
||||
import net.sergeych.lyng.obj.ObjString
|
||||
import net.sergeych.lyng.obj.*
|
||||
|
||||
// Most often used types:
|
||||
|
||||
@@ -53,14 +50,35 @@ object ObjLynonClass : ObjClass("Lynon") {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode any object into Lynon format. Note that it has a special
|
||||
* handling for void values, returning an empty byte array.
|
||||
*
|
||||
* This is the default behavior for encoding void values in Lynon format,
|
||||
* ensuring consistency with decoding behavior. It matches the [lynonDecodeAny]
|
||||
* behavior for handling void values.
|
||||
*/
|
||||
@Suppress("unused")
|
||||
suspend fun lynonEncodeAny(scope: Scope, value: Obj): UByteArray =
|
||||
(ObjLynonClass.encodeAny(scope, value))
|
||||
.bitArray.asUByteArray()
|
||||
if (value == ObjVoid)
|
||||
ubyteArrayOf()
|
||||
else
|
||||
(ObjLynonClass.encodeAny(scope, value))
|
||||
.bitArray.asUByteArray()
|
||||
|
||||
|
||||
/**
|
||||
* Decode any object from Lynon format. If the input is empty, returns ObjVoid.
|
||||
* This behavior is designed to handle cases where the input data might be incomplete
|
||||
* or intentionally left empty, indicating a void or null value and matches
|
||||
* the [lynonEncodeAny] behavior [ObjVoid].
|
||||
*/
|
||||
@Suppress("unused")
|
||||
suspend fun lynonDecodeAny(scope: Scope, encoded: UByteArray): Obj =
|
||||
ObjLynonClass.decodeAny(
|
||||
if (encoded.isEmpty())
|
||||
ObjVoid
|
||||
else
|
||||
ObjLynonClass.decodeAny(
|
||||
scope,
|
||||
ObjBitBuffer(
|
||||
BitArray(encoded, 8)
|
||||
|
||||
Reference in new issue
Block a user