Skip to content

Commit

Permalink
fix: Fix UInt not supported for VssNodes
Browse files Browse the repository at this point in the history
UInt could not be used before this commit because @jvmoverloads was
used for all generated VSS data classes. Since UInt is a Kotlin
specific data type it was incompatible with the annotation. As long as
we are only using one constructor param for VssSignals we can remove
the annotation because the default constructor will still be
available.

Note: The java byte code will still show an Int for the Kotlin UInt
model. This is fine as long as the SDK is speaking Kotlin while
interacting with these models.

close #93
  • Loading branch information
Chrylo committed Mar 15, 2024
1 parent af19daf commit 07e9f04
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ fun <T : Any> VssSignal<T>.copy(datapoint: Datapoint): VssSignal<T> {
BOOL -> bool
INT32 -> int32
INT64 -> int64
UINT32 -> uint32
UINT64 -> uint64
UINT32 -> uint32.toUInt()
UINT64 -> uint64.toULong()
FLOAT -> float
DOUBLE -> double
STRING_ARRAY -> stringArray.valuesList
Expand Down Expand Up @@ -179,7 +179,7 @@ fun <T : VssNode> T.copy(
// region Operators

/**
* Convenience operator for [deepCopy] with a [VssNode]. It will return the [VssNode] with the updated
* Convenience operator for [deepCopy] with a [VssNode]. It will return the parent [VssNode] with the updated child
* [VssNode].
*
* @throws [IllegalArgumentException] if the copied types do not match.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,17 @@ internal class VssNodeSpecModel(
return when (datatype) {
"string" -> String::class.asTypeName()
"boolean" -> Boolean::class.asTypeName()
// Do not use UInt because it is incompatible with @JvmOverloads annotation
"uint8", "uint16", "uint32" -> Int::class.asTypeName()
"uint8", "uint16", "uint32" -> UInt::class.asTypeName()
"uint64" -> ULong::class.asTypeName()
"int8", "int16", "int32" -> Int::class.asTypeName()
"int64", "uint64" -> Long::class.asTypeName()
"int64" -> Long::class.asTypeName()
"float" -> Float::class.asTypeName()
"double" -> Double::class.asTypeName()
"string[]" -> Array::class.parameterizedBy(String::class)
"boolean[]" -> BooleanArray::class.asTypeName()
"uint8[]", "uint16[]", "uint32[]", "int8[]", "int16[]", "int32[]" -> IntArray::class.asTypeName()
"int64[]", "uint64[]" -> LongArray::class.asTypeName()
"float[]" -> FloatArray::class.asTypeName()
else -> Any::class.asTypeName()
}
}
Expand Down Expand Up @@ -112,7 +113,6 @@ internal class VssNodeSpecModel(

val nestedChildSpecs = mutableListOf<TypeSpec>()
val constructorBuilder = FunSpec.constructorBuilder()
.addAnnotation(JvmOverloads::class)
val propertySpecs = mutableListOf<PropertySpec>()
val superInterfaces = mutableSetOf<TypeName>(VssBranch::class.asTypeName())

Expand Down

0 comments on commit 07e9f04

Please sign in to comment.