[Wasm] Use Unit in IDL event handler return type
Return value can be used in rare cases to stop event propagation. Event methods can be called instead. ^KT-57058 Fixed
This commit is contained in:
committed by
Space Team
parent
5f00bfecff
commit
c1100042b2
+1
-1
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.tools.dukat.wasm
|
||||
import org.jetbrains.dukat.astCommon.IdentifierEntity
|
||||
import org.jetbrains.dukat.astCommon.NameEntity
|
||||
import org.jetbrains.dukat.astModel.*
|
||||
import org.jetbrains.dukat.astModel.modifiers.VisibilityModifierModel
|
||||
import org.jetbrains.dukat.commonLowerings.AddExplicitGettersAndSetters
|
||||
import org.jetbrains.dukat.idlLowerings.*
|
||||
import org.jetbrains.dukat.idlParser.parseIDL
|
||||
@@ -19,6 +18,7 @@ import org.jetbrains.dukat.ownerContext.NodeOwner
|
||||
fun translateIdlToSourceSet(fileName: String): SourceSetModel {
|
||||
val translationContext = TranslationContext()
|
||||
return parseIDL(fileName, DirectoryReferencesResolver())
|
||||
.voidifyEventHandlerReturnType()
|
||||
.resolvePartials()
|
||||
.addConstructors()
|
||||
.resolveTypedefs()
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package org.jetbrains.kotlin.tools.dukat.wasm
|
||||
|
||||
import org.jetbrains.dukat.idlDeclarations.*
|
||||
import org.jetbrains.dukat.idlLowerings.IDLLowering
|
||||
|
||||
private class VoidifyEventHandlerReturnType : IDLLowering {
|
||||
override fun lowerTypedefDeclaration(declaration: IDLTypedefDeclaration, owner: IDLFileDeclaration): IDLTypedefDeclaration {
|
||||
if (declaration.name == "EventHandlerNonNull") {
|
||||
val type = declaration.typeReference as IDLFunctionTypeDeclaration
|
||||
return declaration.copy(typeReference = type.copy(returnType = voidType))
|
||||
}
|
||||
return super.lowerTypedefDeclaration(declaration, owner)
|
||||
}
|
||||
}
|
||||
|
||||
private val voidType = IDLSingleTypeDeclaration("void", null, false)
|
||||
|
||||
fun IDLSourceSetDeclaration.voidifyEventHandlerReturnType(): IDLSourceSetDeclaration {
|
||||
return VoidifyEventHandlerReturnType().lowerSourceSetDeclaration(this)
|
||||
}
|
||||
Reference in New Issue
Block a user