JS: replace all usages of @native annotation with external modifier, in tests, stdlib, etc

This commit is contained in:
Alexey Andreev
2016-11-25 12:36:47 +03:00
parent e0cb56b3c3
commit 68412ae94f
173 changed files with 486 additions and 651 deletions
+1 -2
View File
@@ -1,7 +1,6 @@
package foo
@native
class A(b: Int) {
external class A(b: Int) {
fun g(): Int = noImpl
fun m(): Int = noImpl
}
+2 -4
View File
@@ -1,9 +1,7 @@
package foo
@native
class A(val c: Int) {
@native
companion object {
external class A(val c: Int) {
external companion object {
val g: Int = noImpl
val c: String = noImpl
}
@@ -1,13 +1,12 @@
package foo
@native
internal open class A(val a: Int) {
internal external open class A(val a: Int) {
fun g(): Int = noImpl
fun m(): Int = noImpl
public open fun foo(i: Int): String = noImpl
public fun boo(i: Int): String = noImpl
@native("bar")
@JsName("bar")
open fun baz(i: Int): String = noImpl
}
@@ -1,11 +1,10 @@
package foo
@native
interface NativeTrait {
external interface NativeTrait {
val foo: String
fun bar(a: Int): Any
@native("boo")
@JsName("boo")
fun baz(): String
}
@@ -12,9 +12,9 @@ open class B {
open fun bar(n: Int) = 142
}
@native fun createA(): A
external fun createA(): A
@native fun createB(): B
external fun createB(): B
fun box(): String {
val a = createA()
+2 -4
View File
@@ -1,13 +1,11 @@
package foo
@native
class Wow() {
external class Wow() {
val x: Int = noImpl
val y: Int = noImpl
}
@native
fun Wow.sum(): Int = noImpl
external fun Wow.sum(): Int = noImpl
fun Wow.dblSum(): Int {
return 2 * sum()
+4 -8
View File
@@ -1,22 +1,18 @@
package foo
@native
interface Chrome {
external interface Chrome {
val extension: Extension
}
@native
interface Extension {
external interface Extension {
val lastError: LastError?
}
@native
interface LastError {
external interface LastError {
val message: String
}
@native
val chrome: Chrome = noImpl
external val chrome: Chrome = noImpl
fun box(): String {
val lastError = chrome.extension.lastError?.message
+3 -4
View File
@@ -1,10 +1,9 @@
package foo
@native
val classes: Map<String, Any> = noImpl
@native
val classesMutable: HashMap<String, String> = noImpl
external val classes: Map<String, Any> = noImpl
external val classesMutable: HashMap<String, String> = noImpl
fun box(): String {
classesMutable.set("why", "?")
@@ -1,7 +1,6 @@
package foo
@native
open class A(val value: String) {
external open class A(val value: String) {
}
class B : A("B") {
@@ -9,9 +8,9 @@ class B : A("B") {
var prop: String = "B prop"
}
@native fun A.bar(): String = noImpl
external fun A.bar(): String = noImpl
@native var A.prop: String
external var A.prop: String
get() = noImpl
set(value) = noImpl
@@ -1,7 +1,7 @@
package foo
@native("Object")
class JsObject {
@JsName("Object")
external class JsObject {
@nativeGetter
operator fun get(a: String): Any? = noImpl
@@ -30,8 +30,7 @@ fun JsObject.put(a: String, v: Any?): Unit = noImpl
object t{}
@native
fun getTestObject(): JsObject = noImpl
external fun getTestObject(): JsObject = noImpl
fun test(obj: JsObject, key: String, oldValue: Any?, newValue: Any) {
assertEquals(oldValue, obj[key])
+1 -2
View File
@@ -1,7 +1,6 @@
package foo
@native
class Function(vararg argsAndCode: String) {
external class Function(vararg argsAndCode: String) {
@nativeInvoke
operator fun invoke(a: Any?): Any? = noImpl
+8 -10
View File
@@ -85,14 +85,13 @@ fun box(): String {
return "OK";
}
@native
object Object {
external object Object {
object Object {
val a: String = noImpl
var b: String = noImpl
fun test(): Int = noImpl
@native("AnotherClass")
@JsName("AnotherClass")
class Class(val a: String) {
var b: String = noImpl
fun test(): Int = noImpl
@@ -133,8 +132,8 @@ object Object {
fun test(): Int = noImpl
}
@native("SomeClass")
class Class {
@JsName("SomeClass")
external class Class {
object Object {
val a: String = noImpl
var b: String = noImpl
@@ -170,16 +169,15 @@ class Class {
}
companion object {
@native("aaa")
@JsName("aaa")
val a: Trait = noImpl
var b: String = noImpl
fun test(): Int = noImpl
}
}
@native
interface Trait {
@native("SomeObject")
external interface Trait {
@JsName("SomeObject")
object Object {
val a: String = noImpl
var b: String = noImpl
@@ -197,7 +195,7 @@ interface Trait {
}
}
@native("SomeTrait")
@JsName("SomeTrait")
interface Trait {
val a: String
var b: String
@@ -1,14 +1,13 @@
package foo
@native
internal class A(val v: String)
internal external class A(val v: String)
internal class B {
fun bar(a: A, extLambda: A.(Int, String) -> String): String = a.extLambda(7, "_rr_")
}
@native
internal fun nativeBox(b: B): String = noImpl
internal external fun nativeBox(b: B): String = noImpl
fun box(): String {
val r = nativeBox(B())
@@ -1,10 +1,8 @@
package foo
@native
class A(val v: String)
external class A(val v: String)
@native
fun bar(a: A, extLambda: A.(Int, String) -> String): String = noImpl
external fun bar(a: A, extLambda: A.(Int, String) -> String): String = noImpl
fun box(): String {
val a = A("test")
@@ -1,14 +1,13 @@
package foo
@native
class A(val v: String) {
external class A(val v: String) {
fun m(i:Int, s:String): String = noImpl
}
@native
fun A.nativeExt(i:Int, s:String): String = noImpl
@native("nativeExt2AnotherName")
fun A.nativeExt2(i:Int, s:String): String = noImpl
external fun A.nativeExt(i:Int, s:String): String = noImpl
@JsName("nativeExt2AnotherName")
external fun A.nativeExt2(i:Int, s:String): String = noImpl
fun bar(a: A, extLambda: A.(Int, String) -> String): String = a.(extLambda)(4, "boo")
@@ -8,8 +8,7 @@ class B(v: String): A(v) {
override fun m(i:Int, s:String): String = "B.m ${this.v} $i $s"
}
@native
fun bar(a: A, extLambda: A.(Int, String) -> String): String = noImpl
external fun bar(a: A, extLambda: A.(Int, String) -> String): String = noImpl
fun A.topLevelExt(i:Int, s:String): String = "A::topLevelExt ${this.v} $i $s"
@@ -1,7 +1,6 @@
package foo
@native
fun nativeFun(i:Int, s:String): String = noImpl
external fun nativeFun(i:Int, s:String): String = noImpl
fun bar(funRef: (Int, String) -> String): String = funRef(4, "boo")
@@ -1,7 +1,6 @@
package foo
@native
fun run(i:Int, s:String, funRef: (Int, String) -> String): String = noImpl
external fun run(i:Int, s:String, funRef: (Int, String) -> String): String = noImpl
fun funTopLevel(i:Int, s:String): String = "funTopLevel $i $s"
+1 -2
View File
@@ -22,8 +22,7 @@ val EXPECTED_NEWLINE_FOR_EACH = """Hello
"""
@native
var buffer: String = noImpl
external var buffer: String = noImpl
fun test(expected: String, initCode: String, getResult: () -> String) {
buffer = ""
@@ -1,7 +1,6 @@
package foo
@native
class A {
external class A {
constructor()
constructor(s: String)
constructor(i: Int)
+1 -2
View File
@@ -1,6 +1,5 @@
package foo
@native
fun returnFalse(): Boolean = noImpl
external fun returnFalse(): Boolean = noImpl
fun box() = if (!returnFalse()) "OK" else "fail"
+1 -2
View File
@@ -1,7 +1,6 @@
package foo
@native
val c: Any? = noImpl
external val c: Any? = noImpl
fun box(): String {
if (c != null) return "fail1"
+13 -22
View File
@@ -1,13 +1,12 @@
package foo
@native
fun paramCount(vararg a: Int): Int = noImpl
external fun paramCount(vararg a: Int): Int = noImpl
@native("paramCount")
fun anotherParamCount(vararg a: Int): Int = noImpl
@JsName("paramCount")
external fun anotherParamCount(vararg a: Int): Int = noImpl
@native("paramCount")
fun <T> genericParamCount(vararg a: T): Int = noImpl
@JsName("paramCount")
external fun <T> genericParamCount(vararg a: T): Int = noImpl
// test spread operator
fun count(vararg a: Int) = paramCount(*a)
@@ -15,14 +14,11 @@ fun count(vararg a: Int) = paramCount(*a)
// test spread operator
fun anotherCount(vararg a: Int) = anotherParamCount(*a)
@native
fun test3(bar: Bar, dummy: Int, vararg args: Int): Boolean = noImpl
external fun test3(bar: Bar, dummy: Int, vararg args: Int): Boolean = noImpl
@native
fun Bar.test2(order: Int, dummy: Int, vararg args: Int): Boolean = noImpl
external fun Bar.test2(order: Int, dummy: Int, vararg args: Int): Boolean = noImpl
@native
class Bar(val size: Int, order: Int = 0) {
external class Bar(val size: Int, order: Int = 0) {
fun test(order: Int, dummy: Int, vararg args: Int): Boolean = noImpl
companion object {
fun startNewTest(): Boolean = noImpl
@@ -30,8 +26,7 @@ class Bar(val size: Int, order: Int = 0) {
}
}
@native
object obj {
external object obj {
fun test(size: Int, vararg args: Int): Boolean = noImpl
}
@@ -43,8 +38,7 @@ fun spreadInMethodCallWithReceiver(size: Int, vararg args: Int) = Bar(size).test
fun spreadInPackageMethodCall(size: Int, vararg args: Int) = test3(Bar(size), 1, *args)
@native
fun testNativeVarargWithFunLit(vararg args: Int, f: (a: IntArray) -> Boolean): Boolean = noImpl
external fun testNativeVarargWithFunLit(vararg args: Int, f: (a: IntArray) -> Boolean): Boolean = noImpl
fun testSpreadOperatorWithSafeCall(a: Bar?, expected: Boolean?, vararg args: Int): Boolean {
return a?.test(0, 1, *args) == expected
@@ -59,14 +53,11 @@ fun testCallOrder(vararg args: Int) =
Bar(args.size, 0).test(1, 1, *args) && Bar(args.size, 2).test(3, 1, *args) &&
!Bar.hasOrderProblem
@native
fun sumOfParameters(x: Int, y: Int, vararg a: Int): Int = noImpl
external fun sumOfParameters(x: Int, y: Int, vararg a: Int): Int = noImpl
@native
fun sumFunValuesOnParameters(x: Int, y: Int, vararg a: Int, f: (Int) -> Int): Int = noImpl
external fun sumFunValuesOnParameters(x: Int, y: Int, vararg a: Int, f: (Int) -> Int): Int = noImpl
@native
fun <T> idArrayVarArg(vararg a: Array<T>): Array<T> = noImpl
external fun <T> idArrayVarArg(vararg a: Array<T>): Array<T> = noImpl
fun box(): String {
if (paramCount() != 0)