| 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 7146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7157 {"dot_accessor", CXFA_FM2JSContext::dot_accessor}, | 7157 {"dot_accessor", CXFA_FM2JSContext::dot_accessor}, |
| 7158 {"dotdot_accessor", CXFA_FM2JSContext::dotdot_accessor}, | 7158 {"dotdot_accessor", CXFA_FM2JSContext::dotdot_accessor}, |
| 7159 {"concat_fm_object", CXFA_FM2JSContext::concat_fm_object}, | 7159 {"concat_fm_object", CXFA_FM2JSContext::concat_fm_object}, |
| 7160 {"is_fm_object", CXFA_FM2JSContext::is_fm_object}, | 7160 {"is_fm_object", CXFA_FM2JSContext::is_fm_object}, |
| 7161 {"is_fm_array", CXFA_FM2JSContext::is_fm_array}, | 7161 {"is_fm_array", CXFA_FM2JSContext::is_fm_array}, |
| 7162 {"get_fm_value", CXFA_FM2JSContext::get_fm_value}, | 7162 {"get_fm_value", CXFA_FM2JSContext::get_fm_value}, |
| 7163 {"get_fm_jsobj", CXFA_FM2JSContext::get_fm_jsobj}, | 7163 {"get_fm_jsobj", CXFA_FM2JSContext::get_fm_jsobj}, |
| 7164 {"fm_var_filter", CXFA_FM2JSContext::fm_var_filter}, | 7164 {"fm_var_filter", CXFA_FM2JSContext::fm_var_filter}, |
| 7165 }; | 7165 }; |
| 7166 CXFA_FM2JSContext::CXFA_FM2JSContext() | 7166 CXFA_FM2JSContext::CXFA_FM2JSContext() |
| 7167 : m_hFMClass(nullptr), m_pDocument(nullptr) { | 7167 : m_pFMClass(nullptr), m_pDocument(nullptr) { |
| 7168 FXSYS_memset(&m_fmClass, 0, sizeof(FXJSE_CLASS)); | 7168 FXSYS_memset(&m_fmClass, 0, sizeof(FXJSE_CLASS)); |
| 7169 } | 7169 } |
| 7170 CXFA_FM2JSContext::~CXFA_FM2JSContext() { | 7170 CXFA_FM2JSContext::~CXFA_FM2JSContext() { |
| 7171 m_pDocument = NULL; | 7171 m_pDocument = NULL; |
| 7172 if (m_hValue) { | 7172 if (m_hValue) { |
| 7173 FXJSE_Value_Release(m_hValue); | 7173 FXJSE_Value_Release(m_hValue); |
| 7174 m_hValue = NULL; | 7174 m_hValue = NULL; |
| 7175 } | 7175 } |
| 7176 m_pIsolate = NULL; | 7176 m_pIsolate = NULL; |
| 7177 } | 7177 } |
| 7178 void CXFA_FM2JSContext::Initialize(v8::Isolate* pScriptIsolate, | 7178 void CXFA_FM2JSContext::Initialize(v8::Isolate* pScriptIsolate, |
| 7179 CFXJSE_Context* pScriptContext, | 7179 CFXJSE_Context* pScriptContext, |
| 7180 CXFA_Document* pDoc) { | 7180 CXFA_Document* pDoc) { |
| 7181 m_pDocument = pDoc; | 7181 m_pDocument = pDoc; |
| 7182 m_pIsolate = pScriptIsolate; | 7182 m_pIsolate = pScriptIsolate; |
| 7183 m_fmClass.name = "XFA_FM2JS_FormCalcClass"; | 7183 m_fmClass.name = "XFA_FM2JS_FormCalcClass"; |
| 7184 m_fmClass.constructor = NULL; | 7184 m_fmClass.constructor = NULL; |
| 7185 m_fmClass.properties = NULL; | 7185 m_fmClass.properties = NULL; |
| 7186 m_fmClass.methods = formcalc_fm2js_functions; | 7186 m_fmClass.methods = formcalc_fm2js_functions; |
| 7187 m_fmClass.propNum = 0; | 7187 m_fmClass.propNum = 0; |
| 7188 m_fmClass.methNum = | 7188 m_fmClass.methNum = |
| 7189 sizeof(formcalc_fm2js_functions) / sizeof(formcalc_fm2js_functions[0]); | 7189 sizeof(formcalc_fm2js_functions) / sizeof(formcalc_fm2js_functions[0]); |
| 7190 m_hFMClass = FXJSE_DefineClass(pScriptContext, &m_fmClass); | 7190 m_pFMClass = FXJSE_DefineClass(pScriptContext, &m_fmClass); |
| 7191 m_hValue = FXJSE_Value_Create(pScriptIsolate); | 7191 m_hValue = FXJSE_Value_Create(pScriptIsolate); |
| 7192 FXJSE_Value_SetNull(m_hValue); | 7192 FXJSE_Value_SetNull(m_hValue); |
| 7193 FXJSE_Value_SetObject(m_hValue, this, m_hFMClass); | 7193 FXJSE_Value_SetObject(m_hValue, this, m_pFMClass); |
| 7194 } | 7194 } |
| 7195 void CXFA_FM2JSContext::GlobalPropertyGetter(FXJSE_HVALUE hValue) { | 7195 void CXFA_FM2JSContext::GlobalPropertyGetter(FXJSE_HVALUE hValue) { |
| 7196 FXJSE_Value_Set(hValue, m_hValue); | 7196 FXJSE_Value_Set(hValue, m_hValue); |
| 7197 } | 7197 } |
| 7198 void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) { | 7198 void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) { |
| 7199 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); | 7199 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); |
| 7200 ASSERT(pAppProvider); | 7200 ASSERT(pAppProvider); |
| 7201 CFX_WideString wsFormat; | 7201 CFX_WideString wsFormat; |
| 7202 pAppProvider->LoadString(iStringID, wsFormat); | 7202 pAppProvider->LoadString(iStringID, wsFormat); |
| 7203 CFX_WideString wsMessage; | 7203 CFX_WideString wsMessage; |
| 7204 va_list arg_ptr; | 7204 va_list arg_ptr; |
| 7205 va_start(arg_ptr, iStringID); | 7205 va_start(arg_ptr, iStringID); |
| 7206 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 7206 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
| 7207 va_end(arg_ptr); | 7207 va_end(arg_ptr); |
| 7208 FXJSE_ThrowMessage( | 7208 FXJSE_ThrowMessage( |
| 7209 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 7209 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
| 7210 } | 7210 } |
| OLD | NEW |