Update dart2js_foreign suite as we now validate annotations.
Review URL: https://codereview.chromium.org//11293272 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14885 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'native_metadata.dart';
|
||||
|
||||
foreign1(var a, var b) {
|
||||
return JS("num", r"# + #", a, b);
|
||||
}
|
||||
|
||||
@@ -10,12 +10,14 @@
|
||||
// * Named arguments are passed in the correct position, so require preceding
|
||||
// arguments to be passed.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
@native int foo(int x);
|
||||
}
|
||||
|
||||
@native("*B")
|
||||
@Native("*B")
|
||||
class B {
|
||||
@native int foo([x, y, z]);
|
||||
}
|
||||
@@ -26,7 +28,7 @@ class B {
|
||||
@native A makeA() { return new A(); }
|
||||
@native B makeB() { return new B(); }
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
A.prototype.foo = function () { return arguments.length; };
|
||||
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
// This is a similar test to NativeCallArity1FrogTest, but makes sure
|
||||
// that subclasses also get the right number of arguments.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
@native int foo([x, y]);
|
||||
}
|
||||
|
||||
@native("*B")
|
||||
@Native("*B")
|
||||
class B extends A {
|
||||
@native int foo([x, y]);
|
||||
}
|
||||
@@ -18,7 +20,7 @@ class B extends A {
|
||||
@native A makeA() { return new A(); }
|
||||
@native B makeB() { return new B(); }
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function inherits(child, parent) {
|
||||
if (child.prototype.__proto__) {
|
||||
child.prototype.__proto__ = parent.prototype;
|
||||
|
||||
@@ -6,12 +6,14 @@
|
||||
// parameters set to null. These parameters should be treated as if they
|
||||
// do not have a default value for the native methods.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
@native int foo(int x);
|
||||
}
|
||||
|
||||
@native("*B")
|
||||
@Native("*B")
|
||||
class B {
|
||||
@native int foo([x = null, y, z = null]);
|
||||
}
|
||||
@@ -22,7 +24,7 @@ class B {
|
||||
@native A makeA() { return new A(); }
|
||||
@native B makeB() { return new B(); }
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
A.prototype.foo = function () { return arguments.length; };
|
||||
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
|
||||
// Test that type checks occur on native methods.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
@native int foo(int x);
|
||||
@native int cmp(A other);
|
||||
}
|
||||
|
||||
@native("*B")
|
||||
@Native("*B")
|
||||
class B {
|
||||
@native String foo(String x);
|
||||
@native int cmp(B other);
|
||||
@@ -19,7 +21,7 @@ class B {
|
||||
@native A makeA() { return new A(); }
|
||||
@native B makeB() { return new B(); }
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
A.prototype.foo = function (x) { return x + 1; };
|
||||
A.prototype.cmp = function (x) { return 0; };
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
|
||||
// Test that type checks occur on assignment to fields of native methods.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
int foo;
|
||||
}
|
||||
|
||||
@native("*B")
|
||||
@Native("*B")
|
||||
class B {
|
||||
String foo;
|
||||
}
|
||||
@@ -17,7 +19,7 @@ class B {
|
||||
@native A makeA() { return new A(); }
|
||||
@native B makeB() { return new B(); }
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
|
||||
function B() {}
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
|
||||
// Test that hidden native class names are not used by generated code.
|
||||
|
||||
@native("*B")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*B")
|
||||
class A {
|
||||
get name => 'A';
|
||||
static A create() => makeA();
|
||||
}
|
||||
|
||||
@native("*C")
|
||||
@Native("*C")
|
||||
class B {
|
||||
get name => 'B';
|
||||
static B create() => makeB();
|
||||
@@ -24,7 +26,7 @@ class C { // Ordinary class with name clashing with native class.
|
||||
@native makeA();
|
||||
@native makeB();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
// Poison hidden native names 'B' and 'C' to prove the compiler didn't place
|
||||
// anthing on the hidden native class.
|
||||
B = null;
|
||||
@@ -32,7 +34,7 @@ C = null;
|
||||
""")
|
||||
void setup1();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
// This code is all inside 'setup' and so not accesible from the global scope.
|
||||
function B(){}
|
||||
function C(){}
|
||||
|
||||
@@ -7,13 +7,15 @@
|
||||
// superclass caches the method in the prototype, so shadowing the dispatcher
|
||||
// stored on Object.prototype.
|
||||
|
||||
import 'native_metadata.dart';
|
||||
|
||||
// Version 1: It might be possible to call foo directly.
|
||||
@native("*A1")
|
||||
@Native("*A1")
|
||||
class A1 {
|
||||
@native foo();
|
||||
}
|
||||
|
||||
@native("*B1")
|
||||
@Native("*B1")
|
||||
class B1 extends A1 {
|
||||
@native foo();
|
||||
}
|
||||
@@ -23,12 +25,12 @@ class B1 extends A1 {
|
||||
|
||||
|
||||
// Version 2: foo needs some kind of trampoline.
|
||||
@native("*A2")
|
||||
@Native("*A2")
|
||||
class A2 {
|
||||
@native foo([a=99]);
|
||||
}
|
||||
|
||||
@native("*B2")
|
||||
@Native("*B2")
|
||||
class B2 extends A2 {
|
||||
@native foo([z=1000]);
|
||||
}
|
||||
@@ -36,7 +38,7 @@ class B2 extends A2 {
|
||||
@native makeA2();
|
||||
@native makeB2();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
// This code is all inside 'setup' and so not accesible from the global scope.
|
||||
function inherits(child, parent) {
|
||||
if (child.prototype.__proto__) {
|
||||
|
||||
@@ -7,21 +7,23 @@
|
||||
// superclass caches the method in the prototype, so shadowing the dispatcher
|
||||
// stored on Object.prototype.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
@native foo([a=100]);
|
||||
}
|
||||
|
||||
@native("*B")
|
||||
@Native("*B")
|
||||
class B extends A {
|
||||
}
|
||||
|
||||
@native("*C")
|
||||
@Native("*C")
|
||||
class C extends B {
|
||||
@native foo([z=300]);
|
||||
}
|
||||
|
||||
@native("*D")
|
||||
@Native("*D")
|
||||
class D extends C {
|
||||
}
|
||||
|
||||
@@ -30,7 +32,7 @@ class D extends C {
|
||||
@native makeC();
|
||||
@native makeD();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
// This code is all inside 'setup' and so not accesible from the global scope.
|
||||
function inherits(child, parent) {
|
||||
if (child.prototype.__proto__) {
|
||||
|
||||
@@ -6,11 +6,13 @@
|
||||
// interferes with subsequent resolving of the method. This might happen if the
|
||||
// noSuchMethod is cached on Object.prototype.
|
||||
|
||||
@native("*A1")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A1")
|
||||
class A1 {
|
||||
}
|
||||
|
||||
@native("*B1")
|
||||
@Native("*B1")
|
||||
class B1 extends A1 {
|
||||
}
|
||||
|
||||
@@ -18,12 +20,12 @@ class B1 extends A1 {
|
||||
@native makeB1();
|
||||
|
||||
|
||||
@native("*A2")
|
||||
@Native("*A2")
|
||||
class A2 {
|
||||
@native foo([a=99]);
|
||||
}
|
||||
|
||||
@native("*B2")
|
||||
@Native("*B2")
|
||||
class B2 extends A2 {
|
||||
}
|
||||
|
||||
@@ -32,7 +34,7 @@ class B2 extends A2 {
|
||||
|
||||
@native makeObject();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
// This code is all inside 'setup' and so not accesible from the global scope.
|
||||
function inherits(child, parent) {
|
||||
if (child.prototype.__proto__) {
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
// inheritance, the superclass method must not be reached by a call on the
|
||||
// subclass.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
var _field;
|
||||
|
||||
@@ -16,7 +18,7 @@ class A {
|
||||
int method(int z) => _field + z;
|
||||
}
|
||||
|
||||
@native("*B")
|
||||
@Native("*B")
|
||||
class B extends A {
|
||||
var _field2;
|
||||
|
||||
@@ -29,7 +31,7 @@ class B extends A {
|
||||
@native A makeA() { return new A(); }
|
||||
@native B makeB() { return new B(); }
|
||||
|
||||
@native(r"""
|
||||
@Native(r"""
|
||||
function inherits(child, parent) {
|
||||
if (child.prototype.__proto__) {
|
||||
child.prototype.__proto__ = parent.prototype;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
// Test for correct simple is-checks on hidden native classes.
|
||||
|
||||
import 'native_metadata.dart';
|
||||
|
||||
interface I {
|
||||
I read();
|
||||
write(I x);
|
||||
@@ -11,7 +13,7 @@ interface I {
|
||||
|
||||
// Native implementation.
|
||||
|
||||
@native("*A")
|
||||
@Native("*A")
|
||||
class A implements I {
|
||||
// The native class accepts only other native instances.
|
||||
@native A read();
|
||||
@@ -20,7 +22,7 @@ class A implements I {
|
||||
|
||||
@native makeA();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
// This code is all inside 'setup' and so not accesible from the global scope.
|
||||
function A(){}
|
||||
A.prototype.read = function() { return this._x; };
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
// Test for correct simple is-checks on hidden native classes.
|
||||
|
||||
import 'native_metadata.dart';
|
||||
|
||||
interface J {
|
||||
}
|
||||
|
||||
@@ -14,21 +16,21 @@ interface I extends J {
|
||||
|
||||
// Native implementation.
|
||||
|
||||
@native("*A")
|
||||
@Native("*A")
|
||||
class A implements I {
|
||||
// The native class accepts only other native instances.
|
||||
@native A read();
|
||||
@native write(A x);
|
||||
}
|
||||
|
||||
@native("*B")
|
||||
@Native("*B")
|
||||
class B extends A {
|
||||
}
|
||||
|
||||
@native makeA();
|
||||
@native makeB();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
// This code is all inside 'setup' and so not accesible from the global scope.
|
||||
function inherits(child, parent) {
|
||||
if (child.prototype.__proto__) {
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
|
||||
// Additional Dart code may be 'placed on' hidden native classes.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
|
||||
var _field;
|
||||
@@ -17,7 +19,7 @@ class A {
|
||||
|
||||
@native A makeA() { return new A(); }
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
makeA = function(){return new A;};
|
||||
""")
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'native_metadata.dart';
|
||||
|
||||
typedef void MyFunctionType();
|
||||
|
||||
@native("*A")
|
||||
@Native("*A")
|
||||
class A {
|
||||
@native setClosure(MyFunctionType f);
|
||||
@native check(MyFunctionType f);
|
||||
@@ -13,7 +15,7 @@ class A {
|
||||
|
||||
@native makeA() { return new A(); }
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
A.prototype.setClosure = function(f) { this.f = f; };
|
||||
A.prototype.check = function(f) { return this.f === f; };
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
// is no place in the Dart language to communicate (3). So we use the following
|
||||
// fake body technique.
|
||||
|
||||
import 'native_metadata.dart';
|
||||
|
||||
// The exception type.
|
||||
@native("*E")
|
||||
@Native("*E")
|
||||
class E {
|
||||
@native E._used(); // Bogus native constructor, called only from fake body.
|
||||
|
||||
@@ -23,7 +24,7 @@ class E {
|
||||
}
|
||||
|
||||
// Type with exception-throwing methods.
|
||||
@native("*A")
|
||||
@Native("*A")
|
||||
class A {
|
||||
@native op(int x) {
|
||||
// Fake body calls constructor to mark the exception class (E) as used.
|
||||
@@ -39,14 +40,14 @@ class B {
|
||||
|
||||
@native makeA();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
// Ensure we are not relying on global names 'A' and 'E'.
|
||||
A = null;
|
||||
E = null;
|
||||
""")
|
||||
void setup1();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
// This code is all inside 'setup2' and so not accesible from the global scope.
|
||||
function E(x){ this.code = x; }
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
// fields. However, native fields keep their name. The implication: a getter
|
||||
// for the field must be based on the field's name, not the field's jsname.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
int key; // jsname is 'key'
|
||||
int getKey() => key;
|
||||
@@ -18,9 +20,9 @@ class B {
|
||||
int getKey() => key;
|
||||
}
|
||||
|
||||
@native("*X")
|
||||
@Native("*X")
|
||||
class X {
|
||||
@native('key') int native_key_method();
|
||||
@Native('key') int native_key_method();
|
||||
// This should cause B.key to be renamed, but not A.key.
|
||||
|
||||
@natve('key') int key();
|
||||
@@ -30,7 +32,7 @@ class X {
|
||||
@native X makeX();
|
||||
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
// This code is all inside 'setup' and so not accesible from the global scope.
|
||||
function A(){ this.key = 111; }
|
||||
A.prototype.getKey = function(){return this.key;};
|
||||
|
||||
@@ -6,11 +6,13 @@
|
||||
// fields. However, native fields keep their name. The implication: a getter
|
||||
// for the field must be based on the field's name, not the field's jsname.
|
||||
|
||||
import 'native_metadata.dart';
|
||||
|
||||
interface I {
|
||||
int key;
|
||||
}
|
||||
|
||||
@native("*A")
|
||||
@Native("*A")
|
||||
class A implements I {
|
||||
int key; // jsname is 'key'
|
||||
int getKey() => key;
|
||||
@@ -22,18 +24,18 @@ class B implements I {
|
||||
int getKey() => key;
|
||||
}
|
||||
|
||||
@native("*X")
|
||||
@Native("*X")
|
||||
class X {
|
||||
@native('key') int native_key_method();
|
||||
@Native('key') int native_key_method();
|
||||
// This should cause B.key to be renamed, but not A.key.
|
||||
@native('key') int key();
|
||||
@Native('key') int key();
|
||||
}
|
||||
|
||||
@native A makeA();
|
||||
@native X makeX();
|
||||
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
// This code is all inside 'setup' and so not accesible from the global scope.
|
||||
function A(){ this.key = 111; }
|
||||
A.prototype.getKey = function(){return this.key;};
|
||||
|
||||
@@ -8,7 +8,7 @@ library lib2;
|
||||
import 'native_library_same_name_used_lib1.dart'; // To get interface I.
|
||||
|
||||
// Native impl has same name as interface.
|
||||
@native("*I")
|
||||
@Native("*I")
|
||||
class Impl implements I {
|
||||
@native Impl read();
|
||||
@native write(Impl x);
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
|
||||
library main;
|
||||
import 'native_library_same_name_used_lib1.dart';
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
// This code is all inside 'setup' and so not accesible from the global scope.
|
||||
function I(){}
|
||||
I.prototype.read = function() { return this._x; };
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@native("= {log: function() { return 42 } }")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("= {log: function() { return 42 } }")
|
||||
class A {
|
||||
@native void log();
|
||||
}
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
return A;
|
||||
""")
|
||||
getA();
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
library native_metadata;
|
||||
|
||||
class Native {
|
||||
final String info;
|
||||
const Native(this.info);
|
||||
}
|
||||
|
||||
const Native native = const Native(null);
|
||||
@@ -4,11 +4,13 @@
|
||||
|
||||
// Test the feature where the native string declares the native method's name.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
@native('fooA') int foo();
|
||||
@native('barA') int bar();
|
||||
@native('bazA') int baz();
|
||||
@Native('fooA') int foo();
|
||||
@Native('barA') int bar();
|
||||
@Native('bazA') int baz();
|
||||
}
|
||||
|
||||
@native A makeA();
|
||||
@@ -18,7 +20,7 @@ class B {
|
||||
int baz() => 900;
|
||||
}
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
// This code is all inside 'setup' and so not accesible from the global scope.
|
||||
function A(){}
|
||||
A.prototype.fooA = function(){return 100;};
|
||||
|
||||
@@ -4,22 +4,24 @@
|
||||
|
||||
// Test the feature where the native string declares the native method's name.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
@native('fooA')
|
||||
@Native('fooA')
|
||||
int foo();
|
||||
}
|
||||
|
||||
@native("*B")
|
||||
@Native("*B")
|
||||
class B extends A {
|
||||
@native('fooB')
|
||||
@Native('fooB')
|
||||
int foo();
|
||||
}
|
||||
|
||||
@native makeA();
|
||||
@native makeB();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
// This code is all inside 'setup' and so not accesible from the global scope.
|
||||
function inherits(child, parent) {
|
||||
if (child.prototype.__proto__) {
|
||||
|
||||
@@ -5,15 +5,17 @@
|
||||
// Test the feature where the native string declares the native method's name.
|
||||
// #3. The name does not get
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
@native('fooA')
|
||||
@Native('fooA')
|
||||
int foo();
|
||||
}
|
||||
|
||||
@native("*B")
|
||||
@Native("*B")
|
||||
class B extends A {
|
||||
@native('fooB')
|
||||
@Native('fooB')
|
||||
int foo();
|
||||
int fooA() => 333;
|
||||
}
|
||||
@@ -27,7 +29,7 @@ class Decoy {
|
||||
@native makeB();
|
||||
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
// This code is all inside 'setup' and so not accesible from the global scope.
|
||||
function inherits(child, parent) {
|
||||
if (child.prototype.__proto__) {
|
||||
|
||||
@@ -4,14 +4,16 @@
|
||||
|
||||
// Make sure we can have a native with a name that is a JavaScript keyword.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
@native int delete();
|
||||
}
|
||||
|
||||
@native A makeA() { return new A(); }
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
A.prototype.delete = function() { return 87; };
|
||||
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
}
|
||||
|
||||
@native makeA();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {};
|
||||
A.prototype.foo = function() { return 42; }
|
||||
makeA = function() { return new A; }
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
}
|
||||
|
||||
@native makeA();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {};
|
||||
A.prototype.foo = function() { return 42; }
|
||||
makeA = function() { return new A; }
|
||||
|
||||
@@ -4,26 +4,27 @@
|
||||
|
||||
// Hidden native class wwith named constructors and static methods.
|
||||
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@native("*A")
|
||||
@Native("*A")
|
||||
class A {
|
||||
|
||||
factory A(int len) => _construct(len);
|
||||
|
||||
factory A.fromString(String s) => _construct(s.length);
|
||||
|
||||
@native(r'return makeA(a+b);')
|
||||
@Native(r'return makeA(a+b);')
|
||||
factory A.nativeConstructor(int a, int b);
|
||||
|
||||
static A _construct(v) { return makeA(v); }
|
||||
|
||||
@native('return this._x;')
|
||||
@Native('return this._x;')
|
||||
foo();
|
||||
}
|
||||
|
||||
@native makeA(v);
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
// This code is all inside 'setup' and so not accesible from the global scope.
|
||||
function A(arg) { this._x = arg; }
|
||||
makeA = function(arg) { return new A(arg); }
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
// Hidden native class with factory constructors and NO static methods.
|
||||
// Regression test.
|
||||
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@native("*A")
|
||||
@Native("*A")
|
||||
class A {
|
||||
|
||||
// No static methods in this class.
|
||||
@@ -15,16 +16,16 @@ class A {
|
||||
|
||||
factory A.fromString(String s) => makeA(s.length);
|
||||
|
||||
@native(r'return makeA(a+b);')
|
||||
@Native(r'return makeA(a+b);')
|
||||
factory A.nativeConstructor(int a, int b);
|
||||
|
||||
@native('return this._x;')
|
||||
@Native('return this._x;')
|
||||
foo();
|
||||
}
|
||||
|
||||
@native makeA(v);
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
// This code is all inside 'setup' and so not accesible from the global scope.
|
||||
function A(arg) { this._x = arg; }
|
||||
makeA = function(arg) { return new A(arg); }
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
}
|
||||
|
||||
@native("*B")
|
||||
@Native("*B")
|
||||
class B extends A {
|
||||
@native foo();
|
||||
}
|
||||
@@ -14,7 +16,7 @@ class B extends A {
|
||||
@native makeA();
|
||||
@native makeB();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function inherits(child, parent) {
|
||||
if (child.prototype.__proto__) {
|
||||
child.prototype.__proto__ = parent.prototype;
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
bar() => 42;
|
||||
}
|
||||
|
||||
@native("*B")
|
||||
@Native("*B")
|
||||
class B {
|
||||
foo() => 42;
|
||||
}
|
||||
@@ -19,7 +21,7 @@ class C {
|
||||
|
||||
@native makeA();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
makeA = function() { return new A; }
|
||||
""")
|
||||
|
||||
@@ -2,20 +2,22 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
bar() => 42;
|
||||
noSuchMethod(x,y) => "native($x:$y)";
|
||||
}
|
||||
|
||||
@native("*B")
|
||||
@Native("*B")
|
||||
class B {
|
||||
baz() => 42;
|
||||
}
|
||||
|
||||
@native makeA();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
makeA = function() { return new A; }
|
||||
""")
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
bar() => 42;
|
||||
noSuchMethod(x,y) => "native($x:$y)";
|
||||
}
|
||||
|
||||
@native("*B")
|
||||
@Native("*B")
|
||||
class B {
|
||||
baz() => 42;
|
||||
}
|
||||
@@ -20,7 +22,7 @@ class C {
|
||||
|
||||
@native makeA();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
makeA = function() { return new A; }
|
||||
""")
|
||||
|
||||
@@ -2,19 +2,21 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
bar() => 42;
|
||||
}
|
||||
|
||||
@native("*B")
|
||||
@Native("*B")
|
||||
class B {
|
||||
foo() => 42;
|
||||
}
|
||||
|
||||
@native makeA();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
makeA = function() { return new A; }
|
||||
""")
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'native_metadata.dart';
|
||||
|
||||
typedef void MyFunctionType();
|
||||
|
||||
@native("*A")
|
||||
@Native("*A")
|
||||
class A {
|
||||
@native setClosure(MyFunctionType f);
|
||||
@native check(MyFunctionType f);
|
||||
@@ -13,7 +15,7 @@ class A {
|
||||
|
||||
@native makeA() { return new A(); }
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
A.prototype.setClosure = function(f) { this.f = f; };
|
||||
A.prototype.check = function(f) { return this.f === f; };
|
||||
|
||||
@@ -5,21 +5,23 @@
|
||||
// Test that parameters in native methods are not mangled. This test is needed
|
||||
// until we change all libraries to using the JS foreign element.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
@native("return null;")
|
||||
@Native("return null;")
|
||||
returnNull();
|
||||
@native("return undefined;")
|
||||
@Native("return undefined;")
|
||||
returnUndefined();
|
||||
@native("return '';")
|
||||
@Native("return '';")
|
||||
returnEmptyString();
|
||||
@native("return 0;")
|
||||
@Native("return 0;")
|
||||
returnZero();
|
||||
}
|
||||
|
||||
@native A makeA();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
makeA = function(){return new A;};
|
||||
""")
|
||||
|
||||
@@ -5,17 +5,19 @@
|
||||
// Test that parameters in native methods are not mangled. This test is needed
|
||||
// until we change all libraries to using the JS foreign element.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
@native("return name;")
|
||||
@Native("return name;")
|
||||
foo(name);
|
||||
@native("return undefined;")
|
||||
@Native("return undefined;")
|
||||
bar(undefined);
|
||||
}
|
||||
|
||||
@native A makeA();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
makeA = function(){return new A;};
|
||||
""")
|
||||
|
||||
@@ -4,14 +4,16 @@
|
||||
|
||||
// Properties on hidden native classes.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {
|
||||
|
||||
// Setters and getters should be similar to these methods:
|
||||
@native('return this._x;')
|
||||
@Native('return this._x;')
|
||||
int getX();
|
||||
|
||||
@native('this._x = value;')
|
||||
@Native('this._x = value;')
|
||||
void setX(int value);
|
||||
|
||||
@native
|
||||
@@ -26,17 +28,17 @@ class A {
|
||||
@native
|
||||
set Y(int value);
|
||||
|
||||
@native('return this._z;')
|
||||
@Native('return this._z;')
|
||||
int get Z;
|
||||
|
||||
@native('this._z = value;')
|
||||
@Native('this._z = value;')
|
||||
set Z(int value);
|
||||
}
|
||||
|
||||
@native
|
||||
A makeA() { return new A(); }
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
|
||||
Object.defineProperty(A.prototype, "X", {
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
@native("*A")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*A")
|
||||
class A {}
|
||||
@native makeA();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
makeA = function(){return new A;};
|
||||
""")
|
||||
|
||||
@@ -5,19 +5,21 @@
|
||||
// Test that we put native names and not Dart names into the dynamic
|
||||
// dispatch table.
|
||||
|
||||
@native("*NativeA")
|
||||
import 'native_metadata.dart';
|
||||
|
||||
@Native("*NativeA")
|
||||
class A {
|
||||
@native foo();
|
||||
}
|
||||
|
||||
@native("*NativeB")
|
||||
@Native("*NativeB")
|
||||
class B extends A {
|
||||
}
|
||||
|
||||
@native A makeA() { return new A(); }
|
||||
@native B makeB() { return new B(); }
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function inherits(child, parent) {
|
||||
if (child.prototype.__proto__) {
|
||||
child.prototype.__proto__ = parent.prototype;
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'native_metadata.dart';
|
||||
|
||||
interface Window {
|
||||
final int document;
|
||||
}
|
||||
|
||||
// Defining this global object makes Frog eager on optimizing
|
||||
// call sites where the receiver is typed 'Window'.
|
||||
@native("@*DOMWindow")
|
||||
@Native("@*DOMWindow")
|
||||
class _DOMWindowJs implements Window {
|
||||
final int document;
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'native_metadata.dart';
|
||||
|
||||
interface Window {
|
||||
final int document;
|
||||
}
|
||||
|
||||
// Defining this global object makes Frog eager on optimizing
|
||||
// call sites where the receiver is typed 'Window'.
|
||||
@native("@*DOMWindow")
|
||||
@Native("@*DOMWindow")
|
||||
class _DOMWindowJs implements Window {
|
||||
final int document;
|
||||
}
|
||||
|
||||
@@ -2,28 +2,30 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'native_metadata.dart';
|
||||
|
||||
typedef void Callback0();
|
||||
typedef void Callback1(arg1);
|
||||
typedef void Callback2(arg1, arg2);
|
||||
|
||||
@native("*A")
|
||||
@Native("*A")
|
||||
class A {
|
||||
@native("return closure();")
|
||||
@Native("return closure();")
|
||||
foo0(Callback0 closure);
|
||||
|
||||
@native("return closure(arg1);")
|
||||
@Native("return closure(arg1);")
|
||||
foo1(Callback1 closure, arg1);
|
||||
|
||||
@native("return closure(arg1, arg2);")
|
||||
@Native("return closure(arg1, arg2);")
|
||||
foo2(Callback2 closure, arg1, arg2);
|
||||
|
||||
@native("return closure == (void 0) ? 42 : closure();")
|
||||
@Native("return closure == (void 0) ? 42 : closure();")
|
||||
foo3([Callback0 closure]);
|
||||
}
|
||||
|
||||
@native makeA();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
makeA = function(){return new A;};
|
||||
""")
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'native_metadata.dart';
|
||||
|
||||
typedef void Callback0();
|
||||
typedef void Callback1(arg1);
|
||||
typedef void Callback2(arg1, arg2);
|
||||
|
||||
@native("*A")
|
||||
@Native("*A")
|
||||
class A {
|
||||
@native foo1(Callback1 closure, [arg1 = 0]);
|
||||
@native foo2(Callback2 closure, [arg1 = 0, arg2 = 1]);
|
||||
@@ -14,7 +16,7 @@ class A {
|
||||
|
||||
@native makeA();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
A.prototype.foo1 = function(closure, arg1) { return closure(arg1); };
|
||||
A.prototype.foo2 = function(closure, arg1, arg2) {
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'native_metadata.dart';
|
||||
|
||||
typedef void Callback0();
|
||||
typedef void Callback1(arg1);
|
||||
typedef void Callback2(arg1, arg2);
|
||||
|
||||
@native("*A")
|
||||
@Native("*A")
|
||||
class A {
|
||||
@native foo0(Callback0 closure);
|
||||
@native foo1(Callback1 closure, arg1);
|
||||
@@ -15,7 +17,7 @@ class A {
|
||||
|
||||
@native makeA();
|
||||
|
||||
@native("""
|
||||
@Native("""
|
||||
function A() {}
|
||||
A.prototype.foo0 = function(closure) { return closure(); };
|
||||
A.prototype.foo1 = function(closure, arg1) { return closure(arg1); };
|
||||
|
||||
Reference in New Issue
Block a user