Bug 1091900 - Remove iteratorObject hook. r=jorendorff

This commit is contained in:
Tom Schuster 2014-11-05 20:36:49 +01:00
parent d35cbaac21
commit 5ab9fec9c7
14 changed files with 6 additions and 138 deletions

View File

@ -704,7 +704,6 @@ const js::Class OuterWindowProxyClass =
PROXY_MAKE_EXT( PROXY_MAKE_EXT(
nullptr, /* outerObject */ nullptr, /* outerObject */
js::proxy_innerObject, js::proxy_innerObject,
nullptr, /* iteratorObject */
false, /* isWrappedNative */ false, /* isWrappedNative */
nsOuterWindowProxy::ObjectMoved nsOuterWindowProxy::ObjectMoved
)); ));

View File

@ -370,7 +370,6 @@ class CGDOMJSClass(CGThing):
{ {
nullptr, /* outerObject */ nullptr, /* outerObject */
nullptr, /* innerObject */ nullptr, /* innerObject */
nullptr, /* iteratorObject */
false, /* isWrappedNative */ false, /* isWrappedNative */
nullptr, /* weakmapKeyDelegateOp */ nullptr, /* weakmapKeyDelegateOp */
${objectMoved} /* objectMovedOp */ ${objectMoved} /* objectMovedOp */
@ -388,7 +387,6 @@ class CGDOMJSClass(CGThing):
{ {
nsGlobalWindow::OuterObject, /* outerObject */ nsGlobalWindow::OuterObject, /* outerObject */
nullptr, /* innerObject */ nullptr, /* innerObject */
nullptr, /* iteratorObject */
false, /* isWrappedNative */ false, /* isWrappedNative */
nullptr, /* weakmapKeyDelegateOp */ nullptr, /* weakmapKeyDelegateOp */
${objectMoved} /* objectMovedOp */ ${objectMoved} /* objectMovedOp */
@ -500,7 +498,6 @@ class CGDOMProxyJSClass(CGThing):
${flags}, ${flags},
PROXY_MAKE_EXT(nullptr, /* outerObject */ PROXY_MAKE_EXT(nullptr, /* outerObject */
nullptr, /* innerObject */ nullptr, /* innerObject */
nullptr, /* iteratorObject */
false, /* isWrappedNative */ false, /* isWrappedNative */
${objectMoved})), ${objectMoved})),
$*{descriptor} $*{descriptor}

View File

@ -177,11 +177,6 @@ typedef bool
typedef void typedef void
(* JSTraceOp)(JSTracer *trc, JSObject *obj); (* 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 * typedef JSObject *
(* JSWeakmapKeyDelegateOp)(JSObject *obj); (* JSWeakmapKeyDelegateOp)(JSObject *obj);
@ -325,7 +320,6 @@ struct ClassExtension
{ {
ObjectOp outerObject; ObjectOp outerObject;
InnerObjectOp innerObject; InnerObjectOp innerObject;
JSIteratorOp iteratorObject;
/* /*
* isWrappedNative is true only if the class is an XPCWrappedNative. * 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_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 struct ObjectOps
{ {
@ -401,7 +395,7 @@ typedef void (*JSClassInternal)();
struct JSClass { struct JSClass {
JS_CLASS_MEMBERS(JSFinalizeOp); JS_CLASS_MEMBERS(JSFinalizeOp);
void *reserved[33]; void *reserved[32];
}; };
#define JSCLASS_HAS_PRIVATE (1<<0) // objects have private slot #define JSCLASS_HAS_PRIVATE (1<<0) // objects have private slot

View File

@ -19,7 +19,6 @@ UNIFIED_SOURCES += [
'testClassGetter.cpp', 'testClassGetter.cpp',
'testCloneScript.cpp', 'testCloneScript.cpp',
'testContexts.cpp', 'testContexts.cpp',
'testCustomIterator.cpp',
'testDebugger.cpp', 'testDebugger.cpp',
'testDeepFreeze.cpp', 'testDeepFreeze.cpp',
'testDefineGetterSetterNonEnumerable.cpp', 'testDefineGetterSetterNonEnumerable.cpp',

View File

@ -21,7 +21,6 @@ const js::Class OuterWrapperClass =
PROXY_MAKE_EXT( PROXY_MAKE_EXT(
nullptr, /* outerObject */ nullptr, /* outerObject */
js::proxy_innerObject, js::proxy_innerObject,
nullptr, /* iteratorObject */
false, /* isWrappedNative */ false, /* isWrappedNative */
nullptr /* objectMoved */ nullptr /* objectMoved */
)); ));

View File

@ -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)

View File

@ -150,7 +150,6 @@ JSObject *newKey()
nullptr, nullptr,
JS_NULL_CLASS_SPEC, JS_NULL_CLASS_SPEC,
{ {
nullptr,
nullptr, nullptr,
nullptr, nullptr,
false, false,

View File

@ -275,12 +275,11 @@ namespace js {
* NB: The macro invocation must be surrounded by braces, so as to * NB: The macro invocation must be surrounded by braces, so as to
* allow for potential JSClass extensions. * allow for potential JSClass extensions.
*/ */
#define PROXY_MAKE_EXT(outerObject, innerObject, iteratorObject, \ #define PROXY_MAKE_EXT(outerObject, innerObject, isWrappedNative, \
isWrappedNative, objectMoved) \ objectMoved) \
{ \ { \
outerObject, \ outerObject, \
innerObject, \ innerObject, \
iteratorObject, \
isWrappedNative, \ isWrappedNative, \
js::proxy_WeakmapKeyDelegate, \ js::proxy_WeakmapKeyDelegate, \
objectMoved \ objectMoved \
@ -335,7 +334,6 @@ namespace js {
PROXY_MAKE_EXT( \ PROXY_MAKE_EXT( \
nullptr, /* outerObject */ \ nullptr, /* outerObject */ \
nullptr, /* innerObject */ \ nullptr, /* innerObject */ \
nullptr, /* iteratorObject */ \
false, /* isWrappedNative */ \ false, /* isWrappedNative */ \
js::proxy_ObjectMoved \ js::proxy_ObjectMoved \
)) ))

View File

@ -666,11 +666,8 @@ js::GetIterator(JSContext *cx, HandleObject obj, unsigned flags, MutableHandleVa
bool keysOnly = (flags == JSITER_ENUMERATE); bool keysOnly = (flags == JSITER_ENUMERATE);
if (obj) { if (obj) {
if (JSIteratorOp op = obj->getClass()->ext.iteratorObject) { if (obj->is<PropertyIteratorObject>() || obj->is<LegacyGeneratorObject>()) {
JSObject *iterobj = op(cx, obj, !(flags & JSITER_FOREACH)); vp.setObject(*obj);
if (!iterobj)
return false;
vp.setObject(*iterobj);
return true; return true;
} }
@ -891,12 +888,6 @@ static const JSFunctionSpec iterator_methods[] = {
JS_FS_END JS_FS_END
}; };
static JSObject *
iterator_iteratorObject(JSContext *cx, HandleObject obj, bool keysonly)
{
return obj;
}
size_t size_t
PropertyIteratorObject::sizeOfMisc(mozilla::MallocSizeOf mallocSizeOf) const PropertyIteratorObject::sizeOfMisc(mozilla::MallocSizeOf mallocSizeOf) const
{ {
@ -935,12 +926,6 @@ const Class PropertyIteratorObject::class_ = {
nullptr, /* hasInstance */ nullptr, /* hasInstance */
nullptr, /* construct */ nullptr, /* construct */
trace, trace,
JS_NULL_CLASS_SPEC,
{
nullptr, /* outerObject */
nullptr, /* innerObject */
iterator_iteratorObject,
}
}; };
enum { enum {

View File

@ -126,7 +126,6 @@ const Class ArrayBufferObject::class_ = {
{ {
nullptr, /* outerObject */ nullptr, /* outerObject */
nullptr, /* innerObject */ nullptr, /* innerObject */
nullptr, /* iteratorObject */
false, /* isWrappedNative */ false, /* isWrappedNative */
nullptr, /* weakmapKeyDelegateOp */ nullptr, /* weakmapKeyDelegateOp */
ArrayBufferObject::objectMoved ArrayBufferObject::objectMoved

View File

@ -201,12 +201,6 @@ LegacyGeneratorObject::close(JSContext *cx, HandleObject obj)
return Invoke(cx, args); return Invoke(cx, args);
} }
static JSObject *
iterator_iteratorObject(JSContext *cx, HandleObject obj, bool keysonly)
{
return obj;
}
const Class LegacyGeneratorObject::class_ = { const Class LegacyGeneratorObject::class_ = {
"Generator", "Generator",
JSCLASS_HAS_RESERVED_SLOTS(GeneratorObject::RESERVED_SLOTS), JSCLASS_HAS_RESERVED_SLOTS(GeneratorObject::RESERVED_SLOTS),
@ -222,12 +216,6 @@ const Class LegacyGeneratorObject::class_ = {
nullptr, /* hasInstance */ nullptr, /* hasInstance */
nullptr, /* construct */ nullptr, /* construct */
nullptr, /* trace */ nullptr, /* trace */
JS_NULL_CLASS_SPEC,
{
nullptr, /* outerObject */
nullptr, /* innerObject */
iterator_iteratorObject,
}
}; };
const Class StarGeneratorObject::class_ = { const Class StarGeneratorObject::class_ = {

View File

@ -1747,7 +1747,6 @@ IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Float64, double, double)
{ \ { \
nullptr, /* outerObject */ \ nullptr, /* outerObject */ \
nullptr, /* innerObject */ \ nullptr, /* innerObject */ \
nullptr, /* iteratorObject */ \
false, /* isWrappedNative */ \ false, /* isWrappedNative */ \
nullptr, /* weakmapKeyDelegateOp */ \ nullptr, /* weakmapKeyDelegateOp */ \
TypedArrayObject::ObjectMoved \ TypedArrayObject::ObjectMoved \

View File

@ -467,7 +467,6 @@ static const js::Class SandboxClass = {
{ {
nullptr, /* outerObject */ nullptr, /* outerObject */
nullptr, /* innerObject */ nullptr, /* innerObject */
nullptr, /* iteratorObject */
false, /* isWrappedNative */ false, /* isWrappedNative */
nullptr, /* weakmapKeyDelegateOp */ nullptr, /* weakmapKeyDelegateOp */
sandbox_moved /* objectMovedOp */ sandbox_moved /* objectMovedOp */
@ -487,7 +486,6 @@ static const js::Class SandboxWriteToProtoClass = {
{ {
nullptr, /* outerObject */ nullptr, /* outerObject */
nullptr, /* innerObject */ nullptr, /* innerObject */
nullptr, /* iteratorObject */
false, /* isWrappedNative */ false, /* isWrappedNative */
nullptr, /* weakmapKeyDelegateOp */ nullptr, /* weakmapKeyDelegateOp */
sandbox_moved /* objectMovedOp */ sandbox_moved /* objectMovedOp */

View File

@ -673,7 +673,6 @@ const XPCWrappedNativeJSClass XPC_WN_NoHelper_JSClass = {
{ {
nullptr, // outerObject nullptr, // outerObject
nullptr, // innerObject nullptr, // innerObject
nullptr, // iteratorObject
true, // isWrappedNative true, // isWrappedNative
nullptr, // weakmapKeyDelegateOp nullptr, // weakmapKeyDelegateOp
WrappedNativeObjectMoved WrappedNativeObjectMoved
@ -1389,7 +1388,6 @@ XPC_WN_ModsAllowed_Proto_Resolve(JSContext *cx, HandleObject obj, HandleId id)
{ \ { \
nullptr, /* outerObject */ \ nullptr, /* outerObject */ \
nullptr, /* innerObject */ \ nullptr, /* innerObject */ \
nullptr, /* iteratorObject */ \
false, /* isWrappedNative */ \ false, /* isWrappedNative */ \
nullptr, /* weakmapKeyDelegateOp */ \ nullptr, /* weakmapKeyDelegateOp */ \
XPC_WN_Shared_Proto_ObjectMoved \ XPC_WN_Shared_Proto_ObjectMoved \
@ -1646,7 +1644,6 @@ const js::Class XPC_WN_Tearoff_JSClass = {
{ {
nullptr, // outerObject nullptr, // outerObject
nullptr, // innerObject nullptr, // innerObject
nullptr, // iteratorObject
false, // isWrappedNative false, // isWrappedNative
nullptr, // weakmapKeyDelegateOp nullptr, // weakmapKeyDelegateOp
XPC_WN_TearOff_ObjectMoved XPC_WN_TearOff_ObjectMoved