| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 * for details. All rights reserved. Use of this source code is governed by a | 3 * for details. All rights reserved. Use of this source code is governed by a |
| 4 * BSD-style license that can be found in the LICENSE file. | 4 * BSD-style license that can be found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #ifndef INCLUDE_DART_API_H_ | 7 #ifndef INCLUDE_DART_API_H_ |
| 8 #define INCLUDE_DART_API_H_ | 8 #define INCLUDE_DART_API_H_ |
| 9 | 9 |
| 10 /** \mainpage Dart Embedding API Reference | 10 /** \mainpage Dart Embedding API Reference |
| (...skipping 2447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2458 * After obtaining the service isolate the embedder specific glue code can | 2458 * After obtaining the service isolate the embedder specific glue code can |
| 2459 * be loaded in and the isolate can be run by the embedder. | 2459 * be loaded in and the isolate can be run by the embedder. |
| 2460 * | 2460 * |
| 2461 * NOTE: It is not safe to call this from multiple threads concurrently. | 2461 * NOTE: It is not safe to call this from multiple threads concurrently. |
| 2462 * | 2462 * |
| 2463 * \return Returns NULL if an error occurred. | 2463 * \return Returns NULL if an error occurred. |
| 2464 */ | 2464 */ |
| 2465 DART_EXPORT Dart_Isolate Dart_GetServiceIsolate(void* callback_data); | 2465 DART_EXPORT Dart_Isolate Dart_GetServiceIsolate(void* callback_data); |
| 2466 | 2466 |
| 2467 | 2467 |
| 2468 /** |
| 2469 * Returns true if the service is enabled. False otherwise. |
| 2470 * |
| 2471 * \return Returns true if service is running. |
| 2472 */ |
| 2473 DART_EXPORT bool Dart_IsServiceRunning(); |
| 2474 |
| 2475 |
| 2476 /** |
| 2477 * A service request callback function. |
| 2478 * |
| 2479 * These callbacks, registered by the embedder, are called when the VM receives |
| 2480 * a service request it can't handle and the service request command name |
| 2481 * matches one of the embedder registered handlers. |
| 2482 * |
| 2483 * \param name The service request command name. Always the first entry |
| 2484 * in the arguments array. Will match the name the callback was |
| 2485 * registered with. |
| 2486 * \param arguments The service request command arguments. Incoming service |
| 2487 * request paths are split like file system paths and flattened into an array |
| 2488 * (e.g. /foo/bar becomes the array ["foo", "bar"]. |
| 2489 * \param num_arguments The length of the arguments array. |
| 2490 * \param option_keys Service requests can have options key-value pairs. The |
| 2491 * keys and values are flattened and stored in arrays. |
| 2492 * \param option_values The values associated with the keys. |
| 2493 * \param num_options The length of the option_keys and option_values array. |
| 2494 * \param user_data The user_data pointer registered with this handler. |
| 2495 * |
| 2496 * \return Returns a C string containing a valid JSON object. The returned |
| 2497 * pointer will be freed by the VM by calling free. |
| 2498 */ |
| 2499 typedef const char* (*Dart_ServiceRequestCallback)( |
| 2500 const char* name, |
| 2501 const char** arguments, |
| 2502 intptr_t num_arguments, |
| 2503 const char** option_keys, |
| 2504 const char** option_values, |
| 2505 intptr_t num_options, |
| 2506 void* user_data); |
| 2507 |
| 2508 /** |
| 2509 * Register a Dart_ServiceRequestCallback to be called to handle requests |
| 2510 * with name on a specific isolate. The callback will be invoked with the |
| 2511 * current isolate set to the request target. |
| 2512 * |
| 2513 * \param name The name of the command that this callback is responsible for. |
| 2514 * \param callback The callback to invoke. |
| 2515 * \param user_data The user data passed to the callback. |
| 2516 * |
| 2517 * NOTE: If multiple callbacks with the same name are registered, only the |
| 2518 * last callback registered will be remembered. |
| 2519 */ |
| 2520 DART_EXPORT void Dart_RegisterIsolateServiceRequestCallback( |
| 2521 const char* name, |
| 2522 Dart_ServiceRequestCallback callback, |
| 2523 void* user_data); |
| 2524 |
| 2525 /** |
| 2526 * Register a Dart_ServiceRequestCallback to be called to handle requests |
| 2527 * with name. The callback will be invoked without a current isolate. |
| 2528 * |
| 2529 * \param name The name of the command that this callback is responsible for. |
| 2530 * \param callback The callback to invoke. |
| 2531 * \param user_data The user data passed to the callback. |
| 2532 * |
| 2533 * NOTE: If multiple callbacks with the same name are registered, only the |
| 2534 * last callback registered will be remembered. |
| 2535 */ |
| 2536 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
| 2537 const char* name, |
| 2538 Dart_ServiceRequestCallback callback, |
| 2539 void* user_data); |
| 2540 |
| 2541 |
| 2468 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ | 2542 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ |
| OLD | NEW |