Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: xfa/fxjse/value.cpp

Issue 2045883004: Remove more FXJSE c-method wrappers. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« xfa/fxjse/value.h ('K') | « xfa/fxjse/value.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "xfa/fxjse/value.h" 7 #include "xfa/fxjse/value.h"
8 8
9 #include <math.h> 9 #include <math.h>
10 10
11 #include "xfa/fxjse/class.h" 11 #include "xfa/fxjse/class.h"
12 #include "xfa/fxjse/context.h" 12 #include "xfa/fxjse/context.h"
13 13
14 FX_BOOL FXJSE_Value_IsUndefined(CFXJSE_Value* pValue) { 14 void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Message) {
dsinclair 2016/06/08 14:10:47 The utf8Name parameter was always "" so I removed
Tom Sepez 2016/06/08 17:08:11 Acknowledged.
15 return pValue && pValue->IsUndefined();
16 }
17
18 FX_BOOL FXJSE_Value_IsNull(CFXJSE_Value* pValue) {
19 return pValue && pValue->IsNull();
20 }
21
22 FX_BOOL FXJSE_Value_IsBoolean(CFXJSE_Value* pValue) {
23 return pValue && pValue->IsBoolean();
24 }
25
26 FX_BOOL FXJSE_Value_IsUTF8String(CFXJSE_Value* pValue) {
27 return pValue && pValue->IsString();
28 }
29
30 FX_BOOL FXJSE_Value_IsNumber(CFXJSE_Value* pValue) {
31 return pValue && pValue->IsNumber();
32 }
33
34 FX_BOOL FXJSE_Value_IsObject(CFXJSE_Value* pValue) {
35 return pValue && pValue->IsObject();
36 }
37
38 FX_BOOL FXJSE_Value_IsArray(CFXJSE_Value* pValue) {
39 return pValue && pValue->IsArray();
40 }
41
42 FX_BOOL FXJSE_Value_IsFunction(CFXJSE_Value* pValue) {
43 return pValue && pValue->IsFunction();
44 }
45
46 void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Name,
47 const CFX_ByteStringC& utf8Message) {
48 v8::Isolate* pIsolate = v8::Isolate::GetCurrent(); 15 v8::Isolate* pIsolate = v8::Isolate::GetCurrent();
49 ASSERT(pIsolate); 16 ASSERT(pIsolate);
50 17
51 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); 18 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate);
52 v8::Local<v8::String> hMessage = v8::String::NewFromUtf8( 19 v8::Local<v8::String> hMessage = v8::String::NewFromUtf8(
53 pIsolate, utf8Message.c_str(), v8::String::kNormalString, 20 pIsolate, utf8Message.c_str(), v8::String::kNormalString,
54 utf8Message.GetLength()); 21 utf8Message.GetLength());
55 v8::Local<v8::Value> hError; 22 v8::Local<v8::Value> hError = v8::Exception::Error(hMessage);
23 pIsolate->ThrowException(hError);
24 }
56 25
57 if (utf8Name == "RangeError") { 26 // static.
58 hError = v8::Exception::RangeError(hMessage); 27 FX_BOOL CFXJSE_Value::IsUndefined(CFXJSE_Value* pValue) {
59 } else if (utf8Name == "ReferenceError") { 28 return pValue && pValue->IsUndefined();
60 hError = v8::Exception::ReferenceError(hMessage); 29 }
61 } else if (utf8Name == "SyntaxError") { 30
62 hError = v8::Exception::SyntaxError(hMessage); 31 // static.
63 } else if (utf8Name == "TypeError") { 32 FX_BOOL CFXJSE_Value::IsNull(CFXJSE_Value* pValue) {
64 hError = v8::Exception::TypeError(hMessage); 33 return pValue && pValue->IsNull();
65 } else { 34 }
66 hError = v8::Exception::Error(hMessage); 35
67 if (utf8Name != "Error" && !utf8Name.IsEmpty()) { 36 // static.
68 hError.As<v8::Object>()->Set( 37 FX_BOOL CFXJSE_Value::IsBoolean(CFXJSE_Value* pValue) {
69 v8::String::NewFromUtf8(pIsolate, "name"), 38 return pValue && pValue->IsBoolean();
70 v8::String::NewFromUtf8(pIsolate, utf8Name.c_str(), 39 }
71 v8::String::kNormalString, 40
72 utf8Name.GetLength())); 41 // static.
73 } 42 FX_BOOL CFXJSE_Value::IsUTF8String(CFXJSE_Value* pValue) {
74 } 43 return pValue && pValue->IsString();
75 pIsolate->ThrowException(hError); 44 }
45
46 // static.
47 FX_BOOL CFXJSE_Value::IsNumber(CFXJSE_Value* pValue) {
48 return pValue && pValue->IsNumber();
49 }
50
51 // static.
52 FX_BOOL CFXJSE_Value::IsObject(CFXJSE_Value* pValue) {
53 return pValue && pValue->IsObject();
54 }
55
56 // static.
57 FX_BOOL CFXJSE_Value::IsArray(CFXJSE_Value* pValue) {
58 return pValue && pValue->IsArray();
59 }
60
61 // static.
62 FX_BOOL CFXJSE_Value::IsFunction(CFXJSE_Value* pValue) {
63 return pValue && pValue->IsFunction();
76 } 64 }
77 65
78 CFXJSE_HostObject* CFXJSE_Value::ToHostObject(CFXJSE_Class* lpClass) const { 66 CFXJSE_HostObject* CFXJSE_Value::ToHostObject(CFXJSE_Class* lpClass) const {
79 ASSERT(!m_hValue.IsEmpty()); 67 ASSERT(!m_hValue.IsEmpty());
80 68
81 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 69 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
82 v8::Local<v8::Value> pValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 70 v8::Local<v8::Value> pValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
83 ASSERT(!pValue.IsEmpty()); 71 ASSERT(!pValue.IsEmpty());
84 72
85 if (!pValue->IsObject()) 73 if (!pValue->IsObject())
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 if (lpRetValue) 328 if (lpRetValue)
341 lpRetValue->ForceSetValue(hReturnValue); 329 lpRetValue->ForceSetValue(hReturnValue);
342 330
343 if (lpLocalArgs) { 331 if (lpLocalArgs) {
344 for (uint32_t i = 0; i < nArgCount; i++) 332 for (uint32_t i = 0; i < nArgCount; i++)
345 lpLocalArgs[i].~Local(); 333 lpLocalArgs[i].~Local();
346 FX_Free(lpLocalArgs); 334 FX_Free(lpLocalArgs);
347 } 335 }
348 return bRetValue; 336 return bRetValue;
349 } 337 }
OLDNEW
« xfa/fxjse/value.h ('K') | « xfa/fxjse/value.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698