1 // Copyright 2014 PDFium Authors. All rights reserved.
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/cjs_console.h"
8 
9 #include <vector>
10 
11 #include "fxjs/JS_Define.h"
12 #include "fxjs/cjs_event_context.h"
13 #include "fxjs/cjs_eventhandler.h"
14 #include "fxjs/cjs_object.h"
15 
16 const JSMethodSpec CJS_Console::MethodSpecs[] = {{"clear", clear_static},
17                                                  {"hide", hide_static},
18                                                  {"println", println_static},
19                                                  {"show", show_static}};
20 
21 int CJS_Console::ObjDefnID = -1;
22 
23 // static
DefineJSObjects(CFXJS_Engine * pEngine)24 void CJS_Console::DefineJSObjects(CFXJS_Engine* pEngine) {
25   ObjDefnID = pEngine->DefineObj("console", FXJSOBJTYPE_STATIC,
26                                  JSConstructor<CJS_Console, console>,
27                                  JSDestructor<CJS_Console>);
28   DefineMethods(pEngine, ObjDefnID, MethodSpecs, FX_ArraySize(MethodSpecs));
29 }
30 
console(CJS_Object * pJSObject)31 console::console(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
32 
~console()33 console::~console() {}
34 
clear(CJS_Runtime * pRuntime,const std::vector<v8::Local<v8::Value>> & params)35 CJS_Return console::clear(CJS_Runtime* pRuntime,
36                           const std::vector<v8::Local<v8::Value>>& params) {
37   return CJS_Return(true);
38 }
39 
hide(CJS_Runtime * pRuntime,const std::vector<v8::Local<v8::Value>> & params)40 CJS_Return console::hide(CJS_Runtime* pRuntime,
41                          const std::vector<v8::Local<v8::Value>>& params) {
42   return CJS_Return(true);
43 }
44 
println(CJS_Runtime * pRuntime,const std::vector<v8::Local<v8::Value>> & params)45 CJS_Return console::println(CJS_Runtime* pRuntime,
46                             const std::vector<v8::Local<v8::Value>>& params) {
47   return CJS_Return(params.size() > 0);
48 }
49 
show(CJS_Runtime * pRuntime,const std::vector<v8::Local<v8::Value>> & params)50 CJS_Return console::show(CJS_Runtime* pRuntime,
51                          const std::vector<v8::Local<v8::Value>>& params) {
52   return CJS_Return(true);
53 }
54