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

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

Issue 1916793003: - Allow for loading dart:html and friends into the standalone (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rebase. Created 4 years, 7 months 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.dart ('k') | runtime/bin/builtin_nolib.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 <stdlib.h> 5 #include <stdlib.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "include/dart_tools_api.h" 10 #include "include/dart_tools_api.h"
(...skipping 26 matching lines...) Expand all
37 37
38 static struct NativeEntries { 38 static struct NativeEntries {
39 const char* name_; 39 const char* name_;
40 Dart_NativeFunction function_; 40 Dart_NativeFunction function_;
41 int argument_count_; 41 int argument_count_;
42 } BuiltinEntries[] = { 42 } BuiltinEntries[] = {
43 BUILTIN_NATIVE_LIST(REGISTER_FUNCTION) 43 BUILTIN_NATIVE_LIST(REGISTER_FUNCTION)
44 }; 44 };
45 45
46 46
47 void Builtin_DummyNative(Dart_NativeArguments args) {
48 UNREACHABLE();
49 }
50
51
52
47 /** 53 /**
48 * Looks up native functions in both libdart_builtin and libdart_io. 54 * Looks up native functions in both libdart_builtin and libdart_io.
49 */ 55 */
50 Dart_NativeFunction Builtin::NativeLookup(Dart_Handle name, 56 Dart_NativeFunction Builtin::NativeLookup(Dart_Handle name,
51 int argument_count, 57 int argument_count,
52 bool* auto_setup_scope) { 58 bool* auto_setup_scope) {
53 const char* function_name = NULL; 59 const char* function_name = NULL;
54 Dart_Handle result = Dart_StringToCString(name, &function_name); 60 Dart_Handle err = Dart_StringToCString(name, &function_name);
55 DART_CHECK_VALID(result); 61 DART_CHECK_VALID(err);
56 ASSERT(function_name != NULL); 62 ASSERT(function_name != NULL);
57 ASSERT(auto_setup_scope != NULL); 63 ASSERT(auto_setup_scope != NULL);
58 *auto_setup_scope = true; 64 *auto_setup_scope = true;
59 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); 65 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries);
60 for (int i = 0; i < num_entries; i++) { 66 for (int i = 0; i < num_entries; i++) {
61 struct NativeEntries* entry = &(BuiltinEntries[i]); 67 struct NativeEntries* entry = &(BuiltinEntries[i]);
62 if ((strcmp(function_name, entry->name_) == 0) && 68 if ((strcmp(function_name, entry->name_) == 0) &&
63 (entry->argument_count_ == argument_count)) { 69 (entry->argument_count_ == argument_count)) {
64 return reinterpret_cast<Dart_NativeFunction>(entry->function_); 70 return reinterpret_cast<Dart_NativeFunction>(entry->function_);
65 } 71 }
66 } 72 }
67 return IONativeLookup(name, argument_count, auto_setup_scope); 73 Dart_NativeFunction result =
74 IONativeLookup(name, argument_count, auto_setup_scope);
75 if (result == NULL) {
76 result = Builtin_DummyNative;
77 }
78 return result;
68 } 79 }
69 80
70 81
71 const uint8_t* Builtin::NativeSymbol(Dart_NativeFunction nf) { 82 const uint8_t* Builtin::NativeSymbol(Dart_NativeFunction nf) {
72 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); 83 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries);
73 for (int i = 0; i < num_entries; i++) { 84 for (int i = 0; i < num_entries; i++) {
74 struct NativeEntries* entry = &(BuiltinEntries[i]); 85 struct NativeEntries* entry = &(BuiltinEntries[i]);
75 if (reinterpret_cast<Dart_NativeFunction>(entry->function_) == nf) { 86 if (reinterpret_cast<Dart_NativeFunction>(entry->function_) == nf) {
76 return reinterpret_cast<const uint8_t*>(entry->name_); 87 return reinterpret_cast<const uint8_t*>(entry->name_);
77 } 88 }
(...skipping 22 matching lines...) Expand all
100 // For now we report print output on the Stdout stream. 111 // For now we report print output on the Stdout stream.
101 uint8_t newline[] = { '\n' }; 112 uint8_t newline[] = { '\n' };
102 Dart_ServiceSendDataEvent("Stdout", "WriteEvent", chars, length); 113 Dart_ServiceSendDataEvent("Stdout", "WriteEvent", chars, length);
103 Dart_ServiceSendDataEvent("Stdout", "WriteEvent", 114 Dart_ServiceSendDataEvent("Stdout", "WriteEvent",
104 newline, sizeof(newline)); 115 newline, sizeof(newline));
105 } 116 }
106 } 117 }
107 118
108 } // namespace bin 119 } // namespace bin
109 } // namespace dart 120 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/builtin.dart ('k') | runtime/bin/builtin_nolib.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698