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 "JS_Value.h" | 7 #include "JS_Value.h" |
8 | 8 |
9 #include <time.h> | 9 #include <time.h> |
| 10 #include <algorithm> |
10 #include <cmath> | 11 #include <cmath> |
11 #include <limits> | 12 #include <limits> |
12 | 13 |
13 #include "Document.h" | 14 #include "Document.h" |
14 #include "JS_Define.h" | 15 #include "JS_Define.h" |
15 #include "JS_Object.h" | 16 #include "JS_Object.h" |
16 | 17 |
17 static const FX_DWORD g_nan[2] = {0, 0x7FF80000}; | 18 static const FX_DWORD g_nan[2] = {0, 0x7FF80000}; |
18 static double GetNan() { | 19 static double GetNan() { |
19 return *(double*)g_nan; | 20 return *(double*)g_nan; |
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 return day * 86400000 + time; | 873 return day * 86400000 + time; |
873 } | 874 } |
874 | 875 |
875 bool JS_PortIsNan(double d) { | 876 bool JS_PortIsNan(double d) { |
876 return d != d; | 877 return d != d; |
877 } | 878 } |
878 | 879 |
879 double JS_LocalTime(double d) { | 880 double JS_LocalTime(double d) { |
880 return JS_GetDateTime() + _getDaylightSavingTA(d); | 881 return JS_GetDateTime() + _getDaylightSavingTA(d); |
881 } | 882 } |
| 883 |
| 884 std::vector<CJS_Value> JS_ExpandKeywordParams( |
| 885 CJS_Runtime* pRuntime, |
| 886 const std::vector<CJS_Value>& originals, |
| 887 size_t nKeywords, |
| 888 ...) { |
| 889 ASSERT(nKeywords); |
| 890 |
| 891 std::vector<CJS_Value> result(nKeywords, CJS_Value(pRuntime)); |
| 892 size_t size = std::min(originals.size(), nKeywords); |
| 893 for (size_t i = 0; i < size; ++i) |
| 894 result[i] = originals[i]; |
| 895 |
| 896 if (originals.size() != 1 || originals[0].GetType() != CJS_Value::VT_object || |
| 897 originals[0].IsArrayObject()) { |
| 898 return result; |
| 899 } |
| 900 v8::Local<v8::Object> pObj = originals[0].ToV8Object(); |
| 901 result[0] = CJS_Value(pRuntime); // Make unknown. |
| 902 |
| 903 va_list ap; |
| 904 va_start(ap, nKeywords); |
| 905 for (int i = 0; i < nKeywords; ++i) { |
| 906 const wchar_t* property = va_arg(ap, const wchar_t*); |
| 907 v8::Local<v8::Value> v8Value = |
| 908 FXJS_GetObjectElement(pRuntime->GetIsolate(), pObj, property); |
| 909 if (!v8Value->IsUndefined()) |
| 910 result[i] = CJS_Value(pRuntime, v8Value, CJS_Value::VT_unknown); |
| 911 } |
| 912 va_end(ap); |
| 913 return result; |
| 914 } |
OLD | NEW |