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

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

Issue 8490016: Renaming: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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_api.h" 5 #include "include/dart_api.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 HandleScope scope; // Setup a VM handle scope. 425 HandleScope scope; // Setup a VM handle scope.
426 const Library& lib = Library::CheckedHandle(Api::UnwrapHandle(library)); 426 const Library& lib = Library::CheckedHandle(Api::UnwrapHandle(library));
427 if (lib.IsNull()) { 427 if (lib.IsNull()) {
428 return Api::Error("Invalid parameter, Unknown library specified"); 428 return Api::Error("Invalid parameter, Unknown library specified");
429 } 429 }
430 lib.set_native_entry_resolver(resolver); 430 lib.set_native_entry_resolver(resolver);
431 return Api::Success(); 431 return Api::Success();
432 } 432 }
433 433
434 434
435 DART_EXPORT Dart_Handle Dart_ObjectToString(Dart_Handle object) { 435 DART_EXPORT Dart_Handle Dart_ToString(Dart_Handle object) {
436 Zone zone; // Setup a VM zone as we are creating some handles. 436 Zone zone; // Setup a VM zone as we are creating some handles.
437 HandleScope scope; // Setup a VM handle scope. 437 HandleScope scope; // Setup a VM handle scope.
438 const Object& obj = Object::Handle(Api::UnwrapHandle(object)); 438 const Object& obj = Object::Handle(Api::UnwrapHandle(object));
439 Object& result = Object::Handle(); 439 Object& result = Object::Handle();
440 if (obj.IsString()) { 440 if (obj.IsString()) {
441 result = obj.raw(); 441 result = obj.raw();
442 } else if (obj.IsInstance()) { 442 } else if (obj.IsInstance()) {
443 Instance& receiver = Instance::Handle(); 443 Instance& receiver = Instance::Handle();
444 receiver ^= obj.raw(); 444 receiver ^= obj.raw();
445 result = DartLibraryCalls::ToString(receiver); 445 result = DartLibraryCalls::ToString(receiver);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 486
487 DART_EXPORT void Dart_ClosureSetSmrck(Dart_Handle object, int64_t value) { 487 DART_EXPORT void Dart_ClosureSetSmrck(Dart_Handle object, int64_t value) {
488 Zone zone; 488 Zone zone;
489 HandleScope scope; 489 HandleScope scope;
490 const Closure& obj = Closure::CheckedHandle(Api::UnwrapHandle(object)); 490 const Closure& obj = Closure::CheckedHandle(Api::UnwrapHandle(object));
491 const Integer& smrck = Integer::Handle(Integer::New(value)); 491 const Integer& smrck = Integer::Handle(Integer::New(value));
492 obj.set_smrck(smrck); 492 obj.set_smrck(smrck);
493 } 493 }
494 494
495 495
496 DART_EXPORT Dart_Handle Dart_Objects_Equal(Dart_Handle obj1, Dart_Handle obj2, 496 DART_EXPORT Dart_Handle Dart_ObjectEquals(Dart_Handle obj1, Dart_Handle obj2,
497 bool* value) { 497 bool* value) {
498 Zone zone; // Setup a VM zone as we are creating some handles. 498 Zone zone; // Setup a VM zone as we are creating some handles.
499 HandleScope scope; // Setup a VM handle scope. 499 HandleScope scope; // Setup a VM handle scope.
500 const Instance& expected = Instance::CheckedHandle(Api::UnwrapHandle(obj1)); 500 const Instance& expected = Instance::CheckedHandle(Api::UnwrapHandle(obj1));
501 const Instance& actual = Instance::CheckedHandle(Api::UnwrapHandle(obj2)); 501 const Instance& actual = Instance::CheckedHandle(Api::UnwrapHandle(obj2));
502 const Instance& result = 502 const Instance& result =
503 Instance::Handle(DartLibraryCalls::Equals(expected, actual)); 503 Instance::Handle(DartLibraryCalls::Equals(expected, actual));
504 if (result.IsBool()) { 504 if (result.IsBool()) {
505 Bool& b = Bool::Handle(); 505 Bool& b = Bool::Handle();
506 b ^= result.raw(); 506 b ^= result.raw();
507 *value = b.value(); 507 *value = b.value();
508 return Api::Success(); 508 return Api::Success();
509 } else { 509 } else {
510 return Api::Error("An exception occured when calling '=='"); 510 return Api::Error("An exception occured when calling '=='");
511 } 511 }
512 } 512 }
513 513
514 514
515 DART_EXPORT Dart_Handle Dart_IsSame(Dart_Handle obj1, Dart_Handle obj2,
Ivan Posva 2011/11/07 23:48:30 I am wondering whether this function should just r
turnidge 2011/11/10 20:30:58 We have been discussing returning an error handle
516 bool* value) {
517 Zone zone; // Setup a VM zone as we are creating some handles.
518 HandleScope scope; // Setup a VM handle scope.
519 const Object& expected = Object::Handle(Api::UnwrapHandle(obj1));
520 const Object& actual = Object::Handle(Api::UnwrapHandle(obj2));
521 *value = (expected.raw() == actual.raw());
522 return Api::Success();
523 }
524
525
515 DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, Dart_Handle name) { 526 DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, Dart_Handle name) {
516 Zone zone; // Setup a VM zone as we are creating some handles. 527 Zone zone; // Setup a VM zone as we are creating some handles.
517 HandleScope scope; // Setup a VM handle scope. 528 HandleScope scope; // Setup a VM handle scope.
518 const Object& param = Object::Handle(Api::UnwrapHandle(name)); 529 const Object& param = Object::Handle(Api::UnwrapHandle(name));
519 if (param.IsNull() || !param.IsString()) { 530 if (param.IsNull() || !param.IsString()) {
520 return Api::Error("Invalid class name specified"); 531 return Api::Error("Invalid class name specified");
521 } 532 }
522 const Library& lib = Library::CheckedHandle(Api::UnwrapHandle(library)); 533 const Library& lib = Library::CheckedHandle(Api::UnwrapHandle(library));
523 if (lib.IsNull()) { 534 if (lib.IsNull()) {
524 return Api::Error("Invalid parameter, Unknown library specified"); 535 return Api::Error("Invalid parameter, Unknown library specified");
525 } 536 }
526 String& cls_name = String::Handle(); 537 String& cls_name = String::Handle();
527 cls_name ^= param.raw(); 538 cls_name ^= param.raw();
528 const Class& cls = Class::Handle(lib.LookupClass(cls_name)); 539 const Class& cls = Class::Handle(lib.LookupClass(cls_name));
529 if (cls.IsNull()) { 540 if (cls.IsNull()) {
530 return Api::Error("Specified class does not exist"); 541 return Api::Error("Specified class does not exist");
531 } 542 }
532 return Api::NewLocalHandle(cls); 543 return Api::NewLocalHandle(cls);
533 } 544 }
534 545
535 546
536 // TODO(iposva): This call actually implements IsInstanceOfClass. 547 // TODO(iposva): This call actually implements IsInstanceOfClass.
537 // Do we also need a real Dart_IsInstanceOf, which should take an instance 548 // Do we also need a real Dart_IsInstanceOf, which should take an instance
538 // rather than an object and a type rather than a class? 549 // rather than an object and a type rather than a class?
539 DART_EXPORT Dart_Handle Dart_IsInstanceOf(Dart_Handle object, 550 DART_EXPORT Dart_Handle Dart_ObjectIsType(Dart_Handle object,
540 Dart_Handle clazz, 551 Dart_Handle clazz,
541 bool* value) { 552 bool* value) {
542 Zone zone; // Setup a VM zone as we are creating some handles. 553 Zone zone; // Setup a VM zone as we are creating some handles.
543 HandleScope scope; // Setup a VM handle scope. 554 HandleScope scope; // Setup a VM handle scope.
544 const Class& cls = Class::CheckedHandle(Api::UnwrapHandle(clazz)); 555 const Class& cls = Class::CheckedHandle(Api::UnwrapHandle(clazz));
545 if (cls.IsNull()) { 556 if (cls.IsNull()) {
546 return Api::Error("instanceof check against null class"); 557 return Api::Error("instanceof check against null class");
547 } 558 }
548 const Object& obj = Object::Handle(Api::UnwrapHandle(object)); 559 const Object& obj = Object::Handle(Api::UnwrapHandle(object));
549 Instance& instance = Instance::Handle(); 560 Instance& instance = Instance::Handle();
(...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after
2063 ASSERT(isolate != NULL); 2074 ASSERT(isolate != NULL);
2064 ApiState* state = isolate->api_state(); 2075 ApiState* state = isolate->api_state();
2065 ASSERT(state != NULL); 2076 ASSERT(state != NULL);
2066 ApiLocalScope* scope = state->top_scope(); 2077 ApiLocalScope* scope = state->top_scope();
2067 ASSERT(scope != NULL); 2078 ASSERT(scope != NULL);
2068 return scope->zone().Reallocate(ptr, old_size, new_size); 2079 return scope->zone().Reallocate(ptr, old_size, new_size);
2069 } 2080 }
2070 2081
2071 2082
2072 } // namespace dart 2083 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698