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

Side by Side Diff: pkg/js/lib/js.dart

Issue 1318043005: Support user generated custom native JS classes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: ptal Created 5 years, 2 months 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * The js library allows Dart library authors to export their APIs to JavaScript
7 * and to define Dart interfaces for JavaScript objects.
8 */
9 library js;
10
11 export 'dart:js' show allowInterop, allowInteropCaptureThis;
12
13 // XXX this is a hack. remove.
14 export 'dart:js' show registerJsInterfaces;
15
16 /// A metadata annotation that indicates that a Library, Class, or member is
17 /// implemented directly in JavaScript. All external members of a class or
18 /// library with this annotation implicitly have it as well.
19 ///
20 /// Specifying [name] customizes the JavaScript name to use. By default the
21 /// dart name is used. It is not valid to specify a custom [name] for class
22 /// instance members.
23 ///
24 /// Example 1:
25 ///
26 /// @Js('google.maps')
27 /// library maps
28 ///
29 /// external Map get map;
30 ///
31 /// @Js("LatLng")
32 /// class Location {
33 /// external Location(num lat, num lng);
34 /// }
35 ///
36 /// @Js()
37 /// class Map {
38 /// external Map(Location location);
39 /// external Location getLocation();
40 /// }
41 ///
42 /// In this example the top level map getter will invoke the JavaScript getter
43 /// google.maps.map
44 /// Calls to the Map constructor will be translated to calls to the JavaScript
45 /// new google.maps.Map(location)
46 /// Calls to the Location constructor willbe translated to calls to the
47 /// JavaScript
48 /// new google.maps.LatLng(lat, lng)
49 /// because a custom JavaScript name for the Location class.
50 /// In general, we recommend against using custom JavaScript names whenever
51 /// possible as it is easier for users if the JavaScript names and Dart names
52 /// are consistent.
53 ///
54 /// Example 2:
55 /// library utils;
56 ///
57 /// @Js("JSON.stringify")
58 /// external String stringify(obj);
59 ///
60 /// @Js()
61 /// void debugger();
62 ///
63 /// In this example no custom JavaScript namespace is specified.
64 /// Calls to debugger map to calls to JavaScript
65 /// self.debugger()
66 /// Calls to stringify map to calls to
67 /// JSON.stringify(obj)
68 class Js {
69 final String name;
70 const Js([this.name]);
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698