summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/fm2js')
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jsapi.cpp61
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jsapi.h35
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jscontext.cpp32
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jscontext.h4
4 files changed, 33 insertions, 99 deletions
diff --git a/xfa/fxfa/fm2js/xfa_fm2jsapi.cpp b/xfa/fxfa/fm2js/xfa_fm2jsapi.cpp
deleted file mode 100644
index 826739a9e7..0000000000
--- a/xfa/fxfa/fm2js/xfa_fm2jsapi.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-
-#include "core/fxcrt/include/fx_basic.h"
-#include "xfa/fxfa/fm2js/xfa_fm2jscontext.h"
-#include "xfa/fxfa/fm2js/xfa_program.h"
-#include "xfa/fxfa/parser/xfa_document.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int32_t XFA_FM2JS_Translate(const CFX_WideStringC& wsFormcalc,
- CFX_WideTextBuf& wsJavascript,
- CFX_WideString& wsError) {
- if (wsFormcalc.IsEmpty()) {
- wsJavascript.Clear();
- wsError.clear();
- return 0;
- }
- int32_t status = 0;
- CXFA_FMProgram program;
- status = program.Init(wsFormcalc);
- if (status) {
- wsError = program.GetError().message;
- return status;
- }
- status = program.ParseProgram();
- if (status) {
- wsError = program.GetError().message;
- return status;
- }
- program.TranslateProgram(wsJavascript);
- return 0;
-}
-
-XFA_HFM2JSCONTEXT XFA_FM2JS_ContextCreate(v8::Isolate* pScriptIsolate,
- CFXJSE_Context* pScriptContext,
- CXFA_Document* pDocument) {
- return reinterpret_cast<XFA_HFM2JSCONTEXT>(
- new CXFA_FM2JSContext(pScriptIsolate, pScriptContext, pDocument));
-}
-
-void XFA_FM2JS_GlobalPropertyGetter(XFA_HFM2JSCONTEXT hFM2JSContext,
- CFXJSE_Value* pValue) {
- CXFA_FM2JSContext* pContext =
- reinterpret_cast<CXFA_FM2JSContext*>(hFM2JSContext);
- pContext->GlobalPropertyGetter(pValue);
-}
-
-void XFA_FM2JS_ContextRelease(XFA_HFM2JSCONTEXT hFM2JSContext) {
- delete reinterpret_cast<CXFA_FM2JSContext*>(hFM2JSContext);
-}
-#ifdef __cplusplus
-}
-#endif
diff --git a/xfa/fxfa/fm2js/xfa_fm2jsapi.h b/xfa/fxfa/fm2js/xfa_fm2jsapi.h
deleted file mode 100644
index e48591dbc0..0000000000
--- a/xfa/fxfa/fm2js/xfa_fm2jsapi.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXFA_FM2JS_XFA_FM2JSAPI_H_
-#define XFA_FXFA_FM2JS_XFA_FM2JSAPI_H_
-
-#include "core/fxcrt/include/fx_basic.h"
-#include "xfa/fxfa/parser/xfa_document.h"
-#include "xfa/fxjse/include/fxjse.h"
-
-#define FOXIT_XFA_FM2JS_FORMCALC_RUNTIME "foxit_xfa_formcalc_runtime"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct XFA_HFM2JSCONTEXT_ { void** pData; } * XFA_HFM2JSCONTEXT;
-int32_t XFA_FM2JS_Translate(const CFX_WideStringC& wsFormcalc,
- CFX_WideTextBuf& wsJavascript,
- CFX_WideString& wsError);
-XFA_HFM2JSCONTEXT XFA_FM2JS_ContextCreate(v8::Isolate* pScriptIsolate,
- CFXJSE_Context* pScriptContext,
- CXFA_Document* pDocument);
-void XFA_FM2JS_GlobalPropertyGetter(XFA_HFM2JSCONTEXT hFM2JSContext,
- CFXJSE_Value* pValue);
-void XFA_FM2JS_ContextRelease(XFA_HFM2JSCONTEXT hFM2JSContext);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // XFA_FXFA_FM2JS_XFA_FM2JSAPI_H_
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
index e778d42994..6eb8249cc1 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
@@ -11,7 +11,7 @@
#include "core/fxcrt/include/fx_ext.h"
#include "xfa/fgas/localization/fgas_locale.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
-#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
+#include "xfa/fxfa/fm2js/xfa_program.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localevalue.h"
#include "xfa/fxfa/parser/xfa_parser.h"
@@ -3404,7 +3404,7 @@ void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis,
CFX_WideTextBuf wsJavaScriptBuf;
CFX_WideString javaScript;
CFX_WideString wsError;
- XFA_FM2JS_Translate(
+ CXFA_FM2JSContext::Translate(
CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(),
wsJavaScriptBuf, wsError);
CFXJSE_Context* pContext =
@@ -6417,7 +6417,8 @@ void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis,
CFX_WideString::FromUTF8(argString.AsStringC());
CFX_WideTextBuf wsJavaScriptBuf;
CFX_WideString wsError;
- XFA_FM2JS_Translate(scriptString.AsStringC(), wsJavaScriptBuf, wsError);
+ CXFA_FM2JSContext::Translate(scriptString.AsStringC(), wsJavaScriptBuf,
+ wsError);
if (wsError.IsEmpty()) {
CFX_WideString javaScript = wsJavaScriptBuf.MakeString();
FXJSE_Value_SetUTF8String(
@@ -7122,6 +7123,31 @@ void CXFA_FM2JSContext::ValueToUTF8String(CFXJSE_Value* arg,
}
}
+// static.
+int32_t CXFA_FM2JSContext::Translate(const CFX_WideStringC& wsFormcalc,
+ CFX_WideTextBuf& wsJavascript,
+ CFX_WideString& wsError) {
+ if (wsFormcalc.IsEmpty()) {
+ wsJavascript.Clear();
+ wsError.clear();
+ return 0;
+ }
+ int32_t status = 0;
+ CXFA_FMProgram program;
+ status = program.Init(wsFormcalc);
+ if (status) {
+ wsError = program.GetError().message;
+ return status;
+ }
+ status = program.ParseProgram();
+ if (status) {
+ wsError = program.GetError().message;
+ return status;
+ }
+ program.TranslateProgram(wsJavascript);
+ return 0;
+}
+
CXFA_FM2JSContext::CXFA_FM2JSContext(v8::Isolate* pScriptIsolate,
CFXJSE_Context* pScriptContext,
CXFA_Document* pDoc)
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.h b/xfa/fxfa/fm2js/xfa_fm2jscontext.h
index 2af67f62cf..a5270092e8 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.h
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.h
@@ -432,6 +432,10 @@ class CXFA_FM2JSContext : public CFXJSE_HostObject {
static void ValueToUTF8String(CFXJSE_Value* pValue,
CFX_ByteString& outputValue);
+ static int32_t Translate(const CFX_WideStringC& wsFormcalc,
+ CFX_WideTextBuf& wsJavascript,
+ CFX_WideString& wsError);
+
CXFA_FM2JSContext(v8::Isolate* pScriptIsolate,
CFXJSE_Context* pScriptContext,
CXFA_Document* pDoc);