提交 8603909a 编写于 作者: A Adam Barth

Merge pull request #43 from eseidel/skydart

Skydart
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
source_set("bindings2") {
sources = [
"dart_master.h",
"dart_master.cc"
]
deps = [
":dart_controller",
"//dart/runtime/bin:libdart_withcore",
"//base:base"
]
}
action("generate_snapshot_bin") {
deps = [
"//dart/runtime/bin:gen_snapshot($host_toolchain)",
]
inputs = [
"snapshot.dart",
"//dart/runtime/tools/create_snapshot_bin.py",
]
output = "$target_gen_dir/snapshot_gen.bin"
outputs = [
output,
]
gen_snapshot_dir = get_label_info(
"//dart/runtime/bin:gen_snapshot($host_toolchain)", "root_out_dir")
script = "//dart/runtime/tools/create_snapshot_bin.py"
args = [
"--executable", rebase_path("$gen_snapshot_dir/gen_snapshot"),
"--package_root", rebase_path("$root_gen_dir"),
"--script", rebase_path("snapshot.dart"),
"--output_bin", rebase_path(output, root_build_dir),
"--target_os", os,
]
}
action("generate_snapshot_file") {
deps = [
":generate_snapshot_bin",
]
inputs = [
"//dart/runtime/tools/create_snapshot_file.py",
"snapshot.cc.tmpl",
"$target_gen_dir/snapshot_gen.bin",
]
output = "$target_gen_dir/snapshot.cc"
outputs = [
output,
]
script = "//dart/runtime/tools/create_snapshot_file.py"
args = [
"--input_bin", rebase_path("$target_gen_dir/snapshot_gen.bin"),
"--input_cc", rebase_path("snapshot.cc.tmpl"),
"--output", rebase_path(output),
]
}
source_set("dart_controller") {
sources = [
"$target_gen_dir/snapshot.cc",
]
deps = [
":generate_snapshot_file"
]
}
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sky/engine/config.h"
#include "sky/engine/bindings2/dart_master.h"
#include "base/logging.h"
namespace mojo {
namespace dart {
extern const uint8_t* snapshot_buffer;
}
}
namespace blink {
static Dart_Isolate IsolateCreateCallback(const char* script_uri,
const char* main,
const char* package_root,
void* callback_data,
char** error) {
// LOG(INFO) << "IsolateCreateCallback";
return nullptr;
}
static void UnhandledExceptionCallback(Dart_Handle error) {
// LOG(INFO) << "UnhandledExceptionCallback";
}
static void IsolateShutdownCallback(void* callback_data) {
// LOG(INFO) << "IsolateShutdownCallback";
}
static Dart_Isolate ServiceIsolateCreateCallback(void* callback_data,
char** error) {
// LOG(INFO) << "ServiceIsolateCreateCallback";
return nullptr;
}
void DartMaster::InitVM() {
bool result = Dart_SetVMFlags(0, NULL);
result = Dart_Initialize(IsolateCreateCallback,
nullptr, // Isolate interrupt callback.
UnhandledExceptionCallback, IsolateShutdownCallback,
// File IO callbacks.
nullptr, nullptr, nullptr, nullptr, nullptr,
ServiceIsolateCreateCallback);
char* error;
Dart_Isolate isolate = Dart_CreateIsolate(
"bogus:uri", "main", mojo::dart::snapshot_buffer, nullptr, &error);
CHECK(isolate);
Dart_EnterScope();
Dart_Handle library = Dart_LoadLibrary(
Dart_NewStringFromCString("foo:bar"),
Dart_NewStringFromCString("main() { int foo = 2; foo++; return foo; }"),
0, 0);
Dart_FinalizeLoading(true);
if (Dart_IsError(library)) {
LOG(INFO) << Dart_GetError(library);
abort();
}
Dart_Handle invoke_result =
Dart_Invoke(library, Dart_NewStringFromCString("main"), 0, nullptr);
if (Dart_IsError(invoke_result)) {
LOG(INFO) << Dart_GetError(invoke_result);
abort();
}
CHECK(Dart_IsInteger(invoke_result));
Dart_Handle str = Dart_ToString(invoke_result);
const char* xyz = "invalid";
Dart_StringToCString(str, &xyz);
LOG(INFO) << xyz;
}
}
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "dart/runtime/include/dart_api.h"
namespace blink {
class DartMaster {
public:
static void InitVM();
};
}
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// This file is linked into the dart executable when it has a snapshot
// linked into it.
#include <inttypes.h>
#include <stdint.h>
#include <stddef.h>
namespace mojo {
namespace dart {
// The string on the next line will be filled in with the contents of the
// generated snapshot binary file.
// This string forms the content of a snapshot which is loaded in by dart.
static const uint8_t snapshot_buffer_[] = { % s};
const uint8_t* snapshot_buffer = snapshot_buffer_;
} // namespace dart
} // namespace mojo
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'dart:core';
import 'dart:collection';
import 'dart:convert';
import 'dart:isolate';
import 'dart:math';
import 'dart:mirrors';
import 'dart:typed_data';
......@@ -37,6 +37,13 @@ source_set("libraries") {
"//url",
"//v8",
]
if (sky_use_dart) {
deps = [
"//dart/runtime:libdart",
"//dart/runtime/bin:libdart_embedder_noio",
]
}
}
source_set("prerequisites") {
......@@ -64,6 +71,7 @@ static_library("core") {
":libraries",
":prerequisites",
"//sky/engine/platform",
"//sky/engine/bindings2"
]
sources = sky_core_files
......
......@@ -31,6 +31,7 @@
#include "sky/engine/core/frame/LocalFrame.h"
#include "gen/sky/platform/RuntimeEnabledFeatures.h"
#include "sky/engine/bindings2/dart_master.h"
#include "sky/engine/bindings/core/v8/ScriptController.h"
#include "sky/engine/core/editing/Editor.h"
#include "sky/engine/core/editing/FrameSelection.h"
......@@ -77,6 +78,7 @@ inline LocalFrame::LocalFrame(FrameLoaderClient* client, FrameHost* host)
, m_inputMethodController(InputMethodController::create(*this))
{
page()->setMainFrame(this);
DartMaster::InitVM();
}
PassRefPtr<LocalFrame> LocalFrame::create(FrameLoaderClient* client, FrameHost* host)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册