mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out 2 changesets (bug 952873) for build bustage on a CLOSED TREE
Backed out changeset 92dfed2592ae (bug 952873) Backed out changeset 1ae58fcd61a9 (bug 952873)
This commit is contained in:
parent
8cfbeafe04
commit
cf19b21c97
@ -27,7 +27,6 @@ using mozilla::IsNaN;
|
||||
using mozilla::Move;
|
||||
using mozilla::ArrayLength;
|
||||
using JS::DoubleNaNValue;
|
||||
using JS::ForOfIterator;
|
||||
|
||||
|
||||
/*** OrderedHashTable ****************************************************************************/
|
||||
|
@ -4807,63 +4807,6 @@ struct AsmJSCacheOps
|
||||
extern JS_PUBLIC_API(void)
|
||||
SetAsmJSCacheOps(JSRuntime *rt, const AsmJSCacheOps *callbacks);
|
||||
|
||||
/*
|
||||
* Convenience class for imitating a JS level for-of loop. Typical usage:
|
||||
*
|
||||
* ForOfIterator it(cx);
|
||||
* if (!it.init(iterable))
|
||||
* return false;
|
||||
* RootedValue val(cx);
|
||||
* while (true) {
|
||||
* bool done;
|
||||
* if (!it.next(&val, &done))
|
||||
* return false;
|
||||
* if (done)
|
||||
* break;
|
||||
* if (!DoStuff(cx, val))
|
||||
* return false;
|
||||
* }
|
||||
*/
|
||||
class MOZ_STACK_CLASS JS_PUBLIC_API(ForOfIterator) {
|
||||
protected:
|
||||
JSContext *cx_;
|
||||
JS::RootedObject iterator;
|
||||
|
||||
ForOfIterator(const ForOfIterator &) MOZ_DELETE;
|
||||
ForOfIterator &operator=(const ForOfIterator &) MOZ_DELETE;
|
||||
|
||||
public:
|
||||
ForOfIterator(JSContext *cx) : cx_(cx), iterator(cx) { }
|
||||
|
||||
enum NonIterableBehavior {
|
||||
ThrowOnNonIterable,
|
||||
AllowNonIterable
|
||||
};
|
||||
|
||||
/*
|
||||
* Initialize the iterator. If AllowNonIterable is passed then if iterable
|
||||
* does not have a callable @@iterator init() will just return true instead
|
||||
* of throwing. Callers should then check valueIsIterable() before
|
||||
* continuing with the iteration.
|
||||
*/
|
||||
JS_PUBLIC_API(bool) init(JS::HandleValue iterable,
|
||||
NonIterableBehavior nonIterableBehavior = ThrowOnNonIterable);
|
||||
|
||||
/*
|
||||
* Get the next value from the iterator. If false *done is true
|
||||
* after this call, do not examine val.
|
||||
*/
|
||||
JS_PUBLIC_API(bool) next(JS::MutableHandleValue val, bool *done);
|
||||
|
||||
/*
|
||||
* If initialized with throwOnNonCallable = false, check whether
|
||||
* the value is iterable.
|
||||
*/
|
||||
bool valueIsIterable() const {
|
||||
return iterator;
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace JS */
|
||||
|
||||
#endif /* jsapi_h */
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "jsarray.h"
|
||||
#include "jsatom.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsgc.h"
|
||||
#include "jsobj.h"
|
||||
#include "jsopcode.h"
|
||||
@ -40,7 +39,6 @@
|
||||
|
||||
using namespace js;
|
||||
using namespace js::gc;
|
||||
using JS::ForOfIterator;
|
||||
|
||||
using mozilla::ArrayLength;
|
||||
#ifdef JS_MORE_DETERMINISTIC
|
||||
@ -1270,10 +1268,9 @@ const Class StopIterationObject::class_ = {
|
||||
nullptr /* construct */
|
||||
};
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
ForOfIterator::init(HandleValue iterable, NonIterableBehavior nonIterableBehavior)
|
||||
bool
|
||||
ForOfIterator::init(HandleValue iterable)
|
||||
{
|
||||
JSContext *cx = cx_;
|
||||
RootedObject iterableObj(cx, ToObject(cx, iterable));
|
||||
if (!iterableObj)
|
||||
return false;
|
||||
@ -1288,13 +1285,10 @@ ForOfIterator::init(HandleValue iterable, NonIterableBehavior nonIterableBehavio
|
||||
if (!JSObject::getProperty(cx, iterableObj, iterableObj, cx->names().std_iterator, &callee))
|
||||
return false;
|
||||
|
||||
// Throw if obj[@@iterator] isn't callable if we were asked to do so.
|
||||
// js::Invoke is about to check for this kind of error anyway, but it would
|
||||
// throw an inscrutable error message about |method| rather than this nice
|
||||
// one about |obj|.
|
||||
// Throw if obj[@@iterator] isn't callable. js::Invoke is about to check
|
||||
// for this kind of error anyway, but it would throw an inscrutable
|
||||
// error message about |method| rather than this nice one about |obj|.
|
||||
if (!callee.isObject() || !callee.toObject().isCallable()) {
|
||||
if (nonIterableBehavior == AllowNonIterable)
|
||||
return true;
|
||||
char *bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, iterable, NullPtr());
|
||||
if (!bytes)
|
||||
return false;
|
||||
@ -1314,12 +1308,11 @@ ForOfIterator::init(HandleValue iterable, NonIterableBehavior nonIterableBehavio
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
bool
|
||||
ForOfIterator::next(MutableHandleValue vp, bool *done)
|
||||
{
|
||||
JS_ASSERT(iterator);
|
||||
|
||||
JSContext *cx = cx_;
|
||||
RootedValue method(cx);
|
||||
if (!JSObject::getProperty(cx, iterator, iterator, cx->names().next, &method))
|
||||
return false;
|
||||
|
@ -218,6 +218,40 @@ js_ThrowStopIteration(JSContext *cx);
|
||||
|
||||
namespace js {
|
||||
|
||||
/*
|
||||
* Convenience class for imitating a JS level for-of loop. Typical usage:
|
||||
*
|
||||
* ForOfIterator it(cx, iterable);
|
||||
* while (it.next()) {
|
||||
* if (!DoStuff(cx, it.value()))
|
||||
* return false;
|
||||
* }
|
||||
* if (!it.close())
|
||||
* return false;
|
||||
*
|
||||
* The final it.close() check is needed in order to check for cases where
|
||||
* any of the iterator operations fail.
|
||||
*
|
||||
* it.close() may be skipped only if something in the body of the loop fails
|
||||
* and the failure is allowed to propagate on cx, as in this example if DoStuff
|
||||
* fails. In that case, ForOfIterator's destructor does all necessary cleanup.
|
||||
*/
|
||||
class ForOfIterator
|
||||
{
|
||||
private:
|
||||
JSContext *cx;
|
||||
RootedObject iterator;
|
||||
|
||||
ForOfIterator(const ForOfIterator &) MOZ_DELETE;
|
||||
ForOfIterator &operator=(const ForOfIterator &) MOZ_DELETE;
|
||||
|
||||
public:
|
||||
ForOfIterator(JSContext *cx) : cx(cx), iterator(cx) { }
|
||||
|
||||
bool init(HandleValue iterable);
|
||||
bool next(MutableHandleValue val, bool *done);
|
||||
};
|
||||
|
||||
/*
|
||||
* Create an object of the form { value: VALUE, done: DONE }.
|
||||
* ES6 draft from 2013-09-05, section 25.4.3.4.
|
||||
|
Loading…
Reference in New Issue
Block a user