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

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

Issue 8380020: Refactor the dart api a bit: (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
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 27 matching lines...) Expand all
38 #else 38 #else
39 #error Tool chain not supported. 39 #error Tool chain not supported.
40 #endif 40 #endif
41 #endif 41 #endif
42 42
43 #include <assert.h> 43 #include <assert.h>
44 44
45 typedef void* Dart_Isolate; 45 typedef void* Dart_Isolate;
46 typedef void* Dart_Handle; 46 typedef void* Dart_Handle;
47 typedef void* Dart_NativeArguments; 47 typedef void* Dart_NativeArguments;
48 typedef enum {
49 kRetCIntptr = 0,
50 kRetCBool,
51 kRetCString,
52 kRetObject,
53 kRetCInt64,
54 kRetCDouble,
55 kRetLibSpec,
56 } Dart_ReturnType;
57
58 typedef struct {
59 Dart_ReturnType type_;
60 union {
61 intptr_t int_value;
62 bool bool_value;
63 const char* str_value;
64 Dart_Handle obj_value;
65 int64_t int64_value;
66 double double_value;
67 } retval_;
68 } Dart_Result;
69 48
70 typedef enum { 49 typedef enum {
71 kLibraryTag = 0, 50 kLibraryTag = 0,
72 kImportTag, 51 kImportTag,
73 kSourceTag, 52 kSourceTag,
74 kCanonicalizeUrl, 53 kCanonicalizeUrl,
75 } Dart_LibraryTag; 54 } Dart_LibraryTag;
76 55
77 typedef void Dart_Snapshot; 56 typedef void Dart_Snapshot;
78 57
79 typedef int64_t Dart_Port; 58 typedef int64_t Dart_Port;
80 typedef void* Dart_Message; 59 typedef void* Dart_Message;
81 60
82 // Allow the embedder to intercept isolate creation. Both at startup 61 // Allow the embedder to intercept isolate creation. Both at startup
83 // and when spawning new isolates from Dart code. The result returned 62 // and when spawning new isolates from Dart code. The result returned
84 // from this callback is handed to all isolates spawned from the 63 // from this callback is handed to all isolates spawned from the
85 // isolate currently being initialized. 64 // isolate currently being initialized.
86 // 65 //
87 // Return NULL if an error is encountered. The isolate being 66 // Return NULL if an error is encountered. The isolate being
88 // initialized will be shutdown. No Dart code will execute before it 67 // initialized will be shutdown. No Dart code will execute before it
89 // is shutdown. 68 // is shutdown.
90 // 69 //
91 // TODO(iposva): Pass a specification of the app file being spawned. 70 // TODO(iposva): Pass a specification of the app file being spawned.
92 typedef void* (*Dart_IsolateInitCallback)(void* data); 71 typedef void* (*Dart_IsolateInitCallback)(void* data);
93 72
94 typedef void (*Dart_NativeFunction)(Dart_NativeArguments arguments); 73 typedef void (*Dart_NativeFunction)(Dart_NativeArguments arguments);
95 typedef Dart_NativeFunction (*Dart_NativeEntryResolver)(Dart_Handle name, 74 typedef Dart_NativeFunction (*Dart_NativeEntryResolver)(Dart_Handle name,
96 int num_of_arguments); 75 int num_of_arguments);
97 typedef Dart_Result (*Dart_LibraryTagHandler)(Dart_LibraryTag tag, 76 typedef Dart_Handle (*Dart_LibraryTagHandler)(Dart_LibraryTag tag,
98 Dart_Handle library, 77 Dart_Handle library,
99 Dart_Handle url); 78 Dart_Handle url);
100 79
101 // TODO(iposva): This is a placeholder for the eventual external Dart API. 80 // TODO(iposva): This is a placeholder for the eventual external Dart API.
102 81
103 // Return value handling after a Dart API call. 82 // Return value handling after a Dart API call.
104 DART_EXPORT bool Dart_IsValidResult(const Dart_Result& result); 83 DART_EXPORT bool Dart_IsValid(const Dart_Handle& result);
105 84
106 inline intptr_t Dart_GetResultAsCIntptr(const Dart_Result& result) { 85 DART_EXPORT const char* Dart_GetError(const Dart_Handle& result);
107 assert(result.type_ == kRetCIntptr); // Valid to access result as C int. 86 DART_EXPORT Dart_Handle Dart_Error(const char* value);
108 return result.retval_.int_value;
109 }
110 inline Dart_Result Dart_ResultAsCIntptr(intptr_t value) {
111 Dart_Result result;
112 result.type_ = kRetCIntptr;
113 result.retval_.int_value = value;
114 return result;
115 }
116 inline bool Dart_GetResultAsCBoolean(const Dart_Result& result) {
117 assert(result.type_ == kRetCBool); // Valid to access result as C bool.
118 return result.retval_.bool_value;
119 }
120 inline Dart_Result Dart_ResultAsCBoolean(bool value) {
121 Dart_Result result;
122 result.type_ = kRetCBool;
123 result.retval_.bool_value = value;
124 return result;
125 }
126 inline const char* Dart_GetResultAsCString(const Dart_Result& result) {
127 assert(result.type_ == kRetCString); // Valid to access result as C string.
128 return result.retval_.str_value;
129 }
130 inline Dart_Result Dart_ResultAsCString(const char* value) {
131 // Assumes passed in string value will be available on return.
132 Dart_Result result;
133 result.type_ = kRetCString;
134 result.retval_.str_value = value;
135 return result;
136 }
137 inline Dart_Handle Dart_GetResult(const Dart_Result& result) {
138 assert(result.type_ == kRetObject); // Valid to access result as Dart obj.
139 return result.retval_.obj_value;
140 }
141 inline Dart_Result Dart_ResultAsObject(Dart_Handle value) {
142 Dart_Result result;
143 result.type_ = kRetObject;
144 result.retval_.obj_value = value;
145 return result;
146 }
147 inline int64_t Dart_GetResultAsCInt64(const Dart_Result& result) {
148 assert(result.type_ == kRetCInt64); // Valid to access result as C int64_t.
149 return result.retval_.int64_value;
150 }
151 inline Dart_Result Dart_ResultAsCInt64(int64_t value) {
152 Dart_Result result;
153 result.type_ = kRetCInt64;
154 result.retval_.int64_value = value;
155 return result;
156 }
157 inline double Dart_GetResultAsCDouble(const Dart_Result& result) {
158 assert(result.type_ == kRetCDouble); // Valid to access result as C double.
159 return result.retval_.double_value;
160 }
161 inline Dart_Result Dart_ResultAsCDouble(double value) {
162 Dart_Result result;
163 result.type_ = kRetCDouble;
164 result.retval_.double_value = value;
165 return result;
166 }
167 DART_EXPORT const char* Dart_GetErrorCString(const Dart_Result& result);
168 DART_EXPORT Dart_Result Dart_ErrorResult(const char* value);
169 87
170 88
171 // Initialize the VM with commmand line flags. 89 // Initialize the VM with commmand line flags.
172 DART_EXPORT bool Dart_Initialize(int argc, char** argv, 90 DART_EXPORT bool Dart_Initialize(int argc, char** argv,
173 Dart_IsolateInitCallback callback); 91 Dart_IsolateInitCallback callback);
174 92
175 93
176 // Isolate handling. 94 // Isolate handling.
177 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, 95 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot,
178 void* data); 96 void* data);
179 DART_EXPORT void Dart_ShutdownIsolate(); 97 DART_EXPORT void Dart_ShutdownIsolate();
180 98
181 DART_EXPORT Dart_Isolate Dart_CurrentIsolate(); 99 DART_EXPORT Dart_Isolate Dart_CurrentIsolate();
182 DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate); 100 DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate);
183 DART_EXPORT void Dart_ExitIsolate(); 101 DART_EXPORT void Dart_ExitIsolate();
184 102
185 // A convenience routine which processes any incoming messages for the 103 // A convenience routine which processes any incoming messages for the
186 // current isolate. The routine exits when all ports to the current 104 // current isolate. The routine exits when all ports to the current
187 // isolate are closed. 105 // isolate are closed.
188 // 106 //
189 // This routine may only be used when the embedder has not provided an 107 // This routine may only be used when the embedder has not provided an
190 // alternate message delivery mechanism with Dart_SetPostMessageCallback. 108 // alternate message delivery mechanism with Dart_SetPostMessageCallback.
191 DART_EXPORT Dart_Result Dart_RunLoop(); 109 DART_EXPORT Dart_Handle Dart_RunLoop();
192 110
193 // Messages/ports 111 // Messages/ports
194 112
195 // A post message callback allows the embedder to provide an alternate 113 // A post message callback allows the embedder to provide an alternate
196 // delivery mechanism for inter-isolate messages. It is the 114 // delivery mechanism for inter-isolate messages. It is the
197 // responsibility of the embedder to call Dart_HandleMessage to 115 // responsibility of the embedder to call Dart_HandleMessage to
198 // process the message. 116 // process the message.
199 // 117 //
200 // If there is no reply port, then the constant 'kNoReplyPort' is 118 // If there is no reply port, then the constant 'kNoReplyPort' is
201 // passed as the 'reply_port' parameter. 119 // passed as the 'reply_port' parameter.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 Dart_PostMessageCallback post_message_callback, 154 Dart_PostMessageCallback post_message_callback,
237 Dart_ClosePortCallback close_port_callback); 155 Dart_ClosePortCallback close_port_callback);
238 156
239 // Handle a message on the current isolate. 157 // Handle a message on the current isolate.
240 DART_EXPORT void Dart_HandleMessage(Dart_Port dest_port, 158 DART_EXPORT void Dart_HandleMessage(Dart_Port dest_port,
241 Dart_Port reply_port, 159 Dart_Port reply_port,
242 Dart_Message dart_message); 160 Dart_Message dart_message);
243 161
244 162
245 // Object. 163 // Object.
246 DART_EXPORT Dart_Result Dart_ObjectToString(Dart_Handle object); 164 DART_EXPORT Dart_Handle Dart_ObjectToString(Dart_Handle object);
247 DART_EXPORT bool Dart_IsNull(Dart_Handle object); 165 DART_EXPORT bool Dart_IsNull(Dart_Handle object);
248 166
249 167
250 // Returns true if the two objects are equal. 168 // Returns true if the two objects are equal.
251 DART_EXPORT Dart_Result Dart_Objects_Equal(Dart_Handle obj1, Dart_Handle obj2); 169 DART_EXPORT Dart_Handle Dart_Objects_Equal(Dart_Handle obj1,
170 Dart_Handle obj2,
171 bool* value);
252 172
253 173
254 // Classes. 174 // Classes.
255 DART_EXPORT Dart_Result Dart_GetClass(Dart_Handle library, Dart_Handle name); 175 DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, Dart_Handle name);
256 DART_EXPORT Dart_Result Dart_IsInstanceOf(Dart_Handle object, Dart_Handle cls); 176 DART_EXPORT Dart_Handle Dart_IsInstanceOf(Dart_Handle object,
177 Dart_Handle cls,
178 bool* value);
257 179
258 180
259 // Number. 181 // Number.
260 DART_EXPORT bool Dart_IsNumber(Dart_Handle object); 182 DART_EXPORT bool Dart_IsNumber(Dart_Handle object);
261 183
262 184
263 // Integer. 185 // Integer.
264 DART_EXPORT bool Dart_IsInteger(Dart_Handle object); 186 DART_EXPORT bool Dart_IsInteger(Dart_Handle object);
265 DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value); 187 DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value);
266 DART_EXPORT Dart_Handle Dart_NewIntegerFromHexCString(const char* value); 188 DART_EXPORT Dart_Handle Dart_NewIntegerFromHexCString(const char* value);
267 DART_EXPORT Dart_Result Dart_IntegerValue(Dart_Handle integer); 189 DART_EXPORT Dart_Handle Dart_IntegerValue(Dart_Handle integer, int64_t* value);
268 DART_EXPORT Dart_Result Dart_IntegerFitsIntoInt64(Dart_Handle integer); 190 DART_EXPORT Dart_Handle Dart_IntegerValueHexCString(Dart_Handle integer,
191 const char** value);
192 DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer,
193 bool* value);
269 194
270 195
271 // Boolean. 196 // Boolean.
272 DART_EXPORT bool Dart_IsBoolean(Dart_Handle object); 197 DART_EXPORT bool Dart_IsBoolean(Dart_Handle object);
273 DART_EXPORT Dart_Handle Dart_NewBoolean(bool value); 198 DART_EXPORT Dart_Handle Dart_NewBoolean(bool value);
274 DART_EXPORT Dart_Result Dart_BooleanValue(Dart_Handle bool_object); 199 DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle bool_object, bool* value);
275 200
276 201
277 // Double. 202 // Double.
278 DART_EXPORT bool Dart_IsDouble(Dart_Handle object); 203 DART_EXPORT bool Dart_IsDouble(Dart_Handle object);
279 DART_EXPORT Dart_Handle Dart_NewDouble(double value); 204 DART_EXPORT Dart_Handle Dart_NewDouble(double value);
280 DART_EXPORT Dart_Result Dart_DoubleValue(Dart_Handle integer); 205 DART_EXPORT Dart_Handle Dart_DoubleValue(Dart_Handle integer, double* result);
281 206
282 207
283 // String. 208 // String.
284 DART_EXPORT bool Dart_IsString(Dart_Handle object); 209 DART_EXPORT bool Dart_IsString(Dart_Handle object);
285 210
286 DART_EXPORT Dart_Result Dart_StringLength(Dart_Handle str); 211 DART_EXPORT Dart_Handle Dart_StringLength(Dart_Handle str, intptr_t* len);
287 212
288 DART_EXPORT Dart_Handle Dart_NewString(const char* str); 213 DART_EXPORT Dart_Handle Dart_NewString(const char* str);
289 DART_EXPORT Dart_Handle Dart_NewString8(const uint8_t* codepoints, 214 DART_EXPORT Dart_Handle Dart_NewString8(const uint8_t* codepoints,
290 intptr_t length); 215 intptr_t length);
291 DART_EXPORT Dart_Handle Dart_NewString16(const uint16_t* codepoints, 216 DART_EXPORT Dart_Handle Dart_NewString16(const uint16_t* codepoints,
292 intptr_t length); 217 intptr_t length);
293 DART_EXPORT Dart_Handle Dart_NewString32(const uint32_t* codepoints, 218 DART_EXPORT Dart_Handle Dart_NewString32(const uint32_t* codepoints,
294 intptr_t length); 219 intptr_t length);
295 220
296 // The functions below test whether the object is a String and its codepoints 221 // The functions below test whether the object is a String and its codepoints
297 // all fit into 8 or 16 bits respectively. 222 // all fit into 8 or 16 bits respectively.
298 DART_EXPORT bool Dart_IsString8(Dart_Handle object); 223 DART_EXPORT bool Dart_IsString8(Dart_Handle object);
299 DART_EXPORT bool Dart_IsString16(Dart_Handle object); 224 DART_EXPORT bool Dart_IsString16(Dart_Handle object);
300 225
301 DART_EXPORT Dart_Result Dart_StringGet8(Dart_Handle str, 226 DART_EXPORT Dart_Handle Dart_StringGet8(Dart_Handle str,
302 uint8_t* codepoints, 227 uint8_t* codepoints,
303 intptr_t length); 228 intptr_t length,
304 DART_EXPORT Dart_Result Dart_StringGet16(Dart_Handle str, 229 intptr_t* used);
Ivan Posva 2011/10/25 21:50:53 Not sure if it makes it easier to use this way: D
turnidge 2011/10/25 22:07:23 Yeah, I debated that. Changed.
230 DART_EXPORT Dart_Handle Dart_StringGet16(Dart_Handle str,
305 uint16_t* codepoints, 231 uint16_t* codepoints,
306 intptr_t length); 232 intptr_t length,
307 DART_EXPORT Dart_Result Dart_StringGet32(Dart_Handle str, 233 intptr_t* used);
234 DART_EXPORT Dart_Handle Dart_StringGet32(Dart_Handle str,
308 uint32_t* codepoints, 235 uint32_t* codepoints,
309 intptr_t length); 236 intptr_t length,
237 intptr_t* used);
310 238
311 DART_EXPORT Dart_Result Dart_StringToCString(Dart_Handle str); 239 DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle str,
240 const char** result);
312 241
313 242
314 // Array. 243 // Array.
315 DART_EXPORT bool Dart_IsArray(Dart_Handle object); 244 DART_EXPORT bool Dart_IsArray(Dart_Handle object);
316 DART_EXPORT Dart_Handle Dart_NewArray(intptr_t length); 245 DART_EXPORT Dart_Handle Dart_NewArray(intptr_t length);
317 DART_EXPORT Dart_Result Dart_GetLength(Dart_Handle array); 246 DART_EXPORT Dart_Handle Dart_GetLength(Dart_Handle array, intptr_t* len);
318 DART_EXPORT Dart_Result Dart_ArrayGetAt(Dart_Handle array, 247 DART_EXPORT Dart_Handle Dart_ArrayGetAt(Dart_Handle array,
319 intptr_t index); 248 intptr_t index);
320 DART_EXPORT Dart_Result Dart_ArrayGet(Dart_Handle array, 249 DART_EXPORT Dart_Handle Dart_ArrayGet(Dart_Handle array,
321 intptr_t offset, 250 intptr_t offset,
322 uint8_t* native_array, 251 uint8_t* native_array,
323 intptr_t length); 252 intptr_t length);
324 DART_EXPORT Dart_Result Dart_ArraySetAt(Dart_Handle array, 253 DART_EXPORT Dart_Handle Dart_ArraySetAt(Dart_Handle array,
325 intptr_t index, 254 intptr_t index,
326 Dart_Handle value); 255 Dart_Handle value);
327 DART_EXPORT Dart_Result Dart_ArraySet(Dart_Handle array, 256 DART_EXPORT Dart_Handle Dart_ArraySet(Dart_Handle array,
328 intptr_t offset, 257 intptr_t offset,
329 uint8_t* native_array, 258 uint8_t* native_array,
330 intptr_t length); 259 intptr_t length);
331 260
332 // Closure. 261 // Closure.
333 DART_EXPORT bool Dart_IsClosure(Dart_Handle object); 262 DART_EXPORT bool Dart_IsClosure(Dart_Handle object);
334 // DEPRECATED: The API below is a temporary hack. 263 // DEPRECATED: The API below is a temporary hack.
335 DART_EXPORT Dart_Result Dart_ClosureSmrck(Dart_Handle object); 264 DART_EXPORT Dart_Handle Dart_ClosureSmrck(Dart_Handle object);
Ivan Posva 2011/10/25 21:50:53 This does not match the result type in dart_api_im
turnidge 2011/10/25 22:07:23 Fixed.
336 DART_EXPORT void Dart_ClosureSetSmrck(Dart_Handle object, int64_t value); 265 DART_EXPORT void Dart_ClosureSetSmrck(Dart_Handle object, int64_t value);
337 266
338 267
339 // Invocation of methods. 268 // Invocation of methods.
340 DART_EXPORT Dart_Result Dart_InvokeStatic(Dart_Handle library, 269 DART_EXPORT Dart_Handle Dart_InvokeStatic(Dart_Handle library,
341 Dart_Handle class_name, 270 Dart_Handle class_name,
342 Dart_Handle function_name, 271 Dart_Handle function_name,
343 int number_of_arguments, 272 int number_of_arguments,
344 Dart_Handle* arguments); 273 Dart_Handle* arguments);
345 DART_EXPORT Dart_Result Dart_InvokeDynamic(Dart_Handle receiver, 274 DART_EXPORT Dart_Handle Dart_InvokeDynamic(Dart_Handle receiver,
346 Dart_Handle function_name, 275 Dart_Handle function_name,
347 int number_of_arguments, 276 int number_of_arguments,
348 Dart_Handle* arguments); 277 Dart_Handle* arguments);
349 DART_EXPORT Dart_Result Dart_InvokeClosure(Dart_Handle closure, 278 DART_EXPORT Dart_Handle Dart_InvokeClosure(Dart_Handle closure,
350 int number_of_arguments, 279 int number_of_arguments,
351 Dart_Handle* arguments); 280 Dart_Handle* arguments);
352 281
353 282
354 // Interaction with native methods. 283 // Interaction with native methods.
355 DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, 284 DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args,
356 int index); 285 int index);
357 DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args, 286 DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args,
358 Dart_Handle retval); 287 Dart_Handle retval);
359 288
360 // Library. 289 // Library.
361 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object); 290 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object);
362 DART_EXPORT Dart_Result Dart_LibraryUrl(Dart_Handle library); 291 DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library);
363 DART_EXPORT Dart_Result Dart_LibraryImportLibrary(Dart_Handle library, 292 DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library,
364 Dart_Handle import); 293 Dart_Handle import);
365 294
366 DART_EXPORT Dart_Result Dart_LookupLibrary(Dart_Handle url); 295 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url);
367 296
368 DART_EXPORT Dart_Result Dart_LoadLibrary(Dart_Handle url, 297 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url,
369 Dart_Handle source); 298 Dart_Handle source);
370 DART_EXPORT Dart_Result Dart_LoadSource(Dart_Handle library, 299 DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library,
371 Dart_Handle url, 300 Dart_Handle url,
372 Dart_Handle source); 301 Dart_Handle source);
373 DART_EXPORT Dart_Result Dart_SetNativeResolver( 302 DART_EXPORT Dart_Handle Dart_SetNativeResolver(
374 Dart_Handle library, 303 Dart_Handle library,
375 Dart_NativeEntryResolver resolver); 304 Dart_NativeEntryResolver resolver);
376 305
377 306
378 // Script handling. 307 // Script handling.
379 DART_EXPORT Dart_Result Dart_LoadScript(Dart_Handle url, 308 DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url,
380 Dart_Handle source, 309 Dart_Handle source,
381 Dart_LibraryTagHandler handler); 310 Dart_LibraryTagHandler handler);
382 311
383 // Compile all loaded classes and functions eagerly. 312 // Compile all loaded classes and functions eagerly.
384 DART_EXPORT Dart_Result Dart_CompileAll(); 313 DART_EXPORT Dart_Handle Dart_CompileAll();
385 314
386 // Exception related. 315 // Exception related.
387 DART_EXPORT bool Dart_ExceptionOccurred(Dart_Handle result); 316 DART_EXPORT bool Dart_ExceptionOccurred(Dart_Handle result);
388 DART_EXPORT Dart_Result Dart_GetException(Dart_Handle result); 317 DART_EXPORT Dart_Handle Dart_GetException(Dart_Handle result);
389 DART_EXPORT Dart_Result Dart_GetStacktrace(Dart_Handle unhandled_exception); 318 DART_EXPORT Dart_Handle Dart_GetStacktrace(Dart_Handle unhandled_exception);
390 DART_EXPORT Dart_Result Dart_ThrowException(Dart_Handle exception); 319 DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception);
391 DART_EXPORT Dart_Result Dart_ReThrowException(Dart_Handle exception, 320 DART_EXPORT Dart_Handle Dart_ReThrowException(Dart_Handle exception,
392 Dart_Handle stacktrace); 321 Dart_Handle stacktrace);
393 322
394 // Global Handles and Scope for local handles and zone based memory allocation. 323 // Global Handles and Scope for local handles and zone based memory allocation.
395 DART_EXPORT void Dart_EnterScope(); 324 DART_EXPORT void Dart_EnterScope();
396 DART_EXPORT void Dart_ExitScope(); 325 DART_EXPORT void Dart_ExitScope();
397 326
398 DART_EXPORT Dart_Handle Dart_NewPersistentHandle(Dart_Handle object); 327 DART_EXPORT Dart_Handle Dart_NewPersistentHandle(Dart_Handle object);
399 DART_EXPORT Dart_Handle Dart_MakeWeakPersistentHandle(Dart_Handle object); 328 DART_EXPORT Dart_Handle Dart_MakeWeakPersistentHandle(Dart_Handle object);
400 DART_EXPORT Dart_Handle Dart_MakePersistentHandle(Dart_Handle object); 329 DART_EXPORT Dart_Handle Dart_MakePersistentHandle(Dart_Handle object);
401 DART_EXPORT void Dart_DeletePersistentHandle(Dart_Handle object); 330 DART_EXPORT void Dart_DeletePersistentHandle(Dart_Handle object);
402 331
403 // Fields. 332 // Fields.
404 DART_EXPORT Dart_Result Dart_GetStaticField(Dart_Handle cls, Dart_Handle name); 333 DART_EXPORT Dart_Handle Dart_GetStaticField(Dart_Handle cls, Dart_Handle name);
405 DART_EXPORT Dart_Result Dart_SetStaticField(Dart_Handle cls, 334 DART_EXPORT Dart_Handle Dart_SetStaticField(Dart_Handle cls,
406 Dart_Handle name, 335 Dart_Handle name,
407 Dart_Handle value); 336 Dart_Handle value);
408 DART_EXPORT Dart_Result Dart_GetInstanceField(Dart_Handle obj, 337 DART_EXPORT Dart_Handle Dart_GetInstanceField(Dart_Handle obj,
409 Dart_Handle name); 338 Dart_Handle name);
410 DART_EXPORT Dart_Result Dart_SetInstanceField(Dart_Handle obj, 339 DART_EXPORT Dart_Handle Dart_SetInstanceField(Dart_Handle obj,
411 Dart_Handle name, 340 Dart_Handle name,
412 Dart_Handle value); 341 Dart_Handle value);
413 342
414 // Native fields. 343 // Native fields.
415 DART_EXPORT Dart_Result Dart_CreateNativeWrapperClass(Dart_Handle library, 344 DART_EXPORT Dart_Handle Dart_CreateNativeWrapperClass(Dart_Handle library,
416 Dart_Handle class_name, 345 Dart_Handle class_name,
417 int field_count); 346 int field_count);
418 DART_EXPORT Dart_Result Dart_GetNativeInstanceField(Dart_Handle obj, 347 DART_EXPORT Dart_Handle Dart_GetNativeInstanceField(Dart_Handle obj,
419 int index); 348 int index,
420 DART_EXPORT Dart_Result Dart_SetNativeInstanceField(Dart_Handle obj, 349 intptr_t* value);
350 DART_EXPORT Dart_Handle Dart_SetNativeInstanceField(Dart_Handle obj,
421 int index, 351 int index,
422 intptr_t value); 352 intptr_t value);
423 353
424 // Snapshot creation. 354 // Snapshot creation.
425 DART_EXPORT Dart_Result Dart_CreateSnapshot(uint8_t** snaphot_buffer, 355 DART_EXPORT Dart_Handle Dart_CreateSnapshot(uint8_t** snaphot_buffer,
426 intptr_t* snapshot_size); 356 intptr_t* snapshot_size);
427 357
428 // Message communication. 358 // Message communication.
429 DART_EXPORT Dart_Result Dart_PostIntArray(Dart_Port port, 359 DART_EXPORT bool Dart_PostIntArray(Dart_Port port,
430 int field_count, 360 int field_count,
431 intptr_t* data); 361 intptr_t* data);
432 362
433 DART_EXPORT Dart_Result Dart_Post(Dart_Port port, Dart_Handle value); 363 DART_EXPORT bool Dart_Post(Dart_Port port, Dart_Handle value);
434 364
435 // External pprof support for gathering and dumping symbolic information 365 // External pprof support for gathering and dumping symbolic information
436 // that can be used for better profile reports for dynamically generated 366 // that can be used for better profile reports for dynamically generated
437 // code. 367 // code.
438 DART_EXPORT void Dart_InitPprofSupport(); 368 DART_EXPORT void Dart_InitPprofSupport();
439 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); 369 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size);
440 370
441 // Check set vm flags. 371 // Check set vm flags.
442 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name); 372 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name);
443 373
444 #endif // INCLUDE_DART_API_H_ 374 #endif // INCLUDE_DART_API_H_
OLDNEW
« no previous file with comments | « runtime/bin/socket.cc ('k') | runtime/vm/dart_api_impl.h » ('j') | runtime/vm/dart_api_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698