mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 725907 - for-of improvements, part 5: Make ctypes arrays iterable. r=bhackett.
--HG-- extra : rebase_source : 598baa07d9cfa41255aadff979ca8319e288a05b
This commit is contained in:
parent
f9a50fa00d
commit
0d459625e3
@ -514,6 +514,7 @@ static JSPropertySpec sArrayProps[] = {
|
||||
|
||||
static JSFunctionSpec sArrayInstanceFunctions[] = {
|
||||
JS_FN("addressOfElement", ArrayType::AddressOfElement, 1, CDATAFN_FLAGS),
|
||||
JS_FN("iterator", JS_ArrayIterator, 0, CDATAFN_FLAGS),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
|
17
js/src/jit-test/tests/for-of/ctypes.js
Normal file
17
js/src/jit-test/tests/for-of/ctypes.js
Normal file
@ -0,0 +1,17 @@
|
||||
// for-of works on CData objects of array type, but throws for other CData objects.
|
||||
|
||||
if (this.ctypes) {
|
||||
load(libdir + "asserts.js");
|
||||
var v = ctypes.int32_t(17);
|
||||
assertThrowsInstanceOf(function () { for (var x of v) ; }, TypeError);
|
||||
|
||||
var intarray_t = ctypes.int32_t.array();
|
||||
var a = new intarray_t([0, 1, 1, 2, 3]);
|
||||
var b = [x for (x of a)];
|
||||
assertEq(b.join(), '0,1,1,2,3');
|
||||
|
||||
var it = a.iterator();
|
||||
assertEq(it.next(), 0);
|
||||
a[1] = -100;
|
||||
assertEq(it.next(), -100);
|
||||
}
|
Loading…
Reference in New Issue
Block a user