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

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

Issue 1207313002: initial sync*, part of #221 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 5 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
1 dart_library.library('dart/js', null, /* Imports */[ 1 dart_library.library('dart/js', null, /* Imports */[
2 "dart_runtime/dart", 2 "dart_runtime/dart",
3 'dart/_foreign_helper', 3 'dart/_foreign_helper',
4 'dart/core', 4 'dart/core',
5 'dart/collection', 5 'dart/collection',
6 'dart/typed_data', 6 'dart/typed_data',
7 'dart/_js_helper' 7 'dart/_js_helper'
8 ], /* Lazy imports */[ 8 ], /* Lazy imports */[
9 ], function(exports, dart, _foreign_helper, core, collection, typed_data, _js_he lper) { 9 ], function(exports, dart, _foreign_helper, core, collection, typed_data, _js_he lper) {
10 'use strict'; 10 'use strict';
11 let dartx = dart.dartx; 11 let dartx = dart.dartx;
12 dart.defineLazyProperties(exports, { 12 dart.defineLazyProperties(exports, {
13 get context() { 13 get context() {
14 return _wrapToDart(self); 14 return _wrapToDart(self);
15 } 15 }
16 }); 16 });
17 function _convertDartFunction(f, opts) { 17 function _convertDartFunction(f, opts) {
18 let captureThis = opts && 'captureThis' in opts ? opts.captureThis : false; 18 let captureThis = opts && 'captureThis' in opts ? opts.captureThis : false;
19 return function(_call, f, captureThis) { 19 return (function(_call, f, captureThis) {
20 return function() { 20 return function() {
21 return _call(f, captureThis, this, Array.prototype.slice.apply(arguments )); 21 return _call(f, captureThis, this, Array.prototype.slice.apply(arguments ));
22 }; 22 };
23 }(_foreign_helper.DART_CLOSURE_TO_JS(_callDartFunction), f, captureThis); 23 })(_foreign_helper.DART_CLOSURE_TO_JS(_callDartFunction), f, captureThis);
24 } 24 }
25 dart.fn(_convertDartFunction, dart.dynamic, [core.Function], {captureThis: cor e.bool}); 25 dart.fn(_convertDartFunction, dart.dynamic, [core.Function], {captureThis: cor e.bool});
26 function _callDartFunction(callback, captureThis, self, arguments$) { 26 function _callDartFunction(callback, captureThis, self, arguments$) {
27 if (dart.notNull(captureThis)) { 27 if (dart.notNull(captureThis)) {
28 let _ = [self]; 28 let _ = [self];
29 _[dartx.addAll](arguments$); 29 _[dartx.addAll](arguments$);
30 arguments$ = _; 30 arguments$ = _;
31 } 31 }
32 let dartArgs = core.List.from(arguments$[dartx.map](_convertToDart)); 32 let dartArgs = core.List.from(arguments$[dartx.map](_convertToDart));
33 return _convertToJS(core.Function.apply(dart.as(callback, core.Function), da rtArgs)); 33 return _convertToJS(core.Function.apply(dart.as(callback, core.Function), da rtArgs));
(...skipping 26 matching lines...) Expand all
60 return _wrapToDart(_convertToJS(object)); 60 return _wrapToDart(_convertToJS(object));
61 } 61 }
62 static jsify(object) { 62 static jsify(object) {
63 if (!dart.is(object, core.Map) && !dart.is(object, core.Iterable)) { 63 if (!dart.is(object, core.Map) && !dart.is(object, core.Iterable)) {
64 throw new core.ArgumentError("object must be a Map or Iterable"); 64 throw new core.ArgumentError("object must be a Map or Iterable");
65 } 65 }
66 return _wrapToDart(JsObject._convertDataTree(object)); 66 return _wrapToDart(JsObject._convertDataTree(object));
67 } 67 }
68 static _convertDataTree(data) { 68 static _convertDataTree(data) {
69 let _convertedObjects = collection.HashMap.identity(); 69 let _convertedObjects = collection.HashMap.identity();
70 let _convert = o => { 70 function _convert(o) {
71 if (dart.notNull(_convertedObjects.containsKey(o))) { 71 if (dart.notNull(_convertedObjects.containsKey(o))) {
72 return _convertedObjects.get(o); 72 return _convertedObjects.get(o);
73 } 73 }
74 if (dart.is(o, core.Map)) { 74 if (dart.is(o, core.Map)) {
75 let convertedMap = {}; 75 let convertedMap = {};
76 _convertedObjects.set(o, convertedMap); 76 _convertedObjects.set(o, convertedMap);
77 for (let key of dart.as(dart.dload(o, 'keys'), core.Iterable)) { 77 for (let key of dart.as(dart.dload(o, 'keys'), core.Iterable)) {
78 convertedMap[key] = _convert(dart.dindex(o, key)); 78 convertedMap[key] = _convert(dart.dindex(o, key));
79 } 79 }
80 return convertedMap; 80 return convertedMap;
81 } else if (dart.is(o, core.Iterable)) { 81 } else if (dart.is(o, core.Iterable)) {
82 let convertedList = []; 82 let convertedList = [];
83 _convertedObjects.set(o, convertedList); 83 _convertedObjects.set(o, convertedList);
84 convertedList[dartx.addAll](dart.as(dart.dsend(o, 'map', _convert), co re.Iterable)); 84 convertedList[dartx.addAll](dart.as(dart.dsend(o, 'map', _convert), co re.Iterable));
85 return convertedList; 85 return convertedList;
86 } else { 86 } else {
87 return _convertToJS(o); 87 return _convertToJS(o);
88 } 88 }
89 }; 89 }
90 dart.fn(_convert); 90 dart.fn(_convert);
91 return _convert(data); 91 return _convert(data);
92 } 92 }
93 get(property) { 93 get(property) {
94 if (!(typeof property == 'string') && !dart.is(property, core.num)) { 94 if (!(typeof property == 'string') && !dart.is(property, core.num)) {
95 throw new core.ArgumentError("property is not a String or num"); 95 throw new core.ArgumentError("property is not a String or num");
96 } 96 }
97 return _convertToDart(this[_jsObject][property]); 97 return _convertToDart(this[_jsObject][property]);
98 } 98 }
99 set(property, value) { 99 set(property, value) {
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 let __CastType0 = dart.typedef('__CastType0', () => dart.functionType(dart.d ynamic, [E])); 443 let __CastType0 = dart.typedef('__CastType0', () => dart.functionType(dart.d ynamic, [E]));
444 return __CastType0; 444 return __CastType0;
445 }); 445 });
446 let __CastType0 = __CastType0$(); 446 let __CastType0 = __CastType0$();
447 // Exports: 447 // Exports:
448 exports.JsObject = JsObject; 448 exports.JsObject = JsObject;
449 exports.JsFunction = JsFunction; 449 exports.JsFunction = JsFunction;
450 exports.JsArray$ = JsArray$; 450 exports.JsArray$ = JsArray$;
451 exports.JsArray = JsArray; 451 exports.JsArray = JsArray;
452 }); 452 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698