summaryrefslogtreecommitdiff
path: root/fpdfsdk/include
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-04-23 11:23:10 -0700
committerTom Sepez <tsepez@chromium.org>2015-04-23 11:23:10 -0700
commite4fde52cc2c827e637c96e8e1f76ba4644cf718a (patch)
tree01208f95d013429d2682a228577880a64ae1845b /fpdfsdk/include
parent4eeef1d776ce7368063f9a7698cfa736821d4186 (diff)
downloadpdfium-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/include')
-rw-r--r--fpdfsdk/include/javascript/JS_Define.h6
-rw-r--r--fpdfsdk/include/javascript/JS_Value.h20
2 files changed, 13 insertions, 13 deletions
diff --git a/fpdfsdk/include/javascript/JS_Define.h b/fpdfsdk/include/javascript/JS_Define.h
index 67f283b40e..2a033d15c5 100644
--- a/fpdfsdk/include/javascript/JS_Define.h
+++ b/fpdfsdk/include/javascript/JS_Define.h
@@ -137,7 +137,7 @@ void JSMethod(const char* method_name_string,
JS_Error(isolate, JSFormatErrorString(class_name_string, method_name_string, sError));
return;
}
- info.GetReturnValue().Set(valueRes.ToJSValue());
+ info.GetReturnValue().Set(valueRes.ToV8Value());
}
#define JS_STATIC_METHOD(method_name, class_name) \
@@ -404,7 +404,7 @@ void JSGlobalFunc(const char *func_name_string,
JS_Error(isolate, JSFormatErrorString(func_name_string, nullptr, sError));
return;
}
- info.GetReturnValue().Set(valueRes.ToJSValue());
+ info.GetReturnValue().Set(valueRes.ToV8Value());
}
#define JS_STATIC_GLOBAL_FUN(fun_name) \
@@ -452,7 +452,7 @@ for (int i=0; i<size; i++) array.SetElement(i,CJS_Value(pRuntime,ArrayContent[i]
\
CJS_PropValue prop(pRuntime);\
prop << array;\
-if (JS_DefineGlobalConst(pRuntime, (const wchar_t*)ArrayName, prop.ToJSValue()) < 0)\
+if (JS_DefineGlobalConst(pRuntime, (const wchar_t*)ArrayName, prop.ToV8Value()) < 0)\
return -1
/* ============================================================ */
diff --git a/fpdfsdk/include/javascript/JS_Value.h b/fpdfsdk/include/javascript/JS_Value.h
index 1431349552..ecd0f832d4 100644
--- a/fpdfsdk/include/javascript/JS_Value.h
+++ b/fpdfsdk/include/javascript/JS_Value.h
@@ -39,16 +39,16 @@ public:
void Detach();
- operator int() const;
- operator bool() const;
- operator double() const;
- operator float() const;
- operator CJS_Object*() const;
- operator v8::Handle<v8::Object>() const;
- operator v8::Handle<v8::Array>() const;
- operator CFX_WideString() const;
- operator CFX_ByteString() const;
- v8::Handle<v8::Value> ToJSValue();
+ int ToInt() const;
+ bool ToBool() const;
+ double ToDouble() const;
+ float ToFloat() const;
+ CJS_Object* ToCJSObject() const;
+ CFX_WideString ToCFXWideString() const;
+ CFX_ByteString ToCFXByteString() const;
+ v8::Handle<v8::Object> ToV8Object() const;
+ v8::Handle<v8::Array> ToV8Array() const;
+ v8::Handle<v8::Value> ToV8Value() const;
void operator = (int iValue);
void operator = (bool bValue);