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_source.h"
8
9 #include <vector>
10
11 #include "fxjs/js_resources.h"
12 #include "fxjs/xfa/cfxjse_value.h"
13 #include "xfa/fxfa/parser/cxfa_source.h"
14
15 const CJX_MethodSpec CJX_Source::MethodSpecs[] = {
16 {"addNew", addNew_static},
17 {"cancel", cancel_static},
18 {"cancelBatch", cancelBatch_static},
19 {"close", close_static},
20 {"delete", deleteItem_static},
21 {"first", first_static},
22 {"hasDataChanged", hasDataChanged_static},
23 {"isBOF", isBOF_static},
24 {"isEOF", isEOF_static},
25 {"last", last_static},
26 {"next", next_static},
27 {"open", open_static},
28 {"previous", previous_static},
29 {"requery", requery_static},
30 {"resync", resync_static},
31 {"update", update_static},
32 {"updateBatch", updateBatch_static}};
33
CJX_Source(CXFA_Source * src)34 CJX_Source::CJX_Source(CXFA_Source* src) : CJX_Node(src) {
35 DefineMethods(MethodSpecs);
36 }
37
38 CJX_Source::~CJX_Source() = default;
39
DynamicTypeIs(TypeTag eType) const40 bool CJX_Source::DynamicTypeIs(TypeTag eType) const {
41 return eType == static_type__ || ParentType__::DynamicTypeIs(eType);
42 }
43
next(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)44 CJS_Result CJX_Source::next(CFXJSE_Engine* runtime,
45 const std::vector<v8::Local<v8::Value>>& params) {
46 if (!params.empty())
47 return CJS_Result::Failure(JSMessage::kParamError);
48
49 return CJS_Result::Success();
50 }
51
cancelBatch(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)52 CJS_Result CJX_Source::cancelBatch(
53 CFXJSE_Engine* runtime,
54 const std::vector<v8::Local<v8::Value>>& params) {
55 if (!params.empty())
56 return CJS_Result::Failure(JSMessage::kParamError);
57
58 return CJS_Result::Success();
59 }
60
first(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)61 CJS_Result CJX_Source::first(CFXJSE_Engine* runtime,
62 const std::vector<v8::Local<v8::Value>>& params) {
63 if (!params.empty())
64 return CJS_Result::Failure(JSMessage::kParamError);
65
66 return CJS_Result::Success();
67 }
68
updateBatch(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)69 CJS_Result CJX_Source::updateBatch(
70 CFXJSE_Engine* runtime,
71 const std::vector<v8::Local<v8::Value>>& params) {
72 if (!params.empty())
73 return CJS_Result::Failure(JSMessage::kParamError);
74
75 return CJS_Result::Success();
76 }
77
previous(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)78 CJS_Result CJX_Source::previous(
79 CFXJSE_Engine* runtime,
80 const std::vector<v8::Local<v8::Value>>& params) {
81 if (!params.empty())
82 return CJS_Result::Failure(JSMessage::kParamError);
83
84 return CJS_Result::Success();
85 }
86
isBOF(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)87 CJS_Result CJX_Source::isBOF(CFXJSE_Engine* runtime,
88 const std::vector<v8::Local<v8::Value>>& params) {
89 if (!params.empty())
90 return CJS_Result::Failure(JSMessage::kParamError);
91
92 return CJS_Result::Success();
93 }
94
isEOF(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)95 CJS_Result CJX_Source::isEOF(CFXJSE_Engine* runtime,
96 const std::vector<v8::Local<v8::Value>>& params) {
97 if (!params.empty())
98 return CJS_Result::Failure(JSMessage::kParamError);
99
100 return CJS_Result::Success();
101 }
102
cancel(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)103 CJS_Result CJX_Source::cancel(CFXJSE_Engine* runtime,
104 const std::vector<v8::Local<v8::Value>>& params) {
105 if (!params.empty())
106 return CJS_Result::Failure(JSMessage::kParamError);
107
108 return CJS_Result::Success();
109 }
110
update(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)111 CJS_Result CJX_Source::update(CFXJSE_Engine* runtime,
112 const std::vector<v8::Local<v8::Value>>& params) {
113 if (!params.empty())
114 return CJS_Result::Failure(JSMessage::kParamError);
115
116 return CJS_Result::Success();
117 }
118
open(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)119 CJS_Result CJX_Source::open(CFXJSE_Engine* runtime,
120 const std::vector<v8::Local<v8::Value>>& params) {
121 if (!params.empty())
122 return CJS_Result::Failure(JSMessage::kParamError);
123
124 return CJS_Result::Success();
125 }
126
deleteItem(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)127 CJS_Result CJX_Source::deleteItem(
128 CFXJSE_Engine* runtime,
129 const std::vector<v8::Local<v8::Value>>& params) {
130 if (!params.empty())
131 return CJS_Result::Failure(JSMessage::kParamError);
132
133 return CJS_Result::Success();
134 }
135
addNew(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)136 CJS_Result CJX_Source::addNew(CFXJSE_Engine* runtime,
137 const std::vector<v8::Local<v8::Value>>& params) {
138 if (!params.empty())
139 return CJS_Result::Failure(JSMessage::kParamError);
140
141 return CJS_Result::Success();
142 }
143
requery(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)144 CJS_Result CJX_Source::requery(
145 CFXJSE_Engine* runtime,
146 const std::vector<v8::Local<v8::Value>>& params) {
147 if (!params.empty())
148 return CJS_Result::Failure(JSMessage::kParamError);
149
150 return CJS_Result::Success();
151 }
152
resync(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)153 CJS_Result CJX_Source::resync(CFXJSE_Engine* runtime,
154 const std::vector<v8::Local<v8::Value>>& params) {
155 if (!params.empty())
156 return CJS_Result::Failure(JSMessage::kParamError);
157
158 return CJS_Result::Success();
159 }
160
close(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)161 CJS_Result CJX_Source::close(CFXJSE_Engine* runtime,
162 const std::vector<v8::Local<v8::Value>>& params) {
163 if (!params.empty())
164 return CJS_Result::Failure(JSMessage::kParamError);
165
166 return CJS_Result::Success();
167 }
168
last(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)169 CJS_Result CJX_Source::last(CFXJSE_Engine* runtime,
170 const std::vector<v8::Local<v8::Value>>& params) {
171 if (!params.empty())
172 return CJS_Result::Failure(JSMessage::kParamError);
173
174 return CJS_Result::Success();
175 }
176
hasDataChanged(CFXJSE_Engine * runtime,const std::vector<v8::Local<v8::Value>> & params)177 CJS_Result CJX_Source::hasDataChanged(
178 CFXJSE_Engine* runtime,
179 const std::vector<v8::Local<v8::Value>>& params) {
180 if (!params.empty())
181 return CJS_Result::Failure(JSMessage::kParamError);
182
183 return CJS_Result::Success();
184 }
185
db(v8::Isolate * pIsolate,v8::Local<v8::Value> * pValue,bool bSetting,XFA_Attribute eAttribute)186 void CJX_Source::db(v8::Isolate* pIsolate,
187 v8::Local<v8::Value>* pValue,
188 bool bSetting,
189 XFA_Attribute eAttribute) {}
190