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

Side by Side Diff: lib/dom/src/native_DOMImplementation.dart

Issue 10008089: Some additional Utils functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor amendments. Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class Utils { 5 class Utils {
6 static List convertToList(List list) { 6 static List convertToList(List list) {
7 // FIXME: [possible optimization]: do not copy the array if Dart_IsArray is fine w/ it. 7 // FIXME: [possible optimization]: do not copy the array if Dart_IsArray is fine w/ it.
8 final length = list.length; 8 final length = list.length;
9 List result = new List(length); 9 List result = new List(length);
10 result.copyFrom(list, 0, 0, length); 10 result.copyFrom(list, 0, 0, length);
11 return result; 11 return result;
12 } 12 }
13 13
14 static List convertMapToList(Map map) {
15 List result = [];
16 map.forEach((k, v) => result.addAll([k, v]));
17 return result;
18 }
19
20 static void populateMap(Map result, List list) {
21 for (int i = 0; i < list.length; i += 2) {
22 result[list[i]] = list[i + 1];
23 }
24 }
25
26 static bool isMap(obj) => obj is Map;
27
28 static Map createMap() => {};
29
14 static makeNotImplementedException(String fileName, int lineNo) { 30 static makeNotImplementedException(String fileName, int lineNo) {
15 return new UnsupportedOperationException('[info: $fileName:$lineNo]'); 31 return new UnsupportedOperationException('[info: $fileName:$lineNo]');
16 } 32 }
17 33
18 static window() native "Utils_window"; 34 static window() native "Utils_window";
19 static print(String message) native "Utils_print"; 35 static print(String message) native "Utils_print";
20 static SendPort spawnDomIsolate(Window window, String entryPoint) native "Util s_spawnDomIsolate"; 36 static SendPort spawnDomIsolate(Window window, String entryPoint) native "Util s_spawnDomIsolate";
21 } 37 }
22 38
23 /* 39 /*
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 void operator []=(String key, String value) native "DOMStringMap_setItem_Callb ack"; 105 void operator []=(String key, String value) native "DOMStringMap_setItem_Callb ack";
90 String putIfAbsent(String key, String ifAbsent()) => Maps.putIfAbsent(this, ke y, ifAbsent); 106 String putIfAbsent(String key, String ifAbsent()) => Maps.putIfAbsent(this, ke y, ifAbsent);
91 String remove(String key) native "DOMStringMap_remove_Callback"; 107 String remove(String key) native "DOMStringMap_remove_Callback";
92 void clear() => Maps.clear(this); 108 void clear() => Maps.clear(this);
93 void forEach(void f(String key, String value)) => Maps.forEach(this, f); 109 void forEach(void f(String key, String value)) => Maps.forEach(this, f);
94 Collection<String> getKeys() native "DOMStringMap_getKeys_Callback"; 110 Collection<String> getKeys() native "DOMStringMap_getKeys_Callback";
95 Collection<String> getValues() => Maps.getValues(this); 111 Collection<String> getValues() => Maps.getValues(this);
96 int get length() => Maps.length(this); 112 int get length() => Maps.length(this);
97 bool isEmpty() => Maps.isEmpty(this); 113 bool isEmpty() => Maps.isEmpty(this);
98 } 114 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698