Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: runtime/bin/builtin.cc

Issue 2480793002: clang-format runtime/bin (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/bin/builtin.h ('k') | runtime/bin/builtin_common.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <stdio.h> 5 #include <stdio.h>
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "bin/builtin.h" 9 #include "bin/builtin.h"
10 #include "bin/dartutils.h" 10 #include "bin/dartutils.h"
11 #include "bin/platform.h" 11 #include "bin/platform.h"
12 12
13 namespace dart { 13 namespace dart {
14 namespace bin { 14 namespace bin {
15 15
16 Builtin::builtin_lib_props Builtin::builtin_libraries_[] = { 16 Builtin::builtin_lib_props Builtin::builtin_libraries_[] = {
17 /* { url_, source_, patch_url_, patch_source_, has_natives_ } */ 17 /* { url_, source_, patch_url_, patch_source_, has_natives_ } */
18 { DartUtils::kBuiltinLibURL, _builtin_source_paths_, NULL, NULL, true }, 18 {DartUtils::kBuiltinLibURL, _builtin_source_paths_, NULL, NULL, true},
19 { DartUtils::kIOLibURL, io_source_paths_, 19 {DartUtils::kIOLibURL, io_source_paths_, DartUtils::kIOLibPatchURL,
20 DartUtils::kIOLibPatchURL, io_patch_paths_, true }, 20 io_patch_paths_, true},
21 21
22 #if defined(DART_NO_SNAPSHOT) 22 #if defined(DART_NO_SNAPSHOT)
23 // Only include these libraries in the dart_bootstrap case for now. 23 // Only include these libraries in the dart_bootstrap case for now.
24 { "dart:html", html_source_paths_, NULL, NULL, true }, 24 {"dart:html", html_source_paths_, NULL, NULL, true},
25 { "dart:html_common", html_common_source_paths_, NULL, NULL, true}, 25 {"dart:html_common", html_common_source_paths_, NULL, NULL, true},
26 { "dart:js", js_source_paths_, NULL, NULL, true}, 26 {"dart:js", js_source_paths_, NULL, NULL, true},
27 { "dart:js_util", js_util_source_paths_, NULL, NULL, true}, 27 {"dart:js_util", js_util_source_paths_, NULL, NULL, true},
28 { "dart:_blink", _blink_source_paths_, NULL, NULL, true }, 28 {"dart:_blink", _blink_source_paths_, NULL, NULL, true},
29 { "dart:indexed_db", indexed_db_source_paths_, NULL, NULL, true }, 29 {"dart:indexed_db", indexed_db_source_paths_, NULL, NULL, true},
30 { "cached_patches.dart", cached_patches_source_paths_, NULL, NULL, true }, 30 {"cached_patches.dart", cached_patches_source_paths_, NULL, NULL, true},
31 { "dart:web_gl", web_gl_source_paths_, NULL, NULL, true }, 31 {"dart:web_gl", web_gl_source_paths_, NULL, NULL, true},
32 { "metadata.dart", metadata_source_paths_, NULL, NULL, true }, 32 {"metadata.dart", metadata_source_paths_, NULL, NULL, true},
33 { "dart:web_sql", web_sql_source_paths_, NULL, NULL, true }, 33 {"dart:web_sql", web_sql_source_paths_, NULL, NULL, true},
34 { "dart:svg", svg_source_paths_, NULL, NULL, true }, 34 {"dart:svg", svg_source_paths_, NULL, NULL, true},
35 { "dart:web_audio", web_audio_source_paths_, NULL, NULL, true }, 35 {"dart:web_audio", web_audio_source_paths_, NULL, NULL, true},
36 #endif // defined(DART_NO_SNAPSHOT) 36 #endif // defined(DART_NO_SNAPSHOT)
37 37
38 // End marker. 38 // End marker.
39 { NULL, NULL, NULL, NULL, false } 39 {NULL, NULL, NULL, NULL, false}};
40 };
41 40
42 Dart_Port Builtin::load_port_ = ILLEGAL_PORT; 41 Dart_Port Builtin::load_port_ = ILLEGAL_PORT;
43 const int Builtin::num_libs_ = 42 const int Builtin::num_libs_ =
44 sizeof(Builtin::builtin_libraries_) / sizeof(Builtin::builtin_lib_props); 43 sizeof(Builtin::builtin_libraries_) / sizeof(Builtin::builtin_lib_props);
45 44
46 // Patch all the specified patch files in the array 'patch_files' into the 45 // Patch all the specified patch files in the array 'patch_files' into the
47 // library specified in 'library'. 46 // library specified in 'library'.
48 static void LoadPatchFiles(Dart_Handle library, 47 static void LoadPatchFiles(Dart_Handle library,
49 const char* patch_uri, 48 const char* patch_uri,
50 const char** patch_files) { 49 const char** patch_files) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 if (source_paths == NULL) { 92 if (source_paths == NULL) {
94 return Dart_Null(); // No path mapping information exists for library. 93 return Dart_Null(); // No path mapping information exists for library.
95 } 94 }
96 for (intptr_t i = 0; source_paths[i] != NULL; i += 3) { 95 for (intptr_t i = 0; source_paths[i] != NULL; i += 3) {
97 if (!strcmp(uri, source_paths[i])) { 96 if (!strcmp(uri, source_paths[i])) {
98 const char* source_path = source_paths[i + 1]; 97 const char* source_path = source_paths[i + 1];
99 Dart_Handle src = DartUtils::ReadStringFromFile(source_path); 98 Dart_Handle src = DartUtils::ReadStringFromFile(source_path);
100 if (!Dart_IsString(src)) { 99 if (!Dart_IsString(src)) {
101 // In case reading the file caused an error, use the sources directly. 100 // In case reading the file caused an error, use the sources directly.
102 const char* source = source_paths[i + 2]; 101 const char* source = source_paths[i + 2];
103 src = Dart_NewStringFromUTF8( 102 src = Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(source),
104 reinterpret_cast<const uint8_t*>(source), strlen(source)); 103 strlen(source));
105 } 104 }
106 return src; 105 return src;
107 } 106 }
108 } 107 }
109 return Dart_Null(); // Uri does not exist in path mapping information. 108 return Dart_Null(); // Uri does not exist in path mapping information.
110 } 109 }
111 110
112 111
113 void Builtin::SetNativeResolver(BuiltinLibraryId id) { 112 void Builtin::SetNativeResolver(BuiltinLibraryId id) {
114 UNREACHABLE(); 113 UNREACHABLE();
115 } 114 }
116 115
117 116
118 Dart_Handle Builtin::LoadLibrary(Dart_Handle url, BuiltinLibraryId id) { 117 Dart_Handle Builtin::LoadLibrary(Dart_Handle url, BuiltinLibraryId id) {
119 ASSERT(static_cast<int>(id) >= 0); 118 ASSERT(static_cast<int>(id) >= 0);
120 ASSERT(static_cast<int>(id) < num_libs_); 119 ASSERT(static_cast<int>(id) < num_libs_);
121 120
122 Dart_Handle library = Dart_LoadLibrary(url, Dart_Null(), Source(id), 0, 0); 121 Dart_Handle library = Dart_LoadLibrary(url, Dart_Null(), Source(id), 0, 0);
123 if (!Dart_IsError(library) && (builtin_libraries_[id].has_natives_)) { 122 if (!Dart_IsError(library) && (builtin_libraries_[id].has_natives_)) {
124 // Setup the native resolver for built in library functions. 123 // Setup the native resolver for built in library functions.
125 DART_CHECK_VALID( 124 DART_CHECK_VALID(
126 Dart_SetNativeResolver(library, NativeLookup, NativeSymbol)); 125 Dart_SetNativeResolver(library, NativeLookup, NativeSymbol));
127 } 126 }
128 if (builtin_libraries_[id].patch_url_ != NULL) { 127 if (builtin_libraries_[id].patch_url_ != NULL) {
129 ASSERT(builtin_libraries_[id].patch_paths_ != NULL); 128 ASSERT(builtin_libraries_[id].patch_paths_ != NULL);
130 LoadPatchFiles(library, 129 LoadPatchFiles(library, builtin_libraries_[id].patch_url_,
131 builtin_libraries_[id].patch_url_,
132 builtin_libraries_[id].patch_paths_); 130 builtin_libraries_[id].patch_paths_);
133 } 131 }
134 return library; 132 return library;
135 } 133 }
136 134
137 135
138 Builtin::BuiltinLibraryId Builtin::FindId(const char* url_string) { 136 Builtin::BuiltinLibraryId Builtin::FindId(const char* url_string) {
139 int id = 0; 137 int id = 0;
140 while (true) { 138 while (true) {
141 if (builtin_libraries_[id].url_ == NULL) { 139 if (builtin_libraries_[id].url_ == NULL) {
(...skipping 14 matching lines...) Expand all
156 Dart_Handle url = DartUtils::NewString(builtin_libraries_[id].url_); 154 Dart_Handle url = DartUtils::NewString(builtin_libraries_[id].url_);
157 Dart_Handle library = Dart_LookupLibrary(url); 155 Dart_Handle library = Dart_LookupLibrary(url);
158 if (Dart_IsError(library)) { 156 if (Dart_IsError(library)) {
159 library = LoadLibrary(url, id); 157 library = LoadLibrary(url, id);
160 } 158 }
161 return library; 159 return library;
162 } 160 }
163 161
164 } // namespace bin 162 } // namespace bin
165 } // namespace dart 163 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/builtin.h ('k') | runtime/bin/builtin_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698