John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 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. |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Dan Sinclair | e0345a4 | 2017-10-30 20:20:42 +0000 | [diff] [blame] | 7 | #include "fxjs/cjs_console.h" |
Tom Sepez | 3745841 | 2015-10-06 11:33:46 -0700 | [diff] [blame] | 8 | |
Dan Sinclair | 3ebd121 | 2016-03-09 09:59:23 -0500 | [diff] [blame] | 9 | #include <vector> |
| 10 | |
Dan Sinclair | e0345a4 | 2017-10-30 20:20:42 +0000 | [diff] [blame] | 11 | #include "fxjs/cjs_event_context.h" |
| 12 | #include "fxjs/cjs_eventhandler.h" |
| 13 | #include "fxjs/cjs_object.h" |
Tom Sepez | 221f0b3 | 2018-06-04 22:11:27 +0000 | [diff] [blame] | 14 | #include "fxjs/js_define.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 15 | |
Dan Sinclair | c94a793 | 2017-10-26 16:48:57 -0400 | [diff] [blame] | 16 | const JSMethodSpec CJS_Console::MethodSpecs[] = {{"clear", clear_static}, |
| 17 | {"hide", hide_static}, |
| 18 | {"println", println_static}, |
Dan Sinclair | 909fa2d | 2017-12-12 01:53:28 +0000 | [diff] [blame] | 19 | {"show", show_static}}; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 20 | |
Dan Sinclair | ef29953 | 2017-10-26 16:48:30 -0400 | [diff] [blame] | 21 | int CJS_Console::ObjDefnID = -1; |
Dan Sinclair | f743552 | 2018-02-05 22:27:22 +0000 | [diff] [blame] | 22 | const char CJS_Console::kName[] = "console"; |
Dan Sinclair | 89d26c8 | 2017-10-26 12:21:28 -0400 | [diff] [blame] | 23 | |
Dan Sinclair | ef29953 | 2017-10-26 16:48:30 -0400 | [diff] [blame] | 24 | // static |
Dan Sinclair | bef4d3e | 2017-10-26 16:49:38 -0400 | [diff] [blame] | 25 | void CJS_Console::DefineJSObjects(CFXJS_Engine* pEngine) { |
Dan Sinclair | f743552 | 2018-02-05 22:27:22 +0000 | [diff] [blame] | 26 | ObjDefnID = pEngine->DefineObj(CJS_Console::kName, FXJSOBJTYPE_STATIC, |
Dan Sinclair | 998fee3 | 2018-02-05 21:43:19 +0000 | [diff] [blame] | 27 | JSConstructor<CJS_Console>, JSDestructor); |
Dan Sinclair | 909fa2d | 2017-12-12 01:53:28 +0000 | [diff] [blame] | 28 | DefineMethods(pEngine, ObjDefnID, MethodSpecs, FX_ArraySize(MethodSpecs)); |
Dan Sinclair | 89d26c8 | 2017-10-26 12:21:28 -0400 | [diff] [blame] | 29 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 30 | |
Tom Sepez | 36aae4f | 2018-06-04 19:44:37 +0000 | [diff] [blame] | 31 | CJS_Console::CJS_Console(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime) |
| 32 | : CJS_Object(pObject, pRuntime) {} |
Dan Sinclair | 998fee3 | 2018-02-05 21:43:19 +0000 | [diff] [blame] | 33 | |
Dan Sinclair | f743552 | 2018-02-05 22:27:22 +0000 | [diff] [blame] | 34 | CJS_Console::~CJS_Console() = default; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 35 | |
Dan Sinclair | f743552 | 2018-02-05 22:27:22 +0000 | [diff] [blame] | 36 | CJS_Return CJS_Console::clear(CJS_Runtime* pRuntime, |
| 37 | const std::vector<v8::Local<v8::Value>>& params) { |
Tom Sepez | 1699982 | 2018-06-08 18:23:05 +0000 | [diff] [blame] | 38 | return CJS_Return(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 39 | } |
| 40 | |
Dan Sinclair | f743552 | 2018-02-05 22:27:22 +0000 | [diff] [blame] | 41 | CJS_Return CJS_Console::hide(CJS_Runtime* pRuntime, |
| 42 | const std::vector<v8::Local<v8::Value>>& params) { |
Tom Sepez | 1699982 | 2018-06-08 18:23:05 +0000 | [diff] [blame] | 43 | return CJS_Return(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 44 | } |
| 45 | |
Dan Sinclair | f743552 | 2018-02-05 22:27:22 +0000 | [diff] [blame] | 46 | CJS_Return CJS_Console::println( |
| 47 | CJS_Runtime* pRuntime, |
| 48 | const std::vector<v8::Local<v8::Value>>& params) { |
Tom Sepez | 1699982 | 2018-06-08 18:23:05 +0000 | [diff] [blame] | 49 | return CJS_Return(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 50 | } |
| 51 | |
Dan Sinclair | f743552 | 2018-02-05 22:27:22 +0000 | [diff] [blame] | 52 | CJS_Return CJS_Console::show(CJS_Runtime* pRuntime, |
| 53 | const std::vector<v8::Local<v8::Value>>& params) { |
Tom Sepez | 1699982 | 2018-06-08 18:23:05 +0000 | [diff] [blame] | 54 | return CJS_Return(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 55 | } |