OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../include/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
9 #include "../../include/javascript/JS_EventHandler.h" | 9 #include "../../include/javascript/JS_EventHandler.h" |
10 #include "../../include/javascript/JS_Runtime.h" | 10 #include "../../include/javascript/JS_Runtime.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 { | 84 { |
85 m_nGlobalDataCount--; | 85 m_nGlobalDataCount--; |
86 | 86 |
87 if (m_nGlobalDataCount <= 0) | 87 if (m_nGlobalDataCount <= 0) |
88 { | 88 { |
89 delete m_pGlobalData; | 89 delete m_pGlobalData; |
90 m_pGlobalData = NULL; | 90 m_pGlobalData = NULL; |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
| 94 void* CJS_ArrayBufferAllocator::Allocate(size_t length) { |
| 95 return calloc(1, length); |
| 96 } |
| 97 |
| 98 void* CJS_ArrayBufferAllocator::AllocateUninitialized(size_t length) { |
| 99 return malloc(length); |
| 100 } |
| 101 |
| 102 void CJS_ArrayBufferAllocator::Free(void* data, size_t length) { |
| 103 free(data); |
| 104 } |
| 105 |
94 /* ------------------------------ CJS_Runtime ------------------------------ */ | 106 /* ------------------------------ CJS_Runtime ------------------------------ */ |
95 | 107 |
96 CJS_Runtime::CJS_Runtime(CPDFDoc_Environment * pApp) : | 108 CJS_Runtime::CJS_Runtime(CPDFDoc_Environment * pApp) : |
97 m_pApp(pApp), | 109 m_pApp(pApp), |
98 m_pDocument(NULL), | 110 m_pDocument(NULL), |
99 m_bBlocking(FALSE), | 111 m_bBlocking(FALSE), |
100 » m_pFieldEventPath(NULL), | 112 » m_bRegistered(FALSE), |
101 » m_bRegistered(FALSE) | 113 » m_pFieldEventPath(NULL) |
102 { | 114 { |
103 » m_isolate = v8::Isolate::New(); | 115 » m_pArrayBufferAllocator.reset(new CJS_ArrayBufferAllocator()); |
104 » //m_isolate->Enter(); | 116 |
| 117 » v8::Isolate::CreateParams params; |
| 118 » params.array_buffer_allocator = m_pArrayBufferAllocator.get(); |
| 119 » m_isolate = v8::Isolate::New(params); |
105 | 120 |
106 InitJSObjects(); | 121 InitJSObjects(); |
107 | 122 |
108 CJS_Context * pContext = (CJS_Context*)NewContext(); | 123 CJS_Context * pContext = (CJS_Context*)NewContext(); |
109 JS_InitialRuntime(*this, this, pContext, m_context); | 124 JS_InitialRuntime(*this, this, pContext, m_context); |
110 ReleaseContext(pContext); | 125 ReleaseContext(pContext); |
111 } | 126 } |
112 | 127 |
113 CJS_Runtime::~CJS_Runtime() | 128 CJS_Runtime::~CJS_Runtime() |
114 { | 129 { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 { | 332 { |
318 return v8::Local<v8::Context>::New(m_isolate, m_context); | 333 return v8::Local<v8::Context>::New(m_isolate, m_context); |
319 } | 334 } |
320 | 335 |
321 CFX_WideString ChangeObjName(const CFX_WideString& str) | 336 CFX_WideString ChangeObjName(const CFX_WideString& str) |
322 { | 337 { |
323 CFX_WideString sRet = str; | 338 CFX_WideString sRet = str; |
324 sRet.Replace(L"_", L"."); | 339 sRet.Replace(L"_", L"."); |
325 return sRet; | 340 return sRet; |
326 } | 341 } |
OLD | NEW |