From 304bb91238d6909cb5e170f8fc483aa7862558d5 Mon Sep 17 00:00:00 2001 From: tsepez Date: Thu, 3 Nov 2016 06:10:26 -0700 Subject: Remove FX_BOOL entirely. FX_BOOL was a type just like a regular C++ bool, except that it took 4x the space and frequently was used to hold values besides true or false. Review-Url: https://codereview.chromium.org/2471353002 --- fxjs/cfxjse_value.cpp | 124 +++++++++++++++++++++++++------------------------- 1 file changed, 62 insertions(+), 62 deletions(-) (limited to 'fxjs/cfxjse_value.cpp') diff --git a/fxjs/cfxjse_value.cpp b/fxjs/cfxjse_value.cpp index d0a428c9c3..471d85cf76 100644 --- a/fxjs/cfxjse_value.cpp +++ b/fxjs/cfxjse_value.cpp @@ -128,87 +128,87 @@ void CFXJSE_Value::SetFloat(FX_FLOAT fFloat) { m_hValue.Reset(m_pIsolate, pValue); } -FX_BOOL CFXJSE_Value::SetObjectProperty(const CFX_ByteStringC& szPropName, - CFXJSE_Value* lpPropValue) { +bool CFXJSE_Value::SetObjectProperty(const CFX_ByteStringC& szPropName, + CFXJSE_Value* lpPropValue) { ASSERT(lpPropValue); CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); v8::Local hObject = v8::Local::New(m_pIsolate, m_hValue); if (!hObject->IsObject()) - return FALSE; + return false; v8::Local hPropValue = v8::Local::New(m_pIsolate, lpPropValue->DirectGetValue()); - return (FX_BOOL)hObject.As()->Set( + return (bool)hObject.As()->Set( v8::String::NewFromUtf8(m_pIsolate, szPropName.c_str(), v8::String::kNormalString, szPropName.GetLength()), hPropValue); } -FX_BOOL CFXJSE_Value::GetObjectProperty(const CFX_ByteStringC& szPropName, - CFXJSE_Value* lpPropValue) { +bool CFXJSE_Value::GetObjectProperty(const CFX_ByteStringC& szPropName, + CFXJSE_Value* lpPropValue) { ASSERT(lpPropValue); CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); v8::Local hObject = v8::Local::New(m_pIsolate, m_hValue); if (!hObject->IsObject()) - return FALSE; + return false; v8::Local hPropValue = hObject.As()->Get(v8::String::NewFromUtf8( m_pIsolate, szPropName.c_str(), v8::String::kNormalString, szPropName.GetLength())); lpPropValue->ForceSetValue(hPropValue); - return TRUE; + return true; } -FX_BOOL CFXJSE_Value::SetObjectProperty(uint32_t uPropIdx, - CFXJSE_Value* lpPropValue) { +bool CFXJSE_Value::SetObjectProperty(uint32_t uPropIdx, + CFXJSE_Value* lpPropValue) { CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); v8::Local hObject = v8::Local::New(m_pIsolate, m_hValue); if (!hObject->IsObject()) - return FALSE; + return false; v8::Local hPropValue = v8::Local::New(m_pIsolate, lpPropValue->DirectGetValue()); - return (FX_BOOL)hObject.As()->Set(uPropIdx, hPropValue); + return (bool)hObject.As()->Set(uPropIdx, hPropValue); } -FX_BOOL CFXJSE_Value::GetObjectPropertyByIdx(uint32_t uPropIdx, - CFXJSE_Value* lpPropValue) { +bool CFXJSE_Value::GetObjectPropertyByIdx(uint32_t uPropIdx, + CFXJSE_Value* lpPropValue) { CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); v8::Local hObject = v8::Local::New(m_pIsolate, m_hValue); if (!hObject->IsObject()) - return FALSE; + return false; v8::Local hPropValue = hObject.As()->Get(uPropIdx); lpPropValue->ForceSetValue(hPropValue); - return TRUE; + return true; } -FX_BOOL CFXJSE_Value::DeleteObjectProperty(const CFX_ByteStringC& szPropName) { +bool CFXJSE_Value::DeleteObjectProperty(const CFX_ByteStringC& szPropName) { CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); v8::Local hObject = v8::Local::New(m_pIsolate, m_hValue); if (!hObject->IsObject()) - return FALSE; + return false; hObject.As()->Delete(v8::String::NewFromUtf8( m_pIsolate, szPropName.c_str(), v8::String::kNormalString, szPropName.GetLength())); - return TRUE; + return true; } -FX_BOOL CFXJSE_Value::HasObjectOwnProperty(const CFX_ByteStringC& szPropName, - FX_BOOL bUseTypeGetter) { +bool CFXJSE_Value::HasObjectOwnProperty(const CFX_ByteStringC& szPropName, + bool bUseTypeGetter) { CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); v8::Local hObject = v8::Local::New(m_pIsolate, m_hValue); if (!hObject->IsObject()) - return FALSE; + return false; v8::Local hKey = v8::String::NewFromUtf8( m_pIsolate, szPropName.c_str(), v8::String::kNormalString, @@ -220,14 +220,14 @@ FX_BOOL CFXJSE_Value::HasObjectOwnProperty(const CFX_ByteStringC& szPropName, .FromMaybe(false)); } -FX_BOOL CFXJSE_Value::SetObjectOwnProperty(const CFX_ByteStringC& szPropName, - CFXJSE_Value* lpPropValue) { +bool CFXJSE_Value::SetObjectOwnProperty(const CFX_ByteStringC& szPropName, + CFXJSE_Value* lpPropValue) { ASSERT(lpPropValue); CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); v8::Local hObject = v8::Local::New(m_pIsolate, m_hValue); if (!hObject->IsObject()) - return FALSE; + return false; v8::Local pValue = v8::Local::New(m_pIsolate, lpPropValue->m_hValue); @@ -241,8 +241,8 @@ FX_BOOL CFXJSE_Value::SetObjectOwnProperty(const CFX_ByteStringC& szPropName, .FromMaybe(false); } -FX_BOOL CFXJSE_Value::SetFunctionBind(CFXJSE_Value* lpOldFunction, - CFXJSE_Value* lpNewThis) { +bool CFXJSE_Value::SetFunctionBind(CFXJSE_Value* lpOldFunction, + CFXJSE_Value* lpNewThis) { ASSERT(lpOldFunction && lpNewThis); CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); @@ -250,13 +250,13 @@ FX_BOOL CFXJSE_Value::SetFunctionBind(CFXJSE_Value* lpOldFunction, v8::Local hOldFunction = v8::Local::New(m_pIsolate, lpOldFunction->DirectGetValue()); if (hOldFunction.IsEmpty() || !hOldFunction->IsFunction()) - return FALSE; + return false; rgArgs[0] = hOldFunction; v8::Local hNewThis = v8::Local::New(m_pIsolate, lpNewThis->DirectGetValue()); if (hNewThis.IsEmpty()) - return FALSE; + return false; rgArgs[1] = hNewThis; v8::Local hBinderFuncSource = @@ -268,17 +268,17 @@ FX_BOOL CFXJSE_Value::SetFunctionBind(CFXJSE_Value* lpOldFunction, v8::Local hBoundFunction = hBinderFunc->Call(m_pIsolate->GetCurrentContext()->Global(), 2, rgArgs); if (hBoundFunction.IsEmpty() || !hBoundFunction->IsFunction()) - return FALSE; + return false; m_hValue.Reset(m_pIsolate, hBoundFunction); - return TRUE; + return true; } #define FXJSE_INVALID_PTR ((void*)(intptr_t)-1) -FX_BOOL CFXJSE_Value::Call(CFXJSE_Value* lpReceiver, - CFXJSE_Value* lpRetValue, - uint32_t nArgCount, - CFXJSE_Value** lpArgs) { +bool CFXJSE_Value::Call(CFXJSE_Value* lpReceiver, + CFXJSE_Value* lpRetValue, + uint32_t nArgCount, + CFXJSE_Value** lpArgs) { CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); v8::Local hFunctionValue = v8::Local::New(m_pIsolate, DirectGetValue()); @@ -291,7 +291,7 @@ FX_BOOL CFXJSE_Value::Call(CFXJSE_Value* lpReceiver, if (hFunctionObject.IsEmpty() || !hFunctionObject->IsCallable()) { if (lpRetValue) lpRetValue->ForceSetValue(FXJSE_CreateReturnValue(m_pIsolate, trycatch)); - return FALSE; + return false; } v8::Local hReturnValue; @@ -311,7 +311,7 @@ FX_BOOL CFXJSE_Value::Call(CFXJSE_Value* lpReceiver, } } - FX_BOOL bRetValue = TRUE; + bool bRetValue = true; if (lpReceiver == FXJSE_INVALID_PTR) { v8::MaybeLocal maybe_retvalue = hFunctionObject->CallAsConstructor(m_pIsolate->GetCurrentContext(), @@ -333,7 +333,7 @@ FX_BOOL CFXJSE_Value::Call(CFXJSE_Value* lpReceiver, if (trycatch.HasCaught()) { hReturnValue = FXJSE_CreateReturnValue(m_pIsolate, trycatch); - bRetValue = FALSE; + bRetValue = false; } if (lpRetValue) @@ -347,101 +347,101 @@ FX_BOOL CFXJSE_Value::Call(CFXJSE_Value* lpReceiver, return bRetValue; } -FX_BOOL CFXJSE_Value::IsUndefined() const { +bool CFXJSE_Value::IsUndefined() const { if (m_hValue.IsEmpty()) - return FALSE; + return false; CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); v8::Local hValue = v8::Local::New(m_pIsolate, m_hValue); return hValue->IsUndefined(); } -FX_BOOL CFXJSE_Value::IsNull() const { +bool CFXJSE_Value::IsNull() const { if (m_hValue.IsEmpty()) - return FALSE; + return false; CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); v8::Local hValue = v8::Local::New(m_pIsolate, m_hValue); return hValue->IsNull(); } -FX_BOOL CFXJSE_Value::IsBoolean() const { +bool CFXJSE_Value::IsBoolean() const { if (m_hValue.IsEmpty()) - return FALSE; + return false; CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); v8::Local hValue = v8::Local::New(m_pIsolate, m_hValue); return hValue->IsBoolean(); } -FX_BOOL CFXJSE_Value::IsString() const { +bool CFXJSE_Value::IsString() const { if (m_hValue.IsEmpty()) - return FALSE; + return false; CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); v8::Local hValue = v8::Local::New(m_pIsolate, m_hValue); return hValue->IsString(); } -FX_BOOL CFXJSE_Value::IsNumber() const { +bool CFXJSE_Value::IsNumber() const { if (m_hValue.IsEmpty()) - return FALSE; + return false; CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); v8::Local hValue = v8::Local::New(m_pIsolate, m_hValue); return hValue->IsNumber(); } -FX_BOOL CFXJSE_Value::IsInteger() const { +bool CFXJSE_Value::IsInteger() const { if (m_hValue.IsEmpty()) - return FALSE; + return false; CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); v8::Local hValue = v8::Local::New(m_pIsolate, m_hValue); return hValue->IsInt32(); } -FX_BOOL CFXJSE_Value::IsObject() const { +bool CFXJSE_Value::IsObject() const { if (m_hValue.IsEmpty()) - return FALSE; + return false; CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); v8::Local hValue = v8::Local::New(m_pIsolate, m_hValue); return hValue->IsObject(); } -FX_BOOL CFXJSE_Value::IsArray() const { +bool CFXJSE_Value::IsArray() const { if (m_hValue.IsEmpty()) - return FALSE; + return false; CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); v8::Local hValue = v8::Local::New(m_pIsolate, m_hValue); return hValue->IsArray(); } -FX_BOOL CFXJSE_Value::IsFunction() const { +bool CFXJSE_Value::IsFunction() const { if (m_hValue.IsEmpty()) - return FALSE; + return false; CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); v8::Local hValue = v8::Local::New(m_pIsolate, m_hValue); return hValue->IsFunction(); } -FX_BOOL CFXJSE_Value::IsDate() const { +bool CFXJSE_Value::IsDate() const { if (m_hValue.IsEmpty()) - return FALSE; + return false; CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); v8::Local hValue = v8::Local::New(m_pIsolate, m_hValue); return hValue->IsDate(); } -FX_BOOL CFXJSE_Value::ToBoolean() const { +bool CFXJSE_Value::ToBoolean() const { ASSERT(!m_hValue.IsEmpty()); CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); v8::Local hValue = v8::Local::New(m_pIsolate, m_hValue); - return static_cast(hValue->BooleanValue()); + return static_cast(hValue->BooleanValue()); } FX_FLOAT CFXJSE_Value::ToFloat() const { @@ -486,9 +486,9 @@ void CFXJSE_Value::SetNull() { m_hValue.Reset(m_pIsolate, hValue); } -void CFXJSE_Value::SetBoolean(FX_BOOL bBoolean) { +void CFXJSE_Value::SetBoolean(bool bBoolean) { CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); - v8::Local hValue = v8::Boolean::New(m_pIsolate, bBoolean != FALSE); + v8::Local hValue = v8::Boolean::New(m_pIsolate, bBoolean != false); m_hValue.Reset(m_pIsolate, hValue); } -- cgit v1.2.3