blob: ccddc7f8dfba59eac6efcaa5482363f3561e3ee6 [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_object.h"
Dan Sinclaird808dfd2017-10-26 15:04:17 -04008
9// static
10void CJS_Object::DefineConsts(CFXJS_Engine* pEngine,
11 int objId,
12 const JSConstSpec consts[]) {
13 for (size_t i = 0; consts[i].pName != 0; ++i) {
14 pEngine->DefineObjConst(
15 objId, consts[i].pName,
16 consts[i].eType == JSConstSpec::Number
17 ? pEngine->NewNumber(consts[i].number).As<v8::Value>()
18 : pEngine->NewString(consts[i].pStr).As<v8::Value>());
19 }
20}
21
22// static
23void CJS_Object::DefineProps(CFXJS_Engine* pEngine,
24 int objId,
25 const JSPropertySpec props[]) {
26 for (size_t i = 0; props[i].pName != 0; ++i) {
27 pEngine->DefineObjProperty(objId, props[i].pName, props[i].pPropGet,
28 props[i].pPropPut);
29 }
30}
31
32// static
33void CJS_Object::DefineMethods(CFXJS_Engine* pEngine,
34 int objId,
35 const JSMethodSpec methods[]) {
36 for (size_t i = 0; methods[i].pName != 0; ++i)
37 pEngine->DefineObjMethod(objId, methods[i].pName, methods[i].pMethodCall);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070038}
39
Tom Sepez116e4ad2015-09-21 09:22:05 -070040CJS_Object::CJS_Object(v8::Local<v8::Object> pObject) {
Tom Sepez371379d2015-11-06 08:29:39 -080041 m_pIsolate = pObject->GetIsolate();
Tom Sepez116e4ad2015-09-21 09:22:05 -070042 m_pV8Object.Reset(m_pIsolate, pObject);
43}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070044
Dan Sinclairf766ad22016-03-14 13:51:24 -040045CJS_Object::~CJS_Object() {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070046
weili625ad662016-06-15 11:21:33 -070047void CJS_Object::InitInstance(IJS_Runtime* pIRuntime) {}