Zachary Anderson d83427c165 Dart: Removes all but native calls and the handle watcher from the snapshot.
The bindings, core, and application libraries are now referred to as, e.g.:

package:mojo/public/dart/core.dart

Since the handle watcher remains in the snapshot, it no
longer refers to types defined in core.dart. References to types defined
in core.dart are also removed from mojo_natives.cc.

In Dart packaged apps, the SDK is zipped up under mojo/public/dart.

For embedder tests, the SDK is copied into the generated source output directory.

A base_dir parameter is added to the 'dart_package' and 'mojom' GN macros so that
consumers of the Mojo SDK can all import using the same URIs regardless of where
the SDK lives in their source trees.

BUG=
R=erg@chromium.org

Review URL: https://codereview.chromium.org/1027603002
2015-03-23 11:04:03 -07:00

64 lines
2.1 KiB
C++

// 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/bindings/builtin.h"
#include "base/logging.h"
#include "dart/runtime/include/dart_api.h"
#include "gen/sky/bindings/DartGlobal.h"
#include "sky/engine/bindings/builtin_natives.h"
#include "sky/engine/bindings/builtin_sky.h"
#include "sky/engine/bindings/mojo_natives.h"
#include "sky/engine/tonic/dart_builtin.h"
namespace blink {
namespace {
struct LibraryDescriptor {
const char* url;
bool has_natives;
Dart_NativeEntrySymbol native_symbol;
Dart_NativeEntryResolver native_resolver;
};
const LibraryDescriptor kBuiltinLibraries[] = {
/* { url_, has_natives_, native_symbol_, native_resolver_ } */
{"dart:sky_builtin",
true,
BuiltinNatives::NativeSymbol,
BuiltinNatives::NativeLookup},
{"dart:sky", true, skySnapshotSymbolizer, skySnapshotResolver},
{"dart:mojo.internal", true, MojoNativeSymbol, MojoNativeLookup},
};
} // namespace
void Builtin::SetNativeResolver(BuiltinLibraryId id) {
static_assert(arraysize(kBuiltinLibraries) == kInvalidLibrary,
"Unexpected number of builtin libraries");
DCHECK_GE(id, kBuiltinLibrary);
DCHECK_LT(id, kInvalidLibrary);
if (kBuiltinLibraries[id].has_natives) {
Dart_Handle library = DartBuiltin::LookupLibrary(kBuiltinLibraries[id].url);
// Setup the native resolver for built in library functions.
DART_CHECK_VALID(
Dart_SetNativeResolver(library,
kBuiltinLibraries[id].native_resolver,
kBuiltinLibraries[id].native_symbol));
}
}
Dart_Handle Builtin::LoadAndCheckLibrary(BuiltinLibraryId id) {
static_assert(arraysize(kBuiltinLibraries) == kInvalidLibrary,
"Unexpected number of builtin libraries");
DCHECK_GE(id, kBuiltinLibrary);
DCHECK_LT(id, kInvalidLibrary);
Dart_Handle library = DartBuiltin::LookupLibrary(kBuiltinLibraries[id].url);
DART_CHECK_VALID(library);
return library;
}
} // namespace blink