1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

Simplify c api

This commit is contained in:
Ryan Dahl 2018-06-10 04:11:02 +02:00
parent 7c71785981
commit aa857984b0
3 changed files with 12 additions and 10 deletions

View file

@ -295,8 +295,12 @@ void deno_add_isolate(Deno* d, v8::Isolate* isolate) {
d->isolate->SetData(0, d);
}
v8::StartupData deno_make_snapshot(const char* js_filename,
const char* js_source) {
v8::StartupData make_snapshot(v8::StartupData* prev_natives_blob,
v8::StartupData* prev_snapshot_blob,
const char* js_filename, const char* js_source) {
v8::V8::SetNativesDataBlob(prev_natives_blob);
v8::V8::SetSnapshotDataBlob(prev_snapshot_blob);
auto creator = new v8::SnapshotCreator(external_references);
auto* isolate = creator->GetIsolate();

View file

@ -28,8 +28,9 @@ void v8_set_flags(int* argc, char** argv);
// Constructors:
Deno* deno_from_snapshot(v8::StartupData* blob, void* data, RecvCallback cb);
v8::StartupData deno_make_snapshot(const char* js_filename,
const char* js_source);
v8::StartupData make_snapshot(v8::StartupData* prev_natives_blob,
v8::StartupData* prev_snapshot_blob,
const char* js_filename, const char* js_source);
void* deno_get_data();

View file

@ -125,16 +125,13 @@ int main(int argc, char** argv) {
const char* natives_out_cc = argv[4];
const char* snapshot_out_cc = argv[5];
deno::v8_init();
auto js_data = ReadFile(js_fn);
auto natives_blob = ReadFile(natives_in_bin);
auto snapshot_in_blob = ReadFile(snapshot_in_bin);
v8::V8::SetNativesDataBlob(&natives_blob);
v8::V8::SetSnapshotDataBlob(&snapshot_in_blob);
auto snapshot_blob = deno::deno_make_snapshot(js_fn, js_data.data);
deno::v8_init();
auto snapshot_blob = deno::make_snapshot(&natives_blob, &snapshot_in_blob,
js_fn, js_data.data);
StartupDataCppWriter nativesWriter("natives", natives_out_cc, natives_blob);
nativesWriter.Write();