Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 typedef enum { | 72 typedef enum { |
| 73 kLibraryTag = 0, | 73 kLibraryTag = 0, |
| 74 kImportTag, | 74 kImportTag, |
| 75 kSourceTag, | 75 kSourceTag, |
| 76 kCanonicalizeUrl, | 76 kCanonicalizeUrl, |
| 77 } Dart_LibraryTag; | 77 } Dart_LibraryTag; |
| 78 | 78 |
| 79 typedef void Dart_Snapshot; | 79 typedef void Dart_Snapshot; |
| 80 | 80 |
| 81 typedef int64_t Dart_Port; | 81 typedef int64_t Dart_Port; |
| 82 typedef void* Dart_Message; | |
| 82 | 83 |
| 83 // Allow the embedder to intercept isolate creation. Both at startup and when | 84 // Allow the embedder to intercept isolate creation. Both at startup |
| 84 // spawning new isolates from Dart code. | 85 // and when spawning new isolates from Dart code. The result returned |
| 85 // The result returned from this callback is handed to all isolates spawned | 86 // from this callback is handed to all isolates spawned from the |
| 86 // from the isolate currently being initialized. | 87 // isolate currently being initialized. |
| 87 // Return NULL if an error is encountered. The isolate being initialized will | 88 // |
| 88 // be shutdown. No Dart code will execute in before it is shutdown. | 89 // Return NULL if an error is encountered. The isolate being |
| 90 // initialized will be shutdown. No Dart code will execute before it | |
| 91 // is shutdown. | |
| 92 // | |
| 89 // TODO(iposva): Pass a specification of the app file being spawned. | 93 // TODO(iposva): Pass a specification of the app file being spawned. |
| 90 typedef void* (*Dart_IsolateInitCallback)(void* data); | 94 typedef void* (*Dart_IsolateInitCallback)(void* data); |
| 91 | 95 |
| 92 typedef void (*Dart_NativeFunction)(Dart_NativeArguments arguments); | 96 typedef void (*Dart_NativeFunction)(Dart_NativeArguments arguments); |
| 93 typedef Dart_NativeFunction (*Dart_NativeEntryResolver)(Dart_Handle name, | 97 typedef Dart_NativeFunction (*Dart_NativeEntryResolver)(Dart_Handle name, |
| 94 int num_of_arguments); | 98 int num_of_arguments); |
| 95 typedef Dart_Result (*Dart_LibraryTagHandler)(Dart_LibraryTag tag, | 99 typedef Dart_Result (*Dart_LibraryTagHandler)(Dart_LibraryTag tag, |
| 96 Dart_Handle library, | 100 Dart_Handle library, |
| 97 Dart_Handle url); | 101 Dart_Handle url); |
| 98 | 102 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 | 187 |
| 184 // Isolate handling. | 188 // Isolate handling. |
| 185 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, | 189 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, |
| 186 void* data); | 190 void* data); |
| 187 DART_EXPORT void Dart_ShutdownIsolate(); | 191 DART_EXPORT void Dart_ShutdownIsolate(); |
| 188 | 192 |
| 189 DART_EXPORT Dart_Isolate Dart_CurrentIsolate(); | 193 DART_EXPORT Dart_Isolate Dart_CurrentIsolate(); |
| 190 DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate); | 194 DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate); |
| 191 DART_EXPORT void Dart_ExitIsolate(); | 195 DART_EXPORT void Dart_ExitIsolate(); |
| 192 | 196 |
| 197 // A convenience routine for which processes any incoming messages for | |
|
siva
2011/10/14 23:50:32
routine which
turnidge
2011/10/17 18:38:48
Done.
Anton Muhin
2011/10/18 07:01:03
I think Siva meant "A convenience routine which pr
turnidge
2011/10/18 16:42:14
Yeah, forgot to upload, sorry.
On 2011/10/18 07:0
| |
| 198 // the current isolate. The routine exits when all ports to the | |
| 199 // current isolate are closed | |
|
siva
2011/10/14 23:50:32
closed.
turnidge
2011/10/17 18:38:48
Done.
Anton Muhin
2011/10/18 07:01:03
Nit, missing trailing dot.
On 2011/10/17 18:38:48
turnidge
2011/10/18 16:42:14
Ditto upload.
On 2011/10/18 07:01:03, antonmuhin
| |
| 200 // | |
| 201 // This routine may only be used when the embedder has not provided an | |
| 202 // alternate message delivery mechanism with Dart_SetPostMessageCallback. | |
| 193 DART_EXPORT Dart_Result Dart_RunLoop(); | 203 DART_EXPORT Dart_Result Dart_RunLoop(); |
| 194 | 204 |
| 205 // Messages/ports | |
| 206 | |
| 207 // A post message callback allows the embedder to provide an alternate | |
| 208 // delivery mechanism for inter-isolate messages. The callback must | |
|
Anton Muhin
2011/10/17 15:20:29
is it indeed a must? May I just drop some message
turnidge
2011/10/17 18:38:48
I suppose it isn't a must, if you don't care about
Anton Muhin
2011/10/18 07:01:03
I like your new wording, thanks a lot.
On 2011/10
| |
| 209 // eventually cause Dart_HandleMessage to be called to process the | |
| 210 // message. | |
| 211 // | |
| 212 // The memory pointed to by 'message' has been allocated by malloc. It | |
| 213 // is the responsibility of the callback to ensure that free(message) | |
|
Anton Muhin
2011/10/18 07:01:03
that somewhat leaks the abstraction---we have this
turnidge
2011/10/18 16:42:14
I agree that this leaks the abstraction. I've add
| |
| 214 // is called once the message has been processed. | |
| 215 typedef bool (*Dart_PostMessageCallback)(Dart_Isolate dest_isolate, | |
| 216 Dart_Port dest_port, | |
| 217 Dart_Port reply_port, | |
| 218 Dart_Message message); | |
| 219 | |
| 220 // Allow embedders to provide an alternate delivery mechanism for | |
|
Anton Muhin
2011/10/17 15:20:29
nit: it looks like 3rd person is preferred: allow[
turnidge
2011/10/17 18:38:48
Done.
| |
| 221 // inter-isolate messages. This setting only applies to the current | |
| 222 // isolate. | |
| 223 DART_EXPORT void Dart_SetPostMessageCallback(Dart_PostMessageCallback callback); | |
|
Anton Muhin
2011/10/17 15:20:29
is _SetPostMessageCallback thread safe? Imagine m
turnidge
2011/10/17 18:38:48
Added some documentation around this.
I also comb
| |
| 224 | |
| 225 // A close port callback allows the embedder to receive notification | |
| 226 // when a port is closed. The constant 'kCloseAllPorts' is passed | |
|
Anton Muhin
2011/10/17 15:20:29
nit: in port parameter?
turnidge
2011/10/17 18:38:48
Done.
| |
| 227 // when all active ports are being closed at once. | |
| 228 typedef void (*Dart_ClosePortCallback)(Dart_Isolate isolate, | |
| 229 Dart_Port port); | |
| 230 const Dart_Port kCloseAllPorts = 0; | |
| 231 | |
| 232 // Allow embedder to receive notification when a port is closed. This | |
| 233 // setting only applies to the current isolate. | |
| 234 DART_EXPORT void Dart_SetClosePortCallback(Dart_ClosePortCallback callback); | |
| 235 | |
| 236 // Handle a message on the current isolate. | |
| 237 DART_EXPORT void Dart_HandleMessage(Dart_Port dest_port, | |
|
Anton Muhin
2011/10/17 15:20:29
do we need to pass ports around? maybe we can bun
turnidge
2011/10/17 18:38:48
They are sort of useless for the default, standalo
| |
| 238 Dart_Port reply_port, | |
| 239 Dart_Message dart_message); | |
| 240 | |
| 195 | 241 |
| 196 // Object. | 242 // Object. |
| 197 DART_EXPORT Dart_Result Dart_ObjectToString(Dart_Handle object); | 243 DART_EXPORT Dart_Result Dart_ObjectToString(Dart_Handle object); |
| 198 DART_EXPORT bool Dart_IsNull(Dart_Handle object); | 244 DART_EXPORT bool Dart_IsNull(Dart_Handle object); |
| 199 | 245 |
| 200 | 246 |
| 201 // Returns true if the two objects are equal. | 247 // Returns true if the two objects are equal. |
| 202 DART_EXPORT Dart_Result Dart_Objects_Equal(Dart_Handle obj1, Dart_Handle obj2); | 248 DART_EXPORT Dart_Result Dart_Objects_Equal(Dart_Handle obj1, Dart_Handle obj2); |
| 203 | 249 |
| 204 | 250 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 // External pprof support for gathering and dumping symbolic information | 432 // External pprof support for gathering and dumping symbolic information |
| 387 // that can be used for better profile reports for dynamically generated | 433 // that can be used for better profile reports for dynamically generated |
| 388 // code. | 434 // code. |
| 389 DART_EXPORT void Dart_InitPprofSupport(); | 435 DART_EXPORT void Dart_InitPprofSupport(); |
| 390 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); | 436 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); |
| 391 | 437 |
| 392 // Check set vm flags. | 438 // Check set vm flags. |
| 393 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name); | 439 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name); |
| 394 | 440 |
| 395 #endif // INCLUDE_DART_API_H_ | 441 #endif // INCLUDE_DART_API_H_ |
| OLD | NEW |