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

Side by Side Diff: runtime/vm/debugger_api_impl.cc

Issue 10014002: Rename Api::NewLocalHandle -> Api::NewHandle. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_api_state.h ('k') | runtime/vm/native_entry.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 "include/dart_debugger_api.h" 5 #include "include/dart_debugger_api.h"
6 6
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/debugger.h" 9 #include "vm/debugger.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 DART_EXPORT Dart_Handle Dart_ActivationFrameInfo( 87 DART_EXPORT Dart_Handle Dart_ActivationFrameInfo(
88 Dart_ActivationFrame activation_frame, 88 Dart_ActivationFrame activation_frame,
89 Dart_Handle* function_name, 89 Dart_Handle* function_name,
90 Dart_Handle* script_url, 90 Dart_Handle* script_url,
91 intptr_t* line_number) { 91 intptr_t* line_number) {
92 Isolate* isolate = Isolate::Current(); 92 Isolate* isolate = Isolate::Current();
93 DARTSCOPE(isolate); 93 DARTSCOPE(isolate);
94 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); 94 CHECK_AND_CAST(ActivationFrame, frame, activation_frame);
95 if (function_name != NULL) { 95 if (function_name != NULL) {
96 const String& name = String::Handle(frame->QualifiedFunctionName()); 96 *function_name = Api::NewHandle(isolate, frame->QualifiedFunctionName());
97 *function_name = Api::NewLocalHandle(isolate, name);
98 } 97 }
99 if (script_url != NULL) { 98 if (script_url != NULL) {
100 const String& url = String::Handle(frame->SourceUrl()); 99 *script_url = Api::NewHandle(isolate, frame->SourceUrl());
101 *script_url = Api::NewLocalHandle(isolate, url);
102 } 100 }
103 if (line_number != NULL) { 101 if (line_number != NULL) {
104 *line_number = frame->LineNumber(); 102 *line_number = frame->LineNumber();
105 } 103 }
106 return Api::True(isolate); 104 return Api::True(isolate);
107 } 105 }
108 106
109 107
110 DART_EXPORT Dart_Handle Dart_GetLocalVariables( 108 DART_EXPORT Dart_Handle Dart_GetLocalVariables(
111 Dart_ActivationFrame activation_frame) { 109 Dart_ActivationFrame activation_frame) {
112 Isolate* isolate = Isolate::Current(); 110 Isolate* isolate = Isolate::Current();
113 DARTSCOPE(isolate); 111 DARTSCOPE(isolate);
114 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); 112 CHECK_AND_CAST(ActivationFrame, frame, activation_frame);
115 const Array& variables = Array::Handle(frame->GetLocalVariables()); 113 return Api::NewHandle(isolate, frame->GetLocalVariables());
116 return Api::NewLocalHandle(isolate, variables);
117 } 114 }
118 115
119 116
120 DART_EXPORT Dart_Handle Dart_SetBreakpointAtLine( 117 DART_EXPORT Dart_Handle Dart_SetBreakpointAtLine(
121 Dart_Handle script_url_in, 118 Dart_Handle script_url_in,
122 Dart_Handle line_number_in, 119 Dart_Handle line_number_in,
123 Dart_Breakpoint* breakpoint) { 120 Dart_Breakpoint* breakpoint) {
124 Isolate* isolate = Isolate::Current(); 121 Isolate* isolate = Isolate::Current();
125 DARTSCOPE(isolate); 122 DARTSCOPE(isolate);
126 123
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 isolate->debugger()->SetStepOut(); 235 isolate->debugger()->SetStepOut();
239 return Api::True(isolate); 236 return Api::True(isolate);
240 } 237 }
241 238
242 239
243 DART_EXPORT Dart_Handle Dart_GetInstanceFields(Dart_Handle object_in) { 240 DART_EXPORT Dart_Handle Dart_GetInstanceFields(Dart_Handle object_in) {
244 Isolate* isolate = Isolate::Current(); 241 Isolate* isolate = Isolate::Current();
245 DARTSCOPE(isolate); 242 DARTSCOPE(isolate);
246 Instance& obj = Instance::Handle(); 243 Instance& obj = Instance::Handle();
247 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); 244 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in);
248 Array& fields = Array::Handle(); 245 return Api::NewHandle(isolate, isolate->debugger()->GetInstanceFields(obj));
249 fields = isolate->debugger()->GetInstanceFields(obj);
250 return Api::NewLocalHandle(isolate, fields);
251 } 246 }
252 247
253 248
254 DART_EXPORT Dart_Handle Dart_GetStaticFields(Dart_Handle cls_in) { 249 DART_EXPORT Dart_Handle Dart_GetStaticFields(Dart_Handle cls_in) {
255 Isolate* isolate = Isolate::Current(); 250 Isolate* isolate = Isolate::Current();
256 DARTSCOPE(isolate); 251 DARTSCOPE(isolate);
257 Class& cls = Class::Handle(); 252 Class& cls = Class::Handle();
258 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); 253 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in);
259 Array& fields = Array::Handle(); 254 return Api::NewHandle(isolate, isolate->debugger()->GetStaticFields(cls));
260 fields = isolate->debugger()->GetStaticFields(cls);
261 return Api::NewLocalHandle(isolate, fields);
262 } 255 }
263 256
264 257
265 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) { 258 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) {
266 Isolate* isolate = Isolate::Current(); 259 Isolate* isolate = Isolate::Current();
267 DARTSCOPE(isolate); 260 DARTSCOPE(isolate);
268 Instance& obj = Instance::Handle(); 261 Instance& obj = Instance::Handle();
269 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); 262 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in);
270 const Class& cls = Class::Handle(obj.clazz()); 263 return Api::NewHandle(isolate, obj.clazz());
271 return Api::NewLocalHandle(isolate, cls);
272 } 264 }
273 265
274 266
275 DART_EXPORT Dart_Handle Dart_GetSuperclass(Dart_Handle cls_in) { 267 DART_EXPORT Dart_Handle Dart_GetSuperclass(Dart_Handle cls_in) {
276 Isolate* isolate = Isolate::Current(); 268 Isolate* isolate = Isolate::Current();
277 DARTSCOPE(isolate); 269 DARTSCOPE(isolate);
278 Class& cls = Class::Handle(); 270 Class& cls = Class::Handle();
279 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); 271 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in);
280 cls = cls.SuperClass(); 272 return Api::NewHandle(isolate, cls.SuperClass());
281 return Api::NewLocalHandle(isolate, cls);
282 } 273 }
283 274
284 275
285 DART_EXPORT Dart_Handle Dart_GetScriptSource( 276 DART_EXPORT Dart_Handle Dart_GetScriptSource(
286 Dart_Handle library_url_in, 277 Dart_Handle library_url_in,
287 Dart_Handle script_url_in) { 278 Dart_Handle script_url_in) {
288 Isolate* isolate = Isolate::Current(); 279 Isolate* isolate = Isolate::Current();
289 DARTSCOPE(isolate); 280 DARTSCOPE(isolate);
290 String& library_url = String::Handle(); 281 String& library_url = String::Handle();
291 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); 282 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in);
292 String& script_url = String::Handle(); 283 String& script_url = String::Handle();
293 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); 284 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in);
294 285
295 const Library& library = Library::Handle(Library::LookupLibrary(library_url)); 286 const Library& library = Library::Handle(Library::LookupLibrary(library_url));
296 if (library.IsNull()) { 287 if (library.IsNull()) {
297 return Api::NewError("%s: library '%s' not found", 288 return Api::NewError("%s: library '%s' not found",
298 CURRENT_FUNC, library_url.ToCString()); 289 CURRENT_FUNC, library_url.ToCString());
299 } 290 }
300 291
301 const Script& script = Script::Handle(library.LookupScript(script_url)); 292 const Script& script = Script::Handle(library.LookupScript(script_url));
302 if (script.IsNull()) { 293 if (script.IsNull()) {
303 return Api::NewError("%s: script '%s' not found in library '%s'", 294 return Api::NewError("%s: script '%s' not found in library '%s'",
304 CURRENT_FUNC, script_url.ToCString(), 295 CURRENT_FUNC, script_url.ToCString(),
305 library_url.ToCString()); 296 library_url.ToCString());
306 } 297 }
307 298
308 const String& source = String::Handle(script.source()); 299 return Api::NewHandle(isolate, script.source());
309 return Api::NewLocalHandle(isolate, source);
310 } 300 }
311 301
312 302
313 DART_EXPORT Dart_Handle Dart_GetScriptURLs(Dart_Handle library_url_in) { 303 DART_EXPORT Dart_Handle Dart_GetScriptURLs(Dart_Handle library_url_in) {
314 Isolate* isolate = Isolate::Current(); 304 Isolate* isolate = Isolate::Current();
315 DARTSCOPE(isolate); 305 DARTSCOPE(isolate);
316 String& library_url = String::Handle(); 306 String& library_url = String::Handle();
317 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); 307 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in);
318 308
319 const Library& library = Library::Handle(Library::LookupLibrary(library_url)); 309 const Library& library = Library::Handle(Library::LookupLibrary(library_url));
320 if (library.IsNull()) { 310 if (library.IsNull()) {
321 return Api::NewError("%s: library '%s' not found", 311 return Api::NewError("%s: library '%s' not found",
322 CURRENT_FUNC, library_url.ToCString()); 312 CURRENT_FUNC, library_url.ToCString());
323 } 313 }
324 const Array& loaded_scripts = Array::Handle(library.LoadedScripts()); 314 const Array& loaded_scripts = Array::Handle(library.LoadedScripts());
325 ASSERT(!loaded_scripts.IsNull()); 315 ASSERT(!loaded_scripts.IsNull());
326 intptr_t num_scripts = loaded_scripts.Length(); 316 intptr_t num_scripts = loaded_scripts.Length();
327 const Array& script_list = Array::Handle(Array::New(num_scripts)); 317 const Array& script_list = Array::Handle(Array::New(num_scripts));
328 Script& script = Script::Handle(); 318 Script& script = Script::Handle();
329 String& url = String::Handle(); 319 String& url = String::Handle();
330 for (int i = 0; i < num_scripts; i++) { 320 for (int i = 0; i < num_scripts; i++) {
331 script ^= loaded_scripts.At(i); 321 script ^= loaded_scripts.At(i);
332 url = script.url(); 322 url = script.url();
333 script_list.SetAt(i, url); 323 script_list.SetAt(i, url);
334 } 324 }
335 return Api::NewLocalHandle(isolate, script_list); 325 return Api::NewHandle(isolate, script_list.raw());
336 } 326 }
337 327
338 328
339 DART_EXPORT Dart_Handle Dart_GetLibraryURLs() { 329 DART_EXPORT Dart_Handle Dart_GetLibraryURLs() {
340 Isolate* isolate = Isolate::Current(); 330 Isolate* isolate = Isolate::Current();
341 ASSERT(isolate != NULL); 331 ASSERT(isolate != NULL);
342 DARTSCOPE(isolate); 332 DARTSCOPE(isolate);
343 333
344 // Find out how many libraries are loaded in this isolate. 334 // Find out how many libraries are loaded in this isolate.
345 int num_libs = 0; 335 int num_libs = 0;
346 Library &lib = Library::Handle(); 336 Library &lib = Library::Handle();
347 lib = isolate->object_store()->registered_libraries(); 337 lib = isolate->object_store()->registered_libraries();
348 while (!lib.IsNull()) { 338 while (!lib.IsNull()) {
349 num_libs++; 339 num_libs++;
350 lib = lib.next_registered(); 340 lib = lib.next_registered();
351 } 341 }
352 342
353 // Create new list and populate with the url of loaded libraries. 343 // Create new list and populate with the url of loaded libraries.
354 const Array& library_list = Array::Handle(Array::New(num_libs)); 344 const Array& library_list = Array::Handle(Array::New(num_libs));
355 lib = isolate->object_store()->registered_libraries(); 345 lib = isolate->object_store()->registered_libraries();
356 String& lib_url = String::Handle(); 346 String& lib_url = String::Handle();
357 for (int i = 0; i < num_libs; i++) { 347 for (int i = 0; i < num_libs; i++) {
358 ASSERT(!lib.IsNull()); 348 ASSERT(!lib.IsNull());
359 lib_url = lib.url(); 349 lib_url = lib.url();
360 library_list.SetAt(i, lib_url); 350 library_list.SetAt(i, lib_url);
361 lib = lib.next_registered(); 351 lib = lib.next_registered();
362 } 352 }
363 return Api::NewLocalHandle(isolate, library_list); 353 return Api::NewHandle(isolate, library_list.raw());
364 } 354 }
365 355
366 } // namespace dart 356 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_state.h ('k') | runtime/vm/native_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698