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

Unified Diff: client/dom/frog/frog_dom.dart

Issue 8889001: Implement typed array constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: comment Created 9 years 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
« no previous file with comments | « no previous file | client/dom/frog_dom.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/dom/frog/frog_dom.dart
diff --git a/client/dom/frog/frog_dom.dart b/client/dom/frog/frog_dom.dart
index ec594be1464facbb7a62338323364dc15cf057c7..6295315b6850b3bf89f4974b28b90e0cc8e24362 100644
--- a/client/dom/frog/frog_dom.dart
+++ b/client/dom/frog/frog_dom.dart
@@ -10,6 +10,7 @@
+// #source('src/_FactoryProviders.dart');
class Window extends DOMWindow {}
DOMWindow get window() native "return window;";
@@ -597,6 +598,8 @@ class CanvasPixelArray native "*CanvasPixelArray" {
int operator[](int index) native;
+ void operator[]=(int index, int value) native;
+
var dartObjectLocalStorage;
String get typeName() native;
@@ -2318,21 +2321,45 @@ class FileWriterSync native "*FileWriterSync" {
String get typeName() native;
}
-class Float32Array extends ArrayBufferView native "*Float32Array" {
+class Float32Array extends ArrayBufferView implements List<num> native "Float32Array" {
+
+ factory Float32Array(int length) => _construct(length);
+
+ factory Float32Array.fromList(List<num> list) => _construct(list);
+
+ factory Float32Array.fromBuffer(ArrayBuffer buffer) => _construct(buffer);
+
+ static _construct(arg) native 'return new Float32Array(arg);';
static final int BYTES_PER_ELEMENT = 4;
int length;
+ num operator[](int index) native;
+
+ void operator[]=(int index, num value) native;
+
Float32Array subarray(int start, [int end = null]) native;
}
-class Float64Array extends ArrayBufferView native "*Float64Array" {
+class Float64Array extends ArrayBufferView implements List<num> native "Float64Array" {
+
+ factory Float64Array(int length) => _construct(length);
+
+ factory Float64Array.fromList(List<num> list) => _construct(list);
+
+ factory Float64Array.fromBuffer(ArrayBuffer buffer) => _construct(buffer);
+
+ static _construct(arg) native 'return new Float64Array(arg);';
static final int BYTES_PER_ELEMENT = 8;
int length;
+ num operator[](int index) native;
+
+ void operator[]=(int index, num value) native;
+
Float64Array subarray(int start, [int end = null]) native;
}
@@ -2581,6 +2608,10 @@ class HTMLCollection native "HTMLCollection" {
Node operator[](int index) native;
+ void operator[]=(int index, Node value) {
+ throw new UnsupportedOperationException("Cannot assign element of immutable List.");
+ }
+
Node item(int index) native;
Node namedItem(String name) native;
@@ -4206,30 +4237,66 @@ class InspectorFrontendHost native "*InspectorFrontendHost" {
String get typeName() native;
}
-class Int16Array extends ArrayBufferView native "*Int16Array" {
+class Int16Array extends ArrayBufferView implements List<int> native "Int16Array" {
+
+ factory Int16Array(int length) => _construct(length);
+
+ factory Int16Array.fromList(List<int> list) => _construct(list);
+
+ factory Int16Array.fromBuffer(ArrayBuffer buffer) => _construct(buffer);
+
+ static _construct(arg) native 'return new Int16Array(arg);';
static final int BYTES_PER_ELEMENT = 2;
int length;
+ int operator[](int index) native;
+
+ void operator[]=(int index, int value) native;
+
Int16Array subarray(int start, [int end = null]) native;
}
-class Int32Array extends ArrayBufferView native "*Int32Array" {
+class Int32Array extends ArrayBufferView implements List<int> native "Int32Array" {
+
+ factory Int32Array(int length) => _construct(length);
+
+ factory Int32Array.fromList(List<int> list) => _construct(list);
+
+ factory Int32Array.fromBuffer(ArrayBuffer buffer) => _construct(buffer);
+
+ static _construct(arg) native 'return new Int32Array(arg);';
static final int BYTES_PER_ELEMENT = 4;
int length;
+ int operator[](int index) native;
+
+ void operator[]=(int index, int value) native;
+
Int32Array subarray(int start, [int end = null]) native;
}
-class Int8Array extends ArrayBufferView native "*Int8Array" {
+class Int8Array extends ArrayBufferView implements List<int> native "Int8Array" {
+
+ factory Int8Array(int length) => _construct(length);
+
+ factory Int8Array.fromList(List<int> list) => _construct(list);
+
+ factory Int8Array.fromBuffer(ArrayBuffer buffer) => _construct(buffer);
+
+ static _construct(arg) native 'return new Int8Array(arg);';
static final int BYTES_PER_ELEMENT = 1;
int length;
+ int operator[](int index) native;
+
+ void operator[]=(int index, int value) native;
+
Int8Array subarray(int start, [int end = null]) native;
}
@@ -4364,6 +4431,10 @@ class MediaList native "*MediaList" {
String operator[](int index) native;
+ void operator[]=(int index, String value) {
+ throw new UnsupportedOperationException("Cannot assign element of immutable List.");
+ }
+
void appendMedium(String newMedium) native;
void deleteMedium(String oldMedium) native;
@@ -4568,6 +4639,10 @@ class NamedNodeMap native "*NamedNodeMap" {
Node operator[](int index) native;
+ void operator[]=(int index, Node value) {
+ throw new UnsupportedOperationException("Cannot assign element of immutable List.");
+ }
+
Node getNamedItem(String name) native;
Node getNamedItemNS(String namespaceURI, String localName) native;
@@ -4831,6 +4906,10 @@ class NodeList native "*NodeList" {
Node operator[](int index) native;
+ void operator[]=(int index, Node value) {
+ throw new UnsupportedOperationException("Cannot assign element of immutable List.");
+ }
+
Node item(int index) native;
var dartObjectLocalStorage;
@@ -8928,6 +9007,10 @@ class StyleSheetList native "*StyleSheetList" {
StyleSheet operator[](int index) native;
+ void operator[]=(int index, StyleSheet value) {
+ throw new UnsupportedOperationException("Cannot assign element of immutable List.");
+ }
+
StyleSheet item(int index) native;
var dartObjectLocalStorage;
@@ -9114,6 +9197,10 @@ class TouchList native "*TouchList" {
Touch operator[](int index) native;
+ void operator[]=(int index, Touch value) {
+ throw new UnsupportedOperationException("Cannot assign element of immutable List.");
+ }
+
Touch item(int index) native;
var dartObjectLocalStorage;
@@ -9175,30 +9262,66 @@ class UIEvent extends Event native "UIEvent" {
void initUIEvent(String type, bool canBubble, bool cancelable, DOMWindow view, int detail) native;
}
-class Uint16Array extends ArrayBufferView native "*Uint16Array" {
+class Uint16Array extends ArrayBufferView implements List<int> native "Uint16Array" {
+
+ factory Uint16Array(int length) => _construct(length);
+
+ factory Uint16Array.fromList(List<int> list) => _construct(list);
+
+ factory Uint16Array.fromBuffer(ArrayBuffer buffer) => _construct(buffer);
+
+ static _construct(arg) native 'return new Uint16Array(arg);';
static final int BYTES_PER_ELEMENT = 2;
int length;
+ int operator[](int index) native;
+
+ void operator[]=(int index, int value) native;
+
Uint16Array subarray(int start, [int end = null]) native;
}
-class Uint32Array extends ArrayBufferView native "*Uint32Array" {
+class Uint32Array extends ArrayBufferView implements List<int> native "Uint32Array" {
+
+ factory Uint32Array(int length) => _construct(length);
+
+ factory Uint32Array.fromList(List<int> list) => _construct(list);
+
+ factory Uint32Array.fromBuffer(ArrayBuffer buffer) => _construct(buffer);
+
+ static _construct(arg) native 'return new Uint32Array(arg);';
static final int BYTES_PER_ELEMENT = 4;
int length;
+ int operator[](int index) native;
+
+ void operator[]=(int index, int value) native;
+
Uint32Array subarray(int start, [int end = null]) native;
}
-class Uint8Array extends ArrayBufferView native "*Uint8Array" {
+class Uint8Array extends ArrayBufferView implements List<int> native "Uint8Array" {
+
+ factory Uint8Array(int length) => _construct(length);
+
+ factory Uint8Array.fromList(List<int> list) => _construct(list);
+
+ factory Uint8Array.fromBuffer(ArrayBuffer buffer) => _construct(buffer);
+
+ static _construct(arg) native 'return new Uint8Array(arg);';
static final int BYTES_PER_ELEMENT = 1;
int length;
+ int operator[](int index) native;
+
+ void operator[]=(int index, int value) native;
+
Uint8Array subarray(int start, [int end = null]) native;
}
@@ -11059,3 +11182,128 @@ typedef bool RequestAnimationFrameCallback(int time);
// BSD-style license that can be found in the LICENSE file.
typedef void TimeoutHandler();
+// Copyright (c) 2011, 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.
+
+/**
+ * The [Collections] class implements static methods useful when
+ * writing a class that implements [Collection] and the [iterator]
+ * method.
+ */
+class _Collections {
+ static void forEach(Iterable<Object> iterable, void f(Object o)) {
+ for (final e in iterable) {
+ f(e);
+ }
+ }
+
+ static bool some(Iterable<Object> iterable, bool f(Object o)) {
+ for (final e in iterable) {
+ if (f(e)) return true;
+ }
+ return false;
+ }
+
+ static bool every(Iterable<Object> iterable, bool f(Object o)) {
+ for (final e in iterable) {
+ if (!f(e)) return false;
+ }
+ return true;
+ }
+
+ static List filter(Iterable<Object> source,
+ List<Object> destination,
+ bool f(o)) {
+ for (final e in source) {
+ if (f(e)) destination.add(e);
+ }
+ return destination;
+ }
+
+ static bool isEmpty(Iterable<Object> iterable) {
+ return !iterable.iterator().hasNext();
+ }
+}
+// Copyright (c) 2011, 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.
+
+// Iterator for arrays with fixed size.
+class _FixedSizeListIterator<T> extends _VariableSizeListIterator<T> {
+ _FixedSizeListIterator(List<T> array)
+ : super(array),
+ _length = array.length;
+
+ bool hasNext() => _length > _pos;
+
+ final int _length; // Cache array length for faster access.
+}
+
+// Iterator for arrays with variable size.
+class _VariableSizeListIterator<T> implements Iterator<T> {
+ _VariableSizeListIterator(List<T> array)
+ : _array = array,
+ _pos = 0;
+
+ bool hasNext() => _array.length > _pos;
+
+ T next() {
+ if (!hasNext()) {
+ throw const NoMoreElementsException();
+ }
+ return _array[_pos++];
+ }
+
+ final List<T> _array;
+ int _pos;
+}
+// Copyright (c) 2011, 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.
+
+class _Lists {
+
+ /**
+ * Returns the index in the array [a] of the given [element], starting
+ * the search at index [startIndex] to [endIndex] (exclusive).
+ * Returns -1 if [element] is not found.
+ */
+ static int indexOf(List a,
+ Object element,
+ int startIndex,
+ int endIndex) {
+ if (startIndex >= a.length) {
+ return -1;
+ }
+ if (startIndex < 0) {
+ startIndex = 0;
+ }
+ for (int i = startIndex; i < endIndex; i++) {
+ if (a[i] == element) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Returns the last index in the array [a] of the given [element], starting
+ * the search at index [startIndex] to 0.
+ * Returns -1 if [element] is not found.
+ */
+ static int lastIndexOf(List a, Object element, int startIndex) {
+ if (startIndex < 0) {
+ return -1;
+ }
+ if (startIndex >= a.length) {
+ startIndex = a.length - 1;
+ }
+ for (int i = startIndex; i >= 0; i--) {
+ if (a[i] == element) {
+ return i;
+ }
+ }
+ return -1;
+ }
+}
« no previous file with comments | « no previous file | client/dom/frog_dom.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698