|
10 | 10 |
|
11 | 11 | #include <stdlib.h> // malloc, free |
12 | 12 | #include <string.h> // memset, memcpy |
13 | | -#include <libplatform/libplatform.h> |
14 | 13 | #include <v8.h> |
15 | | -#include "wrappers.h" |
| 14 | +#include "c_v8.h" |
16 | 15 |
|
17 | 16 | using namespace v8; |
18 | 17 |
|
19 | | -class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
20 | | -public: |
21 | | - virtual void *Allocate(size_t length){ |
22 | | - void *data = AllocateUninitialized(length); |
23 | | - return data == NULL ? data : memset(data, 0, length); |
24 | | - } |
25 | | - virtual void *AllocateUninitialized(size_t length) { return malloc(length); } |
26 | | - virtual void Free(void *data, size_t) { free(data); } |
27 | | -}; |
28 | | - |
29 | 18 | class GlobalValue { |
30 | 19 | public: |
31 | 20 | explicit GlobalValue(Isolate* isolate, Global<Value>* value): |
@@ -61,32 +50,6 @@ class GlobalValue { |
61 | 50 | }; |
62 | 51 |
|
63 | 52 | extern "C" { |
64 | | - ArrayBufferAllocator bufferAllocator; |
65 | | - |
66 | | - void* initialize() { |
67 | | - V8::InitializeICU(); |
68 | | - auto platform = platform::CreateDefaultPlatform(); |
69 | | - V8::InitializePlatform(platform); |
70 | | - V8::Initialize(); |
71 | | - return platform; |
72 | | - } |
73 | | - |
74 | | - void dispose(void* platform) { |
75 | | - V8::Dispose(); |
76 | | - V8::ShutdownPlatform(); |
77 | | - delete reinterpret_cast<Platform*>(platform);; |
78 | | - } |
79 | | - |
80 | | - void* createIsolate() { |
81 | | - Isolate::CreateParams create_params; |
82 | | - create_params.array_buffer_allocator = &bufferAllocator; |
83 | | - return Isolate::New(create_params); |
84 | | - } |
85 | | - |
86 | | - void disposeIsolate(void* isolate) { |
87 | | - reinterpret_cast<Isolate*>(isolate)->Dispose(); |
88 | | - } |
89 | | - |
90 | 53 | void* createTemplate(void* isolatePtr) { |
91 | 54 | auto isolate = reinterpret_cast<Isolate*>(isolatePtr); |
92 | 55 | Locker isolateLocker(isolate); |
@@ -229,7 +192,6 @@ extern "C" { |
229 | 192 | context->DetachGlobal(); |
230 | 193 |
|
231 | 194 | auto newContext = Context::New(isolate, NULL, globalTemplate, globalObject); |
232 | | - |
233 | 195 | globalContext->Reset(isolate, newContext); |
234 | 196 | } |
235 | 197 |
|
|
0 commit comments