Temporary add jvm.overloads annotation for generated joinToString() method.

Stdlib generator: allow to specify arbitrary annotations for all or some of generic function expansions.
This commit is contained in:
Ilya Gorbunov
2015-04-22 21:43:57 +03:00
parent d531d7130f
commit 16d20ff009
4 changed files with 25 additions and 0 deletions
@@ -0,0 +1,20 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.jvm
// is used in common generated code in stdlib
internal annotation class overloads
@@ -338,6 +338,7 @@ public fun ShortArray.joinToString(separator: String = ", ", prefix: String = ""
* If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
* elements will be appended, followed by the [truncated] string (which defaults to "...").
*/
kotlin.jvm.overloads
public fun <T> Iterable<T>.joinToString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((T) -> String)? = null): String {
return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()
}
@@ -84,6 +84,7 @@ class GenericFunction(val signature: String, val keyword: String = "fun") : Comp
override fun onKeySet(key: Family) = include(key)
}
val customPrimitiveBodies = HashMap<Pair<Family, PrimitiveType>, String>()
val annotations = FamilyProperty<String>()
fun bodyForTypes(family: Family, vararg primitiveTypes: PrimitiveType, b: () -> String) {
include(family)
@@ -295,6 +296,8 @@ class GenericFunction(val signature: String, val keyword: String = "fun") : Comp
?.let { platformName -> builder.append("platformName(\"${platformName}\")\n")}
}
annotations[f]?.let { builder.append(it).append('\n') }
builder.append("public ")
if (inline[f] == true)
builder.append("inline ")
@@ -63,6 +63,7 @@ fun strings(): List<GenericFunction> {
exclude(Strings)
returns("String")
annotations("kotlin.jvm.overloads", Iterables)
body {
"""
return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()