Home | History | Annotate | Download | only in fxjs
      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_object.h"
      8 
      9 // static
     10 void CJS_Object::DefineConsts(CFXJS_Engine* pEngine,
     11                               int objId,
     12                               const JSConstSpec consts[],
     13                               size_t count) {
     14   for (size_t i = 0; i < count; ++i) {
     15     pEngine->DefineObjConst(
     16         objId, consts[i].pName,
     17         consts[i].eType == JSConstSpec::Number
     18             ? pEngine->NewNumber(consts[i].number).As<v8::Value>()
     19             : pEngine->NewString(consts[i].pStr).As<v8::Value>());
     20   }
     21 }
     22 
     23 // static
     24 void CJS_Object::DefineProps(CFXJS_Engine* pEngine,
     25                              int objId,
     26                              const JSPropertySpec props[],
     27                              size_t count) {
     28   for (size_t i = 0; i < count; ++i) {
     29     pEngine->DefineObjProperty(objId, props[i].pName, props[i].pPropGet,
     30                                props[i].pPropPut);
     31   }
     32 }
     33 
     34 // static
     35 void CJS_Object::DefineMethods(CFXJS_Engine* pEngine,
     36                                int objId,
     37                                const JSMethodSpec methods[],
     38                                size_t count) {
     39   for (size_t i = 0; i < count; ++i)
     40     pEngine->DefineObjMethod(objId, methods[i].pName, methods[i].pMethodCall);
     41 }
     42 
     43 CJS_Object::CJS_Object(v8::Local<v8::Object> pObject) {
     44   m_pIsolate = pObject->GetIsolate();
     45   m_pV8Object.Reset(m_pIsolate, pObject);
     46 }
     47 
     48 CJS_Object::~CJS_Object() {}
     49 
     50 void CJS_Object::InitInstance(IJS_Runtime* pIRuntime) {}
     51