Bug 1489242 - Add {} to example code in comments. r=jorendorff

I didn't change some similar comments that were pseudo code or JS code.

Differential Revision: https://phabricator.services.mozilla.com/D7590

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan de Mooij 2018-10-03 14:41:29 +00:00
parent fbee84608f
commit 0811112d77
13 changed files with 52 additions and 26 deletions

View File

@ -46,8 +46,9 @@ CallMethodIfWrapped(JSContext* cx, IsAcceptableThis test, NativeImpl impl, const
// static bool
// IsAnswerObject(const Value& v)
// {
// if (!v.isObject())
// if (!v.isObject()) {
// return false;
// }
// return JS_GetClass(&v.toObject()) == &AnswerClass;
// }
//

View File

@ -102,10 +102,12 @@ IsArray(JSContext* cx, HandleObject obj, IsArrayAnswer* answer);
* Typical usage:
*
* ObjectOpResult result;
* if (!DefineProperty(cx, obj, id, ..., result))
* if (!DefineProperty(cx, obj, id, ..., result)) {
* return false;
* if (!result)
* }
* if (!result) {
* return result.reportError(cx, obj, id);
* }
*
* Users don't have to call `result.report()`; another possible ending is:
*
@ -161,8 +163,9 @@ class ObjectOpResult
*
* Always returns true, as a convenience. Typical usage will be:
*
* if (funny condition)
* if (funny condition) {
* return result.fail(JSMSG_CANT_DO_THE_THINGS);
* }
*
* The true return value indicates that no exception is pending, and it
* would be OK to ignore the failure and continue.

View File

@ -97,8 +97,9 @@ namespace dbg {
// Builder::Object& result)
// {
// JSObject* eventObject = ... obtain debuggee event object somehow ...;
// if (!eventObject)
// if (!eventObject) {
// return false;
// }
// result = builder.newObject(cx);
// return result &&
// result.defineProperty(cx, "eventType", SafelyFetchType(eventObject)) &&

View File

@ -975,8 +975,9 @@ class PreComputedEdgeRange : public EdgeRange {
// {
// mozilla::Maybe<JS::AutoCheckCannotGC> maybeNoGC;
// JS::ubi::RootList rootList(cx, maybeNoGC);
// if (!rootList.init())
// if (!rootList.init()) {
// return false;
// }
//
// // The AutoCheckCannotGC is guaranteed to exist if init returned true.
// MOZ_ASSERT(maybeNoGC.isSome());

View File

@ -137,8 +137,9 @@ using GetAvailable = const char* (*)(int32_t localeIndex);
* returns the corresponding locale as a borrowed string. For example:
*
* RootedValue v(cx);
* if (!GetAvailableLocales(cx, unum_countAvailable, unum_getAvailable, &v))
* if (!GetAvailableLocales(cx, unum_countAvailable, unum_getAvailable, &v)) {
* return false;
* }
*/
extern bool
GetAvailableLocales(JSContext* cx, CountAvailable countAvailable, GetAvailable getAvailable,

View File

@ -24,10 +24,12 @@ template <class ParseHandler> class PerHandlerParser;
//
// Usage:
// pn = parser->statement();
// if (!pn)
// if (!pn) {
// return false;
// if (!FoldConstants(cx, &pn, parser))
// }
// if (!FoldConstants(cx, &pn, parser)) {
// return false;
// }
extern MOZ_MUST_USE bool
FoldConstants(JSContext* cx, ParseNode** pnp, PerHandlerParser<FullParseHandler>* parser);

View File

@ -21,15 +21,18 @@ namespace frontend {
// Example:
//
// JumpList brList;
// if (!emitJump(JSOP_IFEQ, &brList))
// if (!emitJump(JSOP_IFEQ, &brList)) {
// return false;
// }
// ...
// JumpTarget label;
// if (!emitJumpTarget(&label))
// if (!emitJumpTarget(&label)) {
// return false;
// }
// ...
// if (!emitJump(JSOP_GOTO, &brList))
// if (!emitJump(JSOP_GOTO, &brList)) {
// return false;
// }
// ...
// patchJumpsToTarget(brList, label);
//

View File

@ -805,19 +805,22 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
* PossibleError possibleError(*this);
* possibleError.setPendingExpressionErrorAt(pos, JSMSG_BAD_PROP_ID);
* // A JSMSG_BAD_PROP_ID ParseError is reported, returns false.
* if (!possibleError.checkForExpressionError())
* if (!possibleError.checkForExpressionError()) {
* return false; // we reach this point with a pending exception
* }
*
* PossibleError possibleError(*this);
* possibleError.setPendingExpressionErrorAt(pos, JSMSG_BAD_PROP_ID);
* // Returns true, no error is reported.
* if (!possibleError.checkForDestructuringError())
* if (!possibleError.checkForDestructuringError()) {
* return false; // not reached, no pending exception
* }
*
* PossibleError possibleError(*this);
* // Returns true, no error is reported.
* if (!possibleError.checkForExpressionError())
* if (!possibleError.checkForExpressionError()) {
* return false; // not reached, no pending exception
* }
*/
class MOZ_STACK_CLASS PossibleError
{

View File

@ -289,11 +289,13 @@ class ZoneCellIter<TenuredCell> {
// Iterator over the cells in a Zone, where the GC type (JSString, JSObject) is
// known, for a single AllocKind. Example usages:
//
// for (auto obj = zone->cellIter<JSObject>(AllocKind::OBJECT0); !obj.done(); obj.next())
// for (auto obj = zone->cellIter<JSObject>(AllocKind::OBJECT0); !obj.done(); obj.next()) {
// ...
// }
//
// for (auto script = zone->cellIter<JSScript>(); !script.done(); script.next())
// for (auto script = zone->cellIter<JSScript>(); !script.done(); script.next()) {
// f(script->code());
// }
//
// As this code demonstrates, you can use 'script' as if it were a JSScript*.
// Its actual type is ZoneCellIter<JSScript>, but for most purposes it will

View File

@ -33,8 +33,9 @@ namespace jit {
// // Call out to the VM
// // Other effectful operations like TypeScript::Monitor
//
// if (stub.invalid())
// if (stub.invalid()) {
// return true;
// }
//
// // First use of stub after VM call.
//

View File

@ -2827,8 +2827,9 @@ MacroAssembler::alignJitStackBasedOnNArgs(Register nargs)
// aligned if |nargs| is odd.
// if (nargs % 2 == 0) {
// if (sp % JitStackAlignment == 0)
// if (sp % JitStackAlignment == 0) {
// sp -= sizeof(Value);
// }
// MOZ_ASSERT(sp % JitStackAlignment == JitStackAlignment - sizeof(Value));
// } else {
// sp = sp & ~(JitStackAlignment - 1);

View File

@ -1271,8 +1271,9 @@ IonTrackedOptimizationsTypeInfo::ForEachOpAdapter::readType(const IonTrackedType
// void* addr = JS_FUNC_TO_DATA_PTR(void*, fun->native());
// uintptr_t offset;
// Dl_info info;
// if (dladdr(addr, &info) != 0)
// if (dladdr(addr, &info) != 0) {
// offset = uintptr_t(addr) - uintptr_t(info.dli_fbase);
// }
//
char locationBuf[20];
if (!name) {

View File

@ -2526,8 +2526,9 @@ JS_DeleteElement(JSContext* cx, JS::HandleObject obj, uint32_t index);
* This function is roughly equivalent to:
*
* var result = [];
* for (key in obj)
* for (key in obj) {
* result.push(key);
* }
* return result;
*
* This is the closest thing we currently have to the ES6 [[Enumerate]]
@ -3776,8 +3777,9 @@ JS_PutEscapedString(JSContext* cx, char* buffer, size_t size, JSString* str, cha
*
* // in a fallible context
* JSFlatString* fstr = JS_FlattenString(cx, str);
* if (!fstr)
* if (!fstr) {
* return false;
* }
* MOZ_ASSERT(fstr == JS_ASSERT_STRING_IS_FLAT(str));
*
* // in an infallible context, for the same 'str'
@ -4787,17 +4789,21 @@ DeserializeWasmModule(PRFileDesc* bytecode, JS::UniqueChars filename, unsigned l
* Convenience class for imitating a JS level for-of loop. Typical usage:
*
* ForOfIterator it(cx);
* if (!it.init(iterable))
* if (!it.init(iterable)) {
* return false;
* }
* RootedValue val(cx);
* while (true) {
* bool done;
* if (!it.next(&val, &done))
* if (!it.next(&val, &done)) {
* return false;
* if (done)
* }
* if (done) {
* break;
* if (!DoStuff(cx, val))
* }
* if (!DoStuff(cx, val)) {
* return false;
* }
* }
*/
class MOZ_STACK_CLASS JS_PUBLIC_API(ForOfIterator) {