Support generating "deprecated" functions.

This commit is contained in:
Ilya Ryzhenkov
2014-05-30 16:31:15 +04:00
committed by Andrey Breslav
parent e6f5c7012c
commit f5a0701076
@@ -41,6 +41,9 @@ class GenericFunction(val signature: String) : Comparable<GenericFunction> {
val buildFamilies = HashSet<Family>(defaultFamilies.toList()) val buildFamilies = HashSet<Family>(defaultFamilies.toList())
private val buildPrimitives = HashSet<PrimitiveType>(PrimitiveType.values().toList()) private val buildPrimitives = HashSet<PrimitiveType>(PrimitiveType.values().toList())
var deprecate: String = ""
val deprecates = HashMap<Family, String>()
var doc: String = "" var doc: String = ""
val docs = HashMap<Family, String>() val docs = HashMap<Family, String>()
@@ -73,6 +76,16 @@ class GenericFunction(val signature: String) : Comparable<GenericFunction> {
} }
} }
fun deprecate(vararg families: Family, b: () -> String) {
if (families.isEmpty())
deprecate = b()
else {
for (f in families) {
deprecates[f] = b()
}
}
}
fun returns(vararg families: Family, b: () -> String) { fun returns(vararg families: Family, b: () -> String) {
if (families.isEmpty()) if (families.isEmpty())
defaultReturnType = b() defaultReturnType = b()
@@ -225,6 +238,10 @@ class GenericFunction(val signature: String) : Comparable<GenericFunction> {
} }
builder.append(" */\n") builder.append(" */\n")
} }
val deprecated = deprecates[f] ?: deprecate
if (deprecated != "") {
builder.append("deprecated(\"$deprecated\")\n")
}
builder.append("public ") builder.append("public ")
if (inlineFamilies[f] ?: defaultInline) if (inlineFamilies[f] ?: defaultInline)