Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Commit 23ca02b

Browse files
author
Salomon BRYS
committed
Moving JS only runtime to JS sourceset, using unsafeCast instead of dynamicCastTo.
1 parent 8296759 commit 23ca02b

File tree

23 files changed

+16
-349
lines changed

23 files changed

+16
-349
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ plugins {
2424

2525
allprojects {
2626
group = "deezer.kustomexport"
27-
version = "0.7.0"
27+
version = "0.8.0"
2828

2929
repositories {
3030
mavenLocal()

compiler/src/main/kotlin/deezer/kustomexport/compiler/ExportCompiler.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,9 @@ import deezer.kustomexport.compiler.js.InterfaceDescriptor
4343
import deezer.kustomexport.compiler.js.SealedClassDescriptor
4444
import deezer.kustomexport.compiler.js.TopLevelFunctionDescriptor
4545
import deezer.kustomexport.compiler.js.ValueClassDescriptor
46-
import deezer.kustomexport.compiler.js.pattern.`class`.transform
47-
import deezer.kustomexport.compiler.js.pattern.`interface`.transform
48-
import deezer.kustomexport.compiler.js.pattern.enum.transform
49-
import deezer.kustomexport.compiler.js.pattern.function.transform
46+
import deezer.kustomexport.compiler.js.pattern.transform
5047
import deezer.kustomexport.compiler.js.pattern.parseClass
5148
import deezer.kustomexport.compiler.js.pattern.parseFunction
52-
import deezer.kustomexport.compiler.js.pattern.value.transform
5349

5450
// Trick to share the Logger everywhere without injecting the dependency everywhere
5551
internal lateinit var sharedLogger: KSPLogger

compiler/src/main/kotlin/deezer/kustomexport/compiler/js/Extensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import com.squareup.kotlinpoet.TypeName
2525
import deezer.kustomexport.compiler.CompilerArgs
2626

2727
val jsExport = ClassName("kotlin.js", "JsExport")
28+
val unsafeCast = MemberName("kotlin.js", "unsafeCast")
2829

29-
val dynamicCastTo = MemberName("deezer.kustomexport", "dynamicCastTo")
3030
val dynamicNull = MemberName("deezer.kustomexport", "dynamicNull")
3131
val dynamicString = MemberName("deezer.kustomexport", "dynamicString")
3232
val dynamicNotString = MemberName("deezer.kustomexport", "dynamicNotString")

compiler/src/main/kotlin/deezer/kustomexport/compiler/js/pattern/class/ClassTransformer.kt renamed to compiler/src/main/kotlin/deezer/kustomexport/compiler/js/pattern/ClassTransformer.kt

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* under the License.
1616
*/
1717

18-
package deezer.kustomexport.compiler.js.pattern.`class`
18+
package deezer.kustomexport.compiler.js.pattern
1919

2020
import com.squareup.kotlinpoet.ClassName
2121
import com.squareup.kotlinpoet.CodeBlock
@@ -28,22 +28,8 @@ import com.squareup.kotlinpoet.PropertySpec
2828
import com.squareup.kotlinpoet.STRING
2929
import com.squareup.kotlinpoet.TypeName
3030
import com.squareup.kotlinpoet.TypeSpec
31-
import deezer.kustomexport.compiler.js.ALL_KOTLIN_EXCEPTIONS
32-
import deezer.kustomexport.compiler.js.ClassDescriptor
33-
import deezer.kustomexport.compiler.js.FormatString
34-
import deezer.kustomexport.compiler.js.MethodNameDisambiguation
35-
import deezer.kustomexport.compiler.js.ParameterDescriptor
36-
import deezer.kustomexport.compiler.js.dynamicCastTo
37-
import deezer.kustomexport.compiler.js.dynamicNotString
38-
import deezer.kustomexport.compiler.js.dynamicNull
39-
import deezer.kustomexport.compiler.js.dynamicString
40-
import deezer.kustomexport.compiler.js.jsExport
41-
import deezer.kustomexport.compiler.js.jsPackage
31+
import deezer.kustomexport.compiler.js.*
4232
import deezer.kustomexport.compiler.js.mapping.INDENTATION
43-
import deezer.kustomexport.compiler.js.pattern.asClassName
44-
import deezer.kustomexport.compiler.js.pattern.buildWrappingFunction
45-
import deezer.kustomexport.compiler.js.pattern.overrideGetterSetter
46-
import deezer.kustomexport.compiler.js.pattern.suppress
4733

4834
fun ClassDescriptor.transform() = transformClass(this)
4935

@@ -140,9 +126,9 @@ private fun buildExportedClass(
140126
// Without that, it fails at runtime because there is no dynamicCastTo method on null.
141127
// > TypeError: Cannot read properties of null (reading 'dynamicCastTo')
142128
origin.constructorParams
143-
.joinToString { "${it.name}·=·%M${if (ctorDyn == dynamicNull) "?" else ""}.%M<%T>()" },
129+
.joinToString { "${it.name}·=·%M.%M<%T>()" },
144130
*origin.constructorParams
145-
.flatMap { listOf(ctorDyn, dynamicCastTo, it.type.exportedTypeName) }.toTypedArray()
131+
.flatMap { listOf(ctorDyn, unsafeCast, it.type.exportedTypeName) }.toTypedArray()
146132
)
147133
)
148134
.addParameter(ParameterSpec("common", originalClass))
@@ -188,7 +174,7 @@ private fun buildExportedClass(
188174
b.addSuperclassConstructorParameter(
189175
CodeBlock.of(
190176
"common = %M.%M<%T>()",
191-
dynamicNull, dynamicCastTo, supr.origin.concreteTypeName.asClassName()
177+
dynamicNull, unsafeCast, supr.origin.concreteTypeName.asClassName()
192178
)
193179
)
194180
}

compiler/src/main/kotlin/deezer/kustomexport/compiler/js/pattern/enum/EnumTransformer.kt renamed to compiler/src/main/kotlin/deezer/kustomexport/compiler/js/pattern/EnumTransformer.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* under the License.
1616
*/
1717

18-
package deezer.kustomexport.compiler.js.pattern.enum
18+
package deezer.kustomexport.compiler.js.pattern
1919

2020
import com.squareup.kotlinpoet.ARRAY
2121
import com.squareup.kotlinpoet.ClassName
@@ -30,7 +30,6 @@ import deezer.kustomexport.compiler.js.EnumDescriptor
3030
import deezer.kustomexport.compiler.js.jsExport
3131
import deezer.kustomexport.compiler.js.jsPackage
3232
import deezer.kustomexport.compiler.js.mapping.INDENTATION
33-
import deezer.kustomexport.compiler.js.pattern.overrideGetterSetter
3433

3534
fun EnumDescriptor.transform() = transformEnum(this)
3635

compiler/src/main/kotlin/deezer/kustomexport/compiler/js/pattern/function/FunctionTransformer.kt renamed to compiler/src/main/kotlin/deezer/kustomexport/compiler/js/pattern/FunctionTransformer.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,14 @@
1515
* under the License.
1616
*/
1717

18-
package deezer.kustomexport.compiler.js.pattern.function
18+
package deezer.kustomexport.compiler.js.pattern
1919

2020
import com.squareup.kotlinpoet.FileSpec
2121
import com.squareup.kotlinpoet.FunSpec
22-
import com.squareup.kotlinpoet.KModifier
2322
import com.squareup.kotlinpoet.MemberName
2423
import deezer.kustomexport.compiler.js.TopLevelFunctionDescriptor
2524
import deezer.kustomexport.compiler.js.jsExport
2625
import deezer.kustomexport.compiler.js.jsPackage
27-
import deezer.kustomexport.compiler.js.pattern.addParameters
28-
import deezer.kustomexport.compiler.js.pattern.buildWrappingFunctionBody
29-
import deezer.kustomexport.compiler.js.pattern.returnType
3026

3127
fun TopLevelFunctionDescriptor.transform() = transformFunction(this)
3228

compiler/src/main/kotlin/deezer/kustomexport/compiler/js/pattern/interface/InterfaceTransformer.kt renamed to compiler/src/main/kotlin/deezer/kustomexport/compiler/js/pattern/InterfaceTransformer.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* under the License.
1616
*/
1717

18-
package deezer.kustomexport.compiler.js.pattern.`interface`
18+
package deezer.kustomexport.compiler.js.pattern
1919

2020
import com.squareup.kotlinpoet.ClassName
2121
import com.squareup.kotlinpoet.FileSpec
@@ -33,10 +33,6 @@ import deezer.kustomexport.compiler.js.PropertyDescriptor
3333
import deezer.kustomexport.compiler.js.jsExport
3434
import deezer.kustomexport.compiler.js.jsPackage
3535
import deezer.kustomexport.compiler.js.mapping.INDENTATION
36-
import deezer.kustomexport.compiler.js.pattern.OverrideMode
37-
import deezer.kustomexport.compiler.js.pattern.buildWrappingFunction
38-
import deezer.kustomexport.compiler.js.pattern.overrideGetterSetter
39-
import deezer.kustomexport.compiler.js.pattern.packageName
4036
import java.util.Locale
4137

4238
fun InterfaceDescriptor.transform() = transformInterface(this)

compiler/src/main/kotlin/deezer/kustomexport/compiler/js/pattern/class/SealedClassTransformer.kt renamed to compiler/src/main/kotlin/deezer/kustomexport/compiler/js/pattern/SealedClassTransformer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* under the License.
1616
*/
1717

18-
package deezer.kustomexport.compiler.js.pattern.`class`
18+
package deezer.kustomexport.compiler.js.pattern
1919

2020
import com.squareup.kotlinpoet.ClassName
2121
import com.squareup.kotlinpoet.CodeBlock

compiler/src/main/kotlin/deezer/kustomexport/compiler/js/pattern/value/ValueClassTransformer.kt renamed to compiler/src/main/kotlin/deezer/kustomexport/compiler/js/pattern/ValueClassTransformer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* under the License.
1616
*/
1717

18-
package deezer.kustomexport.compiler.js.pattern.value
18+
package deezer.kustomexport.compiler.js.pattern
1919

2020
import com.squareup.kotlinpoet.ClassName
2121
import com.squareup.kotlinpoet.FileSpec

lib/src/commonMain/kotlin/deezer/kustomexport/Dynamics.kt

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)