diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 76cc8509ee73..090a2d486beb 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -704,7 +704,6 @@ const js::Class OuterWindowProxyClass = PROXY_MAKE_EXT( nullptr, /* outerObject */ js::proxy_innerObject, - nullptr, /* iteratorObject */ false, /* isWrappedNative */ nsOuterWindowProxy::ObjectMoved )); diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 10502dac1421..63ce59c1a2e1 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -370,7 +370,6 @@ class CGDOMJSClass(CGThing): { nullptr, /* outerObject */ nullptr, /* innerObject */ - nullptr, /* iteratorObject */ false, /* isWrappedNative */ nullptr, /* weakmapKeyDelegateOp */ ${objectMoved} /* objectMovedOp */ @@ -388,7 +387,6 @@ class CGDOMJSClass(CGThing): { nsGlobalWindow::OuterObject, /* outerObject */ nullptr, /* innerObject */ - nullptr, /* iteratorObject */ false, /* isWrappedNative */ nullptr, /* weakmapKeyDelegateOp */ ${objectMoved} /* objectMovedOp */ @@ -500,7 +498,6 @@ class CGDOMProxyJSClass(CGThing): ${flags}, PROXY_MAKE_EXT(nullptr, /* outerObject */ nullptr, /* innerObject */ - nullptr, /* iteratorObject */ false, /* isWrappedNative */ ${objectMoved})), $*{descriptor} diff --git a/dom/plugins/base/nsJSNPRuntime.cpp b/dom/plugins/base/nsJSNPRuntime.cpp index dc0af98e4c26..74a95cc72cf3 100644 --- a/dom/plugins/base/nsJSNPRuntime.cpp +++ b/dom/plugins/base/nsJSNPRuntime.cpp @@ -201,7 +201,6 @@ const static js::Class sNPObjectJSWrapperClass = { nullptr, /* outerObject */ nullptr, /* innerObject */ - nullptr, /* iteratorObject */ false, /* isWrappedNative */ nullptr, /* weakmapKeyDelegateOp */ NPObjWrapper_ObjectMoved diff --git a/js/public/Class.h b/js/public/Class.h index 27c1f26803e2..d386557b7af9 100644 --- a/js/public/Class.h +++ b/js/public/Class.h @@ -177,11 +177,6 @@ typedef bool typedef void (* JSTraceOp)(JSTracer *trc, JSObject *obj); -// Hook that creates an iterator object for a given object. Returns the -// iterator object or null if an error or exception was thrown on cx. -typedef JSObject * -(* JSIteratorOp)(JSContext *cx, JS::HandleObject obj, bool keysonly); - typedef JSObject * (* JSWeakmapKeyDelegateOp)(JSObject *obj); @@ -325,7 +320,6 @@ struct ClassExtension { ObjectOp outerObject; InnerObjectOp innerObject; - JSIteratorOp iteratorObject; /* * isWrappedNative is true only if the class is an XPCWrappedNative. @@ -361,7 +355,7 @@ struct ClassExtension }; #define JS_NULL_CLASS_SPEC {nullptr,nullptr,nullptr,nullptr,nullptr,nullptr} -#define JS_NULL_CLASS_EXT {nullptr,nullptr,nullptr,false,nullptr,nullptr} +#define JS_NULL_CLASS_EXT {nullptr,nullptr,false,nullptr,nullptr} struct ObjectOps { @@ -401,7 +395,7 @@ typedef void (*JSClassInternal)(); struct JSClass { JS_CLASS_MEMBERS(JSFinalizeOp); - void *reserved[33]; + void *reserved[32]; }; #define JSCLASS_HAS_PRIVATE (1<<0) // objects have private slot diff --git a/js/src/jsapi-tests/moz.build b/js/src/jsapi-tests/moz.build index f483bd137cca..5a4c5c173502 100644 --- a/js/src/jsapi-tests/moz.build +++ b/js/src/jsapi-tests/moz.build @@ -19,7 +19,6 @@ UNIFIED_SOURCES += [ 'testClassGetter.cpp', 'testCloneScript.cpp', 'testContexts.cpp', - 'testCustomIterator.cpp', 'testDebugger.cpp', 'testDeepFreeze.cpp', 'testDefineGetterSetterNonEnumerable.cpp', diff --git a/js/src/jsapi-tests/testBug604087.cpp b/js/src/jsapi-tests/testBug604087.cpp index a672cfa2dd02..89aaf11f61e9 100644 --- a/js/src/jsapi-tests/testBug604087.cpp +++ b/js/src/jsapi-tests/testBug604087.cpp @@ -21,7 +21,6 @@ const js::Class OuterWrapperClass = PROXY_MAKE_EXT( nullptr, /* outerObject */ js::proxy_innerObject, - nullptr, /* iteratorObject */ false, /* isWrappedNative */ nullptr /* objectMoved */ )); diff --git a/js/src/jsapi-tests/testCustomIterator.cpp b/js/src/jsapi-tests/testCustomIterator.cpp deleted file mode 100644 index fa1dd992b385..000000000000 --- a/js/src/jsapi-tests/testCustomIterator.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "js/Class.h" -#include "jsapi-tests/tests.h" - -static int iterCount = 0; - -static bool -IterNext(JSContext *cx, unsigned argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - if (iterCount++ == 100) - return JS_ThrowStopIteration(cx); - args.rval().setInt32(iterCount); - return true; -} - -static JSObject * -IterHook(JSContext *cx, JS::HandleObject obj, bool keysonly) -{ - JS::RootedObject iterObj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); - if (!iterObj) - return nullptr; - if (!JS_DefineFunction(cx, iterObj, "next", IterNext, 0, 0)) - return nullptr; - return iterObj; -} - -const js::Class HasCustomIterClass = { - "HasCustomIter", - 0, - JS_PropertyStub, - JS_DeletePropertyStub, - JS_PropertyStub, - JS_StrictPropertyStub, - JS_EnumerateStub, - JS_ResolveStub, - JS_ConvertStub, - nullptr, - nullptr, /* call */ - nullptr, /* hasInstance */ - nullptr, /* construct */ - nullptr, /* mark */ - JS_NULL_CLASS_SPEC, - { - nullptr, /* outerObject */ - nullptr, /* innerObject */ - IterHook, - false /* isWrappedNative */ - } -}; - -static bool -IterClassConstructor(JSContext *cx, unsigned argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JSObject *obj = JS_NewObjectForConstructor(cx, Jsvalify(&HasCustomIterClass), args); - if (!obj) - return false; - args.rval().setObject(*obj); - return true; -} - -BEGIN_TEST(testCustomIterator_bug612523) -{ - CHECK(JS_InitClass(cx, global, js::NullPtr(), Jsvalify(&HasCustomIterClass), - IterClassConstructor, 0, nullptr, nullptr, nullptr, nullptr)); - - JS::RootedValue result(cx); - EVAL("var o = new HasCustomIter(); \n" - "var j = 0; \n" - "for (var i in o) { ++j; }; \n" - "j;", &result); - - CHECK(result.isInt32()); - CHECK_EQUAL(result.toInt32(), 100); - CHECK_EQUAL(iterCount, 101); - - return true; -} -END_TEST(testCustomIterator_bug612523) diff --git a/js/src/jsapi-tests/testWeakMap.cpp b/js/src/jsapi-tests/testWeakMap.cpp index 8a85ab3c85f4..3ea7421db823 100644 --- a/js/src/jsapi-tests/testWeakMap.cpp +++ b/js/src/jsapi-tests/testWeakMap.cpp @@ -150,7 +150,6 @@ JSObject *newKey() nullptr, JS_NULL_CLASS_SPEC, { - nullptr, nullptr, nullptr, false, diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index 3879e2a6b8cd..d7514cb5f7fb 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -275,12 +275,11 @@ namespace js { * NB: The macro invocation must be surrounded by braces, so as to * allow for potential JSClass extensions. */ -#define PROXY_MAKE_EXT(outerObject, innerObject, iteratorObject, \ - isWrappedNative, objectMoved) \ +#define PROXY_MAKE_EXT(outerObject, innerObject, isWrappedNative, \ + objectMoved) \ { \ outerObject, \ innerObject, \ - iteratorObject, \ isWrappedNative, \ js::proxy_WeakmapKeyDelegate, \ objectMoved \ @@ -335,7 +334,6 @@ namespace js { PROXY_MAKE_EXT( \ nullptr, /* outerObject */ \ nullptr, /* innerObject */ \ - nullptr, /* iteratorObject */ \ false, /* isWrappedNative */ \ js::proxy_ObjectMoved \ )) diff --git a/js/src/jsiter.cpp b/js/src/jsiter.cpp index 8516f474aea6..f85bf94c0de0 100644 --- a/js/src/jsiter.cpp +++ b/js/src/jsiter.cpp @@ -666,11 +666,8 @@ js::GetIterator(JSContext *cx, HandleObject obj, unsigned flags, MutableHandleVa bool keysOnly = (flags == JSITER_ENUMERATE); if (obj) { - if (JSIteratorOp op = obj->getClass()->ext.iteratorObject) { - JSObject *iterobj = op(cx, obj, !(flags & JSITER_FOREACH)); - if (!iterobj) - return false; - vp.setObject(*iterobj); + if (obj->is() || obj->is()) { + vp.setObject(*obj); return true; } @@ -891,12 +888,6 @@ static const JSFunctionSpec iterator_methods[] = { JS_FS_END }; -static JSObject * -iterator_iteratorObject(JSContext *cx, HandleObject obj, bool keysonly) -{ - return obj; -} - size_t PropertyIteratorObject::sizeOfMisc(mozilla::MallocSizeOf mallocSizeOf) const { @@ -935,12 +926,6 @@ const Class PropertyIteratorObject::class_ = { nullptr, /* hasInstance */ nullptr, /* construct */ trace, - JS_NULL_CLASS_SPEC, - { - nullptr, /* outerObject */ - nullptr, /* innerObject */ - iterator_iteratorObject, - } }; enum { diff --git a/js/src/vm/ArrayBufferObject.cpp b/js/src/vm/ArrayBufferObject.cpp index 7020e12f0f87..9e9e915e940d 100644 --- a/js/src/vm/ArrayBufferObject.cpp +++ b/js/src/vm/ArrayBufferObject.cpp @@ -126,7 +126,6 @@ const Class ArrayBufferObject::class_ = { { nullptr, /* outerObject */ nullptr, /* innerObject */ - nullptr, /* iteratorObject */ false, /* isWrappedNative */ nullptr, /* weakmapKeyDelegateOp */ ArrayBufferObject::objectMoved diff --git a/js/src/vm/GeneratorObject.cpp b/js/src/vm/GeneratorObject.cpp index e432851f25ff..dc27855d196f 100644 --- a/js/src/vm/GeneratorObject.cpp +++ b/js/src/vm/GeneratorObject.cpp @@ -194,12 +194,6 @@ LegacyGeneratorObject::close(JSContext *cx, HandleObject obj) return Invoke(cx, args); } -static JSObject * -iterator_iteratorObject(JSContext *cx, HandleObject obj, bool keysonly) -{ - return obj; -} - const Class LegacyGeneratorObject::class_ = { "Generator", JSCLASS_HAS_RESERVED_SLOTS(GeneratorObject::RESERVED_SLOTS), @@ -215,12 +209,6 @@ const Class LegacyGeneratorObject::class_ = { nullptr, /* hasInstance */ nullptr, /* construct */ nullptr, /* trace */ - JS_NULL_CLASS_SPEC, - { - nullptr, /* outerObject */ - nullptr, /* innerObject */ - iterator_iteratorObject, - } }; const Class StarGeneratorObject::class_ = { diff --git a/js/src/vm/TypedArrayObject.cpp b/js/src/vm/TypedArrayObject.cpp index 5a32e388c064..237e307ccd4c 100644 --- a/js/src/vm/TypedArrayObject.cpp +++ b/js/src/vm/TypedArrayObject.cpp @@ -1747,7 +1747,6 @@ IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Float64, double, double) { \ nullptr, /* outerObject */ \ nullptr, /* innerObject */ \ - nullptr, /* iteratorObject */ \ false, /* isWrappedNative */ \ nullptr, /* weakmapKeyDelegateOp */ \ TypedArrayObject::ObjectMoved \ diff --git a/js/xpconnect/src/Sandbox.cpp b/js/xpconnect/src/Sandbox.cpp index c3c23a384ead..0bf08fc34959 100644 --- a/js/xpconnect/src/Sandbox.cpp +++ b/js/xpconnect/src/Sandbox.cpp @@ -467,7 +467,6 @@ static const js::Class SandboxClass = { { nullptr, /* outerObject */ nullptr, /* innerObject */ - nullptr, /* iteratorObject */ false, /* isWrappedNative */ nullptr, /* weakmapKeyDelegateOp */ sandbox_moved /* objectMovedOp */ @@ -487,7 +486,6 @@ static const js::Class SandboxWriteToProtoClass = { { nullptr, /* outerObject */ nullptr, /* innerObject */ - nullptr, /* iteratorObject */ false, /* isWrappedNative */ nullptr, /* weakmapKeyDelegateOp */ sandbox_moved /* objectMovedOp */ diff --git a/js/xpconnect/src/XPCWrappedNativeJSOps.cpp b/js/xpconnect/src/XPCWrappedNativeJSOps.cpp index c2fdbacacd91..1bef4388c0fb 100644 --- a/js/xpconnect/src/XPCWrappedNativeJSOps.cpp +++ b/js/xpconnect/src/XPCWrappedNativeJSOps.cpp @@ -673,7 +673,6 @@ const XPCWrappedNativeJSClass XPC_WN_NoHelper_JSClass = { { nullptr, // outerObject nullptr, // innerObject - nullptr, // iteratorObject true, // isWrappedNative nullptr, // weakmapKeyDelegateOp WrappedNativeObjectMoved @@ -1389,7 +1388,6 @@ XPC_WN_ModsAllowed_Proto_Resolve(JSContext *cx, HandleObject obj, HandleId id) { \ nullptr, /* outerObject */ \ nullptr, /* innerObject */ \ - nullptr, /* iteratorObject */ \ false, /* isWrappedNative */ \ nullptr, /* weakmapKeyDelegateOp */ \ XPC_WN_Shared_Proto_ObjectMoved \ @@ -1646,7 +1644,6 @@ const js::Class XPC_WN_Tearoff_JSClass = { { nullptr, // outerObject nullptr, // innerObject - nullptr, // iteratorObject false, // isWrappedNative nullptr, // weakmapKeyDelegateOp XPC_WN_TearOff_ObjectMoved