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

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

Issue 117723002: Allow the native resolver to setup whether it needs the Dart API scope to (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/builtin_gen_snapshot.cc ('k') | runtime/bin/io_natives.h » ('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 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 int argument_count_; 78 int argument_count_;
79 } BuiltinEntries[] = { 79 } BuiltinEntries[] = {
80 BUILTIN_NATIVE_LIST(REGISTER_FUNCTION) 80 BUILTIN_NATIVE_LIST(REGISTER_FUNCTION)
81 }; 81 };
82 82
83 83
84 /** 84 /**
85 * Looks up native functions in both libdart_builtin and libdart_io. 85 * Looks up native functions in both libdart_builtin and libdart_io.
86 */ 86 */
87 Dart_NativeFunction Builtin::NativeLookup(Dart_Handle name, 87 Dart_NativeFunction Builtin::NativeLookup(Dart_Handle name,
88 int argument_count) { 88 int argument_count,
89 bool* auto_setup_scope) {
89 const char* function_name = NULL; 90 const char* function_name = NULL;
90 Dart_Handle result = Dart_StringToCString(name, &function_name); 91 Dart_Handle result = Dart_StringToCString(name, &function_name);
91 DART_CHECK_VALID(result); 92 DART_CHECK_VALID(result);
92 ASSERT(function_name != NULL); 93 ASSERT(function_name != NULL);
94 ASSERT(auto_setup_scope != NULL);
95 *auto_setup_scope = true;
93 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries); 96 int num_entries = sizeof(BuiltinEntries) / sizeof(struct NativeEntries);
94 for (int i = 0; i < num_entries; i++) { 97 for (int i = 0; i < num_entries; i++) {
95 struct NativeEntries* entry = &(BuiltinEntries[i]); 98 struct NativeEntries* entry = &(BuiltinEntries[i]);
96 if (!strcmp(function_name, entry->name_) && 99 if (!strcmp(function_name, entry->name_) &&
97 (entry->argument_count_ == argument_count)) { 100 (entry->argument_count_ == argument_count)) {
98 return reinterpret_cast<Dart_NativeFunction>(entry->function_); 101 return reinterpret_cast<Dart_NativeFunction>(entry->function_);
99 } 102 }
100 } 103 }
101 return IONativeLookup(name, argument_count); 104 return IONativeLookup(name, argument_count, auto_setup_scope);
102 } 105 }
103 106
104 107
105 // Implementation of native functions which are used for some 108 // Implementation of native functions which are used for some
106 // test/debug functionality in standalone dart mode. 109 // test/debug functionality in standalone dart mode.
107 void FUNCTION_NAME(Logger_PrintString)(Dart_NativeArguments args) { 110 void FUNCTION_NAME(Logger_PrintString)(Dart_NativeArguments args) {
108 intptr_t length = 0; 111 intptr_t length = 0;
109 uint8_t* chars = NULL; 112 uint8_t* chars = NULL;
110 Dart_Handle str = Dart_GetNativeArgument(args, 0); 113 Dart_Handle str = Dart_GetNativeArgument(args, 0);
111 Dart_Handle result = Dart_StringToUTF8(str, &chars, &length); 114 Dart_Handle result = Dart_StringToUTF8(str, &chars, &length);
112 if (Dart_IsError(result)) { 115 if (Dart_IsError(result)) {
113 // TODO(turnidge): Consider propagating some errors here. What if 116 // TODO(turnidge): Consider propagating some errors here. What if
114 // an isolate gets interrupted by the embedder in the middle of 117 // an isolate gets interrupted by the embedder in the middle of
115 // Dart_StringToUTF8? We need to make sure not to swallow the 118 // Dart_StringToUTF8? We need to make sure not to swallow the
116 // interrupt. 119 // interrupt.
117 Platform::PrintBlocking(stdout, "%s\n", Dart_GetError(result)); 120 Platform::PrintBlocking(stdout, "%s\n", Dart_GetError(result));
118 } else { 121 } else {
119 Platform::PrintBlocking(stdout, "%.*s\n", static_cast<int>(length), chars); 122 Platform::PrintBlocking(stdout, "%.*s\n", static_cast<int>(length), chars);
120 } 123 }
121 } 124 }
122 125
123 } // namespace bin 126 } // namespace bin
124 } // namespace dart 127 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/builtin_gen_snapshot.cc ('k') | runtime/bin/io_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698