Support generating "deprecated" functions.
This commit is contained in:
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())
|
||||
private val buildPrimitives = HashSet<PrimitiveType>(PrimitiveType.values().toList())
|
||||
|
||||
var deprecate: String = ""
|
||||
val deprecates = HashMap<Family, String>()
|
||||
|
||||
var doc: 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) {
|
||||
if (families.isEmpty())
|
||||
defaultReturnType = b()
|
||||
@@ -225,6 +238,10 @@ class GenericFunction(val signature: String) : Comparable<GenericFunction> {
|
||||
}
|
||||
builder.append(" */\n")
|
||||
}
|
||||
val deprecated = deprecates[f] ?: deprecate
|
||||
if (deprecated != "") {
|
||||
builder.append("deprecated(\"$deprecated\")\n")
|
||||
}
|
||||
|
||||
builder.append("public ")
|
||||
if (inlineFamilies[f] ?: defaultInline)
|
||||
|
||||
Reference in New Issue
Block a user