Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [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. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
dsinclair | 4355468 | 2016-09-29 17:29:48 -0700 | [diff] [blame] | 7 | #ifndef FXJS_CFXJSE_CLASS_H_ |
| 8 | #define FXJS_CFXJSE_CLASS_H_ |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 9 | |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 10 | #include "core/fxcrt/unowned_ptr.h" |
dsinclair | 4355468 | 2016-09-29 17:29:48 -0700 | [diff] [blame] | 11 | #include "fxjs/fxjse.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 12 | #include "v8/include/v8.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 13 | |
| 14 | class CFXJSE_Context; |
| 15 | class CFXJSE_Value; |
| 16 | |
| 17 | class CFXJSE_Class { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 18 | public: |
| 19 | static CFXJSE_Class* Create(CFXJSE_Context* pContext, |
tsepez | e3b2a4e | 2016-05-26 12:39:34 -0700 | [diff] [blame] | 20 | const FXJSE_CLASS_DESCRIPTOR* lpClassDefintion, |
Tom Sepez | 80547a1 | 2017-04-25 12:43:13 -0700 | [diff] [blame] | 21 | bool bIsJSGlobal); |
| 22 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 23 | static void SetUpNamedPropHandler( |
| 24 | v8::Isolate* pIsolate, |
| 25 | v8::Local<v8::ObjectTemplate>& hObjectTemplate, |
tsepez | e3b2a4e | 2016-05-26 12:39:34 -0700 | [diff] [blame] | 26 | const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 27 | |
Tom Sepez | 80547a1 | 2017-04-25 12:43:13 -0700 | [diff] [blame] | 28 | explicit CFXJSE_Class(CFXJSE_Context* lpContext); |
dsinclair | 08fea80 | 2016-07-12 10:37:52 -0700 | [diff] [blame] | 29 | ~CFXJSE_Class(); |
| 30 | |
Tom Sepez | d0409af | 2017-05-25 15:53:57 -0700 | [diff] [blame] | 31 | CFXJSE_Context* GetContext() const { return m_pContext.Get(); } |
tsepez | 4ee98cd | 2016-06-01 16:58:24 -0700 | [diff] [blame] | 32 | v8::Global<v8::FunctionTemplate>& GetTemplate() { return m_hTemplate; } |
| 33 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 34 | protected: |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 35 | ByteString m_szClassName; |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 36 | UnownedPtr<const FXJSE_CLASS_DESCRIPTOR> m_lpClassDefinition; |
| 37 | UnownedPtr<CFXJSE_Context> m_pContext; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 38 | v8::Global<v8::FunctionTemplate> m_hTemplate; |
| 39 | friend class CFXJSE_Context; |
| 40 | friend class CFXJSE_Value; |
| 41 | }; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 42 | |
dsinclair | 4355468 | 2016-09-29 17:29:48 -0700 | [diff] [blame] | 43 | #endif // FXJS_CFXJSE_CLASS_H_ |