From e36cb683fc6d002930247d6a643b60aa34770a3b Mon Sep 17 00:00:00 2001 From: Victor Turansky Date: Wed, 18 Dec 2024 23:50:38 +0200 Subject: [PATCH] Revert "Use unsigned number types" This reverts commit ff094dc81f1f75662c93f08adef920a7a159b68b. --- .../src/main/kotlin/karakum/browser/IDL.kt | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/buildSrc/src/main/kotlin/karakum/browser/IDL.kt b/buildSrc/src/main/kotlin/karakum/browser/IDL.kt index d6adb2b73..4f0cdadf3 100644 --- a/buildSrc/src/main/kotlin/karakum/browser/IDL.kt +++ b/buildSrc/src/main/kotlin/karakum/browser/IDL.kt @@ -26,10 +26,10 @@ 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", @@ -37,7 +37,7 @@ private val NUMBER_TYPE_MAP = mapOf( "unrestricted double" to "Double", "long" to "Int", - "unsigned long" to "UInt", + "unsigned long" to "Int", "long long" to "JsLong", "unsigned long long" to "JsLong", @@ -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, @@ -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, ) }