default -> companion: default object -> class object in project code, builtins and libs code

This commit is contained in:
Pavel V. Talanov
2015-03-16 14:51:11 +03:00
parent 444b461ba7
commit 2a6facaef6
151 changed files with 205 additions and 205 deletions
@@ -28,12 +28,12 @@ abstract class Tag(val name : String) : Element() {
val attributes = HashMap<String, String>()
protected fun initTag<T : Element>(init : T.()-> Unit) : T
where default object T : Factory<T> {
where class object T : Factory<T> {
val tag = try {
T.create()
} catch (e: NullPointerException) {
val typeName = javaClass.getName()
throw UnsupportedOperationException("No default object create() method for $typeName")
throw UnsupportedOperationException("No class object create() method for $typeName")
}
tag.init()
children.add(tag)
@@ -76,7 +76,7 @@ abstract class TagWithText(name : String) : Tag(name) {
}
class HTML() : TagWithText("html") {
default object : Factory<HTML> {
class object : Factory<HTML> {
override fun create() = HTML()
}
@@ -86,7 +86,7 @@ class HTML() : TagWithText("html") {
}
class Head() : TagWithText("head") {
default object : Factory<Head> {
class object : Factory<Head> {
override fun create() = Head()
}
@@ -94,7 +94,7 @@ class Head() : TagWithText("head") {
}
class Title() : TagWithText("title") {
default object : Factory<Title> {
class object : Factory<Title> {
override fun create() = Title()
}
}
@@ -103,7 +103,7 @@ abstract class BodyTag(name : String) : TagWithText(name) {
}
class Body() : BodyTag("body") {
default object : Factory<Body> {
class object : Factory<Body> {
override fun create() = Body()
}
@@ -122,24 +122,24 @@ class Body() : BodyTag("body") {
}
class B() : BodyTag("b") {
default object : Factory<B> {
class object : Factory<B> {
override fun create() = B()
}
}
class P() : BodyTag("p") {
default object : Factory<P> {
class object : Factory<P> {
override fun create() = P()
}
}
class H1() : BodyTag("h1") {
default object : Factory<H1> {
class object : Factory<H1> {
override fun create() = H1()
}
}
class A() : BodyTag("a") {
default object : Factory<A> {
class object : Factory<A> {
override fun create() = A()
}
@@ -42,7 +42,7 @@ html {
}
}
/** Create a bad element which doesn't have a default object create() method */
/** Create a bad element which doesn't have a class object create() method */
class BadElem() : BodyTag("bad") {
}
@@ -48,7 +48,7 @@ public abstract class FunctionalList<T>(public val size: Int) {
private class Standard<T>(override val head: T, override val tail: FunctionalList<T>) : FunctionalList<T>(tail.size + 1)
default object {
class object {
public fun <T> emptyList(): FunctionalList<T> = Empty<T>()
public fun <T> of(element: T): FunctionalList<T> = FunctionalList.Standard<T>(element, emptyList())
@@ -18,53 +18,53 @@ package kotlin.jvm
/**
* A constant holding the minimum value an `Int` can have, -2^31.
*/
public val Int.Default.MIN_VALUE: Int get() = java.lang.Integer.MIN_VALUE
public val Int.Companion.MIN_VALUE: Int get() = java.lang.Integer.MIN_VALUE
/**
* A constant holding the maximum value an `Int` can have, 2^31-1.
*/
public val Int.Default.MAX_VALUE: Int get() = java.lang.Integer.MAX_VALUE
public val Int.Companion.MAX_VALUE: Int get() = java.lang.Integer.MAX_VALUE
/**
* A constant holding the smallest positive nonzero value of type `Double`, 2^-1074.
*/
public val Double.Default.MIN_VALUE: Double get() = java.lang.Double.MIN_VALUE
public val Double.Companion.MIN_VALUE: Double get() = java.lang.Double.MIN_VALUE
/**
* A constant holding the largest positive finite value of type `Double`, (2-2^-52)*2^1023.
*/
public val Double.Default.MAX_VALUE: Double get() = java.lang.Double.MAX_VALUE
public val Double.Companion.MAX_VALUE: Double get() = java.lang.Double.MAX_VALUE
/**
* A constant holding the smallest positive nonzero value of type `Float`, 2^-149.
*/
public val Float.Default.MIN_VALUE: Float get() = java.lang.Float.MIN_VALUE
public val Float.Companion.MIN_VALUE: Float get() = java.lang.Float.MIN_VALUE
/**
* * A constant holding the largest positive finite value of type `Float`, (2-2^-23)*2^127.
*/
public val Float.Default.MAX_VALUE: Float get() = java.lang.Float.MAX_VALUE
public val Float.Companion.MAX_VALUE: Float get() = java.lang.Float.MAX_VALUE
/**
* A constant holding the minimum value a `Long` can have, -2^63.
*/
public val Long.Default.MIN_VALUE: Long get() = java.lang.Long.MIN_VALUE
public val Long.Companion.MIN_VALUE: Long get() = java.lang.Long.MIN_VALUE
/**
* A constant holding the maximum value a `Long` can have, 2^63-1.
*/
public val Long.Default.MAX_VALUE: Long get() = java.lang.Long.MAX_VALUE
public val Long.Companion.MAX_VALUE: Long get() = java.lang.Long.MAX_VALUE
/**
* A constant holding the minimum value a `Short` can have, -2^15.
*/
public val Short.Default.MIN_VALUE: Short get() = java.lang.Short.MIN_VALUE
public val Short.Companion.MIN_VALUE: Short get() = java.lang.Short.MIN_VALUE
/**
* A constant holding the maximum value a `Short` can have, 2^15-1.
*/
public val Short.Default.MAX_VALUE: Short get() = java.lang.Short.MAX_VALUE
public val Short.Companion.MAX_VALUE: Short get() = java.lang.Short.MAX_VALUE
/**
* A constant holding the minimum value a `Byte` can have, -128.
*/
public val Byte.Default.MIN_VALUE: Byte get() = java.lang.Byte.MIN_VALUE
public val Byte.Companion.MIN_VALUE: Byte get() = java.lang.Byte.MIN_VALUE
/**
* A constant holding the maximum value a `Byte` can have, 127.
*/
public val Byte.Default.MAX_VALUE: Byte get() = java.lang.Byte.MAX_VALUE
public val Byte.Companion.MAX_VALUE: Byte get() = java.lang.Byte.MAX_VALUE
@@ -14,7 +14,7 @@ public class SeleniumTest(val id: String) {
println("Testing $id")
}
default object {
class object {
Parameters public fun findSeleniumUris(): List<String> {
return arrayList("a", "b")
}
@@ -150,7 +150,7 @@ $imports
if (fields != null) {
if (fields.isNotEmpty()) {
println("")
println(" public default object {")
println(" public class object {")
for (field in fields) {
if (field != null) {
val modifiers = field.getModifiers()