Skip to content

Commit

Permalink
Revert "Use unsigned number types"
Browse files Browse the repository at this point in the history
This reverts commit ff094dc.
  • Loading branch information
turansky committed Dec 18, 2024
1 parent 4bee6f2 commit e36cb68
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions buildSrc/src/main/kotlin/karakum/browser/IDL.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ private data class MethodReturnData(
) : MemberNumberData()

private val NUMBER_TYPE_MAP = mapOf(
"octet" to "UByte",
"octet" to "Short /* unsigned byte */",

"short" to "Short",
"unsigned short" to "UShort",
"unsigned short" to "Short",

"float" to "Float",

"double" to "Double",
"unrestricted double" to "Double",

"long" to "Int",
"unsigned long" to "UInt",
"unsigned long" to "Int",

"long long" to "JsLong",
"unsigned long long" to "JsLong",
Expand Down Expand Up @@ -165,15 +165,10 @@ internal object IDLRegistry {
.removePrefix("unrestricted ")
.substringBefore(" = ")

var type = getNumberType(data.substringBeforeLast(" ").removeSuffix("?"))
val type = getNumberType(data.substringBeforeLast(" ").removeSuffix("?"))
?: return emptySequence()

val name = data.substringAfterLast(" ")

// TEMP
if ((name == "length" || name == "size") && type == "UInt")
type = "Int"

return sequenceOf(
PropertyData(
className = className,
Expand All @@ -200,19 +195,13 @@ internal object IDLRegistry {
.map { it.substringAfter("] ") }
.map { it.removePrefix("optional ") }
.mapNotNull { psource ->
var type = getNumberType(psource.substringBeforeLast(" ").removeSuffix("?"))
val type = getNumberType(psource.substringBeforeLast(" ").removeSuffix("?"))
?: return@mapNotNull null

val name = psource.substringAfterLast(" ")

// TEMP
if (name == "index" && type == "UInt")
type = "Int"

ParameterData(
className = className,
methodName = methodName,
parameterName = name,
parameterName = psource.substringAfterLast(" "),
parameterType = type,
)
}
Expand Down

0 comments on commit e36cb68

Please sign in to comment.