Skip to content

Commit

Permalink
Remove old plaintext StubGenerator and introduce Stub IR-based generator
Browse files Browse the repository at this point in the history
  • Loading branch information
sbogolepov committed Jul 3, 2019
1 parent 367b95a commit bff177a
Show file tree
Hide file tree
Showing 17 changed files with 2,730 additions and 1,551 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,4 @@ inline fun buildKotlinCodeLines(scope: KotlinScope, block: KotlinCodeBuilder.()
val builder = KotlinCodeBuilder(scope)
builder.block()
return builder.build()
}

interface StubGenerationContext {
val nativeBridges: NativeBridges
fun addTopLevelDeclaration(lines: List<String>)
}

interface KotlinStub {
fun generate(context: StubGenerationContext): Sequence<String>
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,5 @@ private val charactersAllowedInKotlinStringLiterals: Set<Char> = mutableSetOf<Ch
addAll(listOf('_', '@', ':', ';', '.', ',', '{', '}', '=', '[', ']', '^', '#', '*', ' ', '(', ')'))
}

fun block(header: String, lines: Iterable<String>) = block(header, lines.asSequence())

fun block(header: String, lines: Sequence<String>) =
sequenceOf("$header {") +
lines.map { " $it" } +
sequenceOf("}")

val annotationForUnableToImport
get() = "@Deprecated(${"Unable to import this declaration".quoteAsKotlinLiteral()}, level = DeprecationLevel.ERROR)"

fun String.applyToStrings(vararg arguments: String) =
"${this}(${arguments.joinToString { it.quoteAsKotlinLiteral() }})"

fun List<KotlinParameter>.renderParameters(scope: KotlinScope) = buildString {
this@renderParameters.renderParametersTo(scope, this)
}

fun List<KotlinParameter>.renderParametersTo(scope: KotlinScope, buffer: Appendable) =
this.joinTo(buffer, ", ") { it.render(scope) }

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ abstract class KotlinFile(

override fun declare(classifier: Classifier): String {
if (classifier.pkg != this.pkg) {
throw IllegalArgumentException("wrong package; expected '$pkg', got '${classifier.pkg}'")
throw IllegalArgumentException("wrong package for classifier ${classifier.fqName}; expected '$pkg', got '${classifier.pkg}'")
}

if (!classifier.isTopLevel) {
Expand Down
Loading

0 comments on commit bff177a

Please sign in to comment.