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 #include "fpdfsdk/javascript/JS_Value.h" | 7 #include "fpdfsdk/javascript/JS_Value.h" |
8 | 8 |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 m_pValue = FXJS_NewNumber(m_pJSRuntime->GetIsolate(), dValue); | 179 m_pValue = FXJS_NewNumber(m_pJSRuntime->GetIsolate(), dValue); |
180 m_eType = VT_number; | 180 m_eType = VT_number; |
181 } | 181 } |
182 | 182 |
183 void CJS_Value::operator=(float fValue) { | 183 void CJS_Value::operator=(float fValue) { |
184 m_pValue = FXJS_NewNumber(m_pJSRuntime->GetIsolate(), fValue); | 184 m_pValue = FXJS_NewNumber(m_pJSRuntime->GetIsolate(), fValue); |
185 m_eType = VT_number; | 185 m_eType = VT_number; |
186 } | 186 } |
187 | 187 |
188 void CJS_Value::operator=(v8::Local<v8::Object> pObj) { | 188 void CJS_Value::operator=(v8::Local<v8::Object> pObj) { |
189 m_pValue = FXJS_NewObject(m_pJSRuntime->GetIsolate(), pObj); | 189 m_pValue = pObj; |
190 m_eType = VT_fxobject; | 190 m_eType = VT_fxobject; |
191 } | 191 } |
192 | 192 |
193 void CJS_Value::operator=(CJS_Object* pObj) { | 193 void CJS_Value::operator=(CJS_Object* pObj) { |
194 if (pObj) | 194 if (pObj) |
195 operator=(pObj->ToV8Object()); | 195 operator=(pObj->ToV8Object()); |
196 } | 196 } |
197 | 197 |
198 void CJS_Value::operator=(CJS_Document* pJsDoc) { | 198 void CJS_Value::operator=(CJS_Document* pJsDoc) { |
199 m_eType = VT_object; | 199 m_eType = VT_object; |
200 if (pJsDoc) { | 200 if (pJsDoc) { |
201 m_pValue = pJsDoc->ToV8Object(); | 201 m_pValue = pJsDoc->ToV8Object(); |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 void CJS_Value::operator=(const FX_WCHAR* pWstr) { | 205 void CJS_Value::operator=(const FX_WCHAR* pWstr) { |
206 m_pValue = FXJS_NewString(m_pJSRuntime->GetIsolate(), (wchar_t*)pWstr); | 206 m_pValue = FXJS_NewString(m_pJSRuntime->GetIsolate(), (wchar_t*)pWstr); |
207 m_eType = VT_string; | 207 m_eType = VT_string; |
208 } | 208 } |
209 | 209 |
210 void CJS_Value::SetNull() { | 210 void CJS_Value::SetNull() { |
211 m_pValue = FXJS_NewNull(); | 211 m_pValue = FXJS_NewNull(m_pJSRuntime->GetIsolate()); |
212 m_eType = VT_null; | 212 m_eType = VT_null; |
213 } | 213 } |
214 | 214 |
215 void CJS_Value::operator=(const FX_CHAR* pStr) { | 215 void CJS_Value::operator=(const FX_CHAR* pStr) { |
216 operator=(CFX_WideString::FromLocal(pStr).c_str()); | 216 operator=(CFX_WideString::FromLocal(pStr).c_str()); |
217 } | 217 } |
218 | 218 |
219 void CJS_Value::operator=(CJS_Array& array) { | 219 void CJS_Value::operator=(CJS_Array& array) { |
220 m_pValue = | 220 m_pValue = static_cast<v8::Local<v8::Array>>(array); |
221 FXJS_NewObject2(m_pJSRuntime->GetIsolate(), (v8::Local<v8::Array>)array); | |
222 m_eType = VT_object; | 221 m_eType = VT_object; |
223 } | 222 } |
224 | 223 |
225 void CJS_Value::operator=(CJS_Date& date) { | 224 void CJS_Value::operator=(CJS_Date& date) { |
226 m_pValue = FXJS_NewDate(m_pJSRuntime->GetIsolate(), (double)date); | 225 m_pValue = FXJS_NewDate(m_pJSRuntime->GetIsolate(), (double)date); |
227 m_eType = VT_date; | 226 m_eType = VT_date; |
228 } | 227 } |
229 | 228 |
230 void CJS_Value::operator=(CJS_Value value) { | 229 void CJS_Value::operator=(CJS_Value value) { |
231 m_pValue = value.ToV8Value(); | 230 m_pValue = value.ToV8Value(); |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 for (size_t i = 0; i < nKeywords; ++i) { | 896 for (size_t i = 0; i < nKeywords; ++i) { |
898 const wchar_t* property = va_arg(ap, const wchar_t*); | 897 const wchar_t* property = va_arg(ap, const wchar_t*); |
899 v8::Local<v8::Value> v8Value = | 898 v8::Local<v8::Value> v8Value = |
900 FXJS_GetObjectElement(pRuntime->GetIsolate(), pObj, property); | 899 FXJS_GetObjectElement(pRuntime->GetIsolate(), pObj, property); |
901 if (!v8Value->IsUndefined()) | 900 if (!v8Value->IsUndefined()) |
902 result[i] = CJS_Value(pRuntime, v8Value, CJS_Value::VT_unknown); | 901 result[i] = CJS_Value(pRuntime, v8Value, CJS_Value::VT_unknown); |
903 } | 902 } |
904 va_end(ap); | 903 va_end(ap); |
905 return result; | 904 return result; |
906 } | 905 } |
OLD | NEW |