From c970895f94cf76eb738d0a583ae139fecdd85268 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 23 Oct 2017 09:40:59 -0400 Subject: Cleanup CJS_Value This CL removes unused methods; renames Attach to Set and generally cleans up the CJS_Value classes. Change-Id: I858082100908f3bc51f4b58c11ceda3357fadc70 Reviewed-on: https://pdfium-review.googlesource.com/16430 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- fpdfsdk/javascript/JS_Value.h | 52 +++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 34 deletions(-) (limited to 'fpdfsdk/javascript/JS_Value.h') diff --git a/fpdfsdk/javascript/JS_Value.h b/fpdfsdk/javascript/JS_Value.h index 47e8cce98a..3631dbe6a1 100644 --- a/fpdfsdk/javascript/JS_Value.h +++ b/fpdfsdk/javascript/JS_Value.h @@ -30,12 +30,14 @@ class CJS_Value { VT_undefined }; + static Type GetValueType(v8::Local value); + explicit CJS_Value(CJS_Runtime* pRuntime); CJS_Value(CJS_Runtime* pRuntime, v8::Local pValue); - CJS_Value(CJS_Runtime* pRuntime, const int& iValue); - CJS_Value(CJS_Runtime* pRuntime, const double& dValue); - CJS_Value(CJS_Runtime* pRuntime, const float& fValue); - CJS_Value(CJS_Runtime* pRuntime, const bool& bValue); + CJS_Value(CJS_Runtime* pRuntime, int iValue); + CJS_Value(CJS_Runtime* pRuntime, double dValue); + CJS_Value(CJS_Runtime* pRuntime, float fValue); + CJS_Value(CJS_Runtime* pRuntime, bool bValue); CJS_Value(CJS_Runtime* pRuntime, CJS_Object* pObj); CJS_Value(CJS_Runtime* pRuntime, const char* pStr); CJS_Value(CJS_Runtime* pRuntime, const wchar_t* pWstr); @@ -47,20 +49,19 @@ class CJS_Value { ~CJS_Value(); void SetNull(CJS_Runtime* pRuntime); - void SetValue(const CJS_Value& other); - void Attach(v8::Local pValue); - void Detach(); + void Set(v8::Local pValue); - static Type GetValueType(v8::Local value); Type GetType() const { return GetValueType(m_pValue); } int ToInt(CJS_Runtime* pRuntime) const; bool ToBool(CJS_Runtime* pRuntime) const; double ToDouble(CJS_Runtime* pRuntime) const; float ToFloat(CJS_Runtime* pRuntime) const; - CJS_Object* ToCJSObject(CJS_Runtime* pRuntime) const; - WideString ToCFXWideString(CJS_Runtime* pRuntime) const; - ByteString ToCFXByteString(CJS_Runtime* pRuntime) const; + CJS_Object* ToObject(CJS_Runtime* pRuntime) const; + CJS_Array ToArray(CJS_Runtime* pRuntime) const; + CJS_Date ToDate(CJS_Runtime* pRuntime) const; + WideString ToWideString(CJS_Runtime* pRuntime) const; + ByteString ToByteString(CJS_Runtime* pRuntime) const; v8::Local ToV8Object(CJS_Runtime* pRuntime) const; v8::Local ToV8Array(CJS_Runtime* pRuntime) const; v8::Local ToV8Value(CJS_Runtime* pRuntime) const; @@ -71,10 +72,8 @@ class CJS_Value { bool IsArrayObject() const; bool IsDateObject() const; - bool ConvertToArray(CJS_Runtime* pRuntime, CJS_Array&) const; - bool ConvertToDate(CJS_Runtime* pRuntime, CJS_Date&) const; - protected: + private: v8::Local m_pValue; }; @@ -133,16 +132,14 @@ class CJS_PropValue { class CJS_Array { public: CJS_Array(); + explicit CJS_Array(v8::Local pArray); CJS_Array(const CJS_Array& other); virtual ~CJS_Array(); - void Attach(v8::Local pArray); int GetLength(CJS_Runtime* pRuntime) const; // These two calls may re-enter JS (and hence invalidate objects). - void GetElement(CJS_Runtime* pRuntime, - unsigned index, - CJS_Value& value) const; + CJS_Value GetElement(CJS_Runtime* pRuntime, unsigned index) const; void SetElement(CJS_Runtime* pRuntime, unsigned index, const CJS_Value& value); @@ -156,6 +153,7 @@ class CJS_Array { class CJS_Date { public: CJS_Date(); + explicit CJS_Date(v8::Local pDate); CJS_Date(CJS_Runtime* pRuntime, double dMsec_time); CJS_Date(CJS_Runtime* pRuntime, int year, @@ -167,30 +165,17 @@ class CJS_Date { CJS_Date(const CJS_Date&); virtual ~CJS_Date(); - void Attach(v8::Local pDate); bool IsValidDate(CJS_Runtime* pRuntime) const; int GetYear(CJS_Runtime* pRuntime) const; - void SetYear(CJS_Runtime* pRuntime, int iYear); - int GetMonth(CJS_Runtime* pRuntime) const; - void SetMonth(CJS_Runtime* pRuntime, int iMonth); - int GetDay(CJS_Runtime* pRuntime) const; - void SetDay(CJS_Runtime* pRuntime, int iDay); - int GetHours(CJS_Runtime* pRuntime) const; - void SetHours(CJS_Runtime* pRuntime, int iHours); - int GetMinutes(CJS_Runtime* pRuntime) const; - void SetMinutes(CJS_Runtime* pRuntime, int minutes); - int GetSeconds(CJS_Runtime* pRuntime) const; - void SetSeconds(CJS_Runtime* pRuntime, int seconds); v8::Local ToV8Date(CJS_Runtime* pRuntime) const; - double ToDouble(CJS_Runtime* pRuntime) const; - WideString ToString(CJS_Runtime* pRuntime) const; + WideString ToWideString(int style) const; protected: v8::Local m_pDate; @@ -207,7 +192,6 @@ double JS_DateParse(const WideString& str); double JS_MakeDay(int nYear, int nMonth, int nDay); double JS_MakeTime(int nHour, int nMin, int nSec, int nMs); double JS_MakeDate(double day, double time); -double JS_LocalTime(double d); // Some JS methods have the bizarre convention that they may also be called // with a single argument which is an object containing the actual arguments @@ -215,7 +199,7 @@ double JS_LocalTime(double d); // names as wchar_t string literals corresponding to each positional argument. // The result will always contain |nKeywords| value, with unspecified ones // being set to type VT_unknown. -std::vector JS_ExpandKeywordParams( +std::vector ExpandKeywordParams( CJS_Runtime* pRuntime, const std::vector& originals, size_t nKeywords, -- cgit v1.2.3