From e0518bf0a0e703b1e010081079c988f011834cb6 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 8 Feb 2018 21:44:59 +0000 Subject: Move cjs_v8.cpp to cfx_v8.cpp The layering should be CJS => CFXJS => CFX_V8 with the CJS name being higher up. Change-Id: Ic130f248906e9c4df641dd508389b0555786b999 Reviewed-on: https://pdfium-review.googlesource.com/26051 Commit-Queue: Tom Sepez Reviewed-by: dsinclair --- fxjs/cfx_v8.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 fxjs/cfx_v8.h (limited to 'fxjs/cfx_v8.h') diff --git a/fxjs/cfx_v8.h b/fxjs/cfx_v8.h new file mode 100644 index 0000000000..2f9794c243 --- /dev/null +++ b/fxjs/cfx_v8.h @@ -0,0 +1,68 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FXJS_CFX_V8_H_ +#define FXJS_CFX_V8_H_ + +#include +#include + +#include "core/fxcrt/fx_string.h" +#include "core/fxcrt/unowned_ptr.h" +#include "v8/include/v8-util.h" +#include "v8/include/v8.h" + +class CFX_V8 { + public: + explicit CFX_V8(v8::Isolate* pIsolate); + virtual ~CFX_V8(); + + v8::Isolate* GetIsolate() const { return m_isolate; } + + v8::Local NewNull(); + v8::Local NewUndefined(); + v8::Local NewArray(); + v8::Local NewObject(); + v8::Local NewNumber(int number); + v8::Local NewNumber(double number); + v8::Local NewNumber(float number); + v8::Local NewBoolean(bool b); + v8::Local NewString(const ByteStringView& str); + v8::Local NewString(const WideStringView& str); + v8::Local NewDate(double d); + + int ToInt32(v8::Local pValue); + bool ToBoolean(v8::Local pValue); + double ToDouble(v8::Local pValue); + WideString ToWideString(v8::Local pValue); + ByteString ToByteString(v8::Local pValue); + v8::Local ToObject(v8::Local pValue); + v8::Local ToArray(v8::Local pValue); + + // Arrays. + unsigned GetArrayLength(v8::Local pArray); + v8::Local GetArrayElement(v8::Local pArray, + unsigned index); + unsigned PutArrayElement(v8::Local pArray, + unsigned index, + v8::Local pValue); + + // Objects. + std::vector GetObjectPropertyNames(v8::Local pObj); + v8::Local GetObjectProperty(v8::Local pObj, + const WideString& PropertyName); + void PutObjectProperty(v8::Local pObj, + const WideString& PropertyName, + v8::Local pValue); + + protected: + void SetIsolate(v8::Isolate* pIsolate) { m_isolate = pIsolate; } + + private: + v8::Isolate* m_isolate; +}; + +#endif // FXJS_CFX_V8_H_ -- cgit v1.2.3