OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef FPDFSDK_JAVASCRIPT_JS_VALUE_H_ | 7 #ifndef FPDFSDK_JAVASCRIPT_JS_VALUE_H_ |
8 #define FPDFSDK_JAVASCRIPT_JS_VALUE_H_ | 8 #define FPDFSDK_JAVASCRIPT_JS_VALUE_H_ |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 24 matching lines...) Expand all Loading... |
35 CJS_Value(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue); | 35 CJS_Value(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue); |
36 CJS_Value(CJS_Runtime* pRuntime, const int& iValue); | 36 CJS_Value(CJS_Runtime* pRuntime, const int& iValue); |
37 CJS_Value(CJS_Runtime* pRuntime, const double& dValue); | 37 CJS_Value(CJS_Runtime* pRuntime, const double& dValue); |
38 CJS_Value(CJS_Runtime* pRuntime, const float& fValue); | 38 CJS_Value(CJS_Runtime* pRuntime, const float& fValue); |
39 CJS_Value(CJS_Runtime* pRuntime, const bool& bValue); | 39 CJS_Value(CJS_Runtime* pRuntime, const bool& bValue); |
40 CJS_Value(CJS_Runtime* pRuntime, CJS_Object* pObj); | 40 CJS_Value(CJS_Runtime* pRuntime, CJS_Object* pObj); |
41 CJS_Value(CJS_Runtime* pRuntime, const FX_CHAR* pStr); | 41 CJS_Value(CJS_Runtime* pRuntime, const FX_CHAR* pStr); |
42 CJS_Value(CJS_Runtime* pRuntime, const FX_WCHAR* pWstr); | 42 CJS_Value(CJS_Runtime* pRuntime, const FX_WCHAR* pWstr); |
43 CJS_Value(CJS_Runtime* pRuntime, const CJS_Array& array); | 43 CJS_Value(CJS_Runtime* pRuntime, const CJS_Array& array); |
44 CJS_Value(CJS_Runtime* pRuntime, const CJS_Date& date); | 44 CJS_Value(CJS_Runtime* pRuntime, const CJS_Date& date); |
| 45 CJS_Value(CJS_Runtime* pRuntime, const CJS_Object* object); |
45 CJS_Value(const CJS_Value& other); | 46 CJS_Value(const CJS_Value& other); |
46 | 47 |
47 ~CJS_Value(); | 48 ~CJS_Value(); |
48 | 49 |
49 void SetNull(); | 50 void SetNull(CJS_Runtime* pRuntime); |
| 51 void SetValue(const CJS_Value& other); |
50 void Attach(v8::Local<v8::Value> pValue); | 52 void Attach(v8::Local<v8::Value> pValue); |
51 void Detach(); | 53 void Detach(); |
52 | 54 |
53 static Type GetValueType(v8::Local<v8::Value> value); | 55 static Type GetValueType(v8::Local<v8::Value> value); |
54 Type GetType() const { return GetValueType(m_pValue); } | 56 Type GetType() const { return GetValueType(m_pValue); } |
55 int ToInt() const; | 57 |
56 bool ToBool() const; | 58 int ToInt(v8::Isolate* pIsolate) const; |
57 double ToDouble() const; | 59 bool ToBool(v8::Isolate* pIsolate) const; |
58 float ToFloat() const; | 60 double ToDouble(v8::Isolate* pIsolate) const; |
59 CJS_Object* ToCJSObject() const; | 61 float ToFloat(v8::Isolate* pIsolate) const; |
60 CFX_WideString ToCFXWideString() const; | 62 CJS_Object* ToCJSObject(v8::Isolate* pIsolate) const; |
61 CFX_ByteString ToCFXByteString() const; | 63 CFX_WideString ToCFXWideString(v8::Isolate* pIsolate) const; |
62 v8::Local<v8::Object> ToV8Object() const; | 64 CFX_ByteString ToCFXByteString(v8::Isolate* pIsolate) const; |
63 v8::Local<v8::Array> ToV8Array() const; | 65 v8::Local<v8::Object> ToV8Object(v8::Isolate* pIsolate) const; |
64 v8::Local<v8::Value> ToV8Value() const; | 66 v8::Local<v8::Array> ToV8Array(v8::Isolate* pIsolate) const; |
| 67 v8::Local<v8::Value> ToV8Value(v8::Isolate* pIsolate) const; |
65 | 68 |
66 // Replace the current |m_pValue| with a v8::Number if possible | 69 // Replace the current |m_pValue| with a v8::Number if possible |
67 // to make one from the current |m_pValue|. | 70 // to make one from the current |m_pValue|. |
68 void MaybeCoerceToNumber(); | 71 void MaybeCoerceToNumber(v8::Isolate* pIsolate); |
69 | 72 |
70 void operator=(int iValue); | 73 bool IsArrayObject() const; |
71 void operator=(bool bValue); | 74 bool IsDateObject() const; |
72 void operator=(double val); | 75 bool ConvertToArray(v8::Isolate* pIsolate, CJS_Array&) const; |
73 void operator=(float val); | 76 bool ConvertToDate(v8::Isolate* pIsolate, CJS_Date&) const; |
74 void operator=(CJS_Object* val); | |
75 void operator=(v8::Local<v8::Object> val); | |
76 void operator=(const CJS_Value& value); | |
77 void operator=(const FX_CHAR* pStr); | |
78 void operator=(const FX_WCHAR* pWstr); | |
79 | |
80 FX_BOOL IsArrayObject() const; | |
81 FX_BOOL IsDateObject() const; | |
82 FX_BOOL ConvertToArray(CJS_Array&) const; | |
83 FX_BOOL ConvertToDate(CJS_Date&) const; | |
84 | |
85 CJS_Runtime* GetJSRuntime() const { return m_pJSRuntime; } | |
86 | 77 |
87 protected: | 78 protected: |
88 v8::Local<v8::Value> m_pValue; | 79 v8::Local<v8::Value> m_pValue; |
89 CJS_Runtime* const m_pJSRuntime; | |
90 }; | 80 }; |
91 | 81 |
92 class CJS_PropValue : public CJS_Value { | 82 class CJS_PropValue { |
93 public: | 83 public: |
94 explicit CJS_PropValue(CJS_Runtime* pRuntime); | 84 explicit CJS_PropValue(CJS_Runtime* pRuntime); |
95 CJS_PropValue(const CJS_Value&); | 85 CJS_PropValue(CJS_Runtime* pRuntime, const CJS_Value&); |
96 ~CJS_PropValue(); | 86 ~CJS_PropValue(); |
97 | 87 |
98 void StartSetting() { m_bIsSetting = true; } | 88 void StartSetting() { m_bIsSetting = true; } |
99 void StartGetting() { m_bIsSetting = false; } | 89 void StartGetting() { m_bIsSetting = false; } |
100 bool IsSetting() const { return m_bIsSetting; } | 90 bool IsSetting() const { return m_bIsSetting; } |
101 bool IsGetting() const { return !m_bIsSetting; } | 91 bool IsGetting() const { return !m_bIsSetting; } |
| 92 CJS_Runtime* GetJSRuntime() const { return m_pJSRuntime; } |
| 93 CJS_Value* GetJSValue() { return &m_Value; } |
102 | 94 |
103 void operator<<(int val); | 95 void operator<<(int val); |
104 void operator>>(int&) const; | 96 void operator>>(int&) const; |
105 void operator<<(bool val); | 97 void operator<<(bool val); |
106 void operator>>(bool&) const; | 98 void operator>>(bool&) const; |
107 void operator<<(double val); | 99 void operator<<(double val); |
108 void operator>>(double&) const; | 100 void operator>>(double&) const; |
109 void operator<<(CJS_Object* pObj); | 101 void operator<<(CJS_Object* pObj); |
110 void operator>>(CJS_Object*& ppObj) const; | 102 void operator>>(CJS_Object*& ppObj) const; |
111 void operator<<(CJS_Document* pJsDoc); | 103 void operator<<(CJS_Document* pJsDoc); |
112 void operator>>(CJS_Document*& ppJsDoc) const; | 104 void operator>>(CJS_Document*& ppJsDoc) const; |
113 void operator<<(CFX_ByteString); | 105 void operator<<(CFX_ByteString); |
114 void operator>>(CFX_ByteString&) const; | 106 void operator>>(CFX_ByteString&) const; |
115 void operator<<(CFX_WideString); | 107 void operator<<(CFX_WideString); |
116 void operator>>(CFX_WideString&) const; | 108 void operator>>(CFX_WideString&) const; |
117 void operator<<(const FX_WCHAR* c_string); | 109 void operator<<(const FX_WCHAR* c_string); |
118 void operator<<(v8::Local<v8::Object>); | 110 void operator<<(v8::Local<v8::Object>); |
119 void operator>>(v8::Local<v8::Object>&) const; | 111 void operator>>(v8::Local<v8::Object>&) const; |
120 void operator>>(CJS_Array& array) const; | 112 void operator>>(CJS_Array& array) const; |
121 void operator<<(CJS_Array& array); | 113 void operator<<(CJS_Array& array); |
122 void operator<<(CJS_Date& date); | 114 void operator<<(CJS_Date& date); |
123 void operator>>(CJS_Date& date) const; | 115 void operator>>(CJS_Date& date) const; |
124 | 116 |
125 private: | 117 private: |
126 bool m_bIsSetting; | 118 bool m_bIsSetting; |
| 119 CJS_Value m_Value; |
| 120 CJS_Runtime* const m_pJSRuntime; |
127 }; | 121 }; |
128 | 122 |
129 class CJS_Array { | 123 class CJS_Array { |
130 public: | 124 public: |
131 CJS_Array(); | 125 CJS_Array(); |
132 CJS_Array(const CJS_Array& other); | 126 CJS_Array(const CJS_Array& other); |
133 virtual ~CJS_Array(); | 127 virtual ~CJS_Array(); |
134 | 128 |
135 void Attach(v8::Local<v8::Array> pArray); | 129 void Attach(v8::Local<v8::Array> pArray); |
136 void GetElement(v8::Isolate* pIsolate, | 130 void GetElement(v8::Isolate* pIsolate, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // names as wchar_t string literals corresponding to each positional argument. | 203 // names as wchar_t string literals corresponding to each positional argument. |
210 // The result will always contain |nKeywords| value, with unspecified ones | 204 // The result will always contain |nKeywords| value, with unspecified ones |
211 // being set to type VT_unknown. | 205 // being set to type VT_unknown. |
212 std::vector<CJS_Value> JS_ExpandKeywordParams( | 206 std::vector<CJS_Value> JS_ExpandKeywordParams( |
213 CJS_Runtime* pRuntime, | 207 CJS_Runtime* pRuntime, |
214 const std::vector<CJS_Value>& originals, | 208 const std::vector<CJS_Value>& originals, |
215 size_t nKeywords, | 209 size_t nKeywords, |
216 ...); | 210 ...); |
217 | 211 |
218 #endif // FPDFSDK_JAVASCRIPT_JS_VALUE_H_ | 212 #endif // FPDFSDK_JAVASCRIPT_JS_VALUE_H_ |
OLD | NEW |