Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart

Issue 11299220: Add @JSName annotation for native fields and methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
index f10d3d72408a924c2bf51196010434ddaa2dc7e6..7b046c9e48160576788e171478b5ff946933fceb 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
@@ -557,7 +557,7 @@ class Primitives {
if (end <= kMaxApply) {
subarray = array;
} else {
- subarray = JS('List<int>', r'array.slice(#, #)',
+ subarray = JS('=List', r'array.slice(#, #)',
ahe 2012/11/29 09:19:26 How about adding a new foreign tag that clearly co
sra1 2012/12/04 01:31:31 Do you mean another thing like 'JS'? I don't think
i, i + kMaxApply < end ? i + kMaxApply : end);
}
result = JS('String', '# + String.fromCharCode.apply(#, #)',
@@ -1220,6 +1220,23 @@ class Returns {
}
/**
+ * A metadata annotation placed on native methods and fields of native classes
+ * to specify the JavaScript name.
+ *
+ * This example declares a Dart field + getter + setter called `$dom_title` that
+ * corresponds to the JavaScript property `title`.
+ *
+ * class Docmument native "*Foo" {
+ * @JSName('title')
+ * String $dom_title;
+ * }
+ */
+class JSName {
+ final String name;
+ const JSName(this.name);
+}
+
+/**
* Represents the type of Null. The compiler treats this specially.
* TODO(lrn): Null should be defined in core. It's a class, like int.
* It just happens to act differently in assignability tests and,

Powered by Google App Engine
This is Rietveld 408576698