blob: 056525f30b75fea00f28a4ff82e7f935c0cddff7 [file] [log] [blame]
Dan Sinclair1770c022016-03-14 14:14:16 -04001// 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
dsinclair43554682016-09-29 17:29:48 -07007#ifndef FXJS_CFXJSE_CLASS_H_
8#define FXJS_CFXJSE_CLASS_H_
Dan Sinclair1770c022016-03-14 14:14:16 -04009
Dan Sinclairaee0db02017-09-21 16:53:58 -040010#include "core/fxcrt/unowned_ptr.h"
dsinclair43554682016-09-29 17:29:48 -070011#include "fxjs/fxjse.h"
Dan Sinclair1770c022016-03-14 14:14:16 -040012#include "v8/include/v8.h"
Dan Sinclair1770c022016-03-14 14:14:16 -040013
14class CFXJSE_Context;
15class CFXJSE_Value;
16
17class CFXJSE_Class {
Dan Sinclair1770c022016-03-14 14:14:16 -040018 public:
19 static CFXJSE_Class* Create(CFXJSE_Context* pContext,
tsepeze3b2a4e2016-05-26 12:39:34 -070020 const FXJSE_CLASS_DESCRIPTOR* lpClassDefintion,
Tom Sepez80547a12017-04-25 12:43:13 -070021 bool bIsJSGlobal);
22
Dan Sinclair1770c022016-03-14 14:14:16 -040023 static void SetUpNamedPropHandler(
24 v8::Isolate* pIsolate,
25 v8::Local<v8::ObjectTemplate>& hObjectTemplate,
tsepeze3b2a4e2016-05-26 12:39:34 -070026 const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition);
Dan Sinclair1770c022016-03-14 14:14:16 -040027
Tom Sepez80547a12017-04-25 12:43:13 -070028 explicit CFXJSE_Class(CFXJSE_Context* lpContext);
dsinclair08fea802016-07-12 10:37:52 -070029 ~CFXJSE_Class();
30
Tom Sepezd0409af2017-05-25 15:53:57 -070031 CFXJSE_Context* GetContext() const { return m_pContext.Get(); }
tsepez4ee98cd2016-06-01 16:58:24 -070032 v8::Global<v8::FunctionTemplate>& GetTemplate() { return m_hTemplate; }
33
Dan Sinclair1770c022016-03-14 14:14:16 -040034 protected:
Ryan Harrison275e2602017-09-18 14:23:18 -040035 ByteString m_szClassName;
Dan Sinclairaee0db02017-09-21 16:53:58 -040036 UnownedPtr<const FXJSE_CLASS_DESCRIPTOR> m_lpClassDefinition;
37 UnownedPtr<CFXJSE_Context> m_pContext;
Dan Sinclair1770c022016-03-14 14:14:16 -040038 v8::Global<v8::FunctionTemplate> m_hTemplate;
39 friend class CFXJSE_Context;
40 friend class CFXJSE_Value;
41};
Dan Sinclair1770c022016-03-14 14:14:16 -040042
dsinclair43554682016-09-29 17:29:48 -070043#endif // FXJS_CFXJSE_CLASS_H_