1 // Copyright 2017 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "fxjs/xfa/cjx_logpseudomodel.h"
8
9 #include <vector>
10
11 #include "fxjs/xfa/cfxjse_value.h"
12 #include "xfa/fxfa/parser/cscript_logpseudomodel.h"
13
14 const CJX_MethodSpec CJX_LogPseudoModel::MethodSpecs[] = {
15 {"message", message_static},
16 {"traceEnabled", traceEnabled_static},
17 {"traceActivate", traceActivate_static},
18 {"traceDeactivate", traceDeactivate_static},
19 {"trace", trace_static}};
20
CJX_LogPseudoModel(CScript_LogPseudoModel * model)21 CJX_LogPseudoModel::CJX_LogPseudoModel(CScript_LogPseudoModel* model)
22 : CJX_Object(model) {
23 DefineMethods(MethodSpecs);
24 }
25
26 CJX_LogPseudoModel::~CJX_LogPseudoModel() = default;
27
DynamicTypeIs(TypeTag eType) const28 bool CJX_LogPseudoModel::DynamicTypeIs(TypeTag eType) const {
29 return eType == static_type__ || ParentType__::DynamicTypeIs(eType);
30 }
31
message(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)32 CJS_Result CJX_LogPseudoModel::message(
33 CFXJSE_Engine* runtime,
34 const std::vector<v8::Local<v8::Value>>& params) {
35 // Uncomment to allow using xfa.log.message(""); from JS.
36 // fprintf(stderr, "LOG\n");
37 // for (auto& val : params) {
38 // v8::String::Utf8Value str(runtime->GetIsolate(), val);
39 // fprintf(stderr, " %ls\n", WideString::FromUTF8(*str).c_str());
40 // }
41
42 return CJS_Result::Success();
43 }
44
traceEnabled(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)45 CJS_Result CJX_LogPseudoModel::traceEnabled(
46 CFXJSE_Engine* runtime,
47 const std::vector<v8::Local<v8::Value>>& params) {
48 return CJS_Result::Success();
49 }
50
traceActivate(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)51 CJS_Result CJX_LogPseudoModel::traceActivate(
52 CFXJSE_Engine* runtime,
53 const std::vector<v8::Local<v8::Value>>& params) {
54 return CJS_Result::Success();
55 }
56
traceDeactivate(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)57 CJS_Result CJX_LogPseudoModel::traceDeactivate(
58 CFXJSE_Engine* runtime,
59 const std::vector<v8::Local<v8::Value>>& params) {
60 return CJS_Result::Success();
61 }
62
trace(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)63 CJS_Result CJX_LogPseudoModel::trace(
64 CFXJSE_Engine* runtime,
65 const std::vector<v8::Local<v8::Value>>& params) {
66 return CJS_Result::Success();
67 }
68