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 "xfa/fxfa/fm2js/xfa_fm2jscontext.h" | 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" |
8 | 8 |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
(...skipping 7080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7091 {"dot_accessor", CXFA_FM2JSContext::dot_accessor}, | 7091 {"dot_accessor", CXFA_FM2JSContext::dot_accessor}, |
7092 {"dotdot_accessor", CXFA_FM2JSContext::dotdot_accessor}, | 7092 {"dotdot_accessor", CXFA_FM2JSContext::dotdot_accessor}, |
7093 {"concat_fm_object", CXFA_FM2JSContext::concat_fm_object}, | 7093 {"concat_fm_object", CXFA_FM2JSContext::concat_fm_object}, |
7094 {"is_fm_object", CXFA_FM2JSContext::is_fm_object}, | 7094 {"is_fm_object", CXFA_FM2JSContext::is_fm_object}, |
7095 {"is_fm_array", CXFA_FM2JSContext::is_fm_array}, | 7095 {"is_fm_array", CXFA_FM2JSContext::is_fm_array}, |
7096 {"get_fm_value", CXFA_FM2JSContext::get_fm_value}, | 7096 {"get_fm_value", CXFA_FM2JSContext::get_fm_value}, |
7097 {"get_fm_jsobj", CXFA_FM2JSContext::get_fm_jsobj}, | 7097 {"get_fm_jsobj", CXFA_FM2JSContext::get_fm_jsobj}, |
7098 {"fm_var_filter", CXFA_FM2JSContext::fm_var_filter}, | 7098 {"fm_var_filter", CXFA_FM2JSContext::fm_var_filter}, |
7099 }; | 7099 }; |
7100 CXFA_FM2JSContext::CXFA_FM2JSContext() | 7100 CXFA_FM2JSContext::CXFA_FM2JSContext() |
7101 : m_hFMClass(nullptr), m_pDocument(nullptr) { | 7101 : m_pFMClass(nullptr), m_pDocument(nullptr) { |
7102 FXSYS_memset(&m_fmClass, 0, sizeof(FXJSE_CLASS)); | 7102 FXSYS_memset(&m_fmClass, 0, sizeof(FXJSE_CLASS)); |
7103 } | 7103 } |
7104 CXFA_FM2JSContext::~CXFA_FM2JSContext() { | 7104 CXFA_FM2JSContext::~CXFA_FM2JSContext() { |
7105 m_pDocument = NULL; | 7105 m_pDocument = NULL; |
7106 if (m_hValue) { | 7106 if (m_hValue) { |
7107 FXJSE_Value_Release(m_hValue); | 7107 FXJSE_Value_Release(m_hValue); |
7108 m_hValue = NULL; | 7108 m_hValue = NULL; |
7109 } | 7109 } |
7110 m_pIsolate = NULL; | 7110 m_pIsolate = NULL; |
7111 } | 7111 } |
7112 void CXFA_FM2JSContext::Initialize(v8::Isolate* pScriptIsolate, | 7112 void CXFA_FM2JSContext::Initialize(v8::Isolate* pScriptIsolate, |
7113 CFXJSE_Context* pScriptContext, | 7113 CFXJSE_Context* pScriptContext, |
7114 CXFA_Document* pDoc) { | 7114 CXFA_Document* pDoc) { |
7115 m_pDocument = pDoc; | 7115 m_pDocument = pDoc; |
7116 m_pIsolate = pScriptIsolate; | 7116 m_pIsolate = pScriptIsolate; |
7117 m_fmClass.name = "XFA_FM2JS_FormCalcClass"; | 7117 m_fmClass.name = "XFA_FM2JS_FormCalcClass"; |
7118 m_fmClass.constructor = NULL; | 7118 m_fmClass.constructor = NULL; |
7119 m_fmClass.properties = NULL; | 7119 m_fmClass.properties = NULL; |
7120 m_fmClass.methods = formcalc_fm2js_functions; | 7120 m_fmClass.methods = formcalc_fm2js_functions; |
7121 m_fmClass.propNum = 0; | 7121 m_fmClass.propNum = 0; |
7122 m_fmClass.methNum = | 7122 m_fmClass.methNum = |
7123 sizeof(formcalc_fm2js_functions) / sizeof(formcalc_fm2js_functions[0]); | 7123 sizeof(formcalc_fm2js_functions) / sizeof(formcalc_fm2js_functions[0]); |
7124 m_hFMClass = FXJSE_DefineClass(pScriptContext, &m_fmClass); | 7124 m_pFMClass = FXJSE_DefineClass(pScriptContext, &m_fmClass); |
7125 m_hValue = FXJSE_Value_Create(pScriptIsolate); | 7125 m_hValue = FXJSE_Value_Create(pScriptIsolate); |
7126 FXJSE_Value_SetNull(m_hValue); | 7126 FXJSE_Value_SetNull(m_hValue); |
7127 FXJSE_Value_SetObject(m_hValue, this, m_hFMClass); | 7127 FXJSE_Value_SetObject(m_hValue, this, m_pFMClass); |
7128 } | 7128 } |
7129 void CXFA_FM2JSContext::GlobalPropertyGetter(FXJSE_HVALUE hValue) { | 7129 void CXFA_FM2JSContext::GlobalPropertyGetter(FXJSE_HVALUE hValue) { |
7130 FXJSE_Value_Set(hValue, m_hValue); | 7130 FXJSE_Value_Set(hValue, m_hValue); |
7131 } | 7131 } |
7132 void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) { | 7132 void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) { |
7133 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); | 7133 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); |
7134 ASSERT(pAppProvider); | 7134 ASSERT(pAppProvider); |
7135 CFX_WideString wsFormat; | 7135 CFX_WideString wsFormat; |
7136 pAppProvider->LoadString(iStringID, wsFormat); | 7136 pAppProvider->LoadString(iStringID, wsFormat); |
7137 CFX_WideString wsMessage; | 7137 CFX_WideString wsMessage; |
7138 va_list arg_ptr; | 7138 va_list arg_ptr; |
7139 va_start(arg_ptr, iStringID); | 7139 va_start(arg_ptr, iStringID); |
7140 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 7140 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
7141 va_end(arg_ptr); | 7141 va_end(arg_ptr); |
7142 FXJSE_ThrowMessage( | 7142 FXJSE_ThrowMessage( |
7143 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 7143 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
7144 } | 7144 } |
OLD | NEW |