blob: 2b4dd279773b267b9951c3537a6a52e6782a24d9 [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) {
Dan Sinclair998fee32018-02-05 21:43:19 +000025 ObjDefnID = pEngine->DefineObj("console", FXJSOBJTYPE_STATIC,
26 JSConstructor<CJS_Console>, JSDestructor);
Dan Sinclair909fa2d2017-12-12 01:53:28 +000027 DefineMethods(pEngine, ObjDefnID, MethodSpecs, FX_ArraySize(MethodSpecs));
Dan Sinclair89d26c82017-10-26 12:21:28 -040028}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070029
Dan Sinclair998fee32018-02-05 21:43:19 +000030CJS_Console::CJS_Console(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {
31 m_pEmbedObj = pdfium::MakeUnique<console>(this);
32}
33
Nico Weber9d8ec5a2015-08-04 13:00:21 -070034console::console(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
35
Dan Sinclair998fee32018-02-05 21:43:19 +000036console::~console() = default;
Nico Weber9d8ec5a2015-08-04 13:00:21 -070037
Dan Sinclair8f524d62017-10-25 13:30:31 -040038CJS_Return console::clear(CJS_Runtime* pRuntime,
39 const std::vector<v8::Local<v8::Value>>& params) {
40 return CJS_Return(true);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070041}
42
Dan Sinclair8f524d62017-10-25 13:30:31 -040043CJS_Return console::hide(CJS_Runtime* pRuntime,
44 const std::vector<v8::Local<v8::Value>>& params) {
45 return CJS_Return(true);
tsepez4cf55152016-11-02 14:37:54 -070046}
47
Dan Sinclair8f524d62017-10-25 13:30:31 -040048CJS_Return console::println(CJS_Runtime* pRuntime,
49 const std::vector<v8::Local<v8::Value>>& params) {
50 return CJS_Return(params.size() > 0);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070051}
52
Dan Sinclair8f524d62017-10-25 13:30:31 -040053CJS_Return console::show(CJS_Runtime* pRuntime,
54 const std::vector<v8::Local<v8::Value>>& params) {
55 return CJS_Return(true);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070056}