diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-04-23 11:23:10 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-04-23 11:23:10 -0700 |
commit | e4fde52cc2c827e637c96e8e1f76ba4644cf718a (patch) | |
tree | 01208f95d013429d2682a228577880a64ae1845b /fpdfsdk/src/javascript/global.cpp | |
parent | 4eeef1d776ce7368063f9a7698cfa736821d4186 (diff) | |
download | pdfium-e4fde52cc2c827e637c96e8e1f76ba4644cf718a.tar.xz |
Kill overloaded cast operators in CJS_Value.
The red-flag here is the explicit invocation of things like
params[1].operator CFX_WideString()
rather than
static_cast<CFX_WideString>(params[1])
to invoke the conversion. Turns out the above won't compile due to
ambiguity given the number of implicit constructors for widestrings.
CJS_Value has both constructors and assignment operators for the
primitive types, which means that conversions can take place
unexpectedly in both directions, a second red flag.
We don't want the compiler invoking these at will since it may hide
bugs. In fact, when they are removed, three such places were
discovered.
Also rename ToJSValue to ToV8Value to match the other ToV8xxxxx
functions added.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1096813008
Diffstat (limited to 'fpdfsdk/src/javascript/global.cpp')
-rw-r--r-- | fpdfsdk/src/javascript/global.cpp | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp index 4ed0d66b1e..6b5d5e2725 100644 --- a/fpdfsdk/src/javascript/global.cpp +++ b/fpdfsdk/src/javascript/global.cpp @@ -174,7 +174,7 @@ FX_BOOL global_alternate::DoProperty(IFXJS_Context* cc, FX_LPCWSTR propname, CJS { bool bData; vp >> bData; - return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_BOOLEAN, 0, (bool)vp, "", v8::Handle<v8::Object>(), FALSE); + return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_BOOLEAN, 0, bData, "", v8::Handle<v8::Object>(), FALSE); } case VT_string: { @@ -184,20 +184,9 @@ FX_BOOL global_alternate::DoProperty(IFXJS_Context* cc, FX_LPCWSTR propname, CJS } case VT_object: { - JSObject pData = (JSObject)vp; + JSObject pData; + vp >> pData; return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_OBJECT, 0, false, "", pData, FALSE); -// else -// { -// if (vp.IsArrayObject()) -// { -// CJS_Array array; -// vp.ConvertToArray(array); -// return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_OBJECT, 0, false, "", -// (Dobject*)(Darray*)array, FALSE); -// } -// else -// return FALSE; -// } } case VT_null: { @@ -278,14 +267,14 @@ FX_BOOL global_alternate::setPersistent(IFXJS_Context* cc, const CJS_Parameters& return FALSE; } - CFX_ByteString sName = params[0]; + CFX_ByteString sName = params[0].ToCFXByteString(); js_global_data* pData = NULL; if (m_mapGlobal.Lookup(sName, (FX_LPVOID&)pData)) { if (pData && !pData->bDeleted) { - pData->bPersistent = (bool)params[1]; + pData->bPersistent = params[1].ToBool(); return TRUE; } } @@ -434,7 +423,7 @@ void global_alternate::ObjectToArray(v8::Handle<v8::Object> pObj, CJS_GlobalVari break; case VT_string: { - CFX_ByteString sValue = CJS_Value(isolate, v, VT_string); + CFX_ByteString sValue = CJS_Value(isolate, v, VT_string).ToCFXByteString(); CJS_KeyValue* pObjElement = new CJS_KeyValue; pObjElement->nType = JS_GLOBALDATA_TYPE_STRING; pObjElement->sKey = sKey; |