Flutter Engine
The Flutter Engine
builtin.cc
Go to the documentation of this file.
1// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#include <stdio.h>
6
7#include "include/dart_api.h"
8
9#include "bin/builtin.h"
10#include "bin/dartutils.h"
11
12namespace dart {
13namespace bin {
14
15Builtin::builtin_lib_props Builtin::builtin_libraries_[] = {
16 /* { url_, has_natives_ } */
21
22 // End marker.
23 {nullptr, false}};
24
25const int Builtin::num_libs_ =
26 sizeof(Builtin::builtin_libraries_) / sizeof(Builtin::builtin_lib_props);
27
29 ASSERT(static_cast<int>(id) >= 0);
30 ASSERT(static_cast<int>(id) < num_libs_);
31
32 if (builtin_libraries_[id].has_natives_) {
33 Dart_Handle url = DartUtils::NewString(builtin_libraries_[id].url_);
34 Dart_Handle library = Dart_LookupLibrary(url);
35 ASSERT(!Dart_IsError(library));
36 // Setup the native resolver for built in library functions.
38 Dart_SetNativeResolver(library, NativeLookup, NativeSymbol);
40 }
41}
42
44 ASSERT(static_cast<int>(id) >= 0);
45 ASSERT(static_cast<int>(id) < num_libs_);
46
47 Dart_Handle url = DartUtils::NewString(builtin_libraries_[id].url_);
48 return Dart_LookupLibrary(url);
49}
50
51} // namespace bin
52} // namespace dart
static Dart_Handle LoadAndCheckLibrary(BuiltinLibraryId id)
Definition: builtin.cc:43
static void SetNativeResolver(BuiltinLibraryId id)
Definition: builtin.cc:28
static constexpr const char * kCLILibURL
Definition: dartutils.h:299
static constexpr const char * kIOLibURL
Definition: dartutils.h:297
static constexpr const char * kHttpLibURL
Definition: dartutils.h:296
static Dart_Handle NewString(const char *str)
Definition: dartutils.h:214
static constexpr const char * kBuiltinLibURL
Definition: dartutils.h:292
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
#define ASSERT(E)
GAsyncResult * result
Definition: dart_vm.cc:33
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_SetNativeResolver(Dart_Handle library, Dart_NativeEntryResolver resolver, Dart_NativeEntrySymbol symbol)
DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url)