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(
nullptr, /* outerObject */
js::proxy_innerObject,
nullptr, /* iteratorObject */
false, /* isWrappedNative */
nsOuterWindowProxy::ObjectMoved
));

View File

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

View File

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

View File

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

View File

@ -21,7 +21,6 @@ const js::Class OuterWrapperClass =
PROXY_MAKE_EXT(
nullptr, /* outerObject */
js::proxy_innerObject,
nullptr, /* iteratorObject */
false, /* isWrappedNative */
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,
JS_NULL_CLASS_SPEC,
{
nullptr,
nullptr,
nullptr,
false,

View File

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

View File

@ -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<PropertyIteratorObject>() || obj->is<LegacyGeneratorObject>()) {
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 {

View File

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

View File

@ -201,12 +201,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),
@ -222,12 +216,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_ = {

View File

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

View File

@ -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 */

View File

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