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

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

Issue 8401010: Add DART_CHECKVALID (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
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.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) 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 19 matching lines...) Expand all
30 DART_EXPORT bool Dart_IsValid(const Dart_Handle& handle) { 30 DART_EXPORT bool Dart_IsValid(const Dart_Handle& handle) {
31 ASSERT(Isolate::Current() != NULL); 31 ASSERT(Isolate::Current() != NULL);
32 Zone zone; // Setup a VM zone as we are creating some handles. 32 Zone zone; // Setup a VM zone as we are creating some handles.
33 HandleScope scope; // Setup a VM handle scope. 33 HandleScope scope; // Setup a VM handle scope.
34 34
35 // Make sure that the object isn't an ApiFailure. 35 // Make sure that the object isn't an ApiFailure.
36 const Object& obj = Object::Handle(Api::UnwrapHandle(handle)); 36 const Object& obj = Object::Handle(Api::UnwrapHandle(handle));
37 return !obj.IsApiFailure(); 37 return !obj.IsApiFailure();
38 } 38 }
39 39
40
41 DART_EXPORT void _Dart_ReportInvalidHandle(const char* file,
42 int line,
43 const char* handle,
44 const char* message) {
45 fprintf(stderr, "%s:%d: invalid handle: '%s':\n '%s'\n",
46 file, line, handle, message);
47 OS::Abort();
48 }
49
50
40 DART_EXPORT const char* Dart_GetError(const Dart_Handle& handle) { 51 DART_EXPORT const char* Dart_GetError(const Dart_Handle& handle) {
41 ASSERT(Isolate::Current() != NULL); 52 ASSERT(Isolate::Current() != NULL);
42 Zone zone; // Setup a VM zone as we are creating some handles. 53 Zone zone; // Setup a VM zone as we are creating some handles.
43 HandleScope scope; // Setup a VM handle scope. 54 HandleScope scope; // Setup a VM handle scope.
44 const Object& obj = Object::Handle(Api::UnwrapHandle(handle)); 55 const Object& obj = Object::Handle(Api::UnwrapHandle(handle));
45 if (!obj.IsApiFailure()) { 56 if (!obj.IsApiFailure()) {
46 return ""; 57 return "";
47 } 58 }
48 ApiFailure& failure = ApiFailure::Handle(); 59 ApiFailure& failure = ApiFailure::Handle();
49 failure ^= obj.raw(); 60 failure ^= obj.raw();
50 const String& message = String::Handle(failure.message()); 61 const String& message = String::Handle(failure.message());
51 const char* msg = message.ToCString(); 62 const char* msg = message.ToCString();
52 intptr_t len = strlen(msg) + 1; 63 intptr_t len = strlen(msg) + 1;
53 char* msg_copy = reinterpret_cast<char*>(Api::Allocate(len)); 64 char* msg_copy = reinterpret_cast<char*>(Api::Allocate(len));
54 OS::SNPrint(msg_copy, len, "%s", msg); 65 OS::SNPrint(msg_copy, len, "%s", msg);
55 return msg_copy; 66 return msg_copy;
56 } 67 }
57 68
58 69
59 DART_EXPORT Dart_Handle Dart_Error(const char* value) { 70 DART_EXPORT Dart_Handle Dart_Error(const char* error) {
60 return Api::Error(value); 71 return Api::Error(error);
61 } 72 }
62 73
63 74
64 // TODO(iposva): This is a placeholder for the eventual external Dart API. 75 // TODO(iposva): This is a placeholder for the eventual external Dart API.
65 DART_EXPORT bool Dart_Initialize(int argc, 76 DART_EXPORT bool Dart_Initialize(int argc,
66 char** argv, 77 char** argv,
67 Dart_IsolateInitCallback callback) { 78 Dart_IsolateInitCallback callback) {
68 return Dart::InitOnce(argc, argv, callback); 79 return Dart::InitOnce(argc, argv, callback);
69 } 80 }
70 81
(...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1773 ASSERT(isolate != NULL); 1784 ASSERT(isolate != NULL);
1774 ApiState* state = isolate->api_state(); 1785 ApiState* state = isolate->api_state();
1775 ASSERT(state != NULL); 1786 ASSERT(state != NULL);
1776 ApiLocalScope* scope = state->top_scope(); 1787 ApiLocalScope* scope = state->top_scope();
1777 ASSERT(scope != NULL); 1788 ASSERT(scope != NULL);
1778 return scope->zone().Reallocate(ptr, old_size, new_size); 1789 return scope->zone().Reallocate(ptr, old_size, new_size);
1779 } 1790 }
1780 1791
1781 1792
1782 } // namespace dart 1793 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698