author | Nicholas Nethercote <nnethercote@mozilla.com> |
Tue, 06 Aug 2013 23:59:54 -0700 | |
changeset 141746 | ade325617a7322f9869ce67b359255c542c74587 |
parent 141745 | 56912957f3e96b7a549202dab4e96cd321da3daa |
child 141747 | ab9642207875d08e6351bfe0edaabc165095d4ec |
push id | 25070 |
push user | cbook@mozilla.com |
push date | Thu, 08 Aug 2013 11:13:48 +0000 |
treeherder | mozilla-central@9252e17660dd [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | luke, bz |
bugs | 902332 |
milestone | 26.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/caps/src/nsScriptSecurityManager.cpp +++ b/caps/src/nsScriptSecurityManager.cpp @@ -427,44 +427,44 @@ JSBool nsScriptSecurityManager::ContentSecurityPolicyPermitsJSAction(JSContext *cx) { // Get the security manager nsScriptSecurityManager *ssm = nsScriptSecurityManager::GetScriptSecurityManager(); NS_ASSERTION(ssm, "Failed to get security manager service"); if (!ssm) - return JS_FALSE; + return false; nsresult rv; nsIPrincipal* subjectPrincipal = ssm->GetSubjectPrincipal(cx, &rv); NS_ASSERTION(NS_SUCCEEDED(rv), "CSP: Failed to get nsIPrincipal from js context"); if (NS_FAILED(rv)) - return JS_FALSE; // Not just absence of principal, but failure. + return false; // Not just absence of principal, but failure. if (!subjectPrincipal) - return JS_TRUE; + return true; nsCOMPtr<nsIContentSecurityPolicy> csp; rv = subjectPrincipal->GetCsp(getter_AddRefs(csp)); NS_ASSERTION(NS_SUCCEEDED(rv), "CSP: Failed to get CSP from principal."); // don't do anything unless there's a CSP if (!csp) - return JS_TRUE; + return true; bool evalOK = true; bool reportViolation = false; rv = csp->GetAllowsEval(&reportViolation, &evalOK); if (NS_FAILED(rv)) { NS_WARNING("CSP: failed to get allowsEval"); - return JS_TRUE; // fail open to not break sites. + return true; // fail open to not break sites. } if (reportViolation) { nsAutoString fileName; unsigned lineNum = 0; NS_NAMED_LITERAL_STRING(scriptSample, "call to eval() or related function blocked by CSP"); JSScript *script; @@ -489,17 +489,17 @@ nsScriptSecurityManager::CheckObjectAcce JS::MutableHandle<JS::Value> vp) { // Get the security manager nsScriptSecurityManager *ssm = nsScriptSecurityManager::GetScriptSecurityManager(); NS_WARN_IF_FALSE(ssm, "Failed to get security manager service"); if (!ssm) - return JS_FALSE; + return false; // Get the object being accessed. We protect these cases: // 1. The Function.prototype.caller property's value, which might lead // an attacker up a call-stack to a function or another object from // a different trust domain. // 2. A user-defined getter or setter function accessible on another // trust domain's window or document object. // vp can be a primitive, in that case, we use obj as the target @@ -510,19 +510,19 @@ nsScriptSecurityManager::CheckObjectAcce // Pass the parent object's class name, as we have no class-info for it. nsresult rv = ssm->CheckPropertyAccess(cx, target, js::GetObjectClass(obj)->name, id, (mode & JSACC_WRITE) ? (int32_t)nsIXPCSecurityManager::ACCESS_SET_PROPERTY : (int32_t)nsIXPCSecurityManager::ACCESS_GET_PROPERTY); if (NS_FAILED(rv)) - return JS_FALSE; // Security check failed (XXX was an error reported?) - - return JS_TRUE; + return false; // Security check failed (XXX was an error reported?) + + return true; } NS_IMETHODIMP nsScriptSecurityManager::CheckPropertyAccess(JSContext* cx, JSObject* aJSObject, const char* aClassName, jsid aProperty, uint32_t aAction)
--- a/content/xbl/src/nsXBLDocumentInfo.cpp +++ b/content/xbl/src/nsXBLDocumentInfo.cpp @@ -92,29 +92,29 @@ protected: JSBool nsXBLDocGlobalObject::doCheckAccess(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, uint32_t accessType) { nsIScriptSecurityManager *ssm = nsContentUtils::GetSecurityManager(); if (!ssm) { ::JS_ReportError(cx, "Unable to verify access to a global object property."); - return JS_FALSE; + return false; } // Make sure to actually operate on our object, and not some object further // down on the proto chain. JS::Rooted<JSObject*> base(cx, obj); while (JS_GetClass(base) != &nsXBLDocGlobalObject::gSharedGlobalClass) { if (!::JS_GetPrototype(cx, base, &base)) { - return JS_FALSE; + return false; } if (!base) { ::JS_ReportError(cx, "Invalid access to a global object property."); - return JS_FALSE; + return false; } } nsresult rv = ssm->CheckPropertyAccess(cx, base, JS_GetClass(base)->name, id, accessType); return NS_SUCCEEDED(rv); } @@ -161,17 +161,17 @@ nsXBLDocGlobalObject_finalize(JSFreeOp * // The addref was part of JSObject construction NS_RELEASE(nativeThis); } static JSBool nsXBLDocGlobalObject_resolve(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id) { - JSBool did_resolve = JS_FALSE; + JSBool did_resolve = false; return JS_ResolveStandardClass(cx, obj, id, &did_resolve); } JSClass nsXBLDocGlobalObject::gSharedGlobalClass = { "nsXBLPrototypeScript compilation scope", JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS | JSCLASS_IMPLEMENTS_BARRIERS | JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(0),
--- a/content/xbl/src/nsXBLProtoImplMethod.cpp +++ b/content/xbl/src/nsXBLProtoImplMethod.cpp @@ -337,17 +337,17 @@ nsXBLProtoImplAnonymousMethod::Execute(n return NS_ERROR_OUT_OF_MEMORY; // Now call the method // Check whether it's OK to call the method. rv = nsContentUtils::GetSecurityManager()->CheckFunctionAccess(cx, method, thisObject); - JSBool ok = JS_TRUE; + JSBool ok = true; if (NS_SUCCEEDED(rv)) { JS::Rooted<JS::Value> retval(cx); ok = ::JS_CallFunctionValue(cx, thisObject, OBJECT_TO_JSVAL(method), 0 /* argc */, nullptr /* argv */, retval.address()); } if (!ok) { // If a constructor or destructor threw an exception, it doesn't stop
--- a/content/xul/document/src/nsXULPrototypeDocument.cpp +++ b/content/xul/document/src/nsXULPrototypeDocument.cpp @@ -96,17 +96,17 @@ nsXULPDGlobalObject_finalize(JSFreeOp *f // The addref was part of JSObject construction nsContentUtils::DeferredFinalize(nativeThis); } JSBool nsXULPDGlobalObject_resolve(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id) { - JSBool did_resolve = JS_FALSE; + JSBool did_resolve = false; return JS_ResolveStandardClass(cx, obj, id, &did_resolve); } JSClass nsXULPDGlobalObject::gSharedGlobalClass = { "nsXULPrototypeScript compilation scope", JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS |
--- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -2357,20 +2357,20 @@ nsWindowSH::GlobalScopePolluterGetProper sSecMan->CheckPropertyAccess(cx, ::JS_GetGlobalForObject(cx, obj), "Window", id, nsIXPCSecurityManager::ACCESS_GET_PROPERTY); if (NS_FAILED(rv)) { // The security check failed. The security manager set a JS // exception for us. - return JS_FALSE; + return false; } - return JS_TRUE; + return true; } // Gets a subframe. static JSBool ChildWindowGetter(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) { MOZ_ASSERT(JSID_IS_STRING(id)); @@ -2408,17 +2408,17 @@ GetDocument(JSObject *obj) // static JSBool nsWindowSH::GlobalScopePolluterNewResolve(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, unsigned flags, JS::MutableHandle<JSObject*> objp) { if (!JSID_IS_STRING(id)) { // Nothing to do if we're resolving a non-string property. - return JS_TRUE; + return true; } // Crash reports from the wild seem to get here during shutdown when there's // no more XPConnect singleton. nsIXPConnect *xpc = XPConnect(); NS_ENSURE_TRUE(xpc, true); // Grab the DOM window. @@ -2445,26 +2445,26 @@ nsWindowSH::GlobalScopePolluterNewResolv objp.set(obj); return true; } } JS::Rooted<JSObject*> proto(cx); if (!::JS_GetPrototype(cx, obj, &proto)) { - return JS_FALSE; + return false; } JSBool hasProp; if (!proto || !::JS_HasPropertyById(cx, proto, id, &hasProp) || hasProp) { // No prototype, or the property exists on the prototype. Do // nothing. - return JS_TRUE; + return true; } // // The rest of this function is for HTML documents only. // nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(win->GetExtantDoc()); if (!htmlDoc) @@ -2484,63 +2484,63 @@ nsWindowSH::GlobalScopePolluterNewResolv result = document->ResolveName(str, &cache); } if (result) { JS::Rooted<JS::Value> v(cx); nsCOMPtr<nsIXPConnectJSObjectHolder> holder; nsresult rv = WrapNative(cx, obj, result, cache, true, v.address(), getter_AddRefs(holder)); - NS_ENSURE_SUCCESS(rv, JS_FALSE); + NS_ENSURE_SUCCESS(rv, false); if (!JS_WrapValue(cx, v.address()) || !JS_DefinePropertyById(cx, obj, id, v, JS_PropertyStub, JS_StrictPropertyStub, 0)) { - return JS_FALSE; + return false; } objp.set(obj); } - return JS_TRUE; + return true; } // static JSBool nsWindowSH::InvalidateGlobalScopePolluter(JSContext *cx, JS::Handle<JSObject*> aObj) { JS::Rooted<JSObject*> proto(cx); JS::Rooted<JSObject*> obj(cx, aObj); for (;;) { if (!::JS_GetPrototype(cx, obj, &proto)) { - return JS_FALSE; + return false; } if (!proto) { break; } if (JS_GetClass(proto) == &sGlobalScopePolluterClass) { JS::Rooted<JSObject*> proto_proto(cx); if (!::JS_GetPrototype(cx, proto, &proto_proto)) { - return JS_FALSE; + return false; } // Pull the global scope polluter out of the prototype chain so // that it can be freed. ::JS_SplicePrototype(cx, obj, proto_proto); break; } obj = proto; } - return JS_TRUE; + return true; } // static nsresult nsWindowSH::InstallGlobalScopePolluter(JSContext *cx, JS::Handle<JSObject*> obj) { JS::Rooted<JSObject*> gsp(cx, ::JS_NewObjectWithUniqueType(cx, &sGlobalScopePolluterClass, nullptr, obj)); if (!gsp) { @@ -3013,17 +3013,17 @@ nsDOMConstructor::Construct(nsIXPConnect bool *_retval) { MOZ_ASSERT(obj); const nsGlobalNameStruct *name_struct = GetNameStruct(); NS_ENSURE_TRUE(name_struct, NS_ERROR_FAILURE); if (!IsConstructable(name_struct)) { - // ignore return value, we return JS_FALSE anyway + // ignore return value, we return false anyway return NS_ERROR_DOM_NOT_SUPPORTED_ERR; } return BaseStubConstructor(mWeakOwner, name_struct, cx, obj, args); } nsresult nsDOMConstructor::HasInstance(nsIXPConnectWrappedNative *wrapper, @@ -3094,17 +3094,17 @@ nsDOMConstructor::HasInstance(nsIXPConne // Doesn't have DOM interfaces. return NS_OK; } const nsGlobalNameStruct *class_name_struct = GetNameStruct(); NS_ENSURE_TRUE(class_name_struct, NS_ERROR_FAILURE); if (name_struct == class_name_struct) { - *bp = JS_TRUE; + *bp = true; return NS_OK; } nsScriptNameSpaceManager *nameSpaceManager = nsJSRuntime::GetNameSpaceManager(); NS_ASSERTION(nameSpaceManager, "Can't get namespace manager?"); @@ -3130,17 +3130,17 @@ nsDOMConstructor::HasInstance(nsIXPConne sClassInfoData[alias_struct->mDOMClassInfoID].mProtoChainInterface; } else if (alias_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) { class_iid = alias_struct->mData->mProtoChainInterface; } else { NS_ERROR("Expected eTypeClassConstructor or eTypeExternalClassInfo."); return NS_ERROR_UNEXPECTED; } } else { - *bp = JS_FALSE; + *bp = false; return NS_OK; } if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) { name_struct = nameSpaceManager->GetConstructorProto(name_struct); if (!name_struct) { NS_ERROR("Couldn't get constructor prototype."); @@ -3167,17 +3167,17 @@ nsDOMConstructor::HasInstance(nsIXPConne return NS_ERROR_UNEXPECTED; } nsCOMPtr<nsIInterfaceInfo> if_info; uint32_t count = 0; const nsIID* class_interface; while ((class_interface = ci_data->mInterfaces[count++])) { if (class_iid->Equals(*class_interface)) { - *bp = JS_TRUE; + *bp = true; return NS_OK; } iim->GetInfoForIID(class_interface, getter_AddRefs(if_info)); if (!if_info) { NS_ERROR("nsDOMConstructor::HasInstance can't get interface info."); return NS_ERROR_UNEXPECTED; @@ -3844,20 +3844,20 @@ LocationSetterGuts(JSContext *cx, JSObje template<class Interface> static JSBool LocationSetter(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JSBool strict, JS::MutableHandle<JS::Value> vp) { nsresult rv = LocationSetterGuts<Interface>(cx, obj, vp.address()); if (NS_FAILED(rv)) { xpc::Throw(cx, rv); - return JS_FALSE; + return false; } - return JS_TRUE; + return true; } static JSBool LocationSetterUnwrapper(JSContext *cx, JS::Handle<JSObject*> obj_, JS::Handle<jsid> id, JSBool strict, JS::MutableHandle<JS::Value> vp) { JS::RootedObject obj(cx, obj_); @@ -3977,18 +3977,18 @@ nsWindowSH::NewResolve(nsIXPConnectWrapp nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper); MOZ_ASSERT(win->IsInnerWindow()); nsIScriptContext *my_context = win->GetContextInternal(); // Don't resolve standard classes on XrayWrappers, only resolve them if we're // resolving on the real global object. if (!xpc::WrapperFactory::IsXrayWrapper(obj)) { - JSBool did_resolve = JS_FALSE; - JSBool ok = JS_TRUE; + JSBool did_resolve = false; + JSBool ok = true; JS::Rooted<JS::Value> exn(cx, JSVAL_VOID); { // Resolve standard classes on my_context's JSContext (or on cx, // if we don't have a my_context yet), in case the two contexts // have different origins. We want lazy standard class // initialization to behave as if it were done eagerly, on each // window's own context (not on some other window-caller's @@ -4012,17 +4012,17 @@ nsWindowSH::NewResolve(nsIXPConnectWrapp // JS_SetPendingException is important in the case that my_cx == cx. JS_ClearPendingException(my_cx); } } if (!ok) { JS_SetPendingException(cx, exn); - *_retval = JS_FALSE; + *_retval = false; return NS_OK; } if (did_resolve) { *objp = obj; return NS_OK; } } @@ -4210,26 +4210,26 @@ nsWindowSH::NewResolve(nsIXPConnectWrapp // defined on our prototype chain. This way we can access this // expando w/o ever getting back into XPConnect. if (flags & JSRESOLVE_ASSIGNING) { JS::Rooted<JSObject*> realObj(cx, wrapper->GetJSObject()); if (obj == realObj) { JS::Rooted<JSObject*> proto(cx); if (!js::GetObjectProto(cx, obj, &proto)) { - *_retval = JS_FALSE; + *_retval = false; return NS_OK; } if (proto) { JS::Rooted<JSObject*> pobj(cx); JS::Rooted<JS::Value> val(cx); if (!::JS_LookupPropertyWithFlagsById(cx, proto, id, flags, pobj.address(), &val)) { - *_retval = JS_FALSE; + *_retval = false; return NS_OK; } if (pobj) { // A property was found on the prototype chain. *objp = pobj; return NS_OK; @@ -4245,17 +4245,17 @@ nsWindowSH::NewResolve(nsIXPConnectWrapp // // Since we always create the undeclared property here, shortcutting the // normal process, we go out of our way to tell the JS engine to report // strict warnings/errors using js::ReportIfUndeclaredVarAssignment. JS::Rooted<JSString*> str(cx, JSID_TO_STRING(id)); if (!js::ReportIfUndeclaredVarAssignment(cx, str) || !::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, JS_PropertyStub, JS_StrictPropertyStub, JSPROP_ENUMERATE)) { - *_retval = JS_FALSE; + *_retval = false; return NS_OK; } *objp = obj; } } @@ -4660,45 +4660,45 @@ nsHTMLDocumentSH::GetDocumentAllNodeList // ... and store it in our reserved slot. JS_SetReservedSlot(obj, 0, collection); } if (NS_FAILED(rv)) { xpc::Throw(cx, NS_ERROR_FAILURE); - return JS_FALSE; + return false; } return *nodeList != nullptr; } JSBool nsHTMLDocumentSH::DocumentAllGetProperty(JSContext *cx, JS::Handle<JSObject*> obj_, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) { JS::Rooted<JSObject*> obj(cx, obj_); // document.all.item and .namedItem get their value in the // newResolve hook, so nothing to do for those properties here. And // we need to return early to prevent <div id="item"> from shadowing // document.all.item(), etc. if (nsDOMClassInfo::sItem_id == id || nsDOMClassInfo::sNamedItem_id == id) { - return JS_TRUE; + return true; } JS::Rooted<JSObject*> proto(cx); while (js::GetObjectJSClass(obj) != &sHTMLDocumentAllClass) { if (!js::GetObjectProto(cx, obj, &proto)) { - return JS_FALSE; + return false; } if (!proto) { NS_ERROR("The JS engine lies!"); - return JS_TRUE; + return true; } obj = proto; } nsHTMLDocument *doc = GetDocument(obj); nsISupports *result; nsWrapperCache *cache; @@ -4707,70 +4707,70 @@ nsHTMLDocumentSH::DocumentAllGetProperty if (JSID_IS_STRING(id)) { if (nsDOMClassInfo::sLength_id == id) { // Map document.all.length to the length of the collection // document.getElementsByTagName("*"), and make sure <div // id="length"> doesn't shadow document.all.length. nsRefPtr<nsContentList> nodeList; if (!GetDocumentAllNodeList(cx, obj, doc, getter_AddRefs(nodeList))) { - return JS_FALSE; + return false; } uint32_t length; rv = nodeList->GetLength(&length); if (NS_FAILED(rv)) { xpc::Throw(cx, rv); - return JS_FALSE; + return false; } vp.set(INT_TO_JSVAL(length)); - return JS_TRUE; + return true; } // For all other strings, look for an element by id or name. nsDependentJSString str(id); result = doc->GetDocumentAllResult(str, &cache, &rv); if (NS_FAILED(rv)) { xpc::Throw(cx, rv); - return JS_FALSE; + return false; } } else if (JSID_IS_INT(id) && JSID_TO_INT(id) >= 0) { // Map document.all[n] (where n is a number) to the n:th item in // the document.all node list. nsRefPtr<nsContentList> nodeList; if (!GetDocumentAllNodeList(cx, obj, doc, getter_AddRefs(nodeList))) { - return JS_FALSE; + return false; } nsIContent *node = nodeList->Item(JSID_TO_INT(id)); result = node; cache = node; } else { result = nullptr; } if (result) { rv = WrapNative(cx, JS::CurrentGlobalOrNull(cx), result, cache, true, vp.address()); if (NS_FAILED(rv)) { xpc::Throw(cx, rv); - return JS_FALSE; + return false; } } else { vp.setUndefined(); } - return JS_TRUE; + return true; } JSBool nsHTMLDocumentSH::DocumentAllNewResolve(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, unsigned flags, JS::MutableHandle<JSObject*> objp) { JS::RootedValue v(cx); @@ -4789,21 +4789,21 @@ nsHTMLDocumentSH::DocumentAllNewResolve( // document.all.length. Any jsval other than undefined would do // here, all we need is to get into the code below that defines // this propery on obj, the rest happens in // DocumentAllGetProperty(). v = JSVAL_ONE; } else { if (!DocumentAllGetProperty(cx, obj, id, &v)) { - return JS_FALSE; + return false; } } - JSBool ok = JS_TRUE; + JSBool ok = true; if (v.get() != JSVAL_VOID) { ok = ::JS_DefinePropertyById(cx, obj, id, v, nullptr, nullptr, 0); objp.set(obj); } return ok; }
--- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -6761,17 +6761,17 @@ PostMessageWriteStructuredClone(JSContex const JSStructuredCloneCallbacks* runtimeCallbacks = js::GetContextStructuredCloneCallbacks(cx); if (runtimeCallbacks) { return runtimeCallbacks->write(cx, writer, obj, nullptr); } - return JS_FALSE; + return false; } JSStructuredCloneCallbacks kPostMessageCallbacks = { PostMessageReadStructuredClone, PostMessageWriteStructuredClone, nullptr };
--- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -699,17 +699,17 @@ nsJSContext::DOMOperationCallback(JSCont { nsresult rv; // Get the native context nsJSContext *ctx = static_cast<nsJSContext *>(::JS_GetContextPrivate(cx)); if (!ctx) { // Can happen; see bug 355811 - return JS_TRUE; + return true; } // XXX Save the operation callback time so we can restore it after the GC, // because GCing can cause JS to run on our context, causing our // ScriptEvaluated to be called, and clearing our operation callback time. // See bug 302333. PRTime callbackTime = ctx->mOperationCallbackTime; PRTime modalStateTime = ctx->mModalStateTime; @@ -719,51 +719,51 @@ nsJSContext::DOMOperationCallback(JSCont ctx->mModalStateTime = modalStateTime; PRTime now = PR_Now(); if (callbackTime == 0) { // Initialize mOperationCallbackTime to start timing how long the // script has run ctx->mOperationCallbackTime = now; - return JS_TRUE; + return true; } if (ctx->mModalStateDepth) { // We're waiting on a modal dialog, nothing more to do here. - return JS_TRUE; + return true; } PRTime duration = now - callbackTime; // Check the amount of time this script has been running, or if the // dialog is disabled. JSObject* global = ::JS::CurrentGlobalOrNull(cx); bool isTrackingChromeCodeTime = global && xpc::AccessCheck::isChrome(js::GetObjectCompartment(global)); if (duration < (isTrackingChromeCodeTime ? sMaxChromeScriptRunTime : sMaxScriptRunTime)) { - return JS_TRUE; + return true; } if (!nsContentUtils::IsSafeToRunScript()) { // If it isn't safe to run script, then it isn't safe to bring up the // prompt (since that will cause the event loop to spin). In this case // (which is rare), we just stop the script... But report a warning so // that developers have some idea of what went wrong. JS_ReportWarning(cx, "A long running script was terminated"); - return JS_FALSE; + return false; } // If we get here we're most likely executing an infinite loop in JS, // we'll tell the user about this and we'll give the user the option // of stopping the execution of the script. nsCOMPtr<nsIPrompt> prompt = GetPromptFromContext(ctx); - NS_ENSURE_TRUE(prompt, JS_FALSE); + NS_ENSURE_TRUE(prompt, false); // Check if we should offer the option to debug JS::RootedScript script(cx); unsigned lineno; JSBool hasFrame = ::JS_DescribeScriptedCaller(cx, script.address(), &lineno); bool debugPossible = hasFrame && js::CanCallContextDebugHandler(cx); #ifdef MOZ_JSDEBUGGER @@ -839,17 +839,17 @@ nsJSContext::DOMOperationCallback(JSCont rv = tmp; } } //GetStringFromName can return NS_OK and still give NULL string if (NS_FAILED(rv) || !title || !msg || !stopButton || !waitButton || (!debugButton && debugPossible) || !neverShowDlg) { NS_ERROR("Failed to get localized strings."); - return JS_TRUE; + return true; } // Append file and line number information, if available if (script) { const char *filename = ::JS_GetScriptFilename(cx, script); if (filename) { nsXPIDLString scriptLocation; NS_ConvertUTF8toUTF16 filenameUTF16(filename); @@ -897,24 +897,24 @@ nsJSContext::DOMOperationCallback(JSCont sMaxChromeScriptRunTime = NS_UNLIMITED_SCRIPT_RUNTIME; } else { Preferences::SetInt("dom.max_script_run_time", 0); sMaxScriptRunTime = NS_UNLIMITED_SCRIPT_RUNTIME; } } ctx->mOperationCallbackTime = PR_Now(); - return JS_TRUE; + return true; } else if ((buttonPressed == 2) && debugPossible) { return js_CallContextDebugHandler(cx); } JS_ClearPendingException(cx); - return JS_FALSE; + return false; } void nsJSContext::EnterModalState() { if (!mModalStateDepth) { mModalStateTime = mOperationCallbackTime ? PR_Now() : 0; } @@ -3321,17 +3321,17 @@ NS_DOMWriteStructuredClone(JSContext* cx JS::Handle<JSObject*> obj, void *closure) { ImageData* imageData; nsresult rv = UnwrapObject<ImageData>(cx, obj, imageData); if (NS_FAILED(rv)) { // Don't know what this is. Bail. xpc::Throw(cx, NS_ERROR_DOM_DATA_CLONE_ERR); - return JS_FALSE; + return false; } // Prepare the ImageData internals. uint32_t width = imageData->Width(); uint32_t height = imageData->Height(); JS::Rooted<JSObject*> dataArray(cx, imageData->GetDataObject()); // Write the internals to the stream.
--- a/dom/base/nsJSUtils.cpp +++ b/dom/base/nsJSUtils.cpp @@ -33,23 +33,23 @@ JSBool nsJSUtils::GetCallingLocation(JSContext* aContext, const char* *aFilename, uint32_t* aLineno) { JSScript* script = nullptr; unsigned lineno = 0; if (!JS_DescribeScriptedCaller(aContext, &script, &lineno)) { - return JS_FALSE; + return false; } *aFilename = ::JS_GetScriptFilename(aContext, script); *aLineno = lineno; - return JS_TRUE; + return true; } nsIScriptGlobalObject * nsJSUtils::GetStaticScriptGlobal(JSObject* aObj) { JSClass* clazz; JSObject* glob = aObj; // starting point for search
--- a/dom/base/nsJSUtils.h +++ b/dom/base/nsJSUtils.h @@ -99,22 +99,22 @@ public: { } JSBool init(JSContext* aContext, JSString* str) { size_t length; const jschar* chars = JS_GetStringCharsZAndLength(aContext, str, &length); if (!chars) - return JS_FALSE; + return false; NS_ASSERTION(IsEmpty(), "init() on initialized string"); nsDependentString* base = this; new(base) nsDependentString(chars, length); - return JS_TRUE; + return true; } JSBool init(JSContext* aContext, const JS::Value &v) { return init(aContext, JSVAL_TO_STRING(v)); } void init(JSFlatString* fstr)
--- a/dom/bluetooth/BluetoothHfpManager.cpp +++ b/dom/bluetooth/BluetoothHfpManager.cpp @@ -544,17 +544,17 @@ BluetoothHfpManager::HandleVolumeChanged JS::Rooted<JSObject*> obj(cx, &val.toObject()); JS::Rooted<JS::Value> key(cx); if (!JS_GetProperty(cx, obj, "key", &key) || !key.isString()) { return; } JSBool match; if (!JS_StringEqualsAscii(cx, key.toString(), AUDIO_VOLUME_BT_SCO_ID, &match) || - (match != JS_TRUE)) { + !match) { return; } JS::Rooted<JS::Value> value(cx); if (!JS_GetProperty(cx, obj, "value", &value)|| !value.isNumber()) { return; }
--- a/dom/indexedDB/KeyPath.cpp +++ b/dom/indexedDB/KeyPath.cpp @@ -44,17 +44,17 @@ IsValidKeyPathString(JSContext* aCx, con jsval stringVal; if (!xpc::StringToJsval(aCx, token, &stringVal)) { return false; } NS_ASSERTION(JSVAL_IS_STRING(stringVal), "This should never happen"); JSString* str = JSVAL_TO_STRING(stringVal); - JSBool isIdentifier = JS_FALSE; + JSBool isIdentifier = false; if (!JS_IsIdentifier(aCx, str, &isIdentifier) || !isIdentifier) { return false; } } // If the very last character was a '.', the tokenizer won't give us an empty // token, but the keyPath is still invalid. if (!aKeyPath.IsEmpty() &&
--- a/dom/plugins/base/nsJSNPRuntime.cpp +++ b/dom/plugins/base/nsJSNPRuntime.cpp @@ -468,22 +468,22 @@ ThrowJSException(JSContext *cx, const ch } static JSBool ReportExceptionIfPending(JSContext *cx) { const char *ex = PeekException(); if (!ex) { - return JS_TRUE; + return true; } ThrowJSException(cx, nullptr); - return JS_FALSE; + return false; } nsJSObjWrapper::nsJSObjWrapper(NPP npp) : nsJSObjWrapperKey(nullptr, npp) { MOZ_COUNT_CTOR(nsJSObjWrapper); OnWrapperCreated(); @@ -628,52 +628,50 @@ doInvoke(NPObject *npobj, NPIdentifier m if (!jsargs) { ::JS_ReportOutOfMemory(cx); return false; } } JS::Rooted<JS::Value> v(cx); - JSBool ok; + bool ok; { JS::AutoArrayRooter tvr(cx, 0, jsargs); // Convert args for (uint32_t i = 0; i < argCount; ++i) { jsargs[i] = NPVariantToJSVal(npp, cx, args + i); tvr.changeLength(i + 1); } if (ctorCall) { JSObject *newObj = ::JS_New(cx, npjsobj->mJSObj, argCount, jsargs); if (newObj) { v = OBJECT_TO_JSVAL(newObj); - ok = JS_TRUE; + ok = true; } else { - ok = JS_FALSE; + ok = false; } } else { ok = ::JS_CallFunctionValue(cx, npjsobj->mJSObj, fv, argCount, jsargs, v.address()); } } if (jsargs != jsargs_buf) PR_Free(jsargs); if (ok) ok = JSValToNPVariant(npp, cx, v, result); - // return ok == JS_TRUE to quiet down compiler warning, even if - // return ok is what we really want. - return ok == JS_TRUE; + return ok; } // static bool nsJSObjWrapper::NP_Invoke(NPObject *npobj, NPIdentifier method, const NPVariant *args, uint32_t argCount, NPVariant *result) { @@ -707,17 +705,17 @@ nsJSObjWrapper::NP_HasProperty(NPObject if (!npobj) { ThrowJSException(cx, "Null npobj in nsJSObjWrapper::NP_HasProperty!"); return false; } nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj; - JSBool found, ok = JS_FALSE; + JSBool found, ok = false; nsCxPusher pusher; pusher.Push(cx); AutoJSExceptionReporter reporter(cx); JSAutoCompartment ac(cx, npjsobj->mJSObj); NS_ASSERTION(NPIdentifierIsInt(id) || NPIdentifierIsString(id), "id must be either string or int!\n"); @@ -771,32 +769,30 @@ nsJSObjWrapper::NP_SetProperty(NPObject if (!npobj) { ThrowJSException(cx, "Null npobj in nsJSObjWrapper::NP_SetProperty!"); return false; } nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj; - JSBool ok = JS_FALSE; + bool ok = false; nsCxPusher pusher; pusher.Push(cx); AutoJSExceptionReporter reporter(cx); JSAutoCompartment ac(cx, npjsobj->mJSObj); JS::Rooted<JS::Value> v(cx, NPVariantToJSVal(npp, cx, value)); NS_ASSERTION(NPIdentifierIsInt(id) || NPIdentifierIsString(id), "id must be either string or int!\n"); ok = ::JS_SetPropertyById(cx, npjsobj->mJSObj, NPIdentifierToJSId(id), v); - // return ok == JS_TRUE to quiet down compiler warning, even if - // return ok is what we really want. - return ok == JS_TRUE; + return ok; } // static bool nsJSObjWrapper::NP_RemoveProperty(NPObject *npobj, NPIdentifier id) { NPP npp = NPPStack::Peek(); JSContext *cx = GetJSContext(npp); @@ -808,17 +804,17 @@ nsJSObjWrapper::NP_RemoveProperty(NPObje if (!npobj) { ThrowJSException(cx, "Null npobj in nsJSObjWrapper::NP_RemoveProperty!"); return false; } nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj; - JSBool ok = JS_FALSE; + JSBool ok = false; nsCxPusher pusher; pusher.Push(cx); AutoJSExceptionReporter reporter(cx); bool deleted = false; JSAutoCompartment ac(cx, npjsobj->mJSObj); NS_ASSERTION(NPIdentifierIsInt(id) || NPIdentifierIsString(id), @@ -1108,72 +1104,72 @@ static JSBool NPObjWrapper_AddProperty(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) { NPObject *npobj = GetNPObject(cx, obj); if (!npobj || !npobj->_class || !npobj->_class->hasProperty || !npobj->_class->hasMethod) { ThrowJSException(cx, "Bad NPObject as private data!"); - return JS_FALSE; + return false; } if (NPObjectIsOutOfProcessProxy(npobj)) { - return JS_TRUE; + return true; } PluginDestructionGuard pdg(LookupNPP(npobj)); NPIdentifier identifier = JSIdToNPIdentifier(id); JSBool hasProperty = npobj->_class->hasProperty(npobj, identifier); if (!ReportExceptionIfPending(cx)) - return JS_FALSE; + return false; if (hasProperty) - return JS_TRUE; + return true; // We must permit methods here since JS_DefineUCFunction() will add // the function as a property JSBool hasMethod = npobj->_class->hasMethod(npobj, identifier); if (!ReportExceptionIfPending(cx)) - return JS_FALSE; + return false; if (!hasMethod) { ThrowJSException(cx, "Trying to add unsupported property on NPObject!"); - return JS_FALSE; + return false; } - return JS_TRUE; + return true; } static JSBool NPObjWrapper_DelProperty(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JSBool *succeeded) { NPObject *npobj = GetNPObject(cx, obj); if (!npobj || !npobj->_class || !npobj->_class->hasProperty || !npobj->_class->removeProperty) { ThrowJSException(cx, "Bad NPObject as private data!"); - return JS_FALSE; + return false; } PluginDestructionGuard pdg(LookupNPP(npobj)); NPIdentifier identifier = JSIdToNPIdentifier(id); if (!NPObjectIsOutOfProcessProxy(npobj)) { JSBool hasProperty = npobj->_class->hasProperty(npobj, identifier); if (!ReportExceptionIfPending(cx)) - return JS_FALSE; + return false; if (!hasProperty) { *succeeded = true; - return JS_TRUE; + return true; } } if (!npobj->_class->removeProperty(npobj, identifier)) *succeeded = false; return ReportExceptionIfPending(cx); } @@ -1183,85 +1179,85 @@ NPObjWrapper_SetProperty(JSContext *cx, JS::MutableHandle<JS::Value> vp) { NPObject *npobj = GetNPObject(cx, obj); if (!npobj || !npobj->_class || !npobj->_class->hasProperty || !npobj->_class->setProperty) { ThrowJSException(cx, "Bad NPObject as private data!"); - return JS_FALSE; + return false; } // Find out what plugin (NPP) is the owner of the object we're // manipulating, and make it own any JSObject wrappers created here. NPP npp = LookupNPP(npobj); if (!npp) { ThrowJSException(cx, "No NPP found for NPObject!"); - return JS_FALSE; + return false; } PluginDestructionGuard pdg(npp); NPIdentifier identifier = JSIdToNPIdentifier(id); if (!NPObjectIsOutOfProcessProxy(npobj)) { JSBool hasProperty = npobj->_class->hasProperty(npobj, identifier); if (!ReportExceptionIfPending(cx)) - return JS_FALSE; + return false; if (!hasProperty) { ThrowJSException(cx, "Trying to set unsupported property on NPObject!"); - return JS_FALSE; + return false; } } NPVariant npv; if (!JSValToNPVariant(npp, cx, vp, &npv)) { ThrowJSException(cx, "Error converting jsval to NPVariant!"); - return JS_FALSE; + return false; } JSBool ok = npobj->_class->setProperty(npobj, identifier, &npv); _releasevariantvalue(&npv); // Release the variant if (!ReportExceptionIfPending(cx)) - return JS_FALSE; + return false; if (!ok) { ThrowJSException(cx, "Error setting property on NPObject!"); - return JS_FALSE; + return false; } - return JS_TRUE; + return true; } static JSBool NPObjWrapper_GetProperty(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) { NPObject *npobj = GetNPObject(cx, obj); if (!npobj || !npobj->_class || !npobj->_class->hasProperty || !npobj->_class->hasMethod || !npobj->_class->getProperty) { ThrowJSException(cx, "Bad NPObject as private data!"); - return JS_FALSE; + return false; } // Find out what plugin (NPP) is the owner of the object we're // manipulating, and make it own any JSObject wrappers created here. NPP npp = LookupNPP(npobj); if (!npp) { ThrowJSException(cx, "No NPP found for NPObject!"); - return JS_FALSE; + return false; } PluginDestructionGuard pdg(npp); bool hasProperty, hasMethod; NPVariant npv; VOID_TO_NPVARIANT(npv); @@ -1269,117 +1265,117 @@ NPObjWrapper_GetProperty(JSContext *cx, NPIdentifier identifier = JSIdToNPIdentifier(id); if (NPObjectIsOutOfProcessProxy(npobj)) { PluginScriptableObjectParent* actor = static_cast<ParentNPObject*>(npobj)->parent; // actor may be null if the plugin crashed. if (!actor) - return JS_FALSE; + return false; JSBool success = actor->GetPropertyHelper(identifier, &hasProperty, &hasMethod, &npv); if (!ReportExceptionIfPending(cx)) { if (success) _releasevariantvalue(&npv); - return JS_FALSE; + return false; } if (success) { // We return NPObject Member class here to support ambiguous members. if (hasProperty && hasMethod) return CreateNPObjectMember(npp, cx, obj, npobj, id, &npv, vp.address()); if (hasProperty) { vp.set(NPVariantToJSVal(npp, cx, &npv)); _releasevariantvalue(&npv); if (!ReportExceptionIfPending(cx)) - return JS_FALSE; + return false; } } - return JS_TRUE; + return true; } hasProperty = npobj->_class->hasProperty(npobj, identifier); if (!ReportExceptionIfPending(cx)) - return JS_FALSE; + return false; hasMethod = npobj->_class->hasMethod(npobj, identifier); if (!ReportExceptionIfPending(cx)) - return JS_FALSE; + return false; // We return NPObject Member class here to support ambiguous members. if (hasProperty && hasMethod) return CreateNPObjectMember(npp, cx, obj, npobj, id, nullptr, vp.address()); if (hasProperty) { if (npobj->_class->getProperty(npobj, identifier, &npv)) vp.set(NPVariantToJSVal(npp, cx, &npv)); _releasevariantvalue(&npv); if (!ReportExceptionIfPending(cx)) - return JS_FALSE; + return false; } - return JS_TRUE; + return true; } static JSBool CallNPMethodInternal(JSContext *cx, JS::Handle<JSObject*> obj, unsigned argc, JS::Value *argv, JS::Value *rval, bool ctorCall) { NPObject *npobj = GetNPObject(cx, obj); if (!npobj || !npobj->_class) { ThrowJSException(cx, "Bad NPObject as private data!"); - return JS_FALSE; + return false; } // Find out what plugin (NPP) is the owner of the object we're // manipulating, and make it own any JSObject wrappers created here. NPP npp = LookupNPP(npobj); if (!npp) { ThrowJSException(cx, "Error finding NPP for NPObject!"); - return JS_FALSE; + return false; } PluginDestructionGuard pdg(npp); NPVariant npargs_buf[8]; NPVariant *npargs = npargs_buf; if (argc > (sizeof(npargs_buf) / sizeof(NPVariant))) { // Our stack buffer isn't large enough to hold all arguments, // malloc a buffer. npargs = (NPVariant *)PR_Malloc(argc * sizeof(NPVariant)); if (!npargs) { ThrowJSException(cx, "Out of memory!"); - return JS_FALSE; + return false; } } // Convert arguments uint32_t i; for (i = 0; i < argc; ++i) { if (!JSValToNPVariant(npp, cx, argv[i], npargs + i)) { ThrowJSException(cx, "Error converting jsvals to NPVariants!"); if (npargs != npargs_buf) { PR_Free(npargs); } - return JS_FALSE; + return false; } } NPVariant v; VOID_TO_NPVARIANT(v); JSObject *funobj = JSVAL_TO_OBJECT(argv[-2]); JSBool ok; @@ -1388,65 +1384,65 @@ CallNPMethodInternal(JSContext *cx, JS:: if (ctorCall) { // construct a new NPObject based on the NPClass in npobj. Fail if // no construct method is available. if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npobj->_class) && npobj->_class->construct) { ok = npobj->_class->construct(npobj, npargs, argc, &v); } else { - ok = JS_FALSE; + ok = false; msg = "Attempt to construct object from class with no constructor."; } } else if (funobj != obj) { // A obj.function() style call is made, get the method name from // the function object. if (npobj->_class->invoke) { JSFunction *fun = ::JS_GetObjectFunction(funobj); JSString *name = ::JS_InternJSString(cx, ::JS_GetFunctionId(fun)); NPIdentifier id = StringToNPIdentifier(cx, name); ok = npobj->_class->invoke(npobj, id, npargs, argc, &v); } else { - ok = JS_FALSE; + ok = false; msg = "Attempt to call a method on object with no invoke method."; } } else { if (npobj->_class->invokeDefault) { // obj is a callable object that is being called, no method name // available then. Invoke the default method. ok = npobj->_class->invokeDefault(npobj, npargs, argc, &v); } else { - ok = JS_FALSE; + ok = false; msg = "Attempt to call a default method on object with no " "invokeDefault method."; } } // Release arguments. for (i = 0; i < argc; ++i) { _releasevariantvalue(npargs + i); } if (npargs != npargs_buf) { PR_Free(npargs); } if (!ok) { - // ReportExceptionIfPending returns a return value, which is JS_TRUE + // ReportExceptionIfPending returns a return value, which is true // if no exception was thrown. In that case, throw our own. if (ReportExceptionIfPending(cx)) ThrowJSException(cx, msg); - return JS_FALSE; + return false; } *rval = NPVariantToJSVal(npp, cx, &v); // *rval now owns the value, release our reference. _releasevariantvalue(&v); return ReportExceptionIfPending(cx); @@ -1474,49 +1470,49 @@ NPObjWrapper_newEnumerate(JSContext *cx, { NPObject *npobj = GetNPObject(cx, obj); NPIdentifier *enum_value; uint32_t length; NPObjectEnumerateState *state; if (!npobj || !npobj->_class) { ThrowJSException(cx, "Bad NPObject as private data!"); - return JS_FALSE; + return false; } PluginDestructionGuard pdg(LookupNPP(npobj)); NS_ASSERTION(statep, "Must have a statep to enumerate!"); switch(enum_op) { case JSENUMERATE_INIT: case JSENUMERATE_INIT_ALL: state = new NPObjectEnumerateState(); if (!state) { ThrowJSException(cx, "Memory allocation failed for " "NPObjectEnumerateState!"); - return JS_FALSE; + return false; } if (!NP_CLASS_STRUCT_VERSION_HAS_ENUM(npobj->_class) || !npobj->_class->enumerate) { enum_value = 0; length = 0; } else if (!npobj->_class->enumerate(npobj, &enum_value, &length)) { delete state; if (ReportExceptionIfPending(cx)) { - // ReportExceptionIfPending returns a return value, which is JS_TRUE + // ReportExceptionIfPending returns a return value, which is true // if no exception was thrown. In that case, throw our own. ThrowJSException(cx, "Error enumerating properties on scriptable " "plugin object"); } - return JS_FALSE; + return false; } state->value = enum_value; state->length = length; state->index = 0; *statep = PRIVATE_TO_JSVAL(state); if (idp) { *idp = INT_TO_JSID(length); @@ -1525,86 +1521,86 @@ NPObjWrapper_newEnumerate(JSContext *cx, break; case JSENUMERATE_NEXT: state = (NPObjectEnumerateState *)JSVAL_TO_PRIVATE(*statep); enum_value = state->value; length = state->length; if (state->index != length) { *idp = NPIdentifierToJSId(enum_value[state->index++]); - return JS_TRUE; + return true; } // FALL THROUGH case JSENUMERATE_DESTROY: state = (NPObjectEnumerateState *)JSVAL_TO_PRIVATE(*statep); if (state->value) PR_Free(state->value); delete state; *statep = JSVAL_NULL; break; } - return JS_TRUE; + return true; } static JSBool NPObjWrapper_NewResolve(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, unsigned flags, JS::MutableHandle<JSObject*> objp) { NPObject *npobj = GetNPObject(cx, obj); if (!npobj || !npobj->_class || !npobj->_class->hasProperty || !npobj->_class->hasMethod) { ThrowJSException(cx, "Bad NPObject as private data!"); - return JS_FALSE; + return false; } PluginDestructionGuard pdg(LookupNPP(npobj)); NPIdentifier identifier = JSIdToNPIdentifier(id); bool hasProperty = npobj->_class->hasProperty(npobj, identifier); if (!ReportExceptionIfPending(cx)) - return JS_FALSE; + return false; if (hasProperty) { NS_ASSERTION(JSID_IS_STRING(id) || JSID_IS_INT(id), "id must be either string or int!\n"); if (!::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, nullptr, nullptr, JSPROP_ENUMERATE | JSPROP_SHARED)) { - return JS_FALSE; + return false; } objp.set(obj); - return JS_TRUE; + return true; } bool hasMethod = npobj->_class->hasMethod(npobj, identifier); if (!ReportExceptionIfPending(cx)) - return JS_FALSE; + return false; if (hasMethod) { NS_ASSERTION(JSID_IS_STRING(id) || JSID_IS_INT(id), "id must be either string or int!\n"); JSFunction *fnc = ::JS_DefineFunctionById(cx, obj, id, CallNPMethod, 0, JSPROP_ENUMERATE); objp.set(obj); return fnc != nullptr; } // no property or method - return JS_TRUE; + return true; } static JSBool NPObjWrapper_Convert(JSContext *cx, JS::Handle<JSObject*> obj, JSType hint, JS::MutableHandle<JS::Value> vp) { JS_ASSERT(hint == JSTYPE_NUMBER || hint == JSTYPE_STRING || hint == JSTYPE_VOID); // Plugins do not simply use JS_ConvertStub, and the default [[DefaultValue]] @@ -1943,38 +1939,38 @@ LookupNPP(NPObject *npobj) return entry->mNpp; } JSBool CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject* npobj, JS::Handle<jsid> id, NPVariant* getPropertyResult, JS::Value *vp) { - NS_ENSURE_TRUE(vp, JS_FALSE); + NS_ENSURE_TRUE(vp, false); if (!npobj || !npobj->_class || !npobj->_class->getProperty || !npobj->_class->invoke) { ThrowJSException(cx, "Bad NPObject"); - return JS_FALSE; + return false; } NPObjectMemberPrivate *memberPrivate = (NPObjectMemberPrivate *)PR_Malloc(sizeof(NPObjectMemberPrivate)); if (!memberPrivate) - return JS_FALSE; + return false; // Make sure to clear all members in case something fails here // during initialization. memset(memberPrivate, 0, sizeof(NPObjectMemberPrivate)); JSObject *memobj = ::JS_NewObject(cx, &sNPObjectMemberClass, nullptr, nullptr); if (!memobj) { PR_Free(memberPrivate); - return JS_FALSE; + return false; } *vp = OBJECT_TO_JSVAL(memobj); ::JS_AddValueRoot(cx, vp); ::JS_SetPrivate(memobj, (void *)memberPrivate); NPIdentifier identifier = JSIdToNPIdentifier(id); @@ -1988,22 +1984,22 @@ CreateNPObjectMember(NPP npp, JSContext } else { VOID_TO_NPVARIANT(npv); NPBool hasProperty = npobj->_class->getProperty(npobj, identifier, &npv); if (!ReportExceptionIfPending(cx)) { ::JS_RemoveValueRoot(cx, vp); - return JS_FALSE; + return false; } if (!hasProperty) { ::JS_RemoveValueRoot(cx, vp); - return JS_FALSE; + return false; } } fieldValue = NPVariantToJSVal(npp, cx, &npv); // npobjWrapper is the JSObject through which we make sure we don't // outlive the underlying NPObject, so make sure it points to the // real JSObject wrapper for the NPObject. @@ -2012,50 +2008,50 @@ CreateNPObjectMember(NPP npp, JSContext memberPrivate->npobjWrapper = obj; memberPrivate->fieldValue = fieldValue; memberPrivate->methodName = id; memberPrivate->npp = npp; ::JS_RemoveValueRoot(cx, vp); - return JS_TRUE; + return true; } static JSBool NPObjectMember_Convert(JSContext *cx, JS::Handle<JSObject*> obj, JSType type, JS::MutableHandle<JS::Value> vp) { NPObjectMemberPrivate *memberPrivate = (NPObjectMemberPrivate *)::JS_GetInstancePrivate(cx, obj, &sNPObjectMemberClass, nullptr); if (!memberPrivate) { NS_ERROR("no Ambiguous Member Private data!"); - return JS_FALSE; + return false; } switch (type) { case JSTYPE_VOID: case JSTYPE_STRING: case JSTYPE_NUMBER: vp.set(memberPrivate->fieldValue); if (!JSVAL_IS_PRIMITIVE(vp)) { return JS_DefaultValue(cx, JSVAL_TO_OBJECT(vp), type, vp.address()); } - return JS_TRUE; + return true; case JSTYPE_BOOLEAN: case JSTYPE_OBJECT: vp.set(memberPrivate->fieldValue); - return JS_TRUE; + return true; case JSTYPE_FUNCTION: // Leave this to NPObjectMember_Call. - return JS_TRUE; + return true; default: NS_ERROR("illegal operation on JSObject prototype object"); - return JS_FALSE; + return false; } } static void NPObjectMember_Finalize(JSFreeOp *fop, JSObject *obj) { NPObjectMemberPrivate *memberPrivate; @@ -2127,17 +2123,17 @@ NPObjectMember_Call(JSContext *cx, unsig _releasevariantvalue(npargs + i); } if (npargs != npargs_buf) { PR_Free(npargs); } if (!ok) { - // ReportExceptionIfPending returns a return value, which is JS_TRUE + // ReportExceptionIfPending returns a return value, which is true // if no exception was thrown. In that case, throw our own. if (ReportExceptionIfPending(cx)) ThrowJSException(cx, "Error calling method on NPObject!"); return false; } JS_SET_RVAL(cx, vp, NPVariantToJSVal(memberPrivate->npp, cx, &npv));
--- a/dom/plugins/ipc/PluginScriptableObjectParent.cpp +++ b/dom/plugins/ipc/PluginScriptableObjectParent.cpp @@ -1218,36 +1218,36 @@ PluginScriptableObjectParent::GetPropert bool* aHasMethod, NPVariant* aResult) { NS_ASSERTION(Type() == Proxy, "Bad type!"); ParentNPObject* object = static_cast<ParentNPObject*>(mObject); if (object->invalidated) { NS_WARNING("Calling method on an invalidated object!"); - return JS_FALSE; + return false; } StackIdentifier identifier(GetInstance(), aName); if (!identifier) { - return JS_FALSE; + return false; } bool hasProperty, hasMethod, success; Variant result; if (!CallGetChildProperty(identifier, &hasProperty, &hasMethod, &result, &success)) { - return JS_FALSE; + return false; } if (!success) { - return JS_FALSE; + return false; } if (!ConvertToVariant(result, *aResult, GetInstance())) { NS_WARNING("Failed to convert result!"); - return JS_FALSE; + return false; } *aHasProperty = hasProperty; *aHasMethod = hasMethod; - return JS_TRUE; + return true; }
--- a/dom/src/geolocation/nsGeolocation.cpp +++ b/dom/src/geolocation/nsGeolocation.cpp @@ -719,17 +719,17 @@ nsGeolocationService::HandleMozsettingCh JS::Rooted<JSObject*> obj(cx, &val.toObject()); JS::Rooted<JS::Value> key(cx); if (!JS_GetProperty(cx, obj, "key", &key) || !key.isString()) { return; } JSBool match; - if (!JS_StringEqualsAscii(cx, key.toString(), GEO_SETINGS_ENABLED, &match) || (match != JS_TRUE)) { + if (!JS_StringEqualsAscii(cx, key.toString(), GEO_SETINGS_ENABLED, &match) || !match) { return; } JS::Rooted<JS::Value> value(cx); if (!JS_GetProperty(cx, obj, "value", &value) || !value.isBoolean()) { return; }
--- a/dom/src/json/nsJSON.cpp +++ b/dom/src/json/nsJSON.cpp @@ -160,19 +160,19 @@ nsJSON::EncodeToStream(nsIOutputStream * } static JSBool WriteCallback(const jschar *buf, uint32_t len, void *data) { nsJSONWriter *writer = static_cast<nsJSONWriter*>(data); nsresult rv = writer->Write((const PRUnichar*)buf, (uint32_t)len); if (NS_FAILED(rv)) - return JS_FALSE; + return false; - return JS_TRUE; + return true; } NS_IMETHODIMP nsJSON::EncodeFromJSVal(JS::Value *value, JSContext *cx, nsAString &result) { result.Truncate(); mozilla::Maybe<JSAutoCompartment> ac;
--- a/dom/system/gonk/TimeZoneSettingObserver.cpp +++ b/dom/system/gonk/TimeZoneSettingObserver.cpp @@ -182,17 +182,17 @@ TimeZoneSettingObserver::Observe(nsISupp JSObject &obj(val.toObject()); JS::Rooted<JS::Value> key(cx); if (!JS_GetProperty(cx, &obj, "key", &key) || !key.isString()) { return NS_OK; } JSBool match; if (!JS_StringEqualsAscii(cx, key.toString(), TIME_TIMEZONE, &match) || - match != JS_TRUE) { + !match) { return NS_OK; } // Get the value, which should be a JS string like "America/Chicago". JS::Rooted<JS::Value> value(cx); if (!JS_GetProperty(cx, &obj, "value", &value) || !value.isString()) { return NS_OK;
--- a/gfx/skia/src/xml/SkJS.cpp +++ b/gfx/skia/src/xml/SkJS.cpp @@ -74,63 +74,63 @@ extern "C" { #endif static JSBool global_enumerate(JSContext *cx, JSObject *obj) { #ifdef LAZY_STANDARD_CLASSES return JS_EnumerateStandardClasses(cx, obj); #else - return JS_TRUE; + return true; #endif } static JSBool global_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp) { #ifdef LAZY_STANDARD_CLASSES if ((flags & JSRESOLVE_ASSIGNING) == 0) { JSBool resolved; if (!JS_ResolveStandardClass(cx, obj, id, &resolved)) - return JS_FALSE; + return false; if (resolved) { *objp = obj; - return JS_TRUE; + return true; } } #endif #if defined(SHELL_HACK) && defined(DEBUG) && defined(XP_UNIX) if ((flags & (JSRESOLVE_QUALIFIED | JSRESOLVE_ASSIGNING)) == 0) { /* * Do this expensive hack only for unoptimized Unix builds, which are * not used for benchmarking. */ char *path, *comp, *full; const char *name; JSBool ok, found; JSFunction *fun; if (!JSVAL_IS_STRING(id)) - return JS_TRUE; + return true; path = getenv("PATH"); if (!path) - return JS_TRUE; + return true; path = JS_strdup(cx, path); if (!path) - return JS_FALSE; + return false; name = JS_GetStringBytes(JSVAL_TO_STRING(id)); - ok = JS_TRUE; + ok = true; for (comp = strtok(path, ":"); comp; comp = strtok(NULL, ":")) { if (*comp != '\0') { full = JS_smprintf("%s/%s", comp, name); if (!full) { JS_ReportOutOfMemory(cx); - ok = JS_FALSE; + ok = false; break; } } else { full = (char *)name; } found = (access(full, X_OK) == 0); if (*comp != '\0') free(full); @@ -141,17 +141,17 @@ global_resolve(JSContext *cx, JSObject * *objp = obj; break; } } JS_free(cx, path); return ok; } #else - return JS_TRUE; + return true; #endif } JSClass global_class = { "global", JSCLASS_NEW_RESOLVE, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, global_enumerate, (JSResolveOp) global_resolve,
--- a/gfx/skia/src/xml/SkJSDisplayable.cpp +++ b/gfx/skia/src/xml/SkJSDisplayable.cpp @@ -74,17 +74,17 @@ SkPaint* SkJSDisplayable::gPaint; JSBool SkJSDisplayable::Draw(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { SkJSDisplayable *p = (SkJSDisplayable*) JS_GetPrivate(cx, obj); SkASSERT(p->fDisplayable->isDrawable()); SkDrawable* drawable = (SkDrawable*) p->fDisplayable; SkAnimateMaker maker(NULL, gCanvas, gPaint); drawable->draw(maker); - return JS_TRUE; + return true; } JSFunctionSpec SkJSDisplayable_methods[] = { { "draw", SkJSDisplayable::Draw, 1, 0, 0 }, { 0 } }; @@ -92,17 +92,17 @@ JSFunctionSpec SkJSDisplayable_methods[] static JSPropertySpec* gDisplayableProperties[kNumberOfTypes]; static JSClass gDisplayableClasses[kNumberOfTypes]; #define JS_INIT(_prefix, _class) \ static JSBool _class##Constructor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { \ SkJSDisplayable* jsDisplayable = new SkJSDisplayable(); \ jsDisplayable->fDisplayable = new _prefix##_class(); \ JS_SetPrivate(cx, obj, (void*) jsDisplayable); \ - return JS_TRUE; \ + return true; \ } \ \ static JSObject* _class##Init(JSContext *cx, JSObject *obj, JSObject *proto) { \ JSObject *newProtoObj = JS_InitClass(cx, obj, proto, &gDisplayableClasses[SkType_##_class], \ _class##Constructor, 0, \ NULL, SkJSDisplayable_methods , \ NULL, NULL); \ JS_DefineProperties(cx, newProtoObj, gDisplayableProperties[SkType_##_class]); \ @@ -214,17 +214,17 @@ static void GenerateTables() { void SkJSDisplayable::Destructor(JSContext *cx, JSObject *obj) { delete (SkJSDisplayable*) JS_GetPrivate(cx, obj); } JSBool SkJSDisplayable::GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) { if (JSVAL_IS_INT(id) == 0) - return JS_TRUE; + return true; SkJSDisplayable *p = (SkJSDisplayable *) JS_GetPrivate(cx, obj); SkDisplayable* displayable = p->fDisplayable; SkDisplayTypes displayableType = displayable->getType(); int members; const SkMemberInfo* info = SkDisplayType::GetMembers(NULL /* fMaker */, displayableType, &members); int idIndex = JSVAL_TO_INT(id); SkASSERT(idIndex >= 0 && idIndex < members); info = &info[idIndex]; @@ -285,22 +285,22 @@ JSBool SkJSDisplayable::GetProperty(JSCo break; case SkType_String: str = JS_NewStringCopyN(cx, string->c_str(), string->size()); *vp = STRING_TO_JSVAL(str); break; default: SkASSERT(0); // !!! unimplemented } - return JS_TRUE; + return true; } JSBool SkJSDisplayable::SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) { if (JSVAL_IS_INT(id) == 0) - return JS_TRUE; + return true; SkJSDisplayable *p = (SkJSDisplayable *) JS_GetPrivate(cx, obj); SkDisplayable* displayable = p->fDisplayable; SkDisplayTypes displayableType = displayable->getType(); int members; const SkMemberInfo* info = SkDisplayType::GetMembers(NULL /* fMaker */, displayableType, &members); int idIndex = JSVAL_TO_INT(id); SkASSERT(idIndex >= 0 && idIndex < members); info = &info[idIndex]; @@ -363,17 +363,17 @@ JSBool SkJSDisplayable::SetProperty(JSCo SkOperand operand; operand.fScalar = scalar; info->setValue(displayable, &operand, 1); break; default: SkASSERT(0); // !!! unimplemented } } - return JS_TRUE; + return true; } void SkJS::InitializeDisplayables(const SkBitmap& bitmap, JSContext *cx, JSObject *obj, JSObject *proto) { SkJSDisplayable::gCanvas = new SkCanvas(bitmap); SkJSDisplayable::gPaint = new SkPaint(); #if SK_USE_CONDENSED_INFO == 0 GenerateTables(); #else
--- a/ipc/testshell/TestShellParent.cpp +++ b/ipc/testshell/TestShellParent.cpp @@ -41,46 +41,46 @@ TestShellParent::CommandDone(TestShellCo return true; } JSBool TestShellCommandParent::SetCallback(JSContext* aCx, JS::Value aCallback) { if (!mCallback.Hold(aCx)) { - return JS_FALSE; + return false; } mCallback = aCallback; mCx = aCx; - return JS_TRUE; + return true; } JSBool TestShellCommandParent::RunCallback(const nsString& aResponse) { - NS_ENSURE_TRUE(*mCallback.ToJSValPtr() != JSVAL_NULL && mCx, JS_FALSE); + NS_ENSURE_TRUE(*mCallback.ToJSValPtr() != JSVAL_NULL && mCx, false); JSAutoRequest ar(mCx); - NS_ENSURE_TRUE(mCallback.ToJSObject(), JS_FALSE); + NS_ENSURE_TRUE(mCallback.ToJSObject(), false); JSAutoCompartment ac(mCx, mCallback.ToJSObject()); JS::Rooted<JSObject*> global(mCx, JS::CurrentGlobalOrNull(mCx)); JSString* str = JS_NewUCStringCopyN(mCx, aResponse.get(), aResponse.Length()); - NS_ENSURE_TRUE(str, JS_FALSE); + NS_ENSURE_TRUE(str, false); JS::Rooted<JS::Value> strVal(mCx, JS::StringValue(str)); JS::Rooted<JS::Value> rval(mCx); JSBool ok = JS_CallFunctionValue(mCx, global, mCallback, 1, strVal.address(), rval.address()); - NS_ENSURE_TRUE(ok, JS_FALSE); + NS_ENSURE_TRUE(ok, false); - return JS_TRUE; + return true; } void TestShellCommandParent::ReleaseCallback() { mCallback.Release(); }
--- a/ipc/testshell/XPCShellEnvironment.cpp +++ b/ipc/testshell/XPCShellEnvironment.cpp @@ -116,19 +116,19 @@ static JSBool GetLine(char *bufp, FILE *file, const char *prompt) { char line[256]; fputs(prompt, stdout); fflush(stdout); if (!fgets(line, sizeof line, file)) - return JS_FALSE; + return false; strcpy(bufp, line); - return JS_TRUE; + return true; } static bool Dump(JSContext *cx, unsigned argc, JS::Value *vp) { JS_SET_RVAL(cx, vp, JSVAL_VOID); @@ -448,34 +448,34 @@ XPCShellEnvironment::ProcessFile(JSConte if (script) (void)JS_ExecuteScript(cx, obj, script, result.address()); return; } /* It's an interactive filehandle; drop into read-eval-print loop. */ lineno = 1; - hitEOF = JS_FALSE; + hitEOF = false; do { bufp = buffer; *bufp = '\0'; JSAutoRequest ar(cx); JSAutoCompartment ac(cx, obj); /* * Accumulate lines until we get a 'compilable unit' - one that either * generates an error (before running out of source) or that compiles * cleanly. This should be whenever we get a complete statement that * coincides with the end of a line. */ startline = lineno; do { if (!GetLine(bufp, file, startline == lineno ? "js> " : "")) { - hitEOF = JS_TRUE; + hitEOF = true; break; } bufp += strlen(bufp); lineno++; } while (!JS_BufferIsCompilableUnit(cx, obj, buffer, strlen(buffer))); /* Clear any pending exception from previous failed compiles. */ JS_ClearPendingException(cx); @@ -493,17 +493,17 @@ XPCShellEnvironment::ProcessFile(JSConte JSAutoByteString bytes; if (str) bytes.encodeLatin1(cx, str); JS_SetErrorReporter(cx, older); if (!!bytes) fprintf(stdout, "%s\n", bytes.ptr()); else - ok = JS_FALSE; + ok = false; } } } while (!hitEOF && !env->IsQuitting()); fprintf(stdout, "\n"); } NS_IMETHODIMP_(nsrefcnt) @@ -549,17 +549,17 @@ XPCShellEnvironment::CreateEnvironment() if (env && !env->Init()) { delete env; env = nullptr; } return env; } XPCShellEnvironment::XPCShellEnvironment() -: mQuitting(JS_FALSE) +: mQuitting(false) { } XPCShellEnvironment::~XPCShellEnvironment() { AutoSafeJSContext cx; Rooted<JSObject*> global(cx, GetGlobalObject()); @@ -669,17 +669,17 @@ XPCShellEnvironment::Init() } mGlobalHolder = globalObj; FILE* runtimeScriptFile = fopen(kDefaultRuntimeScriptFilename, "r"); if (runtimeScriptFile) { fprintf(stdout, "[loading '%s'...]\n", kDefaultRuntimeScriptFilename); ProcessFile(cx, globalObj, kDefaultRuntimeScriptFilename, - runtimeScriptFile, JS_FALSE); + runtimeScriptFile, false); fclose(runtimeScriptFile); } return true; } bool XPCShellEnvironment::EvaluateString(const nsString& aString,
--- a/ipc/testshell/XPCShellEnvironment.h +++ b/ipc/testshell/XPCShellEnvironment.h @@ -39,17 +39,17 @@ public: return nsJSPrincipals::get(nsContentUtils::GetSystemPrincipal()); } JSObject* GetGlobalObject() { return mGlobalHolder.ToJSObject(); } void SetIsQuitting() { - mQuitting = JS_TRUE; + mQuitting = true; } JSBool IsQuitting() { return mQuitting; } protected: XPCShellEnvironment(); bool Init();
--- a/js/ipc/JavaScriptShared.cpp +++ b/js/ipc/JavaScriptShared.cpp @@ -353,24 +353,24 @@ JavaScriptShared::fromDescriptor(JSConte return true; } JSBool UnknownPropertyStub(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp) { JS_ReportError(cx, "getter could not be wrapped via CPOWs"); - return JS_FALSE; + return false; } JSBool UnknownStrictPropertyStub(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, MutableHandleValue vp) { JS_ReportError(cx, "setter could not be wrapped via CPOWs"); - return JS_FALSE; + return false; } bool JavaScriptShared::toDescriptor(JSContext *cx, const PPropertyDescriptor &in, JSPropertyDescriptor *out) { out->attrs = in.attrs(); out->shortid = in.shortid(); if (!toValue(cx, in.value(), &out->value))
--- a/js/jsd/idl/jsdIDebuggerService.idl +++ b/js/jsd/idl/jsdIDebuggerService.idl @@ -1198,17 +1198,17 @@ interface jsdIProperty : jsdIEphemeral /** property has an alias id */ const unsigned long FLAG_ALIAS = 0x08; /** argument to function */ const unsigned long FLAG_ARGUMENT = 0x10; /** local variable in function */ const unsigned long FLAG_VARIABLE = 0x20; /** exception occurred looking up property, value is exception */ const unsigned long FLAG_EXCEPTION = 0x40; - /** native getter returned JS_FALSE without throwing an exception */ + /** native getter returned false without throwing an exception */ const unsigned long FLAG_ERROR = 0x80; /** found via explicit lookup (property defined elsewhere.) */ const unsigned long FLAG_HINTED = 0x800; /** FLAG_* values OR'd together, representing the flags for this property. */ readonly attribute unsigned long flags; /** jsdIValue representing the alias for this property. */ readonly attribute jsdIValue alias;
--- a/js/jsd/jsd_high.cpp +++ b/js/jsd/jsd_high.cpp @@ -128,17 +128,17 @@ static JSDContext* JSAutoCompartment ac(cx, jsdc->glob); ok = JS_AddNamedObjectRoot(cx, &jsdc->glob, "JSD context global") && JS_InitStandardClasses(cx, jsdc->glob); } if( ! ok ) goto label_newJSDContext_failure; jsdc->data = NULL; - jsdc->inited = JS_TRUE; + jsdc->inited = true; JSD_LOCK(); JS_INSERT_LINK(&jsdc->links, &_jsd_context_list); JSD_UNLOCK(); return jsdc; label_newJSDContext_failure: @@ -162,17 +162,17 @@ static void JSD_UNLOCK(); if ( jsdc->glob ) { JS_RemoveObjectRootRT(jsdc->jsrt, &jsdc->glob); } jsd_DestroyObjectManager(jsdc); jsd_DestroyAtomTable(jsdc); - jsdc->inited = JS_FALSE; + jsdc->inited = false; /* * We should free jsdc here, but we let it leak in case there are any * asynchronous hooks calling into the system using it as a handle * * XXX we also leak the locks */ } @@ -213,17 +213,17 @@ jsd_DebuggerOn(void) JS_ASSERT(_jsrt); JS_ASSERT(_validateUserCallbacks(&_callbacks)); return jsd_DebuggerOnForUser(_jsrt, &_callbacks, _user, NULL); } void jsd_DebuggerOff(JSDContext* jsdc) { - jsd_DebuggerPause(jsdc, JS_TRUE); + jsd_DebuggerPause(jsdc, true); /* clear hooks here */ JS_SetNewScriptHookProc(jsdc->jsrt, NULL, NULL); JS_SetDestroyScriptHookProc(jsdc->jsrt, NULL, NULL); /* clean up */ JSD_LockScriptSubsystem(jsdc); jsd_DestroyScriptManager(jsdc); JSD_UnlockScriptSubsystem(jsdc); @@ -334,81 +334,81 @@ jsd_DebugErrorHook(JSContext *cx, const { JSDContext* jsdc = (JSDContext*) closure; JSD_ErrorReporter errorReporter; void* errorReporterData; if( ! jsdc ) { JS_ASSERT(0); - return JS_TRUE; + return true; } if( JSD_IS_DANGEROUS_THREAD(jsdc) ) - return JS_TRUE; + return true; /* local in case hook gets cleared on another thread */ JSD_LOCK(); errorReporter = jsdc->errorReporter; errorReporterData = jsdc->errorReporterData; JSD_UNLOCK(); if(!errorReporter) - return JS_TRUE; + return true; switch(errorReporter(jsdc, cx, message, report, errorReporterData)) { case JSD_ERROR_REPORTER_PASS_ALONG: - return JS_TRUE; + return true; case JSD_ERROR_REPORTER_RETURN: - return JS_FALSE; + return false; case JSD_ERROR_REPORTER_DEBUG: { jsval rval; JSD_ExecutionHookProc hook; void* hookData; /* local in case hook gets cleared on another thread */ JSD_LOCK(); hook = jsdc->debugBreakHook; hookData = jsdc->debugBreakHookData; JSD_UNLOCK(); jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_DEBUG_REQUESTED, hook, hookData, &rval); /* XXX Should make this dependent on ExecutionHook retval */ - return JS_TRUE; + return true; } case JSD_ERROR_REPORTER_CLEAR_RETURN: if(report && JSREPORT_IS_EXCEPTION(report->flags)) JS_ClearPendingException(cx); - return JS_FALSE; + return false; default: JS_ASSERT(0); break; } - return JS_TRUE; + return true; } JSBool jsd_SetErrorReporter(JSDContext* jsdc, JSD_ErrorReporter reporter, void* callerdata) { JSD_LOCK(); jsdc->errorReporter = reporter; jsdc->errorReporterData = callerdata; JSD_UNLOCK(); - return JS_TRUE; + return true; } JSBool jsd_GetErrorReporter(JSDContext* jsdc, JSD_ErrorReporter* reporter, void** callerdata) { JSD_LOCK(); if( reporter ) *reporter = jsdc->errorReporter; if( callerdata ) *callerdata = jsdc->errorReporterData; JSD_UNLOCK(); - return JS_TRUE; + return true; }
--- a/js/jsd/jsd_hook.cpp +++ b/js/jsd/jsd_hook.cpp @@ -170,17 +170,17 @@ jsd_CallCallHook (JSDContext* jsdc, JSContext *cx, unsigned type, JSD_CallHookProc hook, void* hookData) { JSBool hookanswer; JSDThreadState* jsdthreadstate; - hookanswer = JS_FALSE; + hookanswer = false; if(hook && NULL != (jsdthreadstate = jsd_NewThreadState(jsdc, cx))) { hookanswer = hook(jsdc, jsdthreadstate, type, hookData); jsd_DestroyThreadState(jsdc, jsdthreadstate); } return hookanswer; } @@ -191,137 +191,137 @@ jsd_SetInterruptHook(JSDContext* void* callerdata) { JSD_LOCK(); jsdc->interruptHookData = callerdata; jsdc->interruptHook = hook; JS_SetInterrupt(jsdc->jsrt, jsd_InterruptHandler, (void*) jsdc); JSD_UNLOCK(); - return JS_TRUE; + return true; } JSBool jsd_ClearInterruptHook(JSDContext* jsdc) { JSD_LOCK(); JS_ClearInterrupt(jsdc->jsrt, NULL, NULL ); jsdc->interruptHook = NULL; JSD_UNLOCK(); - return JS_TRUE; + return true; } JSBool jsd_SetDebugBreakHook(JSDContext* jsdc, JSD_ExecutionHookProc hook, void* callerdata) { JSD_LOCK(); jsdc->debugBreakHookData = callerdata; jsdc->debugBreakHook = hook; JSD_UNLOCK(); - return JS_TRUE; + return true; } JSBool jsd_ClearDebugBreakHook(JSDContext* jsdc) { JSD_LOCK(); jsdc->debugBreakHook = NULL; JSD_UNLOCK(); - return JS_TRUE; + return true; } JSBool jsd_SetDebuggerHook(JSDContext* jsdc, JSD_ExecutionHookProc hook, void* callerdata) { JSD_LOCK(); jsdc->debuggerHookData = callerdata; jsdc->debuggerHook = hook; JSD_UNLOCK(); - return JS_TRUE; + return true; } JSBool jsd_ClearDebuggerHook(JSDContext* jsdc) { JSD_LOCK(); jsdc->debuggerHook = NULL; JSD_UNLOCK(); - return JS_TRUE; + return true; } JSBool jsd_SetThrowHook(JSDContext* jsdc, JSD_ExecutionHookProc hook, void* callerdata) { JSD_LOCK(); jsdc->throwHookData = callerdata; jsdc->throwHook = hook; JSD_UNLOCK(); - return JS_TRUE; + return true; } JSBool jsd_ClearThrowHook(JSDContext* jsdc) { JSD_LOCK(); jsdc->throwHook = NULL; JSD_UNLOCK(); - return JS_TRUE; + return true; } JSBool jsd_SetFunctionHook(JSDContext* jsdc, JSD_CallHookProc hook, void* callerdata) { JSD_LOCK(); jsdc->functionHookData = callerdata; jsdc->functionHook = hook; JSD_UNLOCK(); - return JS_TRUE; + return true; } JSBool jsd_ClearFunctionHook(JSDContext* jsdc) { JSD_LOCK(); jsdc->functionHook = NULL; JSD_UNLOCK(); - return JS_TRUE; + return true; } JSBool jsd_SetTopLevelHook(JSDContext* jsdc, JSD_CallHookProc hook, void* callerdata) { JSD_LOCK(); jsdc->toplevelHookData = callerdata; jsdc->toplevelHook = hook; JSD_UNLOCK(); - return JS_TRUE; + return true; } JSBool jsd_ClearTopLevelHook(JSDContext* jsdc) { JSD_LOCK(); jsdc->toplevelHook = NULL; JSD_UNLOCK(); - return JS_TRUE; + return true; }
--- a/js/jsd/jsd_lock.cpp +++ b/js/jsd/jsd_lock.cpp @@ -144,19 +144,19 @@ jsd_Unlock(JSDStaticLock* lock) #ifdef DEBUG JSBool jsd_IsLocked(JSDStaticLock* lock) { void* me; ASSERT_VALID_LOCK(lock); _CURRENT_THREAD(me); if (lock->owner != me) - return JS_FALSE; + return false; JS_ASSERT(lock->count > 0); - return JS_TRUE; + return true; } #endif /* DEBUG */ void* jsd_CurrentThread() { void* me; _CURRENT_THREAD(me); @@ -192,17 +192,17 @@ void jsd_Unlock(void* lock) { } #ifdef DEBUG JSBool jsd_IsLocked(void* lock) { - return JS_TRUE; + return true; } #endif /* DEBUG */ /* * This Windows only thread id code is here to allow the Java-based * JSDebugger to work with the single threaded js.c shell (even without * real locking and threading support). */
--- a/js/jsd/jsd_scpt.cpp +++ b/js/jsd/jsd_scpt.cpp @@ -400,19 +400,19 @@ jsd_IsActiveScript(JSDContext* jsdc, JSD JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc)); for( current = (JSDScript *)jsdc->scripts.next; current != (JSDScript *)&jsdc->scripts; current = (JSDScript *)current->links.next ) { if(jsdscript == current) - return JS_TRUE; + return true; } - return JS_FALSE; + return false; } const char* jsd_GetScriptFilename(JSDContext* jsdc, JSDScript *jsdscript) { return jsdscript->url; } @@ -488,17 +488,17 @@ jsd_GetLinePCs(JSDContext* jsdc, JSDScri { unsigned first = jsdscript->lineBase; unsigned last = first + jsd_GetScriptLineExtent(jsdc, jsdscript) - 1; JSBool ok; jsbytecode **pcs; unsigned i; if (last < startLine) - return JS_TRUE; + return true; AutoSafeJSContext cx; JSAutoCompartment ac(cx, jsdscript->script); ok = JS_GetLinePCs(cx, jsdscript->script, startLine, maxLines, count, retLines, &pcs); @@ -517,29 +517,29 @@ jsd_GetLinePCs(JSDContext* jsdc, JSDScri JSBool jsd_SetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc hook, void* callerdata) { JSD_LOCK(); jsdc->scriptHook = hook; jsdc->scriptHookData = callerdata; JSD_UNLOCK(); - return JS_TRUE; + return true; } JSBool jsd_GetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc* hook, void** callerdata) { JSD_LOCK(); if( hook ) *hook = jsdc->scriptHook; if( callerdata ) *callerdata = jsdc->scriptHookData; JSD_UNLOCK(); - return JS_TRUE; + return true; } JSBool jsd_EnableSingleStepInterrupts(JSDContext* jsdc, JSDScript* jsdscript, JSBool enable) { JSBool rv; AutoSafeJSContext cx; JSAutoCompartment ac(cx, jsdscript->script); @@ -588,17 +588,17 @@ jsd_NewScriptHookProc( JSD_LOCK(); hook = jsdc->scriptHook; if( hook ) jsdscript->flags = jsdscript->flags | JSD_SCRIPT_CALL_DESTROY_HOOK_BIT; hookData = jsdc->scriptHookData; JSD_UNLOCK(); if( hook ) - hook(jsdc, jsdscript, JS_TRUE, hookData); + hook(jsdc, jsdscript, true, hookData); } void jsd_DestroyScriptHookProc( JSFreeOp *fop, JSScript *script_, void* callerdata ) { @@ -630,17 +630,17 @@ jsd_DestroyScriptHookProc( /* local in case hook gets cleared on another thread */ JSD_LOCK(); hook = (jsdscript->flags & JSD_SCRIPT_CALL_DESTROY_HOOK_BIT) ? jsdc->scriptHook : NULL; hookData = jsdc->scriptHookData; JSD_UNLOCK(); if( hook ) - hook(jsdc, jsdscript, JS_FALSE, hookData); + hook(jsdc, jsdscript, false, hookData); JSD_LOCK_SCRIPTS(jsdc); JS_HashTableRemove(jsdc->scriptsTable, (void *)script); JSD_UNLOCK_SCRIPTS(jsdc); #ifdef JSD_DUMP JSD_LOCK_SCRIPTS(jsdc); _dumpJSDScriptList(jsdc); @@ -674,33 +674,33 @@ static JSBool JSCList* list; JSDScript* jsdscript; JSD_LOCK_SCRIPTS(jsdc); jsdscript = jsd_FindJSDScript(jsdc, script); if( ! jsdscript) { JSD_UNLOCK_SCRIPTS(jsdc); - return JS_FALSE; + return false; } list = &jsdscript->hooks; for( current = (JSDExecHook*)list->next; current != (JSDExecHook*)list; current = (JSDExecHook*)current->links.next ) { if(current == jsdhook) { JSD_UNLOCK_SCRIPTS(jsdc); - return JS_TRUE; + return true; } } JSD_UNLOCK_SCRIPTS(jsdc); - return JS_FALSE; + return false; } JSTrapStatus jsd_TrapHandler(JSContext *cx, JSScript *script_, jsbytecode *pc, jsval *rval, jsval closure) { JS::RootedScript script(cx, script_); @@ -751,33 +751,33 @@ jsd_SetExecutionHook(JSDContext* JSDExecHook* jsdhook; JSBool rv; JSD_LOCK(); if( ! hook ) { jsd_ClearExecutionHook(jsdc, jsdscript, pc); JSD_UNLOCK(); - return JS_TRUE; + return true; } jsdhook = _findHook(jsdc, jsdscript, pc); if( jsdhook ) { jsdhook->hook = hook; jsdhook->callerdata = callerdata; JSD_UNLOCK(); - return JS_TRUE; + return true; } /* else... */ jsdhook = (JSDExecHook*)calloc(1, sizeof(JSDExecHook)); if( ! jsdhook ) { JSD_UNLOCK(); - return JS_FALSE; + return false; } jsdhook->jsdscript = jsdscript; jsdhook->pc = pc; jsdhook->hook = hook; jsdhook->callerdata = callerdata; { AutoSafeJSContext cx; @@ -785,53 +785,53 @@ jsd_SetExecutionHook(JSDContext* rv = JS_SetTrap(cx, jsdscript->script, (jsbytecode*)pc, jsd_TrapHandler, PRIVATE_TO_JSVAL(jsdhook)); } if ( ! rv ) { free(jsdhook); JSD_UNLOCK(); - return JS_FALSE; + return false; } JS_APPEND_LINK(&jsdhook->links, &jsdscript->hooks); JSD_UNLOCK(); - return JS_TRUE; + return true; } JSBool jsd_ClearExecutionHook(JSDContext* jsdc, JSDScript* jsdscript, uintptr_t pc) { JSDExecHook* jsdhook; JSD_LOCK(); jsdhook = _findHook(jsdc, jsdscript, pc); if( ! jsdhook ) { JSD_UNLOCK(); - return JS_FALSE; + return false; } { AutoSafeJSContext cx; JSAutoCompartment ac(cx, jsdscript->script); JS_ClearTrap(cx, jsdscript->script, (jsbytecode*)pc, NULL, NULL ); } JS_REMOVE_LINK(&jsdhook->links); free(jsdhook); JSD_UNLOCK(); - return JS_TRUE; + return true; } JSBool jsd_ClearAllExecutionHooksForScript(JSDContext* jsdc, JSDScript* jsdscript) { JSDExecHook* jsdhook; JSCList* list = &jsdscript->hooks; JSD_LOCK(); @@ -840,30 +840,30 @@ jsd_ClearAllExecutionHooksForScript(JSDC { JS_REMOVE_LINK(&jsdhook->links); free(jsdhook); } JS_ClearScriptTraps(jsdc->jsrt, jsdscript->script); JSD_UNLOCK(); - return JS_TRUE; + return true; } JSBool jsd_ClearAllExecutionHooks(JSDContext* jsdc) { JSDScript* jsdscript; JSDScript* iterp = NULL; JSD_LOCK(); while( NULL != (jsdscript = jsd_IterateScripts(jsdc, &iterp)) ) jsd_ClearAllExecutionHooksForScript(jsdc, jsdscript); JSD_UNLOCK(); - return JS_TRUE; + return true; } void jsd_ScriptCreated(JSDContext* jsdc, JSContext *cx, const char *filename, /* URL this script loads from */ unsigned lineno, /* line where this script starts */ JSScript *script,
--- a/js/jsd/jsd_stak.cpp +++ b/js/jsd/jsd_stak.cpp @@ -356,34 +356,34 @@ jsd_GetIdForStackFrame(JSDContext* jsdc, return rv; } JSBool jsd_IsStackFrameDebugger(JSDContext* jsdc, JSDThreadState* jsdthreadstate, JSDStackFrameInfo* jsdframe) { - JSBool rv = JS_TRUE; + JSBool rv = true; JSD_LOCK_THREADSTATES(jsdc); if( jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) ) { rv = jsdframe->frame.isDebuggerFrame(); } JSD_UNLOCK_THREADSTATES(jsdc); return rv; } JSBool jsd_IsStackFrameConstructing(JSDContext* jsdc, JSDThreadState* jsdthreadstate, JSDStackFrameInfo* jsdframe) { - JSBool rv = JS_TRUE; + JSBool rv = true; JSD_LOCK_THREADSTATES(jsdc); if( jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) ) { rv = jsdframe->isConstructing; } JSD_UNLOCK_THREADSTATES(jsdc); @@ -404,17 +404,17 @@ jsd_EvaluateUCScriptInStackFrame(JSDCont JS_ASSERT(JSD_CURRENT_THREAD() == jsdthreadstate->thread); JSD_LOCK_THREADSTATES(jsdc); valid = jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe); JSD_UNLOCK_THREADSTATES(jsdc); if( ! valid ) - return JS_FALSE; + return false; AutoPushJSContext cx(jsdthreadstate->context); JS_ASSERT(cx); if (eatExceptions) exceptionState = JS_SaveExceptionState(cx); JS_ClearPendingException(cx); jsd_StartingEvalUsingFilename(jsdc, filename); @@ -441,17 +441,17 @@ jsd_EvaluateScriptInStackFrame(JSDContex JS_ASSERT(JSD_CURRENT_THREAD() == jsdthreadstate->thread); JSD_LOCK_THREADSTATES(jsdc); valid = jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe); JSD_UNLOCK_THREADSTATES(jsdc); if (!valid) - return JS_FALSE; + return false; AutoPushJSContext cx(jsdthreadstate->context); JS_ASSERT(cx); if (eatExceptions) exceptionState = JS_SaveExceptionState(cx); JS_ClearPendingException(cx); jsd_StartingEvalUsingFilename(jsdc, filename); @@ -500,37 +500,37 @@ jsd_IsValidThreadState(JSDContext* JS_ASSERT( JSD_THREADSTATES_LOCKED(jsdc) ); for( cur = (JSDThreadState*)jsdc->threadsStates.next; cur != (JSDThreadState*)&jsdc->threadsStates; cur = (JSDThreadState*)cur->links.next ) { if( cur == jsdthreadstate ) - return JS_TRUE; + return true; } - return JS_FALSE; + return false; } JSBool jsd_IsValidFrameInThreadState(JSDContext* jsdc, JSDThreadState* jsdthreadstate, JSDStackFrameInfo* jsdframe) { JS_ASSERT(JSD_THREADSTATES_LOCKED(jsdc)); if( ! jsd_IsValidThreadState(jsdc, jsdthreadstate) ) - return JS_FALSE; + return false; if( jsdframe->jsdthreadstate != jsdthreadstate ) - return JS_FALSE; + return false; JSD_ASSERT_VALID_THREAD_STATE(jsdthreadstate); JSD_ASSERT_VALID_STACK_FRAME(jsdframe); - return JS_TRUE; + return true; } static JSContext* _getContextForThreadState(JSDContext* jsdc, JSDThreadState* jsdthreadstate) { JSBool valid; JSD_LOCK_THREADSTATES(jsdc); valid = jsd_IsValidThreadState(jsdc, jsdthreadstate); @@ -556,17 +556,17 @@ jsd_GetException(JSDContext* jsdc, JSDTh JSBool jsd_SetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate, JSDValue* jsdval) { JSContext* cx; if(!(cx = _getContextForThreadState(jsdc, jsdthreadstate))) - return JS_FALSE; + return false; if(jsdval) JS_SetPendingException(cx, JSD_GetValueWrappedJSVal(jsdc, jsdval)); else JS_ClearPendingException(cx); - return JS_TRUE; + return true; }
--- a/js/jsd/jsd_step.cpp +++ b/js/jsd/jsd_step.cpp @@ -77,33 +77,33 @@ static void #endif JSBool _callHook(JSDContext *jsdc, JSContext *cx, JSAbstractFramePtr frame, bool isConstructing, JSBool before, unsigned type, JSD_CallHookProc hook, void *hookData) { JSDScript* jsdscript; JSScript* jsscript; - JSBool hookresult = JS_TRUE; + JSBool hookresult = true; if (!jsdc || !jsdc->inited) - return JS_FALSE; + return false; if (!hook && !(jsdc->flags & JSD_COLLECT_PROFILE_DATA)) { /* no hook to call, no profile data needs to be collected, * so there is nothing to do here. */ return hookresult; } if (before && isConstructing) { JS::RootedValue newObj(cx); if (!frame.getThisValue(cx, &newObj)) - return JS_FALSE; + return false; jsd_Constructing(jsdc, cx, JSVAL_TO_OBJECT(newObj), frame); } jsscript = frame.script(); if (jsscript) { JSD_LOCK_SCRIPTS(jsdc); jsdscript = jsd_FindOrCreateJSDScript(jsdc, cx, jsscript, frame); @@ -148,17 +148,17 @@ JSBool * called!), and we'll need the call start time. */ pdata->runningTime = 0; pdata->lastCallStart = now; } else { if (++pdata->recurseDepth > pdata->maxRecurseDepth) pdata->maxRecurseDepth = pdata->recurseDepth; } /* make sure we're called for the return too. */ - hookresult = JS_TRUE; + hookresult = true; } else if (!pdata->recurseDepth && pdata->lastCallStart) { int64_t now, ll_delta; double delta; now = JS_Now(); ll_delta = now - pdata->lastCallStart; delta = ll_delta; delta /= 1000.0; pdata->totalExecutionTime += delta; @@ -213,24 +213,24 @@ JSBool } if (hook) jsd_CallCallHook (jsdc, cx, type, hook, hookData); } else { if (hook) hookresult = jsd_CallCallHook (jsdc, cx, type, hook, hookData); else - hookresult = JS_TRUE; + hookresult = true; } } } #ifdef JSD_TRACE _interpreterTrace(jsdc, cx, frame, isConstructing, before); - return JS_TRUE; + return true; #else return hookresult; #endif } void * jsd_FunctionCallHook(JSContext *cx, JSAbstractFramePtr frame, bool isConstructing,
--- a/js/jsd/jsd_text.cpp +++ b/js/jsd/jsd_text.cpp @@ -26,19 +26,19 @@ static void _clearText(JSDContext* jsdc, JSDSourceText* jsdsrc) { if( jsdsrc->text ) free(jsdsrc->text); jsdsrc->text = NULL; jsdsrc->textLength = 0; jsdsrc->textSpace = 0; jsdsrc->status = JSD_SOURCE_CLEARED; - jsdsrc->dirty = JS_TRUE; + jsdsrc->dirty = true; jsdsrc->alterCount = jsdc->sourceAlterCount++ ; - jsdsrc->doingEval = JS_FALSE; + jsdsrc->doingEval = false; } static JSBool _appendText(JSDContext* jsdc, JSDSourceText* jsdsrc, const char* text, size_t length) { #define MEMBUF_GROW 1000 @@ -61,39 +61,39 @@ static JSBool /* try again with the minimal size really asked for */ iNewSize = neededSize; newBuf = (char*) realloc(jsdsrc->text, iNewSize); if( ! newBuf ) { /* out of memory */ _clearText( jsdc, jsdsrc ); jsdsrc->status = JSD_SOURCE_FAILED; - return JS_FALSE; + return false; } } jsdsrc->text = newBuf; jsdsrc->textSpace = iNewSize; } memcpy(jsdsrc->text + jsdsrc->textLength, text, length); jsdsrc->textLength += length; - return JS_TRUE; + return true; } static JSDSourceText* _newSource(JSDContext* jsdc, char* url) { JSDSourceText* jsdsrc = (JSDSourceText*)calloc(1,sizeof(JSDSourceText)); if( ! jsdsrc ) return NULL; jsdsrc->url = url; jsdsrc->status = JSD_SOURCE_INITED; - jsdsrc->dirty = JS_TRUE; + jsdsrc->dirty = true; jsdsrc->alterCount = jsdc->sourceAlterCount++ ; return jsdsrc; } static void _destroySource(JSDContext* jsdc, JSDSourceText* jsdsrc) { @@ -140,19 +140,19 @@ static JSBool { JSDSourceText *jsdsrc; for( jsdsrc = (JSDSourceText*)jsdc->sources.next; jsdsrc != (JSDSourceText*)&jsdc->sources; jsdsrc = (JSDSourceText*)jsdsrc->links.next ) { if( jsdsrc == jsdsrcToFind ) - return JS_TRUE; + return true; } - return JS_FALSE; + return false; } /* compare strings in a case insensitive manner with a length limit */ static int strncasecomp (const char* one, const char * two, int n) { @@ -256,17 +256,17 @@ jsd_GetSourceURL(JSDContext* jsdc, JSDSo } JSBool jsd_GetSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc, const char** ppBuf, int* pLen ) { *ppBuf = jsdsrc->text; *pLen = jsdsrc->textLength; - return JS_TRUE; + return true; } void jsd_ClearSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc) { if( JSD_SOURCE_INITED != jsdsrc->status && JSD_SOURCE_PARTIAL != jsdsrc->status ) { @@ -389,25 +389,25 @@ jsd_AppendSourceText(JSDContext* jsdc, { _removeSourceFromRemovedList( jsdc, jsdsrc ); JSD_UNLOCK_SOURCE_TEXT(jsdc); return NULL; } if( text && length && ! _appendText( jsdc, jsdsrc, text, length ) ) { - jsdsrc->dirty = JS_TRUE; + jsdsrc->dirty = true; jsdsrc->alterCount = jsdc->sourceAlterCount++ ; jsdsrc->status = JSD_SOURCE_FAILED; _moveSourceToRemovedList(jsdc, jsdsrc); JSD_UNLOCK_SOURCE_TEXT(jsdc); return NULL; } - jsdsrc->dirty = JS_TRUE; + jsdsrc->dirty = true; jsdsrc->alterCount = jsdc->sourceAlterCount++ ; jsdsrc->status = status; DEBUG_ITERATE_SOURCES(jsdc); JSD_UNLOCK_SOURCE_TEXT(jsdc); return jsdsrc; } JSDSourceText* @@ -467,17 +467,17 @@ jsd_AddFullSourceText(JSDContext* jsdc, jsdsrc = jsd_AppendSourceText(jsdc, jsdsrc, text, length, JSD_SOURCE_PARTIAL ); if( jsdsrc ) jsdsrc = jsd_AppendSourceText(jsdc, jsdsrc, NULL, 0, JSD_SOURCE_COMPLETED ); JSD_UNLOCK_SOURCE_TEXT(jsdc); - return jsdsrc ? JS_TRUE : JS_FALSE; + return jsdsrc ? true : false; } /***************************************************************************/ void jsd_StartingEvalUsingFilename(JSDContext* jsdc, const char* url) { JSDSourceText* jsdsrc; @@ -488,17 +488,17 @@ jsd_StartingEvalUsingFilename(JSDContext jsdsrc = jsd_FindSourceForURL(jsdc, url); if(jsdsrc) { #if 0 #ifndef JSD_LOWLEVEL_SOURCE JS_ASSERT(! jsdsrc->doingEval); #endif #endif - jsdsrc->doingEval = JS_TRUE; + jsdsrc->doingEval = true; } } void jsd_FinishedEvalUsingFilename(JSDContext* jsdc, const char* url) { JSDSourceText* jsdsrc; @@ -512,13 +512,13 @@ jsd_FinishedEvalUsingFilename(JSDContext /* * when using this low level source addition, this jsdsrc might * not have existed before the eval, but does exist now (without * this flag set!) */ JS_ASSERT(jsdsrc->doingEval); #endif #endif - jsdsrc->doingEval = JS_FALSE; + jsdsrc->doingEval = false; } JSD_UNLOCK_SOURCE_TEXT(jsdc); }
--- a/js/jsd/jsd_val.cpp +++ b/js/jsd/jsd_val.cpp @@ -124,34 +124,34 @@ jsd_IsValueNative(JSDContext* jsdc, JSDV { AutoSafeJSContext cx; JS::RootedFunction fun(cx); if(jsd_IsValueFunction(jsdc, jsdval)) { JSAutoCompartment ac(cx, JSVAL_TO_OBJECT(jsdval->val)); AutoSaveExceptionState as(cx); - JSBool ok = JS_FALSE; + JSBool ok = false; fun = JSD_GetValueFunction(jsdc, jsdval); if(fun) - ok = JS_GetFunctionScript(cx, fun) ? JS_FALSE : JS_TRUE; + ok = JS_GetFunctionScript(cx, fun) ? false : true; JS_ASSERT(fun); return ok; } return !JSVAL_IS_PRIMITIVE(jsdval->val); } /***************************************************************************/ JSBool jsd_GetValueBoolean(JSDContext* jsdc, JSDValue* jsdval) { jsval val = jsdval->val; if(!JSVAL_IS_BOOLEAN(val)) - return JS_FALSE; + return false; return JSVAL_TO_BOOLEAN(val); } int32_t jsd_GetValueInt(JSDContext* jsdc, JSDValue* jsdval) { jsval val = jsdval->val; if(!JSVAL_IS_INT(val)) @@ -249,17 +249,17 @@ jsd_NewValue(JSDContext* jsdc, jsval val if(JSVAL_IS_GCTHING(val)) { JSBool ok; JSAutoCompartment ac(cx, jsdc->glob); ok = JS_AddNamedValueRoot(cx, &jsdval->val, "JSDValue"); if(ok && JSVAL_IS_STRING(val)) { if(!JS_WrapValue(cx, val.address())) { - ok = JS_FALSE; + ok = false; } } if(!ok) { free(jsdval); return NULL; } @@ -358,25 +358,25 @@ static JSBool _buildProps(JSDContext* js JSPropertyDescArray pda; unsigned i; JS_ASSERT(JS_CLIST_IS_EMPTY(&jsdval->props)); JS_ASSERT(!(CHECK_BIT_FLAG(jsdval->flags, GOT_PROPS))); JS_ASSERT(!JSVAL_IS_PRIMITIVE(jsdval->val)); if(JSVAL_IS_PRIMITIVE(jsdval->val)) - return JS_FALSE; + return false; obj = JSVAL_TO_OBJECT(jsdval->val); JSAutoCompartment ac(cx, obj); if(!JS_GetPropertyDescArray(cx, obj, &pda)) { - return JS_FALSE; + return false; } for(i = 0; i < pda.length; i++) { JSDProperty* prop = _newProperty(jsdc, &pda.array[i], 0); if(!prop) { _freeProps(jsdc, jsdval);
--- a/js/jsd/jsd_xpc.cpp +++ b/js/jsd/jsd_xpc.cpp @@ -555,30 +555,30 @@ jsds_CallHookProc (JSDContext* jsdc, JSD gJsds->GetFunctionHook(getter_AddRefs(hook)); break; default: NS_ASSERTION (0, "Unknown hook type."); } if (!hook) - return JS_TRUE; + return true; if (!jsds_FilterHook (jsdc, jsdthreadstate)) - return JS_FALSE; + return false; JSDStackFrameInfo *native_frame = JSD_GetStackFrame (jsdc, jsdthreadstate); nsCOMPtr<jsdIStackFrame> frame = dont_AddRef(jsdStackFrame::FromPtr(jsdc, jsdthreadstate, native_frame)); gJsds->DoPause(nullptr, true); hook->OnCall(frame, type); gJsds->DoUnPause(nullptr, true); jsdStackFrame::InvalidateAll(); - return JS_TRUE; + return true; } static uint32_t jsds_ExecutionHookProc (JSDContext* jsdc, JSDThreadState* jsdthreadstate, unsigned type, void* callerdata, jsval* rval) { nsCOMPtr<jsdIExecutionHook> hook(0); uint32_t hook_rv = JSD_HOOK_RETURN_CONTINUE;
--- a/js/jsd/jsdebug.cpp +++ b/js/jsd/jsdebug.cpp @@ -33,17 +33,17 @@ JSD_DebuggerOff(JSDContext* jsdc) JSD_ASSERT_VALID_CONTEXT(jsdc); jsd_DebuggerOff(jsdc); } JSD_PUBLIC_API(void) JSD_DebuggerPause(JSDContext* jsdc) { JSD_ASSERT_VALID_CONTEXT(jsdc); - jsd_DebuggerPause(jsdc, JS_FALSE); + jsd_DebuggerPause(jsdc, false); } JSD_PUBLIC_API(void) JSD_DebuggerUnpause(JSDContext* jsdc) { JSD_ASSERT_VALID_CONTEXT(jsdc); jsd_DebuggerUnpause(jsdc); } @@ -770,17 +770,17 @@ JSD_EvaluateUCScriptInStackFrame(JSDCont { JSD_ASSERT_VALID_CONTEXT(jsdc); JS_ASSERT(bytes); JS_ASSERT(length); JS_ASSERT(filename); return jsd_EvaluateUCScriptInStackFrame(jsdc, jsdthreadstate,jsdframe, bytes, length, filename, lineno, - JS_TRUE, rval); + true, rval); } JSD_PUBLIC_API(JSBool) JSD_AttemptUCScriptInStackFrame(JSDContext* jsdc, JSDThreadState* jsdthreadstate, JSDStackFrameInfo* jsdframe, const jschar *bytes, unsigned length, const char *filename, unsigned lineno, @@ -788,51 +788,51 @@ JSD_AttemptUCScriptInStackFrame(JSDConte { JSD_ASSERT_VALID_CONTEXT(jsdc); JS_ASSERT(bytes); JS_ASSERT(length); JS_ASSERT(filename); return jsd_EvaluateUCScriptInStackFrame(jsdc, jsdthreadstate,jsdframe, bytes, length, filename, lineno, - JS_FALSE, rval); + false, rval); } JSD_PUBLIC_API(JSBool) JSD_EvaluateScriptInStackFrame(JSDContext* jsdc, JSDThreadState* jsdthreadstate, JSDStackFrameInfo* jsdframe, const char *bytes, unsigned length, const char *filename, unsigned lineno, JS::MutableHandleValue rval) { JSD_ASSERT_VALID_CONTEXT(jsdc); JS_ASSERT(bytes); JS_ASSERT(length); JS_ASSERT(filename); return jsd_EvaluateScriptInStackFrame(jsdc, jsdthreadstate,jsdframe, bytes, length, - filename, lineno, JS_TRUE, rval); + filename, lineno, true, rval); } JSD_PUBLIC_API(JSBool) JSD_AttemptScriptInStackFrame(JSDContext* jsdc, JSDThreadState* jsdthreadstate, JSDStackFrameInfo* jsdframe, const char *bytes, unsigned length, const char *filename, unsigned lineno, JS::MutableHandleValue rval) { JSD_ASSERT_VALID_CONTEXT(jsdc); JS_ASSERT(bytes); JS_ASSERT(length); JS_ASSERT(filename); return jsd_EvaluateScriptInStackFrame(jsdc, jsdthreadstate,jsdframe, bytes, length, - filename, lineno, JS_FALSE, rval); + filename, lineno, false, rval); } JSD_PUBLIC_API(JSString*) JSD_ValToStringInStackFrame(JSDContext* jsdc, JSDThreadState* jsdthreadstate, JSDStackFrameInfo* jsdframe, jsval val) { @@ -876,19 +876,19 @@ JSD_GetErrorReporter(JSDContext* } /***************************************************************************/ JSD_PUBLIC_API(JSBool) JSD_IsLockingAndThreadIdSupported() { #ifdef JSD_THREADSAFE - return JS_TRUE; + return true; #else - return JS_FALSE; + return false; #endif } JSD_PUBLIC_API(JSDStaticLock*) JSD_CreateLock() { #ifdef JSD_THREADSAFE return jsd_CreateLock(); @@ -914,27 +914,27 @@ JSD_Unlock(JSDStaticLock* lock) } JSD_PUBLIC_API(JSBool) JSD_IsLocked(JSDStaticLock* lock) { #if defined(JSD_THREADSAFE) && defined(DEBUG) return jsd_IsLocked(lock); #else - return JS_TRUE; + return true; #endif } JSD_PUBLIC_API(JSBool) JSD_IsUnlocked(JSDStaticLock* lock) { #if defined(JSD_THREADSAFE) && defined(DEBUG) return ! jsd_IsLocked(lock); #else - return JS_TRUE; + return true; #endif } JSD_PUBLIC_API(void*) JSD_CurrentThread() { return JSD_CURRENT_THREAD(); }
--- a/js/jsd/jsdebug.h +++ b/js/jsd/jsdebug.h @@ -413,17 +413,17 @@ JSD_GetScriptBaseLineNumber(JSDContext* /* * Get the count of source lines associated with this script (1 or greater) */ extern JSD_PUBLIC_API(unsigned) JSD_GetScriptLineExtent(JSDContext* jsdc, JSDScript *jsdscript); /* * Declaration of callback for notification of script creation and destruction. -* 'creating' is JS_TRUE if creating new script, JS_FALSE if destroying existing +* 'creating' is true if creating new script, false if destroying existing * script (callback called just before actual destruction). * 'callerdata' is what was passed to JSD_SetScriptHook to set the hook. */ typedef void (* JSD_ScriptHookProc)(JSDContext* jsdc, JSDScript* jsdscript, JSBool creating, void* callerdata); @@ -678,17 +678,17 @@ JSD_AppendUCSourceText(JSDContext* j * jsdsrc = jsd_NewSourceText(jsdc, url); * if(jsdsrc) * jsdsrc = jsd_AppendSourceText(jsdc, jsdsrc, * text, length, JSD_SOURCE_PARTIAL); * if(jsdsrc) * jsdsrc = jsd_AppendSourceText(jsdc, jsdsrc, * NULL, 0, JSD_SOURCE_COMPLETED); * JSD_UNLOCK_SOURCE_TEXT(jsdc); - * return jsdsrc ? JS_TRUE : JS_FALSE; + * return jsdsrc ? true : false; */ extern JSD_PUBLIC_API(JSBool) JSD_AddFullSourceText(JSDContext* jsdc, const char* text, /* *not* zero terminated */ size_t length, const char* url); /***************************************************************************/ @@ -722,17 +722,17 @@ typedef unsigned /* possible 'type' params for JSD_CallHookProc */ #define JSD_HOOK_TOPLEVEL_START 0 /* about to evaluate top level script */ #define JSD_HOOK_TOPLEVEL_END 1 /* done evaluting top level script */ #define JSD_HOOK_FUNCTION_CALL 2 /* about to call a function */ #define JSD_HOOK_FUNCTION_RETURN 3 /* done calling function */ /* * Implement a callback of this form in order to hook function call/returns. -* Return JS_TRUE from a TOPLEVEL_START or FUNCTION_CALL type call hook if you +* Return true from a TOPLEVEL_START or FUNCTION_CALL type call hook if you * want to hear about the TOPLEVEL_END or FUNCTION_RETURN too. Return value is * ignored to TOPLEVEL_END and FUNCTION_RETURN type hooks. */ typedef JSBool (* JSD_CallHookProc)(JSDContext* jsdc, JSDThreadState* jsdthreadstate, unsigned type, void* callerdata); @@ -960,17 +960,17 @@ JSD_IsStackFrameDebugger(JSDContext* jsd */ extern JSD_PUBLIC_API(JSBool) JSD_IsStackFrameConstructing(JSDContext* jsdc, JSDThreadState* jsdthreadstate, JSDStackFrameInfo* jsdframe); /* * Evaluate the given unicode source code in the context of the given stack frame. -* returns JS_TRUE and puts result in rval on success, JS_FALSE on failure. +* returns true and puts result in rval on success, false on failure. * NOTE: The ErrorReporter hook might be called if this fails. */ extern JSD_PUBLIC_API(JSBool) JSD_EvaluateUCScriptInStackFrame(JSDContext* jsdc, JSDThreadState* jsdthreadstate, JSDStackFrameInfo* jsdframe, const jschar *bytes, unsigned length, const char *filename, unsigned lineno, @@ -1094,17 +1094,17 @@ JSD_Lock(JSDStaticLock* lock); /* * Release lock for this thread (or decrement the counter if JSD_Lock * was previous called more than once). */ extern JSD_PUBLIC_API(void) JSD_Unlock(JSDStaticLock* lock); /* -* For debugging only if not (JS_THREADSAFE AND DEBUG) then returns JS_TRUE +* For debugging only if not (JS_THREADSAFE AND DEBUG) then returns true * So JSD_IsLocked(lock) may not equal !JSD_IsUnlocked(lock) */ extern JSD_PUBLIC_API(JSBool) JSD_IsLocked(JSDStaticLock* lock); /* * See above... */ @@ -1359,17 +1359,17 @@ JSD_GetScriptForValue(JSDContext* jsdc, * XXX these must stay the same as the JSPD_ flags in jsdbgapi.h */ #define JSDPD_ENUMERATE JSPD_ENUMERATE /* visible to for/in loop */ #define JSDPD_READONLY JSPD_READONLY /* assignment is error */ #define JSDPD_PERMANENT JSPD_PERMANENT /* property cannot be deleted */ #define JSDPD_ALIAS JSPD_ALIAS /* property has an alias id */ #define JSDPD_EXCEPTION JSPD_EXCEPTION /* exception occurred looking up */ /* proprety, value is exception */ -#define JSDPD_ERROR JSPD_ERROR /* native getter returned JS_FALSE */ +#define JSDPD_ERROR JSPD_ERROR /* native getter returned false */ /* without throwing an exception */ /* this is not one of the JSPD_ flags in jsdbgapi.h - careful not to overlap*/ #define JSDPD_HINTED 0x800 /* found via explicit lookup */ /* * Release this JSDProperty * *** new for version 1.1 **** */
--- a/js/jsd/jshash.cpp +++ b/js/jsd/jshash.cpp @@ -174,24 +174,24 @@ Resize(JSHashTable *ht, uint32_t newshif size_t nold = NBUCKETS(ht); JS_ASSERT(newshift < JS_HASH_BITS); nb = (size_t)1 << (JS_HASH_BITS - newshift); /* Integer overflow protection. */ if (nb > (size_t)-1 / sizeof(JSHashEntry*)) - return JS_FALSE; + return false; nb *= sizeof(JSHashEntry*); oldbuckets = ht->buckets; ht->buckets = (JSHashEntry**)ht->allocOps->allocTable(ht->allocPriv, nb); if (!ht->buckets) { ht->buckets = oldbuckets; - return JS_FALSE; + return false; } memset(ht->buckets, 0, nb); ht->shift = newshift; nentries = ht->nentries; for (i = 0; nentries != 0; i++) { for (he = oldbuckets[i]; he; he = next) { @@ -210,17 +210,17 @@ Resize(JSHashTable *ht, uint32_t newshif *hep = he; } } #ifdef DEBUG memset(oldbuckets, 0xDB, nold * sizeof oldbuckets[0]); #endif ht->allocOps->freeTable(ht->allocPriv, oldbuckets, nold * sizeof oldbuckets[0]); - return JS_TRUE; + return true; } JSHashEntry * JS_HashTableRawAdd(JSHashTable *ht, JSHashEntry **&hep, JSHashNumber keyHash, const void *key, void *value) { uint32_t n; JSHashEntry *he; @@ -293,21 +293,21 @@ JSBool JS_HashTableRemove(JSHashTable *ht, const void *key) { JSHashNumber keyHash; JSHashEntry *he, **hep; keyHash = ht->keyHash(key); hep = JS_HashTableRawLookup(ht, keyHash, key); if ((he = *hep) == NULL) - return JS_FALSE; + return false; /* Hit; remove element */ JS_HashTableRawRemove(ht, hep, he); - return JS_TRUE; + return true; } void * JS_HashTableLookup(JSHashTable *ht, const void *key) { JSHashNumber keyHash; JSHashEntry *he, **hep;
--- a/js/public/Value.h +++ b/js/public/Value.h @@ -432,17 +432,17 @@ JSVAL_TO_BOOLEAN_IMPL(jsval_layout l) { return l.s.payload.boo; } static inline jsval_layout BOOLEAN_TO_JSVAL_IMPL(JSBool b) { jsval_layout l; - MOZ_ASSERT(b == JS_TRUE || b == JS_FALSE); + MOZ_ASSERT(b == JS_TRUE_DEPRECATED || b == JS_FALSE_DEPRECATED); l.s.tag = JSVAL_TAG_BOOLEAN; l.s.payload.boo = b; return l; } static inline JSBool JSVAL_IS_MAGIC_IMPL(jsval_layout l) { @@ -659,17 +659,17 @@ JSVAL_TO_BOOLEAN_IMPL(jsval_layout l) { return (JSBool)l.asBits; } static inline jsval_layout BOOLEAN_TO_JSVAL_IMPL(JSBool b) { jsval_layout l; - MOZ_ASSERT(b == JS_TRUE || b == JS_FALSE); + MOZ_ASSERT(b == JS_TRUE_DEPRECATED || b == JS_FALSE_DEPRECATED); l.asBits = ((uint64_t)(uint32_t)b) | JSVAL_SHIFTED_TAG_BOOLEAN; return l; } static inline JSBool JSVAL_IS_MAGIC_IMPL(jsval_layout l) { return (l.asBits >> JSVAL_TAG_SHIFT) == JSVAL_TAG_MAGIC;
--- a/js/src/builtin/Profilers.cpp +++ b/js/src/builtin/Profilers.cpp @@ -72,54 +72,54 @@ StartOSXProfiling(const char *profileNam } return true; } #endif JS_PUBLIC_API(JSBool) JS_StartProfiling(const char *profileName) { - JSBool ok = JS_TRUE; + JSBool ok = true; #ifdef __APPLE__ ok = StartOSXProfiling(profileName); #endif #ifdef __linux__ if (!js_StartPerf()) - ok = JS_FALSE; + ok = false; #endif return ok; } JS_PUBLIC_API(JSBool) JS_StopProfiling(const char *profileName) { - JSBool ok = JS_TRUE; + JSBool ok = true; #ifdef __APPLE__ #ifdef MOZ_SHARK Shark::Stop(); #endif #ifdef MOZ_INSTRUMENTS Instruments::Stop(profileName); #endif #endif #ifdef __linux__ if (!js_StopPerf()) - ok = JS_FALSE; + ok = false; #endif return ok; } /* * Start or stop whatever platform- and configuration-specific profiling * backends are available. */ static JSBool ControlProfilers(bool toState) { - JSBool ok = JS_TRUE; + JSBool ok = true; if (! Probes::ProfilingActive && toState) { #ifdef __APPLE__ #if defined(MOZ_SHARK) || defined(MOZ_INSTRUMENTS) const char* profiler; #ifdef MOZ_SHARK ok = Shark::Start(); profiler = "Shark"; @@ -131,32 +131,32 @@ ControlProfilers(bool toState) if (!ok) { UnsafeError("Failed to start %s", profiler); } #endif #endif #ifdef MOZ_CALLGRIND if (! js_StartCallgrind()) { UnsafeError("Failed to start Callgrind"); - ok = JS_FALSE; + ok = false; } #endif } else if (Probes::ProfilingActive && ! toState) { #ifdef __APPLE__ #ifdef MOZ_SHARK Shark::Stop(); #endif #ifdef MOZ_INSTRUMENTS Instruments::Pause(); #endif #endif #ifdef MOZ_CALLGRIND if (! js_StopCallgrind()) { UnsafeError("failed to stop Callgrind"); - ok = JS_FALSE; + ok = false; } #endif } Probes::ProfilingActive = toState; return ok; } @@ -179,17 +179,17 @@ JS_PUBLIC_API(JSBool) JS_ResumeProfilers(const char *profileName) { return ControlProfilers(true); } JS_PUBLIC_API(JSBool) JS_DumpProfile(const char *outfile, const char *profileName) { - JSBool ok = JS_TRUE; + JSBool ok = true; #ifdef MOZ_CALLGRIND js_DumpCallgrind(outfile); #endif return ok; } #ifdef MOZ_PROFILING
--- a/js/src/ctypes/CTypes.cpp +++ b/js/src/ctypes/CTypes.cpp @@ -1532,17 +1532,17 @@ static JS_ALWAYS_INLINE bool IsNegative( } // Implicitly convert val to bool, allowing JSBool, int, and double // arguments numerically equal to 0 or 1. static bool jsvalToBool(JSContext* cx, jsval val, bool* result) { if (JSVAL_IS_BOOLEAN(val)) { - *result = JSVAL_TO_BOOLEAN(val) != JS_FALSE; + *result = JSVAL_TO_BOOLEAN(val); return true; } if (JSVAL_IS_INT(val)) { int32_t i = JSVAL_TO_INT(val); *result = i != 0; return i == 0 || i == 1; } if (JSVAL_IS_DOUBLE(val)) { @@ -2221,17 +2221,17 @@ ImplicitConvert(JSContext* cx, sourceType = CDataFinalizer::GetCType(cx, sourceData); CDataFinalizer::Private *p = (CDataFinalizer::Private *) JS_GetPrivate(sourceData); if (!p) { // We have called |dispose| or |forget| already. JS_ReportError(cx, "Attempting to convert an empty CDataFinalizer"); - return JS_FALSE; + return false; } // If the types are equal, copy the buffer contained within the CData. if (CType::TypesEqual(sourceType, targetType)) { memmove(buffer, p->cargs, p->cargs_size); return true; } } @@ -2598,17 +2598,17 @@ ExplicitConvert(JSContext* cx, HandleVal TypeCode type = CType::GetTypeCode(targetType); switch (type) { case TYPE_bool: { // Convert according to the ECMAScript ToBoolean() function. JSBool result; ASSERT_OK(JS_ValueToBoolean(cx, val, &result)); - *static_cast<bool*>(buffer) = result != JS_FALSE; + *static_cast<bool*>(buffer) = result != false; break; } #define DEFINE_INT_TYPE(name, type, ffiType) \ case TYPE_##name: { \ /* Convert numeric values with a C-style cast, and */ \ /* allow conversion from a base-10 or base-16 string. */ \ type result; \ if (!jsvalToIntegerExplicit(val, &result) && \ @@ -3118,31 +3118,31 @@ CType::ConstructData(JSContext* cx, JSBool CType::ConstructBasic(JSContext* cx, HandleObject obj, const CallArgs& args) { if (args.length() > 1) { JS_ReportError(cx, "CType constructor takes zero or one argument"); - return JS_FALSE; + return false; } // construct a CData object RootedObject result(cx, CData::Create(cx, obj, NullPtr(), NULL, true)); if (!result) - return JS_FALSE; + return false; if (args.length() == 1) { if (!ExplicitConvert(cx, args[0], obj, CData::GetData(result))) - return JS_FALSE; + return false; } args.rval().setObject(*result); - return JS_TRUE; + return true; } JSObject* CType::Create(JSContext* cx, HandleObject typeProto, HandleObject dataProto, TypeCode type, JSString* name_, @@ -3591,69 +3591,69 @@ CType::GetProtoFromType(JSContext* cx, J return JSVAL_TO_OBJECT(result); } JSBool CType::PrototypeGetter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandleValue vp) { if (!(CType::IsCType(obj) || CType::IsCTypeProto(obj))) { JS_ReportError(cx, "not a CType or CTypeProto"); - return JS_FALSE; + return false; } unsigned slot = CType::IsCTypeProto(obj) ? (unsigned) SLOT_OURDATAPROTO : (unsigned) SLOT_PROTO; vp.set(JS_GetReservedSlot(obj, slot)); JS_ASSERT(!JSVAL_IS_PRIMITIVE(vp) || JSVAL_IS_VOID(vp)); - return JS_TRUE; + return true; } JSBool CType::NameGetter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandleValue vp) { if (!CType::IsCType(obj)) { JS_ReportError(cx, "not a CType"); - return JS_FALSE; + return false; } JSString* name = CType::GetName(cx, obj); if (!name) - return JS_FALSE; + return false; vp.setString(name); - return JS_TRUE; + return true; } JSBool CType::SizeGetter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandleValue vp) { if (!CType::IsCType(obj)) { JS_ReportError(cx, "not a CType"); - return JS_FALSE; + return false; } vp.set(JS_GetReservedSlot(obj, SLOT_SIZE)); JS_ASSERT(JSVAL_IS_NUMBER(vp) || JSVAL_IS_VOID(vp)); - return JS_TRUE; + return true; } JSBool CType::PtrGetter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandleValue vp) { if (!CType::IsCType(obj)) { JS_ReportError(cx, "not a CType"); - return JS_FALSE; + return false; } JSObject* pointerType = PointerType::CreateInternal(cx, obj); if (!pointerType) - return JS_FALSE; + return false; vp.setObject(*pointerType); - return JS_TRUE; + return true; } bool CType::CreateArray(JSContext* cx, unsigned argc, jsval* vp) { CallArgs args = CallArgsFromVp(argc, vp); RootedObject baseType(cx, JS_THIS_OBJECT(cx, vp)); if (!baseType) @@ -3750,32 +3750,32 @@ CType::HasInstance(JSContext* cx, Handle { JS_ASSERT(CType::IsCType(obj)); jsval slot = JS_GetReservedSlot(obj, SLOT_PROTO); JS::Rooted<JSObject*> prototype(cx, &slot.toObject()); JS_ASSERT(prototype); JS_ASSERT(CData::IsCDataProto(prototype)); - *bp = JS_FALSE; + *bp = false; if (JSVAL_IS_PRIMITIVE(v)) - return JS_TRUE; + return true; RootedObject proto(cx, &v.toObject()); for (;;) { if (!JS_GetPrototype(cx, proto, &proto)) - return JS_FALSE; + return false; if (!proto) break; if (proto == prototype) { - *bp = JS_TRUE; + *bp = true; break; } } - return JS_TRUE; + return true; } static JSObject* CType::GetGlobalCTypes(JSContext* cx, JSObject* objArg) { JS_ASSERT(CType::IsCType(objArg)); RootedObject obj(cx, objArg); @@ -3909,58 +3909,58 @@ PointerType::CreateInternal(JSContext* c JSBool PointerType::ConstructData(JSContext* cx, HandleObject obj, const CallArgs& args) { if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_pointer) { JS_ReportError(cx, "not a PointerType"); - return JS_FALSE; + return false; } if (args.length() > 3) { JS_ReportError(cx, "constructor takes 0, 1, 2, or 3 arguments"); - return JS_FALSE; + return false; } RootedObject result(cx, CData::Create(cx, obj, NullPtr(), NULL, true)); if (!result) - return JS_FALSE; + return false; // Set return value early, must not observe *vp after args.rval().setObject(*result); // There are 3 things that we might be creating here: // 1 - A null pointer (no arguments) // 2 - An initialized pointer (1 argument) // 3 - A closure (1-3 arguments) // // The API doesn't give us a perfect way to distinguish 2 and 3, but the // heuristics we use should be fine. // // Case 1 - Null pointer // if (args.length() == 0) - return JS_TRUE; + return true; // Analyze the arguments a bit to decide what to do next. RootedObject baseObj(cx, PointerType::GetBaseType(obj)); bool looksLikeClosure = CType::GetTypeCode(baseObj) == TYPE_function && args[0].isObject() && JS_ObjectIsCallable(cx, &args[0].toObject()); // // Case 2 - Initialized pointer // if (!looksLikeClosure) { if (args.length() != 1) { JS_ReportError(cx, "first argument must be a function"); - return JS_FALSE; + return false; } return ExplicitConvert(cx, args[0], obj, CData::GetData(result)); } // // Case 3 - Closure // @@ -3969,17 +3969,17 @@ PointerType::ConstructData(JSContext* cx // wish to pass the third argument. RootedObject thisObj(cx, NULL); if (args.length() >= 2) { if (args[1].isNull()) { thisObj = NULL; } else if (!JSVAL_IS_PRIMITIVE(args[1])) { thisObj = &args[1].toObject(); } else if (!JS_ValueToObject(cx, args[1], thisObj.address())) { - return JS_FALSE; + return false; } } // The third argument is an optional error sentinel that js-ctypes will return // if an exception is raised while executing the closure. The type must match // the return type of the callback. jsval errVal = JSVAL_VOID; if (args.length() == 3) @@ -4002,22 +4002,22 @@ PointerType::GetBaseType(JSObject* obj) JSBool PointerType::TargetTypeGetter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandleValue vp) { if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_pointer) { JS_ReportError(cx, "not a PointerType"); - return JS_FALSE; + return false; } vp.set(JS_GetReservedSlot(obj, SLOT_TARGET_T)); JS_ASSERT(vp.isObject()); - return JS_TRUE; + return true; } bool PointerType::IsNull(JSContext* cx, unsigned argc, jsval* vp) { CallArgs args = CallArgsFromVp(argc, vp); JSObject* obj = JS_THIS_OBJECT(cx, vp); if (!obj) @@ -4039,45 +4039,45 @@ PointerType::IsNull(JSContext* cx, unsig return true; } JSBool PointerType::OffsetBy(JSContext* cx, const CallArgs& args, int offset) { JSObject* obj = JS_THIS_OBJECT(cx, args.base()); if (!obj) - return JS_FALSE; + return false; if (!CData::IsCData(obj)) { JS_ReportError(cx, "not a CData"); - return JS_FALSE; + return false; } RootedObject typeObj(cx, CData::GetCType(obj)); if (CType::GetTypeCode(typeObj) != TYPE_pointer) { JS_ReportError(cx, "not a PointerType"); - return JS_FALSE; + return false; } RootedObject baseType(cx, PointerType::GetBaseType(typeObj)); if (!CType::IsSizeDefined(baseType)) { JS_ReportError(cx, "cannot modify pointer of undefined size"); - return JS_FALSE; + return false; } size_t elementSize = CType::GetSize(baseType); char* data = static_cast<char*>(*static_cast<void**>(CData::GetData(obj))); void* address = data + offset * elementSize; // Create a PointerType CData object containing the new address. JSObject* result = CData::Create(cx, typeObj, NullPtr(), &address, true); if (!result) - return JS_FALSE; + return false; args.rval().setObject(*result); - return JS_TRUE; + return true; } bool PointerType::Increment(JSContext* cx, unsigned argc, jsval* vp) { CallArgs args = CallArgsFromVp(argc, vp); return OffsetBy(cx, args, 1); } @@ -4092,75 +4092,75 @@ PointerType::Decrement(JSContext* cx, un JSBool PointerType::ContentsGetter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandleValue vp) { if (!CData::IsCData(obj)) { JS_ReportError(cx, "not a CData"); - return JS_FALSE; + return false; } // Get pointer type and base type. JSObject* typeObj = CData::GetCType(obj); if (CType::GetTypeCode(typeObj) != TYPE_pointer) { JS_ReportError(cx, "not a PointerType"); - return JS_FALSE; + return false; } RootedObject baseType(cx, GetBaseType(typeObj)); if (!CType::IsSizeDefined(baseType)) { JS_ReportError(cx, "cannot get contents of undefined size"); - return JS_FALSE; + return false; } void* data = *static_cast<void**>(CData::GetData(obj)); if (data == NULL) { JS_ReportError(cx, "cannot read contents of null pointer"); - return JS_FALSE; + return false; } RootedValue result(cx); if (!ConvertToJS(cx, baseType, NullPtr(), data, false, false, result.address())) - return JS_FALSE; + return false; vp.set(result); - return JS_TRUE; + return true; } JSBool PointerType::ContentsSetter(JSContext* cx, HandleObject obj, HandleId idval, JSBool strict, MutableHandleValue vp) { if (!CData::IsCData(obj)) { JS_ReportError(cx, "not a CData"); - return JS_FALSE; + return false; } // Get pointer type and base type. JSObject* typeObj = CData::GetCType(obj); if (CType::GetTypeCode(typeObj) != TYPE_pointer) { JS_ReportError(cx, "not a PointerType"); - return JS_FALSE; + return false; } JSObject* baseType = GetBaseType(typeObj); if (!CType::IsSizeDefined(baseType)) { JS_ReportError(cx, "cannot set contents of undefined size"); - return JS_FALSE; + return false; } void* data = *static_cast<void**>(CData::GetData(obj)); if (data == NULL) { JS_ReportError(cx, "cannot write contents to null pointer"); - return JS_FALSE; + return false; } return ImplicitConvert(cx, vp, baseType, data, false, NULL); } /******************************************************************************* ** ArrayType implementation *******************************************************************************/ @@ -4256,35 +4256,35 @@ JSBool ArrayType::ConstructData(JSContext* cx, HandleObject obj_, const CallArgs& args) { RootedObject obj(cx, obj_); // Make a mutable version if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_array) { JS_ReportError(cx, "not an ArrayType"); - return JS_FALSE; + return false; } // Decide whether we have an object to initialize from. We'll override this // if we get a length argument instead. bool convertObject = args.length() == 1; // Check if we're an array of undefined length. If we are, allow construction // with a length argument, or with an actual JS array. if (CType::IsSizeDefined(obj)) { if (args.length() > 1) { JS_ReportError(cx, "constructor takes zero or one argument"); - return JS_FALSE; + return false; } } else { if (args.length() != 1) { JS_ReportError(cx, "constructor takes one argument"); - return JS_FALSE; + return false; } RootedObject baseType(cx, GetBaseType(obj)); size_t length; if (jsvalToSize(cx, args[0], false, &length)) { // Have a length, rather than an object to initialize from. convertObject = false; @@ -4292,17 +4292,17 @@ ArrayType::ConstructData(JSContext* cx, } else if (!JSVAL_IS_PRIMITIVE(args[0])) { // We were given an object with a .length property. // This could be a JS array, or a CData array. RootedObject arg(cx, &args[0].toObject()); RootedValue lengthVal(cx); if (!JS_GetProperty(cx, arg, "length", &lengthVal) || !jsvalToSize(cx, lengthVal, false, &length)) { JS_ReportError(cx, "argument must be an array object or length"); - return JS_FALSE; + return false; } } else if (args[0].isString()) { // We were given a string. Size the array to the appropriate length, // including space for the terminator. JSString* sourceString = args[0].toString(); size_t sourceLength = sourceString->length(); const jschar* sourceChars = sourceString->getChars(cx); @@ -4325,37 +4325,37 @@ ArrayType::ConstructData(JSContext* cx, length = sourceLength + 1; break; default: return TypeError(cx, "array", args[0]); } } else { JS_ReportError(cx, "argument must be an array object or length"); - return JS_FALSE; + return false; } // Construct a new ArrayType of defined length, for the new CData object. obj = CreateInternal(cx, baseType, length, true); if (!obj) - return JS_FALSE; + return false; } JSObject* result = CData::Create(cx, obj, NullPtr(), NULL, true); if (!result) - return JS_FALSE; + return false; args.rval().setObject(*result); if (convertObject) { if (!ExplicitConvert(cx, args[0], obj, CData::GetData(result))) - return JS_FALSE; - } - - return JS_TRUE; + return false; + } + + return true; } JSObject* ArrayType::GetBaseType(JSObject* obj) { JS_ASSERT(CType::IsCType(obj)); JS_ASSERT(CType::GetTypeCode(obj) == TYPE_array); @@ -4448,108 +4448,108 @@ ArrayType::BuildFFIType(JSContext* cx, J return ffiType.forget(); } JSBool ArrayType::ElementTypeGetter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandleValue vp) { if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_array) { JS_ReportError(cx, "not an ArrayType"); - return JS_FALSE; + return false; } vp.set(JS_GetReservedSlot(obj, SLOT_ELEMENT_T)); JS_ASSERT(!JSVAL_IS_PRIMITIVE(vp)); - return JS_TRUE; + return true; } JSBool ArrayType::LengthGetter(JSContext* cx, HandleObject obj_, HandleId idval, MutableHandleValue vp) { JSObject *obj = obj_; // This getter exists for both CTypes and CDatas of the ArrayType persuasion. // If we're dealing with a CData, get the CType from it. if (CData::IsCData(obj)) obj = CData::GetCType(obj); if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_array) { JS_ReportError(cx, "not an ArrayType"); - return JS_FALSE; + return false; } vp.set(JS_GetReservedSlot(obj, SLOT_LENGTH)); JS_ASSERT(vp.isNumber() || vp.isUndefined()); - return JS_TRUE; + return true; } JSBool ArrayType::Getter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandleValue vp) { // This should never happen, but we'll check to be safe. if (!CData::IsCData(obj)) { JS_ReportError(cx, "not a CData"); - return JS_FALSE; + return false; } // Bail early if we're not an ArrayType. (This setter is present for all // CData, regardless of CType.) JSObject* typeObj = CData::GetCType(obj); if (CType::GetTypeCode(typeObj) != TYPE_array) - return JS_TRUE; + return true; // Convert the index to a size_t and bounds-check it. size_t index; size_t length = GetLength(typeObj); bool ok = jsidToSize(cx, idval, true, &index); int32_t dummy; if (!ok && JSID_IS_STRING(idval) && !StringToInteger(cx, JSID_TO_STRING(idval), &dummy)) { // String either isn't a number, or doesn't fit in size_t. // Chances are it's a regular property lookup, so return. - return JS_TRUE; + return true; } if (!ok || index >= length) { JS_ReportError(cx, "invalid index"); - return JS_FALSE; + return false; } RootedObject baseType(cx, GetBaseType(typeObj)); size_t elementSize = CType::GetSize(baseType); char* data = static_cast<char*>(CData::GetData(obj)) + elementSize * index; return ConvertToJS(cx, baseType, obj, data, false, false, vp.address()); } JSBool ArrayType::Setter(JSContext* cx, HandleObject obj, HandleId idval, JSBool strict, MutableHandleValue vp) { // This should never happen, but we'll check to be safe. if (!CData::IsCData(obj)) { JS_ReportError(cx, "not a CData"); - return JS_FALSE; + return false; } // Bail early if we're not an ArrayType. (This setter is present for all // CData, regardless of CType.) JSObject* typeObj = CData::GetCType(obj); if (CType::GetTypeCode(typeObj) != TYPE_array) - return JS_TRUE; + return true; // Convert the index to a size_t and bounds-check it. size_t index; size_t length = GetLength(typeObj); bool ok = jsidToSize(cx, idval, true, &index); int32_t dummy; if (!ok && JSID_IS_STRING(idval) && !StringToInteger(cx, JSID_TO_STRING(idval), &dummy)) { // String either isn't a number, or doesn't fit in size_t. // Chances are it's a regular property lookup, so return. - return JS_TRUE; + return true; } if (!ok || index >= length) { JS_ReportError(cx, "invalid index"); - return JS_FALSE; + return false; } JSObject* baseType = GetBaseType(typeObj); size_t elementSize = CType::GetSize(baseType); char* data = static_cast<char*>(CData::GetData(obj)) + elementSize * index; return ImplicitConvert(cx, vp, baseType, data, false, NULL); } @@ -4754,85 +4754,85 @@ StructType::DefineInternal(JSContext* cx uint32_t len; ASSERT_OK(JS_GetArrayLength(cx, fieldsObj, &len)); // Get the common prototype for CData objects of this type from // ctypes.CType.prototype. RootedObject dataProto(cx, CType::GetProtoFromType(cx, typeObj, SLOT_STRUCTDATAPROTO)); if (!dataProto) - return JS_FALSE; + return false; // Set up the 'prototype' and 'prototype.constructor' properties. // The prototype will reflect the struct fields as properties on CData objects // created from this type. RootedObject prototype(cx, JS_NewObject(cx, &sCDataProtoClass, dataProto, NULL)); if (!prototype) - return JS_FALSE; + return false; if (!JS_DefineProperty(cx, prototype, "constructor", OBJECT_TO_JSVAL(typeObj), NULL, NULL, JSPROP_READONLY | JSPROP_PERMANENT)) - return JS_FALSE; + return false; // Create a FieldInfoHash to stash on the type object, and an array to root // its constituents. (We cannot simply stash the hash in a reserved slot now // to get GC safety for free, since if anything in this function fails we // do not want to mutate 'typeObj'.) AutoPtr<FieldInfoHash> fields(cx->new_<FieldInfoHash>()); Array<jsval, 16> fieldRootsArray; if (!fields || !fields->init(len) || !fieldRootsArray.appendN(JSVAL_VOID, len)) { JS_ReportOutOfMemory(cx); - return JS_FALSE; + return false; } js::AutoArrayRooter fieldRoots(cx, fieldRootsArray.length(), fieldRootsArray.begin()); // Process the field types. size_t structSize, structAlign; if (len != 0) { structSize = 0; structAlign = 0; for (uint32_t i = 0; i < len; ++i) { RootedValue item(cx); if (!JS_GetElement(cx, fieldsObj, i, &item)) - return JS_FALSE; + return false; RootedObject fieldType(cx, NULL); JSFlatString* flat = ExtractStructField(cx, item, fieldType.address()); if (!flat) - return JS_FALSE; + return false; Rooted<JSStableString*> name(cx, flat->ensureStable(cx)); if (!name) - return JS_FALSE; + return false; fieldRootsArray[i] = OBJECT_TO_JSVAL(fieldType); // Make sure each field name is unique FieldInfoHash::AddPtr entryPtr = fields->lookupForAdd(name); if (entryPtr) { JS_ReportError(cx, "struct fields must have unique names"); - return JS_FALSE; + return false; } // Add the field to the StructType's 'prototype' property. if (!JS_DefineUCProperty(cx, prototype, name->chars().get(), name->length(), JSVAL_VOID, StructType::FieldGetter, StructType::FieldSetter, JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_PERMANENT)) - return JS_FALSE; + return false; size_t fieldSize = CType::GetSize(fieldType); size_t fieldAlign = CType::GetAlignment(fieldType); size_t fieldOffset = Align(structSize, fieldAlign); // Check for overflow. Since we hold invariant that fieldSize % fieldAlign // be zero, we can safely check fieldOffset + fieldSize without first // checking fieldOffset for overflow. if (fieldOffset + fieldSize < structSize) { JS_ReportError(cx, "size overflow"); - return JS_FALSE; + return false; } // Add field name to the hash FieldInfo info; info.mType = fieldType; info.mIndex = i; info.mOffset = fieldOffset; ASSERT_OK(fields->add(entryPtr, name, info)); @@ -4843,41 +4843,41 @@ StructType::DefineInternal(JSContext* cx if (fieldAlign > structAlign) structAlign = fieldAlign; } // Pad the struct tail according to struct alignment. size_t structTail = Align(structSize, structAlign); if (structTail < structSize) { JS_ReportError(cx, "size overflow"); - return JS_FALSE; + return false; } structSize = structTail; } else { // Empty structs are illegal in C, but are legal and have a size of // 1 byte in C++. We're going to allow them, and trick libffi into // believing this by adding a char member. The resulting struct will have // no getters or setters, and will be initialized to zero. structSize = 1; structAlign = 1; } RootedValue sizeVal(cx); if (!SizeTojsval(cx, structSize, sizeVal.address())) - return JS_FALSE; + return false; JS_SetReservedSlot(typeObj, SLOT_FIELDINFO, PRIVATE_TO_JSVAL(fields.forget())); JS_SetReservedSlot(typeObj, SLOT_SIZE, sizeVal); JS_SetReservedSlot(typeObj, SLOT_ALIGN, INT_TO_JSVAL(structAlign)); //if (!JS_FreezeObject(cx, prototype)0 // XXX fixme - see bug 541212! // return false; JS_SetReservedSlot(typeObj, SLOT_PROTO, OBJECT_TO_JSVAL(prototype)); - return JS_TRUE; + return true; } ffi_type* StructType::BuildFFIType(JSContext* cx, JSObject* obj) { JS_ASSERT(CType::IsCType(obj)); JS_ASSERT(CType::GetTypeCode(obj) == TYPE_struct); JS_ASSERT(CType::IsSizeDefined(obj)); @@ -4990,56 +4990,56 @@ StructType::Define(JSContext* cx, unsign JSBool StructType::ConstructData(JSContext* cx, HandleObject obj, const CallArgs& args) { if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_struct) { JS_ReportError(cx, "not a StructType"); - return JS_FALSE; + return false; } if (!CType::IsSizeDefined(obj)) { JS_ReportError(cx, "cannot construct an opaque StructType"); - return JS_FALSE; + return false; } JSObject* result = CData::Create(cx, obj, NullPtr(), NULL, true); if (!result) - return JS_FALSE; + return false; args.rval().setObject(*result); if (args.length() == 0) - return JS_TRUE; + return true; char* buffer = static_cast<char*>(CData::GetData(result)); const FieldInfoHash* fields = GetFieldInfo(obj); if (args.length() == 1) { // There are two possible interpretations of the argument: // 1) It may be an object '{ ... }' with properties representing the // struct fields intended to ExplicitConvert wholesale to our StructType. // 2) If the struct contains one field, the arg may be intended to // ImplicitConvert directly to that arg's CType. // Thankfully, the conditions for these two possibilities to succeed // are mutually exclusive, so we can pick the right one. // Try option 1) first. if (ExplicitConvert(cx, args[0], obj, buffer)) - return JS_TRUE; + return true; if (fields->count() != 1) - return JS_FALSE; + return false; // If ExplicitConvert failed, and there is no pending exception, then assume // hard failure (out of memory, or some other similarly serious condition). if (!JS_IsExceptionPending(cx)) - return JS_FALSE; + return false; // Otherwise, assume soft failure, and clear the pending exception so that we // can throw a different one as required. JS_ClearPendingException(cx); // Fall through to try option 2). } @@ -5047,25 +5047,25 @@ StructType::ConstructData(JSContext* cx, // ImplicitConvert each field. if (args.length() == fields->count()) { for (FieldInfoHash::Range r = fields->all(); !r.empty(); r.popFront()) { const FieldInfo& field = r.front().value; STATIC_ASSUME(field.mIndex < fields->count()); /* Quantified invariant */ if (!ImplicitConvert(cx, args[field.mIndex], field.mType, buffer + field.mOffset, false, NULL)) - return JS_FALSE; + return false; } - return JS_TRUE; + return true; } JS_ReportError(cx, "constructor takes 0, 1, or %u arguments", fields->count()); - return JS_FALSE; + return false; } const FieldInfoHash* StructType::GetFieldInfo(JSObject* obj) { JS_ASSERT(CType::IsCType(obj)); JS_ASSERT(CType::GetTypeCode(obj) == TYPE_struct); @@ -5128,81 +5128,81 @@ StructType::BuildFieldsArray(JSContext* return fieldsProp; } JSBool StructType::FieldsArrayGetter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandleValue vp) { if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_struct) { JS_ReportError(cx, "not a StructType"); - return JS_FALSE; + return false; } vp.set(JS_GetReservedSlot(obj, SLOT_FIELDS)); if (!CType::IsSizeDefined(obj)) { JS_ASSERT(JSVAL_IS_VOID(vp)); - return JS_TRUE; + return true; } if (JSVAL_IS_VOID(vp)) { // Build the 'fields' array lazily. JSObject* fields = BuildFieldsArray(cx, obj); if (!fields) - return JS_FALSE; + return false; JS_SetReservedSlot(obj, SLOT_FIELDS, OBJECT_TO_JSVAL(fields)); vp.setObject(*fields); } JS_ASSERT(!JSVAL_IS_PRIMITIVE(vp) && JS_IsArrayObject(cx, JSVAL_TO_OBJECT(vp))); - return JS_TRUE; + return true; } JSBool StructType::FieldGetter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandleValue vp) { if (!CData::IsCData(obj)) { JS_ReportError(cx, "not a CData"); - return JS_FALSE; + return false; } JSObject* typeObj = CData::GetCType(obj); if (CType::GetTypeCode(typeObj) != TYPE_struct) { JS_ReportError(cx, "not a StructType"); - return JS_FALSE; + return false; } const FieldInfo* field = LookupField(cx, typeObj, JSID_TO_FLAT_STRING(idval)); if (!field) - return JS_FALSE; + return false; char* data = static_cast<char*>(CData::GetData(obj)) + field->mOffset; RootedObject fieldType(cx, field->mType); return ConvertToJS(cx, fieldType, obj, data, false, false, vp.address()); } JSBool StructType::FieldSetter(JSContext* cx, HandleObject obj, HandleId idval, JSBool strict, MutableHandleValue vp) { if (!CData::IsCData(obj)) { JS_ReportError(cx, "not a CData"); - return JS_FALSE; + return false; } JSObject* typeObj = CData::GetCType(obj); if (CType::GetTypeCode(typeObj) != TYPE_struct) { JS_ReportError(cx, "not a StructType"); - return JS_FALSE; + return false; } const FieldInfo* field = LookupField(cx, typeObj, JSID_TO_FLAT_STRING(idval)); if (!field) - return JS_FALSE; + return false; char* data = static_cast<char*>(CData::GetData(obj)) + field->mOffset; return ImplicitConvert(cx, vp, field->mType, data, false, NULL); } bool StructType::AddressOfField(JSContext* cx, unsigned argc, jsval* vp) { @@ -5652,27 +5652,27 @@ FunctionType::ConstructData(JSContext* c { JS_ASSERT(CType::GetTypeCode(typeObj) == TYPE_function); PRFuncPtr* data = static_cast<PRFuncPtr*>(CData::GetData(dataObj)); FunctionInfo* fninfo = FunctionType::GetFunctionInfo(typeObj); if (fninfo->mIsVariadic) { JS_ReportError(cx, "Can't declare a variadic callback function"); - return JS_FALSE; + return false; } if (GetABICode(fninfo->mABI) == ABI_WINAPI) { JS_ReportError(cx, "Can't declare a ctypes.winapi_abi callback function, " "use ctypes.stdcall_abi instead"); - return JS_FALSE; + return false; } RootedObject closureObj(cx, CClosure::Create(cx, typeObj, fnObj, thisObj, errVal, data)); if (!closureObj) - return JS_FALSE; + return false; // Set the closure object as the referent of the new CData object. JS_SetReservedSlot(dataObj, SLOT_REFERENT, OBJECT_TO_JSVAL(closureObj)); // Seal the CData object, to prevent modification of the function pointer. // This permanently associates this object with the closure, and avoids // having to do things like reset SLOT_REFERENT when someone tries to // change the pointer value. @@ -5888,86 +5888,86 @@ FunctionType::GetFunctionInfo(JSObject* return static_cast<FunctionInfo*>(JSVAL_TO_PRIVATE(slot)); } static JSBool CheckFunctionType(JSContext* cx, JSObject* obj) { if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_function) { JS_ReportError(cx, "not a FunctionType"); - return JS_FALSE; - } - return JS_TRUE; + return false; + } + return true; } JSBool FunctionType::ArgTypesGetter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandleValue vp) { if (!CheckFunctionType(cx, obj)) - return JS_FALSE; + return false; // Check if we have a cached argTypes array. vp.set(JS_GetReservedSlot(obj, SLOT_ARGS_T)); if (!JSVAL_IS_VOID(vp)) - return JS_TRUE; + return true; FunctionInfo* fninfo = GetFunctionInfo(obj); size_t len = fninfo->mArgTypes.length(); // Prepare a new array. Array<jsval, 16> vec; if (!vec.resize(len)) - return JS_FALSE; + return false; for (size_t i = 0; i < len; ++i) vec[i] = OBJECT_TO_JSVAL(fninfo->mArgTypes[i]); RootedObject argTypes(cx, JS_NewArrayObject(cx, len, vec.begin())); if (!argTypes) - return JS_FALSE; + return false; // Seal and cache it. if (!JS_FreezeObject(cx, argTypes)) - return JS_FALSE; + return false; JS_SetReservedSlot(obj, SLOT_ARGS_T, OBJECT_TO_JSVAL(argTypes)); vp.setObject(*argTypes); - return JS_TRUE; + return true; } JSBool FunctionType::ReturnTypeGetter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandleValue vp) { if (!CheckFunctionType(cx, obj)) - return JS_FALSE; + return false; // Get the returnType object from the FunctionInfo. vp.setObject(*GetFunctionInfo(obj)->mReturnType); - return JS_TRUE; + return true; } JSBool FunctionType::ABIGetter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandleValue vp) { if (!CheckFunctionType(cx, obj)) - return JS_FALSE; + return false; // Get the abi object from the FunctionInfo. vp.setObject(*GetFunctionInfo(obj)->mABI); - return JS_TRUE; + return true; } JSBool FunctionType::IsVariadicGetter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandleValue vp) { if (!CheckFunctionType(cx, obj)) - return JS_FALSE; + return false; vp.setBoolean(GetFunctionInfo(obj)->mIsVariadic); - return JS_TRUE; + return true; } /******************************************************************************* ** CClosure implementation *******************************************************************************/ JSObject* CClosure::Create(JSContext* cx, @@ -6402,33 +6402,33 @@ CData::IsCDataProto(JSObject* obj) return JS_GetClass(obj) == &sCDataProtoClass; } JSBool CData::ValueGetter(JSContext* cx, HandleObject obj, HandleId idval, MutableHandleValue vp) { if (!IsCData(obj)) { JS_ReportError(cx, "not a CData"); - return JS_FALSE; + return false; } // Convert the value to a primitive; do not create a new CData object. RootedObject ctype(cx, GetCType(obj)); if (!ConvertToJS(cx, ctype, NullPtr(), GetData(obj), true, false, vp.address())) - return JS_FALSE; - - return JS_TRUE; + return false; + + return true; } JSBool CData::ValueSetter(JSContext* cx, HandleObject obj, HandleId idval, JSBool strict, MutableHandleValue vp) { if (!IsCData(obj)) { JS_ReportError(cx, "not a CData"); - return JS_FALSE; + return false; } return ImplicitConvert(cx, vp, GetCType(obj), GetData(obj), false, NULL); } bool CData::Address(JSContext* cx, unsigned argc, jsval* vp) { @@ -6691,34 +6691,34 @@ CData::ToSource(JSContext* cx, unsigned return true; } JSBool CData::ErrnoGetter(JSContext* cx, HandleObject obj, HandleId, MutableHandleValue vp) { if (!IsCTypesGlobal(obj)) { JS_ReportError(cx, "this is not not global object ctypes"); - return JS_FALSE; + return false; } vp.set(JS_GetReservedSlot(obj, SLOT_ERRNO)); - return JS_TRUE; + return true; } #if defined(XP_WIN) JSBool CData::LastErrorGetter(JSContext* cx, HandleObject obj, HandleId, MutableHandleValue vp) { if (!IsCTypesGlobal(obj)) { JS_ReportError(cx, "not global object ctypes"); - return JS_FALSE; + return false; } vp.set(JS_GetReservedSlot(obj, SLOT_LASTERROR)); - return JS_TRUE; + return true; } #endif // defined(XP_WIN) bool CDataFinalizer::Methods::ToSource(JSContext *cx, unsigned argc, jsval *vp) { CallArgs args = CallArgsFromVp(argc, vp); RootedObject objThis(cx, JS_THIS_OBJECT(cx, vp));
--- a/js/src/ion/arm/Trampoline-arm.cpp +++ b/js/src/ion/arm/Trampoline-arm.cpp @@ -315,17 +315,17 @@ IonRuntime::generateEnterJIT(JSContext * // We're using a load-double here. In order for that to work, // the data needs to be stored in two consecutive registers, // make sure this is the case // ASSERT(JSReturnReg_Type.code() == JSReturnReg_Data.code()+1); // aasm->as_extdtr(IsStore, 64, true, Offset, // JSReturnReg_Data, EDtrAddr(r5, EDtrOffImm(0))); // Restore non-volatile registers and return. - GenerateReturn(masm, JS_TRUE); + GenerateReturn(masm, true); Linker linker(masm); return linker.newCode(cx, JSC::OTHER_CODE); } IonCode * IonRuntime::generateInvalidator(JSContext *cx) {
--- a/js/src/jsapi-tests/testClassGetter.cpp +++ b/js/src/jsapi-tests/testClassGetter.cpp @@ -10,17 +10,17 @@ #include "jsapi-tests/tests.h" int called_test_fn; int called_test_prop_get; static JSBool test_prop_get( JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp ) { called_test_prop_get++; - return JS_TRUE; + return true; } static bool PTest(JSContext* cx, unsigned argc, jsval *vp); static JSClass ptestClass = { "PTest", JSCLASS_HAS_PRIVATE,
--- a/js/src/jsapi-tests/testDebugger.cpp +++ b/js/src/jsapi-tests/testDebugger.cpp @@ -21,17 +21,17 @@ callCountHook(JSContext *cx, JSAbstractF JS::RootedValue thisv(cx); frame.getThisValue(cx, &thisv); // assert if fp is incomplete return cx; // any non-null value causes the hook to be called again after } BEGIN_TEST(testDebugger_bug519719) { - CHECK(JS_SetDebugMode(cx, JS_TRUE)); + CHECK(JS_SetDebugMode(cx, true)); JS_SetCallHook(rt, callCountHook, NULL); EXEC("function call(fn) { fn(0); }\n" "function f(g) { for (var i = 0; i < 9; i++) call(g); }\n" "f(Math.sin);\n" // record loop, starting in f "f(Math.cos);\n"); // side exit in f -> call CHECK_EQUAL(callCount[0], 20); CHECK_EQUAL(callCount[1], 20); return true; @@ -49,17 +49,17 @@ nonStrictThisHook(JSContext *cx, JSAbstr *allWrapped = *allWrapped && !JSVAL_IS_PRIMITIVE(thisv); } return NULL; } BEGIN_TEST(testDebugger_getThisNonStrict) { bool allWrapped = true; - CHECK(JS_SetDebugMode(cx, JS_TRUE)); + CHECK(JS_SetDebugMode(cx, true)); JS_SetCallHook(rt, nonStrictThisHook, (void *) &allWrapped); EXEC("function nonstrict() { }\n" "Boolean.prototype.nonstrict = nonstrict;\n" "String.prototype.nonstrict = nonstrict;\n" "Number.prototype.nonstrict = nonstrict;\n" "Object.prototype.nonstrict = nonstrict;\n" "nonstrict.call(true);\n" "true.nonstrict();\n" @@ -88,17 +88,17 @@ strictThisHook(JSContext *cx, JSAbstract *anyWrapped = *anyWrapped || !JSVAL_IS_PRIMITIVE(thisv); } return NULL; } BEGIN_TEST(testDebugger_getThisStrict) { bool anyWrapped = false; - CHECK(JS_SetDebugMode(cx, JS_TRUE)); + CHECK(JS_SetDebugMode(cx, true)); JS_SetCallHook(rt, strictThisHook, (void *) &anyWrapped); EXEC("function strict() { 'use strict'; }\n" "Boolean.prototype.strict = strict;\n" "String.prototype.strict = strict;\n" "Number.prototype.strict = strict;\n" "strict.call(true);\n" "true.strict();\n" "strict.call('');\n"
--- a/js/src/jsapi-tests/testDefineGetterSetterNonEnumerable.cpp +++ b/js/src/jsapi-tests/testDefineGetterSetterNonEnumerable.cpp @@ -40,17 +40,17 @@ BEGIN_TEST(testDefineGetterSetterNonEnum JSPROP_GETTER | JSPROP_SETTER | JSPROP_ENUMERATE)); CHECK(JS_DefineProperty(cx, vObject, PROPERTY_NAME, JSVAL_VOID, JS_DATA_TO_FUNC_PTR(JSPropertyOp, (JSObject*) funGetObj), JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp, (JSObject*) funSetObj), JSPROP_GETTER | JSPROP_SETTER | JSPROP_PERMANENT)); - JSBool found = JS_FALSE; + JSBool found = false; unsigned attrs = 0; CHECK(JS_GetPropertyAttributes(cx, vObject, PROPERTY_NAME, &attrs, &found)); CHECK(found); CHECK(attrs & JSPROP_GETTER); CHECK(attrs & JSPROP_SETTER); CHECK(attrs & JSPROP_PERMANENT); CHECK(!(attrs & JSPROP_ENUMERATE));
--- a/js/src/jsapi-tests/testIndexToString.cpp +++ b/js/src/jsapi-tests/testIndexToString.cpp @@ -59,17 +59,17 @@ BEGIN_TEST(testIndexToString) for (size_t i = 0, sz = ArrayLength(tests); i < sz; i++) { uint32_t u = tests[i].num; JSString *str = js::IndexToString(cx, u); CHECK(str); if (!js::StaticStrings::hasUint(u)) CHECK(cx->compartment()->dtoaCache.lookup(10, u) == str); - JSBool match = JS_FALSE; + JSBool match = false; CHECK(JS_StringEqualsAscii(cx, str, tests[i].expected, &match)); CHECK(match); } return true; } END_TEST(testIndexToString)
--- a/js/src/jsapi-tests/testJSEvaluateScript.cpp +++ b/js/src/jsapi-tests/testJSEvaluateScript.cpp @@ -13,37 +13,37 @@ BEGIN_TEST(testJSEvaluateScript) CHECK(options & JSOPTION_VAROBJFIX); static const char src[] = "var x = 5;"; JS::RootedValue retval(cx); CHECK(JS_EvaluateScript(cx, obj, src, sizeof(src) - 1, __FILE__, __LINE__, retval.address())); - JSBool hasProp = JS_TRUE; + JSBool hasProp = true; CHECK(JS_AlreadyHasOwnProperty(cx, obj, "x", &hasProp)); CHECK(!hasProp); - hasProp = JS_FALSE; + hasProp = false; CHECK(JS_HasProperty(cx, global, "x", &hasProp)); CHECK(hasProp); // Now do the same thing, but without JSOPTION_VAROBJFIX JS_SetOptions(cx, options & ~JSOPTION_VAROBJFIX); static const char src2[] = "var y = 5;"; CHECK(JS_EvaluateScript(cx, obj, src2, sizeof(src2) - 1, __FILE__, __LINE__, retval.address())); - hasProp = JS_FALSE; + hasProp = false; CHECK(JS_AlreadyHasOwnProperty(cx, obj, "y", &hasProp)); CHECK(hasProp); - hasProp = JS_TRUE; + hasProp = true; CHECK(JS_AlreadyHasOwnProperty(cx, global, "y", &hasProp)); CHECK(!hasProp); return true; } END_TEST(testJSEvaluateScript)
--- a/js/src/jsapi-tests/testOps.cpp +++ b/js/src/jsapi-tests/testOps.cpp @@ -9,19 +9,19 @@ #include "jsapi-tests/tests.h" static JSBool my_convert(JSContext* context, JS::HandleObject obj, JSType type, JS::MutableHandleValue rval) { if (type == JSTYPE_VOID || type == JSTYPE_STRING || type == JSTYPE_NUMBER || type == JSTYPE_BOOLEAN) { rval.set(JS_NumberValue(123)); - return JS_TRUE; + return true; } - return JS_FALSE; + return false; } static JSClass myClass = { "MyClass", 0, JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, my_convert }; @@ -33,17 +33,17 @@ createMyObject(JSContext* context, unsig //JS_GC(context); //<- if we make GC here, all is ok JSObject* myObject = JS_NewObject(context, &myClass, NULL, NULL); *vp = OBJECT_TO_JSVAL(myObject); JS_EndRequest(context); - return JS_TRUE; + return true; } static const JSFunctionSpec s_functions[] = { JS_FN("createMyObject", createMyObject, 0, 0), JS_FS_END };
--- a/js/src/jsapi-tests/testPropCache.cpp +++ b/js/src/jsapi-tests/testPropCache.cpp @@ -8,17 +8,17 @@ #include "jsapi-tests/tests.h" static int g_counter; static JSBool CounterAdd(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { g_counter++; - return JS_TRUE; + return true; } static JSClass CounterClass = { "Counter", /* name */ 0, /* flags */ CounterAdd, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub };
--- a/js/src/jsapi-tests/testSetProperty.cpp +++ b/js/src/jsapi-tests/testSetProperty.cpp @@ -6,17 +6,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "jsapi-tests/tests.h" static JSBool nativeGet(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { vp.set(INT_TO_JSVAL(17)); - return JS_TRUE; + return true; } BEGIN_TEST(testSetProperty_NativeGetterStubSetter) { JS::RootedObject obj(cx, JS_NewObject(cx, NULL, NULL, NULL)); CHECK(obj); JS::RootedValue vobj(cx, OBJECT_TO_JSVAL(obj));
--- a/js/src/jsapi-tests/testSourcePolicy.cpp +++ b/js/src/jsapi-tests/testSourcePolicy.cpp @@ -26,17 +26,17 @@ END_TEST(testBug795104) const char *simpleSource = "var x = 4;"; static void newScriptHook(JSContext *cx, const char *fn, unsigned lineno, JSScript *script, JSFunction *fun, void *data) { if (!JS_StringEqualsAscii(cx, script->sourceData(cx), simpleSource, (JSBool *)data)) - *((JSBool *)data) = JS_FALSE; + *((JSBool *)data) = false; } BEGIN_TEST(testScriptSourceReentrant) { JS::CompileOptions opts(cx); JSBool match = false; JS_SetNewScriptHook(rt, newScriptHook, &match); CHECK(JS::Evaluate(cx, global, opts, simpleSource, strlen(simpleSource), NULL));
--- a/js/src/jsapi-tests/testTrap.cpp +++ b/js/src/jsapi-tests/testTrap.cpp @@ -40,17 +40,17 @@ BEGIN_TEST(testTrap_gc) // execute JS::RootedValue v2(cx); CHECK(JS_ExecuteScript(cx, global, script, v2.address())); CHECK(v2.isObject()); CHECK_EQUAL(emptyTrapCallCount, 0); // Enable debug mode - CHECK(JS_SetDebugMode(cx, JS_TRUE)); + CHECK(JS_SetDebugMode(cx, true)); static const char trapClosureText[] = "some trap closure"; // scope JSScript usage to make sure that it is not used after // JS_ExecuteScript. This way we avoid using Anchor. JS::RootedString trapClosure(cx); { jsbytecode *line2 = JS_LineNumberToPC(cx, script, 1);
--- a/js/src/jsapi-tests/tests.h +++ b/js/src/jsapi-tests/tests.h @@ -239,28 +239,28 @@ class JSAPITest protected: static JSBool print(JSContext *cx, unsigned argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); for (unsigned i = 0; i < argc; i++) { JSString *str = JS_ValueToString(cx, argv[i]); if (!str) - return JS_FALSE; + return false; char *bytes = JS_EncodeString(cx, str); if (!bytes) - return JS_FALSE; + return false; printf("%s%s", i ? " " : "", bytes); JS_free(cx, bytes); } putchar('\n'); fflush(stdout); JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; + return true; } bool definePrint(); virtual JSRuntime * createRuntime() { JSRuntime *rt = JS_NewRuntime(8L * 1024 * 1024, JS_USE_HELPER_THREADS); if (!rt) return NULL;
--- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -128,18 +128,18 @@ JS::detail::CallMethodIfWrapped(JSContex #ifdef JS_USE_JSID_STRUCT_TYPES const jsid JSID_VOID = { size_t(JSID_TYPE_VOID) }; const jsid JSID_EMPTY = { size_t(JSID_TYPE_OBJECT) }; #endif const jsval JSVAL_NULL = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_NULL, 0)); const jsval JSVAL_ZERO = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_INT32, 0)); const jsval JSVAL_ONE = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_INT32, 1)); -const jsval JSVAL_FALSE = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_BOOLEAN, JS_FALSE)); -const jsval JSVAL_TRUE = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_BOOLEAN, JS_TRUE)); +const jsval JSVAL_FALSE = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_BOOLEAN, false)); +const jsval JSVAL_TRUE = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_BOOLEAN, true)); const jsval JSVAL_VOID = IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_UNDEFINED, 0)); const HandleValue JS::NullHandleValue = HandleValue::fromMarkedLocation(&JSVAL_NULL); const HandleValue JS::UndefinedHandleValue = HandleValue::fromMarkedLocation(&JSVAL_VOID); const jsid voidIdValue = JSID_VOID; const jsid emptyIdValue = JSID_EMPTY; @@ -245,109 +245,109 @@ JS_ConvertArgumentsVA(JSContext *cx, uns JSString *str; RootedObject obj(cx); RootedValue val(cx); AssertHeapIsIdle(cx); CHECK_REQUEST(cx); assertSameCompartment(cx, JSValueArray(argv - 2, argc + 2)); sp = argv; - required = JS_TRUE; + required = true; while ((c = *format++) != '\0') { if (isspace(c)) continue; if (c == '/') { - required = JS_FALSE; + required = false; continue; } if (sp == argv + argc) { if (required) { if (JSFunction *fun = ReportIfNotFunction(cx, argv[-2])) { char numBuf[12]; JS_snprintf(numBuf, sizeof numBuf, "%u", argc); JSAutoByteString funNameBytes; if (const char *name = GetFunctionNameBytes(cx, fun, &funNameBytes)) { JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_MORE_ARGS_NEEDED, name, numBuf, (argc == 1) ? "" : "s"); } } - return JS_FALSE; + return false; } break; } switch (c) { case 'b': *va_arg(ap, JSBool *) = ToBoolean(*sp); break; case 'c': if (!JS_ValueToUint16(cx, *sp, va_arg(ap, uint16_t *))) - return JS_FALSE; + return false; break; case 'i': if (!JS_ValueToECMAInt32(cx, *sp, va_arg(ap, int32_t *))) - return JS_FALSE; + return false; break; case 'u': if (!JS_ValueToECMAUint32(cx, *sp, va_arg(ap, uint32_t *))) - return JS_FALSE; + return false; break; case 'j': if (!JS_ValueToInt32(cx, *sp, va_arg(ap, int32_t *))) - return JS_FALSE; + return false; break; case 'd': if (!JS_ValueToNumber(cx, *sp, va_arg(ap, double *))) - return JS_FALSE; + return false; break; case 'I': if (!JS_ValueToNumber(cx, *sp, &d)) - return JS_FALSE; + return false; *va_arg(ap, double *) = ToInteger(d); break; case 'S': case 'W': val = *sp; str = ToString<CanGC>(cx, val); if (!str) - return JS_FALSE; + return false; *sp = STRING_TO_JSVAL(str); if (c == 'W') { JSStableString *stable = str->ensureStable(cx); if (!stable) - return JS_FALSE; + return false; *va_arg(ap, const jschar **) = stable->chars().get(); } else { *va_arg(ap, JSString **) = str; } break; case 'o': if (!js_ValueToObjectOrNull(cx, *sp, &obj)) - return JS_FALSE; + return false; *sp = OBJECT_TO_JSVAL(obj); *va_arg(ap, JSObject **) = obj; break; case 'f': obj = ReportIfNotFunction(cx, *sp); if (!obj) - return JS_FALSE; + return false; *sp = OBJECT_TO_JSVAL(obj); *va_arg(ap, JSFunction **) = &obj->as<JSFunction>(); break; case 'v': *va_arg(ap, jsval *) = *sp; break; case '*': break; default: JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_CHAR, format); - return JS_FALSE; + return false; } sp++; } - return JS_TRUE; + return true; } JS_PUBLIC_API(JSBool) JS_ConvertValue(JSContext *cx, jsval valueArg, JSType type, jsval *vp) { RootedValue value(cx, valueArg); JSBool ok; RootedObject obj(cx); @@ -355,17 +355,17 @@ JS_ConvertValue(JSContext *cx, jsval val double d; AssertHeapIsIdle(cx); CHECK_REQUEST(cx); assertSameCompartment(cx, value); switch (type) { case JSTYPE_VOID: *vp = JSVAL_VOID; - ok = JS_TRUE; + ok = true; break; case JSTYPE_OBJECT: ok = js_ValueToObjectOrNull(cx, value, &obj); if (ok) *vp = OBJECT_TO_JSVAL(obj); break; case JSTYPE_FUNCTION: *vp = value; @@ -380,22 +380,22 @@ JS_ConvertValue(JSContext *cx, jsval val break; case JSTYPE_NUMBER: ok = JS_ValueToNumber(cx, value, &d); if (ok) *vp = DOUBLE_TO_JSVAL(d); break; case JSTYPE_BOOLEAN: *vp = BooleanValue(ToBoolean(value)); - return JS_TRUE; + return true; default: { char numBuf[12]; JS_snprintf(numBuf, sizeof numBuf, "%d", (int)type); JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_TYPE, numBuf); - ok = JS_FALSE; + ok = false; break; } } return ok; } JS_PUBLIC_API(JSBool) JS_ValueToObject(JSContext *cx, jsval valueArg, JSObject **objpArg) @@ -544,17 +544,17 @@ JS_ValueToUint16(JSContext *cx, jsval va JS_PUBLIC_API(JSBool) JS_ValueToBoolean(JSContext *cx, jsval value, JSBool *bp) { AssertHeapIsIdle(cx); CHECK_REQUEST(cx); assertSameCompartment(cx, value); *bp = ToBoolean(value); - return JS_TRUE; + return true; } JS_PUBLIC_API(JSType) JS_TypeOfValue(JSContext *cx, jsval valueArg) { RootedValue value(cx, valueArg); AssertHeapIsIdle(cx); CHECK_REQUEST(cx); @@ -2267,19 +2267,19 @@ DumpNotify(JSTracer *trc, void **thingp, static JSBool DumpNode(JSDumpingTracer *dtrc, FILE* fp, JSHeapDumpNode *node) { JSHeapDumpNode *prev, *following; size_t chainLimit; enum { MAX_PARENTS_TO_PRINT = 10 }; JS_GetTraceThingInfo(dtrc->buffer, sizeof dtrc->buffer, - &dtrc->base, node->thing, node->kind, JS_TRUE); + &dtrc->base, node->thing, node->kind, true); if (fprintf(fp, "%p %-22s via ", node->thing, dtrc->buffer) < 0) - return JS_FALSE; + return false; /* * We need to print the parent chain in the reverse order. To do it in * O(N) time where N is the chain length we first reverse the chain while * searching for the top and then print each node while restoring the * chain order. */ chainLimit = MAX_PARENTS_TO_PRINT; @@ -2288,17 +2288,17 @@ DumpNode(JSDumpingTracer *dtrc, FILE* fp following = node->parent; node->parent = prev; prev = node; node = following; if (!node) break; if (chainLimit == 0) { if (fputs("...", fp) < 0) - return JS_FALSE; + return false; break; } --chainLimit; } node = prev; prev = following; bool ok = true; @@ -2307,17 +2307,17 @@ DumpNode(JSDumpingTracer *dtrc, FILE* fp if (ok) { if (!prev) { /* Print edge from some runtime root or startThing. */ if (fputs(node->edgeName, fp) < 0) ok = false; } else { JS_GetTraceThingInfo(dtrc->buffer, sizeof dtrc->buffer, &dtrc->base, prev->thing, prev->kind, - JS_FALSE); + false); if (fprintf(fp, "(%p %s).%s", prev->thing, dtrc->buffer, node->edgeName) < 0) { ok = false; } } } following = node->parent; node->parent = prev; @@ -2372,17 +2372,17 @@ JS_DumpHeap(JSRuntime *rt, FILE *fp, voi if (dtrc.ok && depth < maxDepth && (thingToFind != node->thing || !thingToFindWasTraced)) { dtrc.parentNode = node; children = NULL; dtrc.lastNodep = &children; JS_TraceChildren(&dtrc.base, node->thing, node->kind); if (thingToFind == node->thing) - thingToFindWasTraced = JS_TRUE; + thingToFindWasTraced = true; if (children != NULL) { ++depth; node = children; continue; } } } @@ -2670,17 +2670,17 @@ JS_ValueToId(JSContext *cx, jsval valueA JS_PUBLIC_API(JSBool) JS_IdToValue(JSContext *cx, jsid id, jsval *vp) { AssertHeapIsIdle(cx); CHECK_REQUEST(cx); *vp = IdToJsval(id); assertSameCompartment(cx, *vp); - return JS_TRUE; + return true; } JS_PUBLIC_API(JSBool) JS_DefaultValue(JSContext *cx, JSObject *objArg, JSType hint, jsval *vp) { RootedObject obj(cx, objArg); AssertHeapIsIdle(cx); CHECK_REQUEST(cx); @@ -2693,42 +2693,42 @@ JS_DefaultValue(JSContext *cx, JSObject *vp = value; return true; } JS_PUBLIC_API(JSBool) JS_PropertyStub(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp) { - return JS_TRUE; + return true; } JS_PUBLIC_API(JSBool) JS_StrictPropertyStub(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, MutableHandleValue vp) { - return JS_TRUE; + return true; } JS_PUBLIC_API(JSBool) JS_DeletePropertyStub(JSContext *cx, HandleObject obj, HandleId id, JSBool *succeeded) { *succeeded = true; return true; } JS_PUBLIC_API(JSBool) JS_EnumerateStub(JSContext *cx, HandleObject obj) { - return JS_TRUE; + return true; } JS_PUBLIC_API(JSBool) JS_ResolveStub(JSContext *cx, HandleObject obj, HandleId id) { - return JS_TRUE; + return true; } JS_PUBLIC_API(JSBool) JS_ConvertStub(JSContext *cx, HandleObject obj, JSType type, MutableHandleValue vp) { JS_ASSERT(type != JSTYPE_OBJECT && type != JSTYPE_FUNCTION); JS_ASSERT(obj); return DefaultValue(cx, obj, type, vp); @@ -2829,17 +2829,17 @@ JS_GetPrototype(JSContext *cx, JS::Handl JS_PUBLIC_API(JSBool) JS_SetPrototype(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<JSObject*> proto) { AssertHeapIsIdle(cx); CHECK_REQUEST(cx); assertSameCompartment(cx, obj, proto); - return SetClassAndProto(cx, obj, obj->getClass(), proto, JS_FALSE); + return SetClassAndProto(cx, obj, obj->getClass(), proto, false); } JS_PUBLIC_API(JSObject *) JS_GetParent(JSObject *obj) { JS_ASSERT(!obj->is<ScopeObject>()); return obj->getParent(); } @@ -2882,17 +2882,17 @@ JS_GetConstructor(JSContext *cx, JSObjec } JS_PUBLIC_API(JSBool) JS_GetObjectId(JSContext *cx, JSObject *obj, jsid *idp) { AssertHeapIsIdle(cx); assertSameCompartment(cx, obj); *idp = OBJECT_TO_JSID(obj); - return JS_TRUE; + return true; } class AutoHoldZone { public: explicit AutoHoldZone(Zone *zone MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : holdp(&zone->hold) @@ -3111,17 +3111,17 @@ LookupPropertyById(JSContext *cx, Handle static JSBool LookupResult(JSContext *cx, HandleObject obj, HandleObject obj2, HandleId id, HandleShape shape, MutableHandleValue vp) { if (!shape) { /* XXX bad API: no way to tell "not defined" from "void value" */ vp.setUndefined(); - return JS_TRUE; + return true; } if (!obj2->isNative()) { if (obj2->is<ProxyObject>()) { AutoPropertyDescriptorRooter desc(cx); if (!Proxy::getPropertyDescriptor(cx, obj2, id, &desc, 0)) return false; if (!(desc.attrs & JSPROP_SHARED)) { @@ -3268,28 +3268,28 @@ JS_AlreadyHasOwnPropertyById(JSContext * CHECK_REQUEST(cx); assertSameCompartment(cx, obj, id); if (!obj->isNative()) { RootedObject obj2(cx); RootedShape prop(cx); if (!LookupPropertyById(cx, obj, id, 0, &obj2, &prop)) - return JS_FALSE; + return false; *foundp = (obj == obj2); - return JS_TRUE; + return true; } if (JSID_IS_INT(id) && obj->containsDenseElement(JSID_TO_INT(id))) { *foundp = true; - return JS_TRUE; + return true; } *foundp = obj->nativeContains(cx, id); - return JS_TRUE; + return true; } JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnElement(JSContext *cx, JSObject *objArg, uint32_t index, JSBool *foundp) { RootedObject obj(cx, objArg); AssertHeapIsIdle(cx); CHECK_REQUEST(cx); @@ -3453,17 +3453,17 @@ DefineProperty(JSContext *cx, HandleObje RootedId id(cx); if (attrs & JSPROP_INDEX) { id = INT_TO_JSID(intptr_t(name)); attrs &= ~JSPROP_INDEX; } else { JSAtom *atom = Atomize(cx, name, strlen(name)); if (!atom) - return JS_FALSE; + return false; id = AtomToId(atom); } return DefinePropertyById(cx, obj, id, value, getter, setter, attrs, flags, tinyid); } JS_PUBLIC_API(JSBool) JS_DefineProperty(JSContext *cx, JSObject *objArg, const char *name, jsval valueArg, @@ -3566,17 +3566,17 @@ JS_DefineConstDoubles(JSContext *cx, JSO RootedObject obj(cx, objArg); JSBool ok; unsigned attrs; AssertHeapIsIdle(cx); CHECK_REQUEST(cx); JSPropertyOpWrapper noget = GetterWrapper(NULL); JSStrictPropertyOpWrapper noset = SetterWrapper(NULL); - for (ok = JS_TRUE; cds->name; cds++) { + for (ok = true; cds->name; cds++) { Value value = DoubleValue(cds->dval); attrs = cds->flags; if (!attrs) attrs = JSPROP_READONLY | JSPROP_PERMANENT; ok = DefineProperty(cx, obj, cds->name, value, noget, noset, attrs, 0, 0); if (!ok) break; } @@ -3600,25 +3600,25 @@ JS_DefineProperties(JSContext *cx, JSObj static JSBool GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id, unsigned flags, JSBool own, PropertyDescriptor *desc) { RootedObject obj2(cx); RootedShape shape(cx); if (!LookupPropertyById(cx, obj, id, flags, &obj2, &shape)) - return JS_FALSE; + return false; if (!shape || (own && obj != obj2)) { desc->obj = NULL; desc->attrs = 0; desc->getter = NULL; desc->setter = NULL; desc->value.setUndefined(); - return JS_TRUE; + return true; } desc->obj = obj2; if (obj2->isNative()) { if (IsImplicitDenseElement(shape)) { desc->attrs = JSPROP_ENUMERATE; desc->getter = NULL; desc->setter = NULL; @@ -3650,31 +3650,31 @@ GetPropertyDescriptorById(JSContext *cx, JS_PUBLIC_API(JSBool) JS_GetPropertyDescriptorById(JSContext *cx, JSObject *objArg, jsid idArg, unsigned flags, JSPropertyDescriptor *desc_) { RootedObject obj(cx, objArg); RootedId id(cx, idArg); AutoPropertyDescriptorRooter desc(cx); - if (!GetPropertyDescriptorById(cx, obj, id, flags, JS_FALSE, &desc)) + if (!GetPropertyDescriptorById(cx, obj, id, flags, false, &desc)) return false; *desc_ = desc; return true; } JS_PUBLIC_API(JSBool) JS_GetPropertyAttrsGetterAndSetterById(JSContext *cx, JSObject *objArg, jsid idArg, unsigned *attrsp, JSBool *foundp, JSPropertyOp *getterp, JSStrictPropertyOp *setterp) { RootedObject obj(cx, objArg); RootedId id(cx, idArg); AutoPropertyDescriptorRooter desc(cx); - if (!GetPropertyDescriptorById(cx, obj, id, 0, JS_FALSE, &desc)) + if (!GetPropertyDescriptorById(cx, obj, id, 0, false, &desc)) return false; *attrsp = desc.attrs; *foundp = (desc.obj != NULL); if (getterp) *getterp = desc.getter; if (setterp) *setterp = desc.setter; @@ -4512,17 +4512,17 @@ js_generic_native_method_dispatcher(JSCo CallArgs args = CallArgsFromVp(argc, vp); const JSFunctionSpec *fs = (JSFunctionSpec *) vp->toObject().as<JSFunction>().getExtendedSlot(0).toPrivate(); JS_ASSERT((fs->flags & JSFUN_GENERIC_NATIVE) != 0); if (argc < 1) { js_ReportMissingArg(cx, args.calleev(), 0); - return JS_FALSE; + return false; } /* * Copy all actual (argc) arguments down over our |this| parameter, vp[1], * which is almost always the class constructor object, e.g. Array. Then * call the corresponding prototype native method with our first argument * passed as |this|. */ @@ -4543,39 +4543,39 @@ JS_DefineFunctions(JSContext *cx, JSObje assertSameCompartment(cx, objArg); RootedObject obj(cx, objArg); RootedObject ctor(cx); for (; fs->name; fs++) { RootedAtom atom(cx, Atomize(cx, fs->name, strlen(fs->name))); if (!atom) - return JS_FALSE; + return false; Rooted<jsid> id(cx, AtomToId(atom)); /* * Define a generic arity N+1 static method for the arity N prototype * method if flags contains JSFUN_GENERIC_NATIVE. */ unsigned flags = fs->flags; if (flags & JSFUN_GENERIC_NATIVE) { if (!ctor) { ctor = JS_GetConstructor(cx, obj); if (!ctor) - return JS_FALSE; + return false; } flags &= ~JSFUN_GENERIC_NATIVE; JSFunction *fun = DefineFunction(cx, ctor, id, js_generic_native_method_dispatcher, fs->nargs + 1, flags, JSFunction::ExtendedFinalizeKind); if (!fun) - return JS_FALSE; + return false; /* * As jsapi.h notes, fs must point to storage that lives as long * as fun->object lives. */ fun->setExtendedSlot(0, PrivateValue(const_cast<JSFunctionSpec*>(fs))); } @@ -4593,48 +4593,48 @@ JS_DefineFunctions(JSContext *cx, JSObje * in. Self-hosted functions can access each other via their names, * but not via the builtin classes they get installed into. */ if (cx->runtime()->isSelfHostingGlobal(cx->global())) continue; RootedAtom shAtom(cx, Atomize(cx, fs->selfHostedName, strlen(fs->selfHostedName))); if (!shAtom) - return JS_FALSE; + return false; RootedPropertyName shName(cx, shAtom->asPropertyName()); RootedValue funVal(cx); if (!cx->runtime()->maybeWrappedSelfHostedFunction(cx, shName, &funVal)) - return JS_FALSE; + return false; if (!funVal.isUndefined()) { if (!JSObject::defineProperty(cx, obj, atom->asPropertyName(), funVal, NULL, NULL, flags & ~JSFUN_FLAGS_MASK)) { - return JS_FALSE; + return false; } } else { JSFunction *fun = DefineFunction(cx, obj, id, /* native = */ NULL, fs->nargs, 0, JSFunction::ExtendedFinalizeKind, SingletonObject); if (!fun) - return JS_FALSE; + return false; fun->setIsSelfHostedBuiltin(); fun->setExtendedSlot(0, PrivateValue(const_cast<JSFunctionSpec*>(fs))); funVal.setObject(*fun); } RootedObject holder(cx, cx->global()->intrinsicsHolder()); if (!JSObject::defineProperty(cx, holder, shName, funVal)) - return JS_FALSE; + return false; } else { JSFunction *fun = DefineFunction(cx, obj, id, fs->call.op, fs->nargs, flags); if (!fun) - return JS_FALSE; + return false; if (fs->call.info) fun->setJitInfo(fs->call.info); } } - return JS_TRUE; + return true; } JS_PUBLIC_API(JSFunction *) JS_DefineFunction(JSContext *cx, JSObject *objArg, const char *name, JSNative call, unsigned nargs, unsigned attrs) { RootedObject obj(cx, objArg); JS_THREADSAFE_ASSERT(cx->compartment() != cx->runtime()->atomsCompartment); @@ -4921,38 +4921,38 @@ JS_BufferIsCompilableUnit(JSContext *cx, JSExceptionState *exnState; JSErrorReporter older; AssertHeapIsIdle(cx); CHECK_REQUEST(cx); assertSameCompartment(cx, obj); jschar *chars = JS::UTF8CharsToNewTwoByteCharsZ(cx, JS::UTF8Chars(utf8, length), &length).get(); if (!chars) - return JS_TRUE; + return true; /* * Return true on any out-of-memory error, so our caller doesn't try to * collect more buffered source. */ - result = JS_TRUE; + result = true; exnState = JS_SaveExceptionState(cx); { CompileOptions options(cx); options.setCompileAndGo(false); Parser<frontend::FullParseHandler> parser(cx, &cx->tempLifoAlloc(), options, chars, length, /* foldConstants = */ true, NULL, NULL); older = JS_SetErrorReporter(cx, NULL); if (!parser.parse(obj) && parser.isUnexpectedEOF()) { /* * We ran into an error. If it was because we ran out of * source, we return false so our caller knows to try to * collect more buffered source. */ - result = JS_FALSE; + result = false; } JS_SetErrorReporter(cx, older); } js_free(chars); JS_RestoreExceptionState(cx, exnState); return result; } @@ -6455,20 +6455,20 @@ JS_IsExceptionPending(JSContext *cx) } JS_PUBLIC_API(JSBool) JS_GetPendingException(JSContext *cx, jsval *vp) { AssertHeapIsIdle(cx); CHECK_REQUEST(cx); if (!cx->isExceptionPending()) - return JS_FALSE; + return false; *vp = cx->getPendingException(); assertSameCompartment(cx, *vp); - return JS_TRUE; + return true; } JS_PUBLIC_API(void) JS_SetPendingException(JSContext *cx, jsval valueArg) { RootedValue value(cx, valueArg); AssertHeapIsIdle(cx); CHECK_REQUEST(cx); @@ -6713,23 +6713,23 @@ JS_DescribeScriptedCaller(JSContext *cx, { if (script) *script = NULL; if (lineno) *lineno = 0; NonBuiltinScriptFrameIter i(cx); if (i.done()) - return JS_FALSE; + return false; if (script) *script = i.script(); if (lineno) *lineno = js::PCToLineNumber(i.script(), i.pc()); - return JS_TRUE; + return true; } #ifdef JS_THREADSAFE static PRStatus CallOnce(void *func) { JSInitCallback init = JS_DATA_TO_FUNC_PTR(JSInitCallback, func); return init() ? PR_SUCCESS : PR_FAILURE; @@ -6741,17 +6741,17 @@ JS_CallOnce(JSCallOnceType *once, JSInit { #ifdef JS_THREADSAFE return PR_CallOnceWithArg(once, CallOnce, JS_FUNC_TO_DATA_PTR(void *, func)) == PR_SUCCESS; #else if (!*once) { *once = true; return func(); } else { - return JS_TRUE; + return true; } #endif } AutoGCRooter::AutoGCRooter(JSContext *cx, ptrdiff_t tag) : down(ContextFriendFields::get(cx)->autoGCRooters), tag_(tag), stackTop(&ContextFriendFields::get(cx)->autoGCRooters)
--- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -814,17 +814,17 @@ typedef JSBool * state pointed at by statep is destroyed and *statep is set to JSVAL_NULL * if there are no properties left to enumerate. * * JSENUMERATE_DESTROY * Destroy the opaque iterator state previously allocated in *statep by a * call to this function when enum_op was JSENUMERATE_INIT or * JSENUMERATE_INIT_ALL. * - * The return value is used to indicate success, with a value of JS_FALSE + * The return value is used to indicate success, with a value of false * indicating failure. */ typedef JSBool (* JSNewEnumerateOp)(JSContext *cx, JS::Handle<JSObject*> obj, JSIterateOp enum_op, JS::MutableHandle<JS::Value> statep, JS::MutableHandle<jsid> idp); /* * The old-style JSClass.enumerate op should define all lazy properties not @@ -912,17 +912,17 @@ struct JSStringFinalizer { * is either a string or an int jsval. */ typedef JSBool (* JSCheckAccessOp)(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JSAccessMode mode, JS::MutableHandle<JS::Value> vp); /* * Check whether v is an instance of obj. Return false on error or exception, - * true on success with JS_TRUE in *bp if v is an instance of obj, JS_FALSE in + * true on success with true in *bp if v is an instance of obj, false in * *bp otherwise. */ typedef JSBool (* JSHasInstanceOp)(JSContext *cx, JS::Handle<JSObject*> obj, JS::MutableHandle<JS::Value> vp, JSBool *bp); /* * Function type for trace operation of the class called to enumerate all @@ -3335,17 +3335,17 @@ JS_DefinePropertyById(JSContext *cx, JSO extern JS_PUBLIC_API(JSBool) JS_DefineOwnProperty(JSContext *cx, JSObject *obj, jsid id, jsval descriptor, JSBool *bp); /* * Determine the attributes (JSPROP_* flags) of a property on a given object. * * If the object does not have a property by that name, *foundp will be - * JS_FALSE and the value of *attrsp is undefined. + * false and the value of *attrsp is undefined. */ extern JS_PUBLIC_API(JSBool) JS_GetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name, unsigned *attrsp, JSBool *foundp); /* * The same, but if the property is native, return its getter and setter via * *getterp and *setterp, respectively (and only if the out parameter pointer @@ -3364,17 +3364,17 @@ JS_GetPropertyAttrsGetterAndSetterById(J unsigned *attrsp, JSBool *foundp, JSPropertyOp *getterp, JSStrictPropertyOp *setterp); /* * Set the attributes of a property on a given object. * * If the object does not have a property by that name, *foundp will be - * JS_FALSE and nothing will be altered. + * false and nothing will be altered. */ extern JS_PUBLIC_API(JSBool) JS_SetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name, unsigned attrs, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_DefinePropertyWithTinyId(JSContext *cx, JSObject *obj, const char *name, int8_t tinyid, jsval value, @@ -3590,17 +3590,17 @@ JS_DefineUCProperty(JSContext *cx, JSObj const jschar *name, size_t namelen, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); /* * Determine the attributes (JSPROP_* flags) of a property on a given object. * * If the object does not have a property by that name, *foundp will be - * JS_FALSE and the value of *attrsp is undefined. + * false and the value of *attrsp is undefined. */ extern JS_PUBLIC_API(JSBool) JS_GetUCPropertyAttributes(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, unsigned *attrsp, JSBool *foundp); /* * The same, but if the property is native, return its getter and setter via @@ -3613,17 +3613,17 @@ JS_GetUCPropertyAttrsGetterAndSetter(JSC unsigned *attrsp, JSBool *foundp, JSPropertyOp *getterp, JSStrictPropertyOp *setterp); /* * Set the attributes of a property on a given object. * * If the object does not have a property by that name, *foundp will be - * JS_FALSE and nothing will be altered. + * false and nothing will be altered. */ extern JS_PUBLIC_API(JSBool) JS_SetUCPropertyAttributes(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, unsigned attrs, JSBool *foundp); extern JS_PUBLIC_API(JSBool) @@ -3963,19 +3963,19 @@ JS_DefineFunctionById(JSContext *cx, JSO /* * Clone a top-level function into a new scope. This function will dynamically * fail if funobj was lexically nested inside some other function. */ extern JS_PUBLIC_API(JSObject *) JS_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent); /* - * Given a buffer, return JS_FALSE if the buffer might become a valid + * Given a buffer, return false if the buffer might become a valid * javascript statement with the addition of more lines. Otherwise return - * JS_TRUE. The intent is to support interactive compilation - accumulate + * true. The intent is to support interactive compilation - accumulate * lines in a buffer until JS_BufferIsCompilableUnit is true, then pass it to * the compiler. */ extern JS_PUBLIC_API(JSBool) JS_BufferIsCompilableUnit(JSContext *cx, JSObject *obj, const char *utf8, size_t length); extern JS_PUBLIC_API(JSScript *) JS_CompileScript(JSContext *cx, JSObject *obj, @@ -4409,17 +4409,17 @@ JS_FileEscapedString(FILE *fp, JSString * JS_GetFlatStringChars. Note, though, that this is purely a syntactic * distinction: the input and output of JS_FlattenString are the same actual * GC-thing so only one needs to be rooted. If a JSString is known to be flat, * JS_ASSERT_STRING_IS_FLAT can be used to make a debug-checked cast. Example: * * // in a fallible context * JSFlatString *fstr = JS_FlattenString(cx, str); * if (!fstr) - * return JS_FALSE; + * return false; * JS_ASSERT(fstr == JS_ASSERT_STRING_IS_FLAT(str)); * * // in an infallible context, for the same 'str' * const jschar *chars = JS_GetFlatStringChars(fstr) * JS_ASSERT(chars); * * The CharsZ APIs guarantee that the returned array has a null character at * chars[length]. This can require additional copying so clients should prefer @@ -4508,17 +4508,17 @@ JS_ConcatStrings(JSContext *cx, JSString /* * For JS_DecodeBytes, set *dstlenp to the size of the destination buffer before * the call; on return, *dstlenp contains the number of jschars actually stored. * To determine the necessary destination buffer size, make a sizing call that * passes NULL for dst. * * On errors, the functions report the error. In that case, *dstlenp contains * the number of characters or bytes transferred so far. If cx is NULL, no - * error is reported on failure, and the functions simply return JS_FALSE. + * error is reported on failure, and the functions simply return false. * * NB: This function does not store an additional zero byte or jschar after the * transcoded string. */ JS_PUBLIC_API(JSBool) JS_DecodeBytes(JSContext *cx, const char *src, size_t srclen, jschar *dst, size_t *dstlenp);
--- a/js/src/jscntxt.cpp +++ b/js/src/jscntxt.cpp @@ -493,21 +493,21 @@ js_ReportErrorVA(JSContext *cx, unsigned { char *message; jschar *ucmessage; size_t messagelen; JSErrorReport report; JSBool warning; if (checkReportFlags(cx, &flags)) - return JS_TRUE; + return true; message = JS_vsmprintf(format, ap); if (!message) - return JS_FALSE; + return false; messagelen = strlen(message); PodZero(&report); report.flags = flags; report.errorNumber = JSMSG_USER_DEFINED_ERROR; report.ucmessage = ucmessage = InflateString(cx, message, &messagelen); PopulateReportBlame(cx, &report); @@ -662,17 +662,17 @@ js_ExpandErrorArguments(JSContext *cx, J * null it out to act as the caboose when we free the * pointers later. */ if (messageArgsPassed) { JS_ASSERT(!reportp->messageArgs[argCount]); } else { reportp->messageArgs = cx->pod_malloc<const jschar*>(argCount + 1); if (!reportp->messageArgs) - return JS_FALSE; + return false; /* NULL-terminate for easy copying. */ reportp->messageArgs[argCount] = NULL; } for (i = 0; i < argCount; i++) { if (messageArgsPassed) { /* Do nothing. */ } else if (argumentsType == ArgumentsAreASCII) { char *charArg = va_arg(ap, char *); @@ -763,17 +763,17 @@ js_ExpandErrorArguments(JSContext *cx, J const char *defaultErrorMessage = "No error message available for error number %d"; size_t nbytes = strlen(defaultErrorMessage) + 16; *messagep = cx->pod_malloc<char>(nbytes); if (!*messagep) goto error; JS_snprintf(*messagep, nbytes, defaultErrorMessage, errorNumber); } - return JS_TRUE; + return true; error: if (!messageArgsPassed && reportp->messageArgs) { /* free the arguments only if we allocated them */ if (argumentsType == ArgumentsAreASCII) { i = 0; while (reportp->messageArgs[i]) js_free((void *)reportp->messageArgs[i++]); @@ -784,40 +784,40 @@ error: if (reportp->ucmessage) { js_free((void *)reportp->ucmessage); reportp->ucmessage = NULL; } if (*messagep) { js_free((void *)*messagep); *messagep = NULL; } - return JS_FALSE; + return false; } JSBool js_ReportErrorNumberVA(JSContext *cx, unsigned flags, JSErrorCallback callback, void *userRef, const unsigned errorNumber, ErrorArgumentsType argumentsType, va_list ap) { JSErrorReport report; char *message; JSBool warning; if (checkReportFlags(cx, &flags)) - return JS_TRUE; + return true; warning = JSREPORT_IS_WARNING(flags); PodZero(&report); report.flags = flags; report.errorNumber = errorNumber; PopulateReportBlame(cx, &report); if (!js_ExpandErrorArguments(cx, callback, userRef, errorNumber, &message, &report, argumentsType, ap)) { - return JS_FALSE; + return false; } ReportError(cx, message, &report, callback, userRef); if (message) js_free(message); if (report.messageArgs) { /* @@ -903,17 +903,17 @@ JSBool js_ReportIsNullOrUndefined(JSContext *cx, int spindex, HandleValue v, HandleString fallback) { char *bytes; JSBool ok; bytes = DecompileValueGenerator(cx, spindex, v, fallback); if (!bytes) - return JS_FALSE; + return false; if (strcmp(bytes, js_undefined_str) == 0 || strcmp(bytes, js_null_str) == 0) { ok = JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, NULL, JSMSG_NO_PROPERTIES, bytes, NULL, NULL); } else if (v.isUndefined()) { @@ -962,17 +962,17 @@ js_ReportValueErrorFlags(JSContext *cx, { char *bytes; JSBool ok; JS_ASSERT(js_ErrorFormatString[errorNumber].argCount >= 1); JS_ASSERT(js_ErrorFormatString[errorNumber].argCount <= 3); bytes = DecompileValueGenerator(cx, spindex, v, fallback); if (!bytes) - return JS_FALSE; + return false; ok = JS_ReportErrorFlagsAndNumber(cx, flags, js_GetErrorMessage, NULL, errorNumber, bytes, arg1, arg2); js_free(bytes); return ok; } const JSErrorFormatString js_ErrorFormatString[JSErr_Limit] = {
--- a/js/src/jsdate.cpp +++ b/js/src/jsdate.cpp @@ -564,17 +564,17 @@ static const int ttb[] = { 10000 + 8 * 60, 10000 + 7 * 60 /* PST/PDT */ }; /* helper for date_parse */ static JSBool date_regionMatches(const char* s1, int s1off, const jschar* s2, int s2off, int count, int ignoreCase) { - JSBool result = JS_FALSE; + JSBool result = false; /* return true if matches, otherwise, false */ while (count > 0 && s1[s1off] && s2[s2off]) { if (ignoreCase) { if (unicode::ToLowerCase(s1[s1off]) != unicode::ToLowerCase(s2[s2off])) break; } else { if ((jschar)s1[s1off] != s2[s2off]) { @@ -582,17 +582,17 @@ date_regionMatches(const char* s1, int s } } s1off++; s2off++; count--; } if (count == 0) { - result = JS_TRUE; + result = true; } return result; } /* find UTC time from given date... no 1900 correction! */ static double date_msecFromDate(double year, double mon, double mday, double hour, @@ -610,21 +610,21 @@ date_msecFromArgs(JSContext *cx, CallArg unsigned loop; double array[MAXARGS]; double msec_time; for (loop = 0; loop < MAXARGS; loop++) { if (loop < args.length()) { double d; if (!ToNumber(cx, args[loop], &d)) - return JS_FALSE; + return false; /* return NaN if any arg is not finite */ if (!IsFinite(d)) { *rval = js_NaN; - return JS_TRUE; + return true; } array[loop] = ToInteger(d); } else { if (loop == 2) { array[loop] = 1; /* Default the date argument to 1. */ } else { array[loop] = 0; } @@ -633,17 +633,17 @@ date_msecFromArgs(JSContext *cx, CallArg /* adjust 2-digit years into the 20th century */ if (array[0] >= 0 && array[0] <= 99) array[0] += 1900; msec_time = date_msecFromDate(array[0], array[1], array[2], array[3], array[4], array[5], array[6]); *rval = msec_time; - return JS_TRUE; + return true; } /* * See ECMA 15.9.4.[3-10]; */ static bool date_UTC(JSContext *cx, unsigned argc, Value *vp) { @@ -714,17 +714,17 @@ static JSBool ndigits(size_t n, size_t *result, const jschar *s, size_t* i, size_t limit) { size_t init = *i; if (digits(result, s, i, Min(limit, init+n))) return ((*i - init) == n); *i = init; - return JS_FALSE; + return false; } static int DaysInMonth(int year, int month) { bool leap = IsLeapYear(year); int result = int(DayFromMonth(month, leap) - DayFromMonth(month - 1, leap)); return result; @@ -798,17 +798,17 @@ date_parseISOString(JSLinearString *str, int dateMul = 1; size_t year = 1970; size_t month = 1; size_t day = 1; size_t hour = 0; size_t min = 0; size_t sec = 0; double frac = 0; - bool isLocalTime = JS_FALSE; + bool isLocalTime = false; size_t tzHour = 0; size_t tzMin = 0; #define PEEK(ch) (i < limit && s[i] == ch) #define NEED(ch) \ JS_BEGIN_MACRO \ if (i >= limit || s[i] != ch) { goto syntax; } else { ++i; } \ @@ -871,17 +871,17 @@ date_parseISOString(JSLinearString *str, /* * Non-standard extension to the ISO date format (permitted by ES5): * allow "-0700" as a time zone offset, not just "-07:00". */ if (PEEK(':')) ++i; NEED_NDIGITS(2, tzMin); } else { - isLocalTime = JS_TRUE; + isLocalTime = true; } done: if (year > 275943 // ceil(1e8/365) + 1970 || (month == 0 || month > 12) || (day == 0 || day > size_t(DaysInMonth(year,month))) || hour > 24 || ((hour == 24) && (min > 0 || sec > 0)) @@ -907,22 +907,22 @@ date_parseISOString(JSLinearString *str, + (tzMin * msPerMinute))); } if (msec < -8.64e15 || msec > 8.64e15) goto syntax; *result = msec; - return JS_TRUE; + return true; syntax: /* syntax error */ *result = 0; - return JS_FALSE; + return false; #undef PEEK #undef NEED #undef DONE_UNLESS #undef NEED_NDIGITS } static JSBool @@ -938,22 +938,22 @@ date_parseString(JSLinearString *str, do int mday = -1; int hour = -1; int min = -1; int sec = -1; int c = -1; int n = -1; int tzoffset = -1; int prevc = 0; - JSBool seenplusminus = JS_FALSE; + JSBool seenplusminus = false; int temp; - JSBool seenmonthname = JS_FALSE; + JSBool seenmonthname = false; if (date_parseISOString(str, result, dtInfo)) - return JS_TRUE; + return true; s = str->chars(); limit = str->length(); if (limit == 0) goto syntax; while (i < limit) { c = s[i]; i++; @@ -987,17 +987,17 @@ date_parseString(JSLinearString *str, do * works */ /* uses of seenplusminus allow : in TZA, so Java * no-timezone style of GMT+4:30 works */ if ((prevc == '+' || prevc == '-')/* && year>=0 */) { /* make ':' case below change tzoffset */ - seenplusminus = JS_TRUE; + seenplusminus = true; /* offset */ if (n < 24) n = n * 60; /* EG. "GMT-3" */ else n = n % 100 + n / 100 * 60; /* eg "GMT-0430" */ if (prevc == '+') /* plus means east of GMT */ n = -n; @@ -1079,17 +1079,17 @@ date_parseString(JSLinearString *str, do } } } else if (action <= 13) { /* month! */ /* Adjust mon to be 1-based until the final values for mon, mday and year are adjusted below */ if (seenmonthname) { goto syntax; } - seenmonthname = JS_TRUE; + seenmonthname = true; temp = /*byte*/ (action - 2) + 1; if (mon < 0) { mon = temp; } else if (mday < 0) { mday = mon; mon = temp; } else if (year < 0) { @@ -1184,22 +1184,22 @@ date_parseString(JSLinearString *str, do if (tzoffset == -1) { /* no time zone specified, have to use local */ msec = UTC(msec, dtInfo); } else { msec += tzoffset * msPerMinute; } *result = msec; - return JS_TRUE; + return true; syntax: /* syntax error */ *result = 0; - return JS_FALSE; + return false; } static bool date_parse(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); if (args.length() == 0) { vp->setDouble(js_NaN); @@ -2580,36 +2580,36 @@ date_format(JSContext *cx, double date, if (PRMJ_FormatTime(tzbuf, sizeof tzbuf, "(%Z)", &split) != 0) { /* Decide whether to use the resulting timezone string. * * Reject it if it contains any non-ASCII, non-alphanumeric * characters. It's then likely in some other character * encoding, and we probably won't display it correctly. */ - usetz = JS_TRUE; + usetz = true; tzlen = strlen(tzbuf); if (tzlen > 100) { - usetz = JS_FALSE; + usetz = false; } else { for (i = 0; i < tzlen; i++) { jschar c = tzbuf[i]; if (c > 127 || !(isalpha(c) || isdigit(c) || c == ' ' || c == '(' || c == ')')) { - usetz = JS_FALSE; + usetz = false; } } } /* Also reject it if it's not parenthesized or if it's '()'. */ if (tzbuf[0] != '(' || tzbuf[1] == ')') - usetz = JS_FALSE; + usetz = false; } else - usetz = JS_FALSE; + usetz = false; switch (format) { case FORMATSPEC_FULL: /* * Avoid dependence on PRMJ_FormatTimeUSEnglish, because it * requires a PRMJTime... which only has 16-bit years. Sub-ECMA. */ /* Tue Oct 31 2000 09:41:40 GMT-0800 (PST) */
--- a/js/src/jsdbgapi.cpp +++ b/js/src/jsdbgapi.cpp @@ -209,17 +209,17 @@ CheckDebugMode(JSContext *cx) JS_PUBLIC_API(JSBool) JS_SetSingleStepMode(JSContext *cx, JSScript *scriptArg, JSBool singleStep) { RootedScript script(cx, scriptArg); assertSameCompartment(cx, script); if (!CheckDebugMode(cx)) - return JS_FALSE; + return false; return script->setStepModeFlag(cx, singleStep); } JS_PUBLIC_API(JSBool) JS_SetTrap(JSContext *cx, JSScript *scriptArg, jsbytecode *pc, JSTrapHandler handler, jsval closureArg) { RootedScript script(cx, scriptArg); @@ -276,17 +276,17 @@ JS_PUBLIC_API(JSBool) JS_ClearInterrupt(JSRuntime *rt, JSInterruptHook *hoop, void **closurep) { if (hoop) *hoop = rt->debugHooks.interruptHook; if (closurep) *closurep = rt->debugHooks.interruptHookData; rt->debugHooks.interruptHook = 0; rt->debugHooks.interruptHookData = 0; - return JS_TRUE; + return true; } /************************************************************************/ JS_PUBLIC_API(JSBool) JS_SetWatchPoint(JSContext *cx, JSObject *obj_, jsid id_, JSWatchPointHandler handler, JSObject *closure_) { @@ -402,22 +402,22 @@ JS_EndPC(JSContext *cx, JSScript *script JS_PUBLIC_API(JSBool) JS_GetLinePCs(JSContext *cx, JSScript *script, unsigned startLine, unsigned maxLines, unsigned* count, unsigned** retLines, jsbytecode*** retPCs) { size_t len = (script->length > maxLines ? maxLines : script->length); unsigned *lines = cx->pod_malloc<unsigned>(len); if (!lines) - return JS_FALSE; + return false; jsbytecode **pcs = cx->pod_malloc<jsbytecode*>(len); if (!pcs) { js_free(lines); - return JS_FALSE; + return false; } unsigned lineno = script->lineno; unsigned offset = 0; unsigned i = 0; for (jssrcnote *sn = script->notes(); !SN_IS_TERMINATOR(sn); sn = SN_NEXT(sn)) { offset += SN_DELTA(sn); SrcNoteType type = (SrcNoteType) SN_TYPE(sn); @@ -442,17 +442,17 @@ JS_GetLinePCs(JSContext *cx, JSScript *s else js_free(lines); if (retPCs) *retPCs = pcs; else js_free(pcs); - return JS_TRUE; + return true; } JS_PUBLIC_API(unsigned) JS_GetFunctionArgumentCount(JSContext *cx, JSFunction *fun) { return fun->nargs; } @@ -658,17 +658,17 @@ GetPropertyDesc(JSContext *cx, JSObject cx->setPendingException(lastException); pd->flags |= (shape->enumerable() ? JSPD_ENUMERATE : 0) | (!shape->writable() ? JSPD_READONLY : 0) | (!shape->configurable() ? JSPD_PERMANENT : 0); pd->spare = 0; pd->alias = JSVAL_VOID; - return JS_TRUE; + return true; } JS_PUBLIC_API(JSBool) JS_GetPropertyDescArray(JSContext *cx, JSObject *obj_, JSPropertyDescArray *pda) { RootedObject obj(cx, obj_); assertSameCompartment(cx, obj); @@ -774,57 +774,57 @@ JS_PutPropertyDescArray(JSContext *cx, J /************************************************************************/ JS_PUBLIC_API(JSBool) JS_SetDebuggerHandler(JSRuntime *rt, JSDebuggerHandler handler, void *closure) { rt->debugHooks.debuggerHandler = handler; rt->debugHooks.debuggerHandlerData = closure; - return JS_TRUE; + return true; } JS_PUBLIC_API(JSBool) JS_SetSourceHandler(JSRuntime *rt, JSSourceHandler handler, void *closure) { rt->debugHooks.sourceHandler = handler; rt->debugHooks.sourceHandlerData = closure; - return JS_TRUE; + return true; } JS_PUBLIC_API(JSBool) JS_SetExecuteHook(JSRuntime *rt, JSInterpreterHook hook, void *closure) { rt->debugHooks.executeHook = hook; rt->debugHooks.executeHookData = closure; - return JS_TRUE; + return true; } JS_PUBLIC_API(JSBool) JS_SetCallHook(JSRuntime *rt, JSInterpreterHook hook, void *closure) { rt->debugHooks.callHook = hook; rt->debugHooks.callHookData = closure; - return JS_TRUE; + return true; } JS_PUBLIC_API(JSBool) JS_SetThrowHook(JSRuntime *rt, JSThrowHook hook, void *closure) { rt->debugHooks.throwHook = hook; rt->debugHooks.throwHookData = closure; - return JS_TRUE; + return true; } JS_PUBLIC_API(JSBool) JS_SetDebugErrorHook(JSRuntime *rt, JSDebugErrorHook hook, void *closure) { rt->debugHooks.debugErrorHook = hook; rt->debugHooks.debugErrorHookData = closure; - return JS_TRUE; + return true; } /************************************************************************/ JS_PUBLIC_API(const JSDebugHooks *) JS_GetGlobalDebugHooks(JSRuntime *rt) { return &rt->debugHooks; @@ -936,24 +936,24 @@ js_CallContextDebugHandler(JSContext *cx NonBuiltinScriptFrameIter iter(cx); JS_ASSERT(!iter.done()); RootedValue rval(cx); RootedScript script(cx, iter.script()); switch (js::CallContextDebugHandler(cx, script, iter.pc(), rval.address())) { case JSTRAP_ERROR: JS_ClearPendingException(cx); - return JS_FALSE; + return false; case JSTRAP_THROW: JS_SetPendingException(cx, rval); - return JS_FALSE; + return false; case JSTRAP_RETURN: case JSTRAP_CONTINUE: default: - return JS_TRUE; + return true; } } JS_PUBLIC_API(JS::StackDescription *) JS::DescribeStack(JSContext *cx, unsigned maxFrames) { Vector<FrameDescription> frames(cx);
--- a/js/src/jsdbgapi.h +++ b/js/src/jsdbgapi.h @@ -255,17 +255,17 @@ typedef struct JSPropertyDesc { } JSPropertyDesc; #define JSPD_ENUMERATE 0x01 /* visible to for/in loop */ #define JSPD_READONLY 0x02 /* assignment is error */ #define JSPD_PERMANENT 0x04 /* property cannot be deleted */ #define JSPD_ALIAS 0x08 /* property has an alias id */ #define JSPD_EXCEPTION 0x40 /* exception occurred fetching the property, */ /* value is exception */ -#define JSPD_ERROR 0x80 /* native getter returned JS_FALSE without */ +#define JSPD_ERROR 0x80 /* native getter returned false without */ /* throwing an exception */ typedef struct JSPropertyDescArray { uint32_t length; /* number of elements in array */ JSPropertyDesc *array; /* alloc'd by Get, freed by Put */ } JSPropertyDescArray; typedef struct JSScopeProperty JSScopeProperty; @@ -353,18 +353,18 @@ class JS_PUBLIC_API(JSBrokenFrameIterato /* * This hook captures high level script execution and function calls (JS or * native). It is used by JS_SetExecuteHook to hook top level scripts and by * JS_SetCallHook to hook function calls. It will get called twice per script * or function call: just before execution begins and just after it finishes. * In both cases the 'current' frame is that of the executing code. * - * The 'before' param is JS_TRUE for the hook invocation before the execution - * and JS_FALSE for the invocation after the code has run. + * The 'before' param is true for the hook invocation before the execution + * and false for the invocation after the code has run. * * The 'ok' param is significant only on the post execution invocation to * signify whether or not the code completed 'normally'. * * The 'closure' param is as passed to JS_SetExecuteHook or JS_SetCallHook * for the 'before'invocation, but is whatever value is returned from that * invocation for the 'after' invocation. Thus, the hook implementor *could* * allocate a structure in the 'before' invocation and return a pointer to that
--- a/js/src/jsdtoa.cpp +++ b/js/src/jsdtoa.cpp @@ -107,49 +107,49 @@ js_dtostr(DtoaState *state, char *buffer js_memcpy(buffer + 2, numBegin, nDigits); freedtoa(PASS_STATE numBegin); numBegin = buffer + 2; /* +2 leaves space for sign and/or decimal point */ numEnd = numBegin + nDigits; *numEnd = '\0'; /* If Infinity, -Infinity, or NaN, return the string regardless of mode. */ if (decPt != 9999) { - JSBool exponentialNotation = JS_FALSE; + JSBool exponentialNotation = false; int minNDigits = 0; /* Min number of significant digits required */ char *p; char *q; switch (mode) { case DTOSTR_STANDARD: if (decPt < -5 || decPt > 21) - exponentialNotation = JS_TRUE; + exponentialNotation = true; else minNDigits = decPt; break; case DTOSTR_FIXED: if (precision >= 0) minNDigits = decPt + precision; else minNDigits = decPt; break; case DTOSTR_EXPONENTIAL: JS_ASSERT(precision > 0); minNDigits = precision; /* Fall through */ case DTOSTR_STANDARD_EXPONENTIAL: - exponentialNotation = JS_TRUE; + exponentialNotation = true; break; case DTOSTR_PRECISION: JS_ASSERT(precision > 0); minNDigits = precision; if (decPt < -5 || decPt > precision) - exponentialNotation = JS_TRUE; + exponentialNotation = true; break; } /* If the number has fewer than minNDigits, end-pad it with zeros. */ if (nDigits < minNDigits) { p = numBegin + minNDigits; nDigits = minNDigits; do { @@ -417,17 +417,17 @@ js_dtobasestr(DtoaState *state, int base if (!s) goto nomem2; /* At this point we have the following: * s = 2^s2; * 1 > df = b/2^s2 > 0; * (d - prevDouble(d))/2 = mlo/2^s2; * (nextDouble(d) - d)/2 = mhi/2^s2. */ - done = JS_FALSE; + done = false; do { int32_t j, j1; Bigint *delta; b = multadd(PASS_STATE b, base, 0); if (!b) goto nomem2; digit = quorem2(b, s2); @@ -454,17 +454,17 @@ js_dtobasestr(DtoaState *state, int base j1 = delta->sign ? 1 : cmp(b, delta); Bfree(PASS_STATE delta); /* j1 is b/2^s2 compared with 1 - mhi/2^s2. */ #ifndef ROUND_BIASED if (j1 == 0 && !(word1(d) & 1)) { if (j > 0) digit++; - done = JS_TRUE; + done = true; } else #endif if (j < 0 || (j == 0 #ifndef ROUND_BIASED && !(word1(d) & 1) #endif )) { if (j1 > 0) { @@ -473,20 +473,20 @@ js_dtobasestr(DtoaState *state, int base b = lshift(PASS_STATE b, 1); if (!b) goto nomem2; j1 = cmp(b, s); if (j1 > 0) /* The even test (|| (j1 == 0 && (digit & 1))) is not here because it messes up odd base output * such as 3.5 in base 3. */ digit++; } - done = JS_TRUE; + done = true; } else if (j1 > 0) { digit++; - done = JS_TRUE; + done = true; } JS_ASSERT(digit < (uint32_t)base); *p++ = BASEDIGIT(digit); } while (!done); Bfree(PASS_STATE b); Bfree(PASS_STATE s); if (mlo != mhi) Bfree(PASS_STATE mlo);
--- a/js/src/jsexn.h +++ b/js/src/jsexn.h @@ -19,18 +19,18 @@ extern JSObject * js_InitExceptionClasses(JSContext *cx, js::HandleObject obj); /* * Given a JSErrorReport, check to see if there is an exception associated with * the error number. If there is, then create an appropriate exception object, * set it as the pending exception, and set the JSREPORT_EXCEPTION flag on the * error report. Exception-aware host error reporters should probably ignore - * error reports so flagged. Returns JS_TRUE if an associated exception is - * found and set, JS_FALSE otherwise. + * error reports so flagged. Returns true if an associated exception is + * found and set, false otherwise. */ extern JSBool js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp, JSErrorCallback callback, void *userRef); /* * Called if a JS API call to js_Execute or js_InternalCall fails; calls the * error reporter with the error report associated with any uncaught exception
--- a/js/src/jsfun.cpp +++ b/js/src/jsfun.cpp @@ -819,17 +819,17 @@ js_fun_call(JSContext *cx, unsigned argc argc--; argv++; } /* Allocate stack space for fval, obj, and the args. */ InvokeArgs args(cx); if (!args.init(argc)) - return JS_FALSE; + return false; /* Push fval, thisv, and the args. */ args.setCallee(fval); args.setThis(thisv); PodCopy(args.array(), argv, argc); bool ok = Invoke(cx, args); *vp = args.rval();
--- a/js/src/jsnum.cpp +++ b/js/src/jsnum.cpp @@ -294,35 +294,35 @@ num_isFinite(JSContext *cx, unsigned arg static bool num_parseFloat(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); if (args.length() == 0) { args.rval().setDouble(js_NaN); - return JS_TRUE; + return true; } JSString *str = ToString<CanGC>(cx, args[0]); if (!str) - return JS_FALSE; + return false; const jschar *bp = str->getChars(cx); if (!bp) - return JS_FALSE; + return false; const jschar *end = bp + str->length(); const jschar *ep; double d; if (!js_strtod(cx, bp, end, &ep, &d)) - return JS_FALSE; + return false; if (ep == bp) { args.rval().setDouble(js_NaN); - return JS_TRUE; + return true; } args.rval().setDouble(d); - return JS_TRUE; + return true; } /* ES5 15.1.2.2. */ bool js::num_parseInt(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); @@ -1372,17 +1372,17 @@ js::NumberValueToStringBuffer(JSContext ToCStringBuf cbuf; const char *cstr; if (v.isInt32()) { cstr = IntToCString(&cbuf, v.toInt32()); } else { cstr = NumberToCString(cx, &cbuf, v.toDouble()); if (!cstr) { JS_ReportOutOfMemory(cx); - return JS_FALSE; + return false; } } /* * Inflate to jschar string. The input C-string characters are < 127, so * even if jschars are UTF-8, all chars should map to one jschar. */ size_t cstrlen = strlen(cstr); @@ -1680,17 +1680,17 @@ js_strtod(ThreadSafeContext *cx, const j const jschar *s1 = SkipSpace(s, send); size_t length = send - s1; /* Use cbuf to avoid malloc */ if (length >= sizeof cbuf) { cstr = (char *) cx->malloc_(length + 1); if (!cstr) - return JS_FALSE; + return false; } else { cstr = cbuf; } for (i = 0; i != length; i++) { if (s1[i] >> 8) break; cstr[i] = (char)s1[i]; @@ -1712,10 +1712,10 @@ js_strtod(ThreadSafeContext *cx, const j d = js_NegativeInfinity; } i = estr - cstr; if (cstr != cbuf) js_free(cstr); *ep = i ? s1 + i : s; *dp = d; - return JS_TRUE; + return true; }
--- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -537,17 +537,17 @@ Reject(JSContext *cx, unsigned errorNumb static JSBool Reject(JSContext *cx, JSObject *obj, unsigned errorNumber, bool throwError, bool *rval) { if (throwError) return Throw(cx, obj, errorNumber); *rval = false; - return JS_TRUE; + return true; } static bool Reject(JSContext *cx, HandleId id, unsigned errorNumber, bool throwError, bool *rval) { if (throwError) return Throw(cx, id, errorNumber); @@ -603,17 +603,17 @@ static JSBool DefinePropertyOnObject(JSContext *cx, HandleObject obj, HandleId id, const PropDesc &desc, bool throwError, bool *rval) { /* 8.12.9 step 1. */ RootedShape shape(cx); RootedObject obj2(cx); JS_ASSERT(!obj->getOps()->lookupGeneric); if (!HasOwnProperty<CanGC>(cx, NULL, obj, id, &obj2, &shape)) - return JS_FALSE; + return false; JS_ASSERT(!obj->getOps()->defineProperty); /* 8.12.9 steps 2-4. */ if (!shape) { bool extensible; if (!JSObject::isExtensible(cx, obj, &extensible)) return false; @@ -634,17 +634,17 @@ DefinePropertyOnObject(JSContext *cx, Ha /* * Getters and setters are just like watchpoints from an access * control point of view. */ RootedValue dummy(cx); unsigned dummyAttrs; if (!CheckAccess(cx, obj, id, JSACC_WATCH, &dummy, &dummyAttrs)) - return JS_FALSE; + return false; RootedValue tmp(cx, UndefinedValue()); return baseops::DefineGeneric(cx, obj, id, tmp, desc.getter(), desc.setter(), desc.attributes()); } /* 8.12.9 steps 5-6 (note 5 is merely a special case of 6). */ RootedValue v(cx, UndefinedValue()); @@ -719,17 +719,17 @@ DefinePropertyOnObject(JSContext *cx, Ha (!shape->hasDefaultGetter() || !shape->hasDefaultSetter()) && desc.isDataDescriptor() && (desc.hasWritable() ? desc.writable() : shape->writable())) { return Reject(cx, JSMSG_CANT_REDEFINE_PROP, throwError, id, rval); } if (!js_NativeGet(cx, obj, obj2, shape, 0, &v)) - return JS_FALSE; + return false; } if (desc.isDataDescriptor()) { if (!shapeDataDescriptor) break; bool same; if (desc.hasValue()) { @@ -865,17 +865,17 @@ DefinePropertyOnObject(JSContext *cx, Ha JS_ASSERT(desc.isAccessorDescriptor()); /* * Getters and setters are just like watchpoints from an access * control point of view. */ RootedValue dummy(cx); if (!CheckAccess(cx, obj2, id, JSACC_WATCH, &dummy, &attrs)) - return JS_FALSE; + return false; /* 8.12.9 step 12. */ unsigned changed = 0; if (desc.hasConfigurable()) changed |= JSPROP_PERMANENT; if (desc.hasEnumerable()) changed |= JSPROP_ENUMERATE; if (desc.hasGet()) @@ -3147,17 +3147,17 @@ js_FindClassObject(ExclusiveContext *cx, if (protoKey != JSProto_Null) { JS_ASSERT(JSProto_Null < protoKey); JS_ASSERT(protoKey < JSProto_LIMIT); RootedObject cobj(cx); if (!js_GetClassObject(cx, cx->global(), protoKey, &cobj)) return false; if (cobj) { vp.set(ObjectValue(*cobj)); - return JS_TRUE; + return true; } id = NameToId(ClassName(protoKey, cx)); } else { JSAtom *atom = Atomize(cx, clasp->name, strlen(clasp->name)); if (!atom) return false; id = AtomToId(atom); } @@ -4150,38 +4150,38 @@ GetPropertyHelperInline(JSContext *cx, return true; /* Don't warn repeatedly for the same script. */ if (!script || script->warnedAboutUndefinedProp) return true; /* We may just be checking if that object has an iterator. */ if (JSID_IS_ATOM(id, cx->names().iteratorIntrinsic)) - return JS_TRUE; + return true; /* Do not warn about tests like (obj[prop] == undefined). */ if (cx->resolveFlags == RESOLVE_INFER) { pc += js_CodeSpec[op].length; if (Detecting(cx, script, pc)) - return JS_TRUE; + return true; } unsigned flags = JSREPORT_WARNING | JSREPORT_STRICT; script->warnedAboutUndefinedProp = true; /* Ok, bad undefined property reference: whine about it. */ RootedValue val(cx, IdToValue(id)); if (!js_ReportValueErrorFlags(cx, flags, JSMSG_UNDEFINED_PROP, JSDVG_IGNORE_STACK, val, NullPtr(), NULL, NULL)) { return false; } } - return JS_TRUE; + return true; } if (!obj2->isNative()) { if (!allowGC) return false; HandleObject obj2Handle = MaybeRooted<JSObject*, allowGC>::toHandle(obj2); HandleObject receiverHandle = MaybeRooted<JSObject*, allowGC>::toHandle(receiver); HandleId idHandle = MaybeRooted<jsid, allowGC>::toHandle(id); @@ -4193,19 +4193,19 @@ GetPropertyHelperInline(JSContext *cx, if (IsImplicitDenseElement(shape)) { vp.set(obj2->getDenseElement(JSID_TO_INT(id))); return true; } /* This call site is hot -- use the always-inlined variant of js_NativeGet(). */ if (!NativeGetInline<allowGC>(cx, obj, receiver, obj2, shape, getHow, vp)) - return JS_FALSE; - - return JS_TRUE; + return false; + + return true; } bool js::GetPropertyHelper(JSContext *cx, HandleObject obj, HandleId id, uint32_t getHow, MutableHandleValue vp) { return GetPropertyHelperInline<CanGC>(cx, obj, obj, id, getHow, vp); } @@ -4605,28 +4605,28 @@ baseops::SetPropertyHelper(JSContext *cx JS_ASSERT(shape->isDataDescriptor()); if (!shape->writable()) { /* Error in strict mode code, warn with extra warnings options, otherwise do nothing. */ if (strict) return JSObject::reportReadOnly(cx, id, JSREPORT_ERROR); if (cx->hasExtraWarningsOption()) return JSObject::reportReadOnly(cx, id, JSREPORT_STRICT | JSREPORT_WARNING); - return JS_TRUE; + return true; } } attrs = shape->attributes(); if (pobj != obj) { /* * We found id in a prototype object: prepare to share or shadow. */ if (!shape->shadowable()) { if (shape->hasDefaultSetter() && !shape->hasGetterValue()) - return JS_TRUE; + return true; return shape->set(cx, obj, receiver, strict, vp); } /* * Preserve attrs except JSPROP_SHARED, getter, and setter when * shadowing any property that has no slot (is shared). We must * clear the shared attribute for the shadowing shape so that the @@ -5008,26 +5008,26 @@ js::CheckAccess(JSContext *cx, JSObject writing = (mode & JSACC_WRITE) != 0; switch (mode & JSACC_TYPEMASK) { case JSACC_PROTO: pobj = obj; if (!writing) { RootedObject proto(cx); if (!JSObject::getProto(cx, obj, &proto)) - return JS_FALSE; + return false; vp.setObjectOrNull(proto); } *attrsp = JSPROP_PERMANENT; break; default: RootedShape shape(cx); if (!JSObject::lookupGeneric(cx, obj, id, &pobj, &shape)) - return JS_FALSE; + return false; if (!shape) { if (!writing) vp.setUndefined(); *attrsp = 0; pobj = obj; break; } @@ -5277,17 +5277,17 @@ js_ReportGetterOnlyAssignment(JSContext JSMSG_GETTER_ONLY); } JS_FRIEND_API(JSBool) js_GetterOnlyPropertyStub(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, MutableHandleValue vp) { JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_GETTER_ONLY); - return JS_FALSE; + return false; } #ifdef DEBUG /* * Routines to print out values during debugging. These are FRIEND_API to help * the debugger find them and to support temporarily hacking js_Dump* calls * into other code.
--- a/js/src/json.cpp +++ b/js/src/json.cpp @@ -137,24 +137,24 @@ class StringifyContext static JSBool Str(JSContext *cx, const Value &v, StringifyContext *scx); static JSBool WriteIndent(JSContext *cx, StringifyContext *scx, uint32_t limit) { if (!scx->gap.empty()) { if (!scx->sb.append('\n')) - return JS_FALSE; + return false; for (uint32_t i = 0; i < limit; i++) { if (!scx->sb.append(scx->gap.begin(), scx->gap.end())) - return JS_FALSE; + return false; } } - return JS_TRUE; + return true; } template<typename KeyType> class KeyStringifier { }; template<> class KeyStringifier<uint32_t> { @@ -283,17 +283,17 @@ JO(JSContext *cx, HandleObject obj, Stri if (!detect.init()) return false; if (detect.foundCycle()) { JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CYCLIC_VALUE, js_object_str); return false; } if (!scx->sb.append('{')) - return JS_FALSE; + return false; /* Steps 5-7. */ Maybe<AutoIdVector> ids; const AutoIdVector *props; if (scx->replacer && !scx->replacer->isCallable()) { JS_ASSERT(JS_IsArrayObject(cx, scx->replacer)); props = &scx->propertyList; } else { @@ -373,62 +373,62 @@ JA(JSContext *cx, HandleObject obj, Stri if (!detect.init()) return false; if (detect.foundCycle()) { JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CYCLIC_VALUE, js_object_str); return false; } if (!scx->sb.append('[')) - return JS_FALSE; + return false; /* Step 6. */ uint32_t length; if (!GetLengthProperty(cx, obj, &length)) - return JS_FALSE; + return false; /* Steps 7-10. */ if (length != 0) { /* Steps 4, 10b(i). */ if (!WriteIndent(cx, scx, scx->depth)) - return JS_FALSE; + return false; /* Steps 7-10. */ RootedValue outputValue(cx); for (uint32_t i = 0; i < length; i++) { /* * Steps 8a-8c. Again note how the call to the spec's Str method * is broken up into getting the property, running it past toJSON * and the replacer and maybe unboxing, and interpreting some * values as |null| in separate steps. */ if (!JSObject::getElement(cx, obj, obj, i, &outputValue)) - return JS_FALSE; + return false; if (!PreprocessValue(cx, obj, i, &outputValue, scx)) - return JS_FALSE; + return false; if (IsFilteredValue(outputValue)) { if (!scx->sb.append("null")) - return JS_FALSE; + return false; } else { if (!Str(cx, outputValue, scx)) - return JS_FALSE; + return false; } /* Steps 3, 4, 10b(i). */ if (i < length - 1) { if (!scx->sb.append(',')) - return JS_FALSE; + return false; if (!WriteIndent(cx, scx, scx->depth)) - return JS_FALSE; + return false; } } /* Step 10(b)(iii). */ if (!WriteIndent(cx, scx, scx->depth - 1)) - return JS_FALSE; + return false; } return scx->sb.append(']'); } static JSBool Str(JSContext *cx, const Value &v, StringifyContext *scx) { @@ -785,17 +785,17 @@ js::ParseJSONWithReviver(JSContext *cx, return true; } #if JS_HAS_TOSOURCE static bool json_toSource(JSContext *cx, unsigned argc, Value *vp) { vp->setString(cx->names().JSON); - return JS_TRUE; + return true; } #endif /* ES5 15.12.2. */ static bool json_parse(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp);
--- a/js/src/jsopcode.cpp +++ b/js/src/jsopcode.cpp @@ -383,65 +383,65 @@ js_DisassembleAtPC(JSContext *cx, JSScri sp->put(" "); if (script->hasAnalysis() && script->analysis()->maybeCode(next)) Sprint(sp, "%05u ", script->analysis()->getCode(next).stackDepth); else sp->put(" "); } len = js_Disassemble1(cx, script, next, next - script->code, lines, sp); if (!len) - return JS_FALSE; + return false; next += len; } - return JS_TRUE; + return true; } JSBool js_Disassemble(JSContext *cx, HandleScript script, JSBool lines, Sprinter *sp) { return js_DisassembleAtPC(cx, script, lines, NULL, false, sp); } JS_FRIEND_API(JSBool) js_DumpPC(JSContext *cx) { js::gc::AutoSuppressGC suppressGC(cx); Sprinter sprinter(cx); if (!sprinter.init()) - return JS_FALSE; + return false; ScriptFrameIter iter(cx); RootedScript script(cx, iter.script()); JSBool ok = js_DisassembleAtPC(cx, script, true, iter.pc(), false, &sprinter); fprintf(stdout, "%s", sprinter.string()); return ok; } JS_FRIEND_API(JSBool) js_DumpScript(JSContext *cx, JSScript *scriptArg) { js::gc::AutoSuppressGC suppressGC(cx); Sprinter sprinter(cx); if (!sprinter.init()) - return JS_FALSE; + return false; RootedScript script(cx, scriptArg); JSBool ok = js_Disassemble(cx, script, true, &sprinter); fprintf(stdout, "%s", sprinter.string()); return ok; } /* * Useful to debug ReconstructPCStack. */ JS_FRIEND_API(JSBool) js_DumpScriptDepth(JSContext *cx, JSScript *scriptArg, jsbytecode *pc) { js::gc::AutoSuppressGC suppressGC(cx); Sprinter sprinter(cx); if (!sprinter.init()) - return JS_FALSE; + return false; RootedScript script(cx, scriptArg); JSBool ok = js_DisassembleAtPC(cx, script, true, pc, true, &sprinter); fprintf(stdout, "%s", sprinter.string()); return ok; } static char * QuoteString(Sprinter *sp, JSString *str, uint32_t quote);
--- a/js/src/jspubtd.h +++ b/js/src/jspubtd.h @@ -37,17 +37,17 @@ struct Zone; } /* namespace JS */ /* * In release builds, jsid is defined to be an integral type. This * prevents many bugs from being caught at compile time. E.g.: * * jsid id = ... - * if (id == JS_TRUE) // error + * if (id) // error * ... * * size_t n = id; // error * * To catch more errors, jsid is given a struct type in C++ debug builds. * Struct assignment and (in C++) operator== allow correct code to be mostly * oblivious to the change. This feature can be explicitly disabled in debug * builds by defining JS_NO_JSVAL_JSID_STRUCT_TYPES.
--- a/js/src/jsreflect.cpp +++ b/js/src/jsreflect.cpp @@ -2952,129 +2952,129 @@ ASTSerializer::moduleOrFunctionBody(Pars static bool reflect_parse(JSContext *cx, uint32_t argc, jsval *vp) { CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1) { JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_MORE_ARGS_NEEDED, "Reflect.parse", "0", "s"); - return JS_FALSE; + return false; } RootedString src(cx, ToString<CanGC>(cx, args[0])); if (!src) - return JS_FALSE; + return false; ScopedJSFreePtr<char> filename; uint32_t lineno = 1; bool loc = true; RootedObject builder(cx); RootedValue arg(cx, args.get(1)); if (!arg.isNullOrUndefined()) { if (!arg.isObject()) { js_ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK, arg, NullPtr(), "not an object", NULL); - return JS_FALSE; + return false; } RootedObject config(cx, &arg.toObject()); RootedValue prop(cx); /* config.loc */ RootedId locId(cx, NameToId(cx->names().loc)); RootedValue trueVal(cx, BooleanValue(true)); if (!baseops::GetPropertyDefault(cx, config, locId, trueVal, &prop)) - return JS_FALSE; + return false; loc = ToBoolean(prop); if (loc) { /* config.source */ RootedId sourceId(cx, NameToId(cx->names().source)); RootedValue nullVal(cx, NullValue()); if (!baseops::GetPropertyDefault(cx, config, sourceId, nullVal, &prop)) - return JS_FALSE; + return false; if (!prop.isNullOrUndefined()) { RootedString str(cx, ToString<CanGC>(cx, prop)); if (!str) - return JS_FALSE; + return false; size_t length = str->length(); const jschar *chars = str->getChars(cx); if (!chars) - return JS_FALSE; + return false; TwoByteChars tbchars(chars, length); filename = LossyTwoByteCharsToNewLatin1CharsZ(cx, tbchars).c_str(); if (!filename) - return JS_FALSE; + return false; } /* config.line */ RootedId lineId(cx, NameToId(cx->names().line)); RootedValue oneValue(cx, Int32Value(1)); if (!baseops::GetPropertyDefault(cx, config, lineId, oneValue, &prop) || !ToUint32(cx, prop, &lineno)) { - return JS_FALSE; + return false; } } /* config.builder */ RootedId builderId(cx, NameToId(cx->names().builder)); RootedValue nullVal(cx, NullValue()); if (!baseops::GetPropertyDefault(cx, config, builderId, nullVal, &prop)) - return JS_FALSE; + return false; if (!prop.isNullOrUndefined()) { if (!prop.isObject()) { js_ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK, prop, NullPtr(), "not an object", NULL); - return JS_FALSE; + return false; } builder = &prop.toObject(); } } /* Extract the builder methods first to report errors before parsing. */ ASTSerializer serialize(cx, loc, filename, lineno); if (!serialize.init(builder)) - return JS_FALSE; + return false; JSStableString *stable = src->ensureStable(cx); if (!stable) - return JS_FALSE; + return false; const StableCharPtr chars = stable->chars(); size_t length = stable->length(); CompileOptions options(cx); options.setFileAndLine(filename, lineno); options.setCanLazilyParse(false); Parser<FullParseHandler> parser(cx, &cx->tempLifoAlloc(), options, chars.get(), length, /* foldConstants = */ false, NULL, NULL); serialize.setParser(&parser); ParseNode *pn = parser.parse(NULL); if (!pn) - return JS_FALSE; + return false; RootedValue val(cx); if (!serialize.program(pn, &val)) { args.rval().setNull(); - return JS_FALSE; + return false; } args.rval().set(val); - return JS_TRUE; + return true; } static const JSFunctionSpec static_methods[] = { JS_FN("parse", reflect_parse, 1, 0), JS_FS_END }; JS_PUBLIC_API(JSObject *)
--- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -321,17 +321,17 @@ XDRScriptConst(XDRState<mode> *xdr, Heap return false; switch (tag) { case SCRIPT_INT: { uint32_t i; if (mode == XDR_ENCODE) i = uint32_t(vp->toInt32()); if (!xdr->codeUint32(&i)) - return JS_FALSE; + return false; if (mode == XDR_DECODE) vp->init(Int32Value(int32_t(i))); break; } case SCRIPT_DOUBLE: { double d; if (mode == XDR_ENCODE) d = vp->toDouble(); @@ -440,17 +440,17 @@ js::XDRScript(XDRState<mode> *xdr, Handl if (mode == XDR_DECODE) { nargs = argsVars >> 16; nvars = argsVars & 0xFFFF; } if (mode == XDR_ENCODE) length = script->length; if (!xdr->codeUint32(&length)) - return JS_FALSE; + return false; if (mode == XDR_ENCODE) { prologLength = script->mainOffset; JS_ASSERT(script->getVersion() != JSVERSION_UNKNOWN); version = (uint32_t)script->getVersion() | (script->nfixed << 16); lineno = script->lineno; nslots = (uint32_t)script->nslots; nslots = (uint32_t)((script->staticLevel << 16) | script->nslots); @@ -501,42 +501,42 @@ js::XDRScript(XDRState<mode> *xdr, Handl if (script->isLegacyGenerator) scriptBits |= (1 << IsLegacyGenerator); JS_ASSERT(!script->compileAndGo); JS_ASSERT(!script->hasSingletons); } if (!xdr->codeUint32(&prologLength)) - return JS_FALSE; + return false; if (!xdr->codeUint32(&version)) - return JS_FALSE; + return false; /* * To fuse allocations, we need srcnote, atom, objects, regexp, and trynote * counts early. */ if (!xdr->codeUint32(&natoms)) - return JS_FALSE; + return false; if (!xdr->codeUint32(&nsrcnotes)) - return JS_FALSE; + return false; if (!xdr->codeUint32(&ntrynotes)) - return JS_FALSE; + return false; if (!xdr->codeUint32(&nobjects)) - return JS_FALSE; + return false; if (!xdr->codeUint32(&nregexps)) - return JS_FALSE; + return false; if (!xdr->codeUint32(&nconsts)) - return JS_FALSE; + return false; if (!xdr->codeUint32(&nTypeSets)) - return JS_FALSE; + return false; if (!xdr->codeUint32(&ndefaults)) - return JS_FALSE; + return false; if (!xdr->codeUint32(&scriptBits)) - return JS_FALSE; + return false; if (mode == XDR_DECODE) { /* Note: version is packed into the 32b space with another 16b value. */ JSVersion version_ = JSVersion(version & JS_BITMASK(16)); JS_ASSERT((version_ & VersionFlags::MASK) == unsigned(version_)); // staticLevel is set below. CompileOptions options(cx);
--- a/js/src/jsstr.cpp +++ b/js/src/jsstr.cpp @@ -1519,29 +1519,29 @@ js_TrimString(JSContext *cx, Value *vp, call.rval().setString(str); return true; } static bool str_trim(JSContext *cx, unsigned argc, Value *vp) { - return js_TrimString(cx, vp, JS_TRUE, JS_TRUE); + return js_TrimString(cx, vp, true, true); } static bool str_trimLeft(JSContext *cx, unsigned argc, Value *vp) { - return js_TrimString(cx, vp, JS_TRUE, JS_FALSE); + return js_TrimString(cx, vp, true, false); } static bool str_trimRight(JSContext *cx, unsigned argc, Value *vp) { - return js_TrimString(cx, vp, JS_FALSE, JS_TRUE); + return js_TrimString(cx, vp, false, true); } /* * Perl-inspired string functions. */ namespace { @@ -3543,43 +3543,43 @@ bool js::str_fromCharCode(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); JS_ASSERT(args.length() <= ARGS_LENGTH_MAX); if (args.length() == 1) { uint16_t code; if (!ToUint16(cx, args[0], &code)) - return JS_FALSE; + return false; if (StaticStrings::hasUnit(code)) { args.rval().setString(cx->runtime()->staticStrings.getUnit(code)); - return JS_TRUE; + return true; } args[0].setInt32(code); } jschar *chars = cx->pod_malloc<jschar>(args.length() + 1); if (!chars) - return JS_FALSE; + return false; for (unsigned i = 0; i < args.length(); i++) { uint16_t code; if (!ToUint16(cx, args[i], &code)) { js_free(chars); - return JS_FALSE; + return false; } chars[i] = (jschar)code; } chars[args.length()] = 0; JSString *str = js_NewString<CanGC>(cx, chars, args.length()); if (!str) { js_free(chars); - return JS_FALSE; + return false; } args.rval().setString(str); - return JS_TRUE; + return true; } static const JSFunctionSpec string_static_methods[] = { JS_FN("fromCharCode", js::str_fromCharCode, 1, 0), // This must be at the end because of bug 853075: functions listed after // self-hosted methods aren't available in self-hosted code. #if ENABLE_INTL_API @@ -4012,45 +4012,45 @@ js::DeflateStringToBuffer(JSContext *may if (srclen > dstlen) { for (size_t i = 0; i < dstlen; i++) dst[i] = (char) src[i]; if (maybecx) { AutoSuppressGC suppress(maybecx); JS_ReportErrorNumber(maybecx, js_GetErrorMessage, NULL, JSMSG_BUFFER_TOO_SMALL); } - return JS_FALSE; + return false; } for (size_t i = 0; i < srclen; i++) dst[i] = (char) src[i]; *dstlenp = srclen; - return JS_TRUE; + return true; } bool js::InflateStringToBuffer(JSContext *maybecx, const char *src, size_t srclen, jschar *dst, size_t *dstlenp) { if (dst) { size_t dstlen = *dstlenp; if (srclen > dstlen) { for (size_t i = 0; i < dstlen; i++) dst[i] = (unsigned char) src[i]; if (maybecx) { AutoSuppressGC suppress(maybecx); JS_ReportErrorNumber(maybecx, js_GetErrorMessage, NULL, JSMSG_BUFFER_TOO_SMALL); } - return JS_FALSE; + return false; } for (size_t i = 0; i < srclen; i++) dst[i] = (unsigned char) src[i]; } *dstlenp = srclen; - return JS_TRUE; + return true; } #define ____ false /* * Identifier start chars: * - 36: $ * - 65..90: A..Z @@ -4310,31 +4310,31 @@ Decode(JSContext *cx, Handle<JSLinearStr uint32_t v = JS::Utf8ToOneUcs4Char(octets, n); if (v >= 0x10000) { v -= 0x10000; if (v > 0xFFFFF) goto report_bad_uri; c = (jschar)((v & 0x3FF) + 0xDC00); jschar H = (jschar)((v >> 10) + 0xD800); if (!sb.append(H)) - return JS_FALSE; + return false; } else { c = (jschar)v; } } if (c < 128 && reservedSet && reservedSet[c]) { if (!sb.append(chars + start, k - start + 1)) - return JS_FALSE; + return false; } else { if (!sb.append(c)) - return JS_FALSE; + return false; } } else { if (!sb.append(c)) - return JS_FALSE; + return false; } } return TransferBufferToString(sb, rval); report_bad_uri: JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_URI); /* FALL THROUGH */
--- a/js/src/jstypes.h +++ b/js/src/jstypes.h @@ -179,24 +179,21 @@ #else # error "Implement me" #endif /************************************************************************ ** TYPES: JSBool ** DESCRIPTION: -** Use JSBool for variables and parameter types. Use JS_FALSE and JS_TRUE -** for clarity of target type in assignments and actual arguments. Use -** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans -** just as you would C int-valued conditions. +** This type is deprecated; avoid it. See bug 898914. ************************************************************************/ typedef int JSBool; -#define JS_TRUE (int)1 -#define JS_FALSE (int)0 +#define JS_TRUE_DEPRECATED (int)1 +#define JS_FALSE_DEPRECATED (int)0 /*********************************************************************** ** MACROS: JS_LIKELY ** JS_UNLIKELY ** DESCRIPTION: ** These macros allow you to give a hint to the compiler about branch ** probability so that it can better optimize. Use them like this: **
--- a/js/src/jswrapper.cpp +++ b/js/src/jswrapper.cpp @@ -887,17 +887,17 @@ js::NukeCrossCompartmentWrappers(JSConte if (targetFilter.match(wrapped->compartment())) { // We found a wrapper to nuke. e.removeFront(); NukeCrossCompartmentWrapper(cx, wobj); } } } - return JS_TRUE; + return true; } // Given a cross-compartment wrapper |wobj|, update it to point to // |newTarget|. This recomputes the wrapper with JS_WrapValue, and thus can be // useful even if wrapper already points to newTarget. bool js::RemapWrapper(JSContext *cx, JSObject *wobjArg, JSObject *newTargetArg) {
--- a/js/src/perf/jsperf.cpp +++ b/js/src/perf/jsperf.cpp @@ -18,19 +18,19 @@ static PerfMeasurement* GetPMFromThis(JS // Property access #define GETTER(name) \ static JSBool \ pm_get_##name(JSContext* cx, JS::HandleObject obj, JS::HandleId /*unused*/, JS::MutableHandleValue vp) \ { \ PerfMeasurement* p = GetPM(cx, obj, #name); \ if (!p) \ - return JS_FALSE; \ + return false; \ vp.set(JS_NumberValue(double(p->name))); \ - return JS_TRUE; \ + return true; \ } GETTER(cpu_cycles) GETTER(instructions) GETTER(cache_references) GETTER(cache_misses) GETTER(branch_instructions) GETTER(branch_misses)
--- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -5005,19 +5005,19 @@ static int ProcessArgs(JSContext *cx, JSObject *obj_, OptionParser *op) { RootedObject obj(cx, obj_); if (op->getBoolOption('c')) compileOnly = true; if (op->getBoolOption('w')) - reportWarnings = JS_TRUE; + reportWarnings = true; else if (op->getBoolOption('W')) - reportWarnings = JS_FALSE; + reportWarnings = false; if (op->getBoolOption('s')) JS_ToggleOptions(cx, JSOPTION_EXTRA_WARNINGS); if (op->getBoolOption('d')) { JS_SetRuntimeDebugMode(JS_GetRuntime(cx), true); JS_SetDebugMode(cx, true); }
--- a/js/src/vm/ArgumentsObject.cpp +++ b/js/src/vm/ArgumentsObject.cpp @@ -386,17 +386,17 @@ args_resolve(JSContext *cx, HandleObject return true; if (argsobj->callee().isMagic(JS_OVERWRITTEN_CALLEE)) return true; } RootedValue undef(cx, UndefinedValue()); if (!baseops::DefineGeneric(cx, argsobj, id, undef, ArgGetter, ArgSetter, attrs)) - return JS_FALSE; + return false; objp.set(argsobj); return true; } static JSBool args_enumerate(JSContext *cx, HandleObject obj) {
--- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -220,29 +220,29 @@ js::OnUnknownMethod(JSContext *cx, Handl return true; } static JSBool NoSuchMethod(JSContext *cx, unsigned argc, Value *vp) { InvokeArgs args(cx); if (!args.init(2)) - return JS_FALSE; + return false; JS_ASSERT(vp[0].isObject()); JS_ASSERT(vp[1].isObject()); JSObject *obj = &vp[0].toObject(); JS_ASSERT(obj->getClass() == &js_NoSuchMethodClass); args.setCallee(obj->getReservedSlot(JSSLOT_FOUND_FUNCTION)); args.setThis(vp[1]); args[0].set(obj->getReservedSlot(JSSLOT_SAVED_ID)); JSObject *argsobj = NewDenseCopiedArray(cx, argc, vp + 2); if (!argsobj) - return JS_FALSE; + return false; args[1].setObject(*argsobj); JSBool ok = Invoke(cx, args); vp[0] = args.rval(); return ok; } #endif /* JS_HAS_NO_SUCH_METHOD */ @@ -2029,17 +2029,17 @@ END_CASE(JSOP_NE) #define STRICT_EQUALITY_OP(OP, COND) \ JS_BEGIN_MACRO \ const Value &rref = regs.sp[-1]; \ const Value &lref = regs.sp[-2]; \ bool equal; \ if (!StrictlyEqual(cx, lref, rref, &equal)) \ goto error; \ - COND = equal OP JS_TRUE; \ + COND = equal OP true; \ regs.sp--; \ JS_END_MACRO BEGIN_CASE(JSOP_STRICTEQ) { bool cond; STRICT_EQUALITY_OP(==, cond); regs.sp[-1].setBoolean(cond);
--- a/js/xpconnect/idl/nsIXPCSecurityManager.idl +++ b/js/xpconnect/idl/nsIXPCSecurityManager.idl @@ -21,17 +21,17 @@ interface nsIClassInfo; [ptr] native JSStackFramePtr(JSStackFrame); [uuid(31431440-f1ce-11d2-985a-006008962422)] interface nsIXPCSecurityManager : nsISupports { /** * For each of these hooks returning NS_OK means 'let the action continue'. * Returning an error code means 'veto the action'. XPConnect will return - * JS_FALSE to the js engine if the action is vetoed. The implementor of this + * false to the js engine if the action is vetoed. The implementor of this * interface is responsible for setting a JS exception into the JSContext * if that is appropriate. */ void CanCreateWrapper(in JSContextPtr aJSContext, in nsIIDRef aIID, in nsISupports aObj, in nsIClassInfo aClassInfo,
--- a/js/xpconnect/src/dictionary_helper_gen.py +++ b/js/xpconnect/src/dictionary_helper_gen.py @@ -365,17 +365,17 @@ def write_cpp(iface, fd): fd.write("static nsresult\n%s_InitInternal(%s& aDict, JSContext* aCx, JS::HandleObject aObj)\n" % (iface.name, iface.name)) fd.write("{\n") if iface.base is not None: fd.write(" nsresult rv = %s_InitInternal(aDict, aCx, aObj);\n" % iface.base) fd.write(" NS_ENSURE_SUCCESS(rv, rv);\n") - fd.write(" JSBool found = JS_FALSE;\n") + fd.write(" JSBool found = false;\n") needccx = False for a in attributes: if a.realtype.nativeType('in').count("nsIVariant"): needccx = True fd.write(" JS::RootedValue v(aCx, JSVAL_VOID);\n") if needccx: fd.write(" XPCCallContext ccx(NATIVE_CALLER, aCx);\n") fd.write(" NS_ENSURE_STATE(ccx.IsValid());\n")
--- a/js/xpconnect/src/qsgen.py +++ b/js/xpconnect/src/qsgen.py @@ -381,98 +381,98 @@ def substitute(template, vals): return vals[match.group(1)] return re.sub(r'\${(\w+)}', replacement, template) # From JSData2Native. argumentUnboxingTemplates = { 'octet': " uint32_t ${name}_u32;\n" " if (!JS_ValueToECMAUint32(cx, ${argVal}, &${name}_u32))\n" - " return JS_FALSE;\n" + " return false;\n" " uint8_t ${name} = (uint8_t) ${name}_u32;\n", 'short': " int32_t ${name}_i32;\n" " if (!JS_ValueToECMAInt32(cx, ${argVal}, &${name}_i32))\n" - " return JS_FALSE;\n" + " return false;\n" " int16_t ${name} = (int16_t) ${name}_i32;\n", 'unsigned short': " uint32_t ${name}_u32;\n" " if (!JS_ValueToECMAUint32(cx, ${argVal}, &${name}_u32))\n" - " return JS_FALSE;\n" + " return false;\n" " uint16_t ${name} = (uint16_t) ${name}_u32;\n", 'long': " int32_t ${name};\n" " if (!JS_ValueToECMAInt32(cx, ${argVal}, &${name}))\n" - " return JS_FALSE;\n", + " return false;\n", 'unsigned long': " uint32_t ${name};\n" " if (!JS_ValueToECMAUint32(cx, ${argVal}, &${name}))\n" - " return JS_FALSE;\n", + " return false;\n", 'long long': " int64_t ${name};\n" " if (!JS::ToInt64(cx, ${argVal}, &${name}))\n" - " return JS_FALSE;\n", + " return false;\n", 'unsigned long long': " uint64_t ${name};\n" " if (!JS::ToUint64(cx, ${argVal}, &${name}))\n" - " return JS_FALSE;\n", + " return false;\n", 'float': " double ${name}_dbl;\n" " if (!JS_ValueToNumber(cx, ${argVal}, &${name}_dbl))\n" - " return JS_FALSE;\n" + " return false;\n" " float ${name} = (float) ${name}_dbl;\n", 'double': " double ${name};\n" " if (!JS_ValueToNumber(cx, ${argVal}, &${name}))\n" - " return JS_FALSE;\n", + " return false;\n", 'boolean': " JSBool ${name};\n" " JS_ValueToBoolean(cx, ${argVal}, &${name});\n", '[astring]': " xpc_qsAString ${name}(cx, ${argVal}, ${argPtr});\n" " if (!${name}.IsValid())\n" - " return JS_FALSE;\n", + " return false;\n", '[domstring]': " xpc_qsDOMString ${name}(cx, ${argVal}, ${argPtr},\n" " xpc_qsDOMString::e${nullBehavior},\n" " xpc_qsDOMString::e${undefinedBehavior});\n" " if (!${name}.IsValid())\n" - " return JS_FALSE;\n", + " return false;\n", 'string': " JSAutoByteString ${name}_bytes;\n" " if (!xpc_qsJsvalToCharStr(cx, ${argVal}, &${name}_bytes))\n" - " return JS_FALSE;\n" + " return false;\n" " char *${name} = ${name}_bytes.ptr();\n", 'wstring': " const PRUnichar *${name};\n" " if (!xpc_qsJsvalToWcharStr(cx, ${argVal}, ${argPtr}, &${name}))\n" - " return JS_FALSE;\n", + " return false;\n", '[cstring]': " xpc_qsACString ${name}(cx, ${argVal}, ${argPtr});\n" " if (!${name}.IsValid())\n" - " return JS_FALSE;\n", + " return false;\n", '[utf8string]': " xpc_qsAUTF8String ${name}(cx, ${argVal}, ${argPtr});\n" " if (!${name}.IsValid())\n" - " return JS_FALSE;\n", + " return false;\n", '[jsval]': " JS::RootedValue ${name}(cx, ${argVal});\n" } # From JSData2Native. # # Omitted optional arguments are treated as though the caller had passed JS @@ -532,17 +532,17 @@ def writeArgumentUnboxing(f, i, name, ty elif isInterfaceType(type): if type.name == 'nsIVariant': # Totally custom. template = ( " nsCOMPtr<nsIVariant> ${name}(already_AddRefed<nsIVariant>(" "XPCVariant::newVariant(cx, ${argVal})));\n" " if (!${name}) {\n" " xpc_qsThrowBadArg(cx, NS_ERROR_INVALID_ARG, vp, %d);\n" - " return JS_FALSE;\n" + " return false;\n" " }") % i f.write(substitute(template, params)) return rvdeclared elif type.name == 'nsIAtom': # Should have special atomizing behavior. Fall through. pass else: if not rvdeclared: @@ -554,17 +554,17 @@ def writeArgumentUnboxing(f, i, name, ty % (type.name, argVal, name, name, argPtr)) f.write(" if (NS_FAILED(rv)) {\n") if isSetter: assert(propIndex is not None) f.write(" xpc_qsThrowBadSetterValue(cx, rv, JSVAL_TO_OBJECT(vp[1]), (uint16_t)%s);\n" % propIndex) else: f.write(" xpc_qsThrowBadArg(cx, rv, vp, %d);\n" % i) - f.write(" return JS_FALSE;\n" + f.write(" return false;\n" " }\n") return True warn("Unable to unbox argument of type %s (native type %s)" % (type.name, typeName)) if i is None: src = 'argv[0]' else: src = 'argv[%d]' % i @@ -612,55 +612,55 @@ def outParamForm(name, type): return '&' + name else: return 'getter_AddRefs(%s)' % name # From NativeData2JS. resultConvTemplates = { 'void': " ${jsvalRef} = JSVAL_VOID;\n" - " return JS_TRUE;\n", + " return true;\n", 'octet': " ${jsvalRef} = INT_TO_JSVAL((int32_t) result);\n" - " return JS_TRUE;\n", + " return true;\n", 'short': " ${jsvalRef} = INT_TO_JSVAL((int32_t) result);\n" - " return JS_TRUE;\n", + " return true;\n", 'long': " ${jsvalRef} = INT_TO_JSVAL(result);\n" - " return JS_TRUE;\n", + " return true;\n", 'long long': " return xpc_qsInt64ToJsval(cx, result, ${jsvalPtr});\n", 'unsigned short': " ${jsvalRef} = INT_TO_JSVAL((int32_t) result);\n" - " return JS_TRUE;\n", + " return true;\n", 'unsigned long': " ${jsvalRef} = UINT_TO_JSVAL(result);\n" - " return JS_TRUE;\n", + " return true;\n", 'unsigned long long': " return xpc_qsUint64ToJsval(cx, result, ${jsvalPtr});\n", 'float': " ${jsvalRef} = JS_NumberValue(result);\n" - " return JS_TRUE;\n", + " return true;\n", 'double': " ${jsvalRef} = JS_NumberValue(result);\n" - " return JS_TRUE;\n", + " return true;\n", 'boolean': " ${jsvalRef} = (result ? JSVAL_TRUE : JSVAL_FALSE);\n" - " return JS_TRUE;\n", + " return true;\n", '[astring]': " return xpc::StringToJsval(cx, result, ${jsvalPtr});\n", '[domstring]': " return xpc::StringToJsval(cx, result, ${jsvalPtr});\n", '[jsval]': @@ -669,18 +669,18 @@ resultConvTemplates = { } def isVariantType(t): return isSpecificInterfaceType(t, 'nsIVariant') def writeResultConv(f, type, jsvalPtr, jsvalRef): """ Emit code to convert the C++ variable `result` to a jsval. - The emitted code contains a return statement; it returns JS_TRUE on - success, JS_FALSE on error. + The emitted code contains a return statement; it returns true on + success, false on error. """ # From NativeData2JS. typeName = getBuiltinOrNativeTypeName(type) if typeName is not None: template = resultConvTemplates.get(typeName) if template is not None: values = {'jsvalRef': jsvalRef, 'jsvalPtr': jsvalPtr} @@ -690,21 +690,21 @@ def writeResultConv(f, type, jsvalPtr, j elif isInterfaceType(type): if isVariantType(type): f.write(" return xpc_qsVariantToJsval(cx, result, %s);\n" % jsvalPtr) return else: f.write(" if (!result) {\n" " *%s = JSVAL_NULL;\n" - " return JS_TRUE;\n" + " return true;\n" " }\n" " nsWrapperCache* cache = xpc_qsGetWrapperCache(result);\n" " if (xpc_FastGetCachedWrapper(cache, obj, %s)) {\n" - " return JS_TRUE;\n" + " return true;\n" " }\n" " // After this point do not use 'result'!\n" " qsObjectHelper helper(result, cache);\n" " return xpc_qsXPCOMObjectToJsval(cx, " "helper, &NS_GET_IID(%s), &interfaces[k_%s], %s);\n" % (jsvalPtr, jsvalPtr, type.name, type.name, jsvalPtr)) return @@ -830,40 +830,40 @@ def writeQuickStub(f, customMethodCalls, setOptimizationForMSVC(f, False) f.write(signature % (stubName, additionalArguments)) f.write("{\n") f.write(" XPC_QS_ASSERT_CONTEXT_OK(cx);\n") # Compute "this". f.write(" JS::RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));\n" " if (!obj)\n" - " return JS_FALSE;\n") + " return false;\n") # Get the 'self' pointer. if customMethodCall is None or not 'thisType' in customMethodCall: f.write(" %s *self;\n" % member.iface.name) else: f.write(" %s *self;\n" % customMethodCall['thisType']) f.write(" xpc_qsSelfRef selfref;\n") pthisval = '&vp[1]' # as above, ok to overwrite vp[1] if unwrapThisFailureFatal: unwrapFatalArg = "true" else: unwrapFatalArg = "false" f.write(" if (!xpc_qsUnwrapThis(cx, obj, &self, " "&selfref.ptr, %s, %s))\n" % (pthisval, unwrapFatalArg)) - f.write(" return JS_FALSE;\n") + f.write(" return false;\n") if not unwrapThisFailureFatal: f.write(" if (!self) {\n") if (isGetter): f.write(" *vp = JSVAL_NULL;\n") - f.write(" return JS_TRUE;\n") + f.write(" return true;\n") f.write(" }\n"); if isMethod: # If there are any required arguments, check argc. requiredArgs = len(member.params) while requiredArgs and member.params[requiredArgs-1].optional: requiredArgs -= 1 elif isSetter: @@ -979,17 +979,17 @@ def writeQuickStub(f, customMethodCalls, f.write(" return xpc_qsThrowGetterSetterFailed(cx, rv, " + "JSVAL_TO_OBJECT(vp[1]), (uint16_t)%d);\n" % stringtable.stringIndex(member.name)) # Convert the return value. if isMethod or isGetter: writeResultConv(f, member.realtype, 'vp', '*vp') else: - f.write(" return JS_TRUE;\n") + f.write(" return true;\n") # Epilog. f.write("}\n") if disableOptimizationForMSVC: setOptimizationForMSVC(f, True) f.write("\n") # Now write out the call to the template function.
--- a/startupcache/test/TestStartupCache.cpp +++ b/startupcache/test/TestStartupCache.cpp @@ -440,17 +440,17 @@ CompareCountArrays(JSContext *cx, JSObje JS::RootedValue before_num(cx), after_num(cx); for (uint32_t i = 0; i < before_size; ++i) { if (!(JS_GetElement(cx, before, i, &before_num) && JS_GetElement(cx, after, i, &after_num))) { return NS_ERROR_UNEXPECTED; } - JSBool same = JS_TRUE; + JSBool same = true; if (!JS_LooselyEqual(cx, before_num, after_num, &same)) { return NS_ERROR_UNEXPECTED; } else { if (same) { continue; } else { // Some element of the histograms's count arrays differed. // That's a good thing!
--- a/tools/profiler/JSObjectBuilder.cpp +++ b/tools/profiler/JSObjectBuilder.cpp @@ -2,17 +2,17 @@ /* 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 "jsapi.h" #include "nsStringGlue.h" #include "JSObjectBuilder.h" -JSObjectBuilder::JSObjectBuilder(JSContext *aCx) : mCx(aCx), mOk(JS_TRUE) +JSObjectBuilder::JSObjectBuilder(JSContext *aCx) : mCx(aCx), mOk(true) {} void JSObjectBuilder::DefineProperty(JSCustomObject *aObject, const char *name, JSCustomArray *aValue) { DefineProperty(aObject, name, (JSCustomObject*)aValue); } @@ -47,33 +47,33 @@ void JSObjectBuilder::DefineProperty(JSCustomObject *aObject, const char *name, nsAString &value) { if (!mOk) return; const nsString &flat = PromiseFlatString(value); JSString *string = JS_NewUCStringCopyN(mCx, static_cast<const jschar*>(flat.get()), flat.Length()); if (!string) - mOk = JS_FALSE; + mOk = false; if (!mOk) return; mOk = JS_DefineProperty(mCx, (JSObject*)aObject, name, STRING_TO_JSVAL(string), nullptr, nullptr, JSPROP_ENUMERATE); } void JSObjectBuilder::DefineProperty(JSCustomObject *aObject, const char *name, const char *value, size_t valueLength) { if (!mOk) return; JSString *string = JS_InternStringN(mCx, value, valueLength); if (!string) { - mOk = JS_FALSE; + mOk = false; return; } mOk = JS_DefineProperty(mCx, (JSObject*)aObject, name, STRING_TO_JSVAL(string), nullptr, nullptr, JSPROP_ENUMERATE); } void JSObjectBuilder::DefineProperty(JSCustomObject *aObject, const char *name, const char *value) { @@ -99,17 +99,17 @@ JSObjectBuilder::ArrayPush(JSCustomArray void JSObjectBuilder::ArrayPush(JSCustomArray *aArray, const char *value) { if (!mOk) return; JS::RootedString string(mCx, JS_NewStringCopyN(mCx, value, strlen(value))); if (!string) { - mOk = JS_FALSE; + mOk = false; return; } uint32_t length; mOk = JS_GetArrayLength(mCx, (JSObject*)aArray, &length); if (!mOk) return; @@ -133,22 +133,22 @@ JSObjectBuilder::ArrayPush(JSCustomArray JS::Rooted<JS::Value> objval(mCx, OBJECT_TO_JSVAL((JSObject*)aObject)); mOk = JS_SetElement(mCx, (JSObject*)aArray, length, &objval); } JSCustomArray* JSObjectBuilder::CreateArray() { JSCustomArray *array = (JSCustomArray*)JS_NewArrayObject(mCx, 0, nullptr); if (!array) - mOk = JS_FALSE; + mOk = false; return array; } JSCustomObject* JSObjectBuilder::CreateObject() { JSCustomObject *obj = (JSCustomObject*)JS_NewObject(mCx, nullptr, nullptr, nullptr); if (!obj) - mOk = JS_FALSE; + mOk = false; return obj; }
--- a/tools/profiler/SaveProfileTask.cpp +++ b/tools/profiler/SaveProfileTask.cpp @@ -7,17 +7,17 @@ #include "GeckoProfilerImpl.h" static JSBool WriteCallback(const jschar *buf, uint32_t len, void *data) { std::ofstream& stream = *static_cast<std::ofstream*>(data); nsAutoCString profile = NS_ConvertUTF16toUTF8(buf, len); stream << profile.Data(); - return JS_TRUE; + return true; } nsresult SaveProfileTask::Run() { // Get file path #if defined(SPS_PLAT_arm_android) && !defined(MOZ_WIDGET_GONK) nsCString tmpPath; tmpPath.AppendPrintf("/sdcard/profile_%i_%i.txt", XRE_GetProcessType(), getpid());
--- a/widget/xpwidgets/GfxInfoCollector.h +++ b/widget/xpwidgets/GfxInfoCollector.h @@ -33,37 +33,37 @@ class MOZ_STACK_CLASS InfoObject void DefineProperty(const char *name, nsAString &value) { if (!mOk) return; const nsString &flat = PromiseFlatString(value); JSString *string = JS_NewUCStringCopyN(mCx, static_cast<const jschar*>(flat.get()), flat.Length()); if (!string) - mOk = JS_FALSE; + mOk = false; if (!mOk) return; mOk = JS_DefineProperty(mCx, mObj, name, STRING_TO_JSVAL(string), NULL, NULL, JSPROP_ENUMERATE); } void DefineProperty(const char *name, const char *value) { nsAutoString string = NS_ConvertASCIItoUTF16(value); DefineProperty(name, string); } private: // We need to ensure that this object lives on the stack so that GC sees it properly - InfoObject(JSContext *aCx) : mCx(aCx), mObj(aCx), mOk(JS_TRUE) + InfoObject(JSContext *aCx) : mCx(aCx), mObj(aCx), mOk(true) { mObj = JS_NewObject(mCx, NULL, NULL, NULL); if (!mObj) - mOk = JS_FALSE; + mOk = false; } InfoObject(InfoObject&); JSContext *mCx; JS::Rooted<JSObject*> mObj; JSBool mOk; };