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

Side by Side Diff: runtime/include/dart_api.h

Issue 8334009: Use the distinguished class, ApiFailure, to signal when a Dart_Result is (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 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 | « no previous file | runtime/vm/dart_api_impl.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 #ifndef INCLUDE_DART_API_H_ 5 #ifndef INCLUDE_DART_API_H_
6 #define INCLUDE_DART_API_H_ 6 #define INCLUDE_DART_API_H_
7 7
8 #ifdef __cplusplus 8 #ifdef __cplusplus
9 #define DART_EXTERN_C extern "C" 9 #define DART_EXTERN_C extern "C"
10 #else 10 #else
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 typedef void* Dart_Handle; 46 typedef void* Dart_Handle;
47 typedef void* Dart_NativeArguments; 47 typedef void* Dart_NativeArguments;
48 typedef enum { 48 typedef enum {
49 kRetCIntptr = 0, 49 kRetCIntptr = 0,
50 kRetCBool, 50 kRetCBool,
51 kRetCString, 51 kRetCString,
52 kRetObject, 52 kRetObject,
53 kRetCInt64, 53 kRetCInt64,
54 kRetCDouble, 54 kRetCDouble,
55 kRetLibSpec, 55 kRetLibSpec,
56 kRetError,
57 } Dart_ReturnType; 56 } Dart_ReturnType;
58 57
59 typedef struct { 58 typedef struct {
60 Dart_ReturnType type_; 59 Dart_ReturnType type_;
61 union { 60 union {
62 intptr_t int_value; 61 intptr_t int_value;
63 bool bool_value; 62 bool bool_value;
64 const char* str_value; 63 const char* str_value;
65 Dart_Handle obj_value; 64 Dart_Handle obj_value;
66 int64_t int64_value; 65 int64_t int64_value;
67 double double_value; 66 double double_value;
68 const char* errmsg;
69 } retval_; 67 } retval_;
70 } Dart_Result; 68 } Dart_Result;
71 69
72 typedef enum { 70 typedef enum {
73 kLibraryTag = 0, 71 kLibraryTag = 0,
74 kImportTag, 72 kImportTag,
75 kSourceTag, 73 kSourceTag,
76 kCanonicalizeUrl, 74 kCanonicalizeUrl,
77 } Dart_LibraryTag; 75 } Dart_LibraryTag;
78 76
(...skipping 17 matching lines...) Expand all
96 typedef void (*Dart_NativeFunction)(Dart_NativeArguments arguments); 94 typedef void (*Dart_NativeFunction)(Dart_NativeArguments arguments);
97 typedef Dart_NativeFunction (*Dart_NativeEntryResolver)(Dart_Handle name, 95 typedef Dart_NativeFunction (*Dart_NativeEntryResolver)(Dart_Handle name,
98 int num_of_arguments); 96 int num_of_arguments);
99 typedef Dart_Result (*Dart_LibraryTagHandler)(Dart_LibraryTag tag, 97 typedef Dart_Result (*Dart_LibraryTagHandler)(Dart_LibraryTag tag,
100 Dart_Handle library, 98 Dart_Handle library,
101 Dart_Handle url); 99 Dart_Handle url);
102 100
103 // TODO(iposva): This is a placeholder for the eventual external Dart API. 101 // TODO(iposva): This is a placeholder for the eventual external Dart API.
104 102
105 // Return value handling after a Dart API call. 103 // Return value handling after a Dart API call.
106 inline bool Dart_IsValidResult(const Dart_Result& result) { 104 DART_EXPORT bool Dart_IsValidResult(const Dart_Result& result);
107 return (result.type_ != kRetError); 105
108 }
109 inline intptr_t Dart_GetResultAsCIntptr(const Dart_Result& result) { 106 inline intptr_t Dart_GetResultAsCIntptr(const Dart_Result& result) {
110 assert(result.type_ == kRetCIntptr); // Valid to access result as C int. 107 assert(result.type_ == kRetCIntptr); // Valid to access result as C int.
111 return result.retval_.int_value; 108 return result.retval_.int_value;
112 } 109 }
113 inline Dart_Result Dart_ResultAsCIntptr(intptr_t value) { 110 inline Dart_Result Dart_ResultAsCIntptr(intptr_t value) {
114 Dart_Result result; 111 Dart_Result result;
115 result.type_ = kRetCIntptr; 112 result.type_ = kRetCIntptr;
116 result.retval_.int_value = value; 113 result.retval_.int_value = value;
117 return result; 114 return result;
118 } 115 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 inline double Dart_GetResultAsCDouble(const Dart_Result& result) { 157 inline double Dart_GetResultAsCDouble(const Dart_Result& result) {
161 assert(result.type_ == kRetCDouble); // Valid to access result as C double. 158 assert(result.type_ == kRetCDouble); // Valid to access result as C double.
162 return result.retval_.double_value; 159 return result.retval_.double_value;
163 } 160 }
164 inline Dart_Result Dart_ResultAsCDouble(double value) { 161 inline Dart_Result Dart_ResultAsCDouble(double value) {
165 Dart_Result result; 162 Dart_Result result;
166 result.type_ = kRetCDouble; 163 result.type_ = kRetCDouble;
167 result.retval_.double_value = value; 164 result.retval_.double_value = value;
168 return result; 165 return result;
169 } 166 }
170 inline const char* Dart_GetErrorCString(const Dart_Result& result) { 167 DART_EXPORT const char* Dart_GetErrorCString(const Dart_Result& result);
171 assert(result.type_ == kRetError); // Valid to access only on failure. 168 DART_EXPORT Dart_Result Dart_ErrorResult(const char* value);
172 return result.retval_.errmsg;
173 }
174 inline Dart_Result Dart_ErrorResult(const char* value) {
175 // Assumes passed in string value will be available on return.
176 Dart_Result result;
177 result.type_ = kRetError;
178 result.retval_.errmsg = value;
179 return result;
180 }
181 169
182 170
183 // Initialize the VM with commmand line flags. 171 // Initialize the VM with commmand line flags.
184 DART_EXPORT bool Dart_Initialize(int argc, char** argv, 172 DART_EXPORT bool Dart_Initialize(int argc, char** argv,
185 Dart_IsolateInitCallback callback); 173 Dart_IsolateInitCallback callback);
186 174
187 175
188 // Isolate handling. 176 // Isolate handling.
189 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, 177 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot,
190 void* data); 178 void* data);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 // External pprof support for gathering and dumping symbolic information 435 // External pprof support for gathering and dumping symbolic information
448 // that can be used for better profile reports for dynamically generated 436 // that can be used for better profile reports for dynamically generated
449 // code. 437 // code.
450 DART_EXPORT void Dart_InitPprofSupport(); 438 DART_EXPORT void Dart_InitPprofSupport();
451 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); 439 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size);
452 440
453 // Check set vm flags. 441 // Check set vm flags.
454 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name); 442 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name);
455 443
456 #endif // INCLUDE_DART_API_H_ 444 #endif // INCLUDE_DART_API_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698