blob: f4158a9c0ac16f7b61d73804ddfd129e1b03994a [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// 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.
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Dan Sinclaire0345a42017-10-30 20:20:42 +00007#include "fxjs/cjs_console.h"
Tom Sepez37458412015-10-06 11:33:46 -07008
Dan Sinclair3ebd1212016-03-09 09:59:23 -05009#include <vector>
10
Dan Sinclaire0345a42017-10-30 20:20:42 +000011#include "fxjs/JS_Define.h"
12#include "fxjs/cjs_event_context.h"
13#include "fxjs/cjs_eventhandler.h"
14#include "fxjs/cjs_object.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070015
Dan Sinclairc94a7932017-10-26 16:48:57 -040016const JSMethodSpec CJS_Console::MethodSpecs[] = {{"clear", clear_static},
17 {"hide", hide_static},
18 {"println", println_static},
Dan Sinclair909fa2d2017-12-12 01:53:28 +000019 {"show", show_static}};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070020
Dan Sinclairef299532017-10-26 16:48:30 -040021int CJS_Console::ObjDefnID = -1;
Dan Sinclair89d26c82017-10-26 12:21:28 -040022
Dan Sinclairef299532017-10-26 16:48:30 -040023// static
Dan Sinclairbef4d3e2017-10-26 16:49:38 -040024void CJS_Console::DefineJSObjects(CFXJS_Engine* pEngine) {
Tom Sepez57e09772018-02-05 18:52:09 +000025 ObjDefnID =
26 pEngine->DefineObj("console", FXJSOBJTYPE_STATIC,
27 JSConstructor<CJS_Console, console>, JSDestructor);
Dan Sinclair909fa2d2017-12-12 01:53:28 +000028 DefineMethods(pEngine, ObjDefnID, MethodSpecs, FX_ArraySize(MethodSpecs));
Dan Sinclair89d26c82017-10-26 12:21:28 -040029}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070030
Nico Weber9d8ec5a2015-08-04 13:00:21 -070031console::console(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
32
33console::~console() {}
34
Dan Sinclair8f524d62017-10-25 13:30:31 -040035CJS_Return console::clear(CJS_Runtime* pRuntime,
36 const std::vector<v8::Local<v8::Value>>& params) {
37 return CJS_Return(true);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070038}
39
Dan Sinclair8f524d62017-10-25 13:30:31 -040040CJS_Return console::hide(CJS_Runtime* pRuntime,
41 const std::vector<v8::Local<v8::Value>>& params) {
42 return CJS_Return(true);
tsepez4cf55152016-11-02 14:37:54 -070043}
44
Dan Sinclair8f524d62017-10-25 13:30:31 -040045CJS_Return console::println(CJS_Runtime* pRuntime,
46 const std::vector<v8::Local<v8::Value>>& params) {
47 return CJS_Return(params.size() > 0);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070048}
49
Dan Sinclair8f524d62017-10-25 13:30:31 -040050CJS_Return console::show(CJS_Runtime* pRuntime,
51 const std::vector<v8::Local<v8::Value>>& params) {
52 return CJS_Return(true);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070053}