Index: runtime/include/dart_api.h |
diff --git a/runtime/include/dart_api.h b/runtime/include/dart_api.h |
index edac66ea97950fdf65071d32004dd1d74885db29..4d8772fb7a5213e1b397758057c1ee8a87e75925 100755 |
--- a/runtime/include/dart_api.h |
+++ b/runtime/include/dart_api.h |
@@ -535,16 +535,69 @@ DART_EXPORT bool Dart_HasLivePorts(); |
*/ |
DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle object); |
+// --- Message sending/receiving from native code ---- |
+ |
+/** |
+ * A Dart_CObject is used for representing Dart objects as native C |
+ * data outside the Dart heap. These objects are totally detached from |
+ * the Dart heap. Only a subset of the Dart objects have a |
+ * representation as a Dart_CObject. |
+ */ |
+struct Dart_CObject { |
+ enum Type { |
+ kNull = 0, |
+ kBool, |
+ kInt32, |
+ kDouble, |
+ kString, |
+ kArray, |
+ kNumberOfTypes |
+ }; |
+ Type type; |
+ union { |
+ bool as_bool; |
+ int32_t as_int32; |
+ double as_double; |
+ char* as_string; |
+ struct { |
+ int length; |
+ Dart_CObject** values; |
+ } as_array; |
+ } value; |
+}; |
+ |
+/** |
+ * Posts a message on some port. The message will contain the |
+ * Dart_CObject object graph rooted in 'message'. |
+ * |
+ * While the message is being sent the state of the graph of |
+ * Dart_CObject structures rooted in 'message' should not be accessed, |
+ * as the message generation will make temporary modifications to the |
+ * data. When the message has been sent the graph will be fully |
+ * restored. |
+ * |
+ * \param port_id The destination port. |
+ * \param message The message to send. |
+ * |
+ * \return True if the message was posted. |
+ */ |
+DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message); |
+ |
/** |
* A native message handler. |
* |
* This handler is associated with a native port by calling |
* Dart_NewNativePort. |
+ * |
+ * The message received is decoded into the message structure. The |
+ * lifetime of the message data is controlled by the caller. All the |
+ * data references from the message are allocated by the caller and |
+ * will be reclaimed when returning to it. |
*/ |
+ |
typedef void (*Dart_NativeMessageHandler)(Dart_Port dest_port_id, |
Dart_Port reply_port_id, |
- uint8_t* data); |
-// TODO(turnidge): Make this function take more appropriate arguments. |
+ Dart_CObject* message); |
/** |
* Creates a new native port. When messages are received on this |
@@ -1414,52 +1467,4 @@ DART_EXPORT Dart_Handle Dart_SetNativeResolver( |
DART_EXPORT void Dart_InitPprofSupport(); |
DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); |
-// --- Message sending/receiving from native code ---- |
- |
-/** |
- * A Dart_CObject is used for representing Dart objects as native C |
- * data outside the Dart heap. These objects are totally detached from |
- * the Dart heap. Only a subset of the Dart objects have a |
- * representation as a Dart_CObject. |
- */ |
-struct Dart_CObject { |
- enum Type { |
- kNull = 0, |
- kBool, |
- kInt32, |
- kDouble, |
- kString, |
- kArray, |
- kNumberOfTypes |
- }; |
- Type type; |
- union { |
- bool as_bool; |
- int32_t as_int32; |
- double as_double; |
- char* as_string; |
- struct { |
- int length; |
- Dart_CObject** values; |
- } as_array; |
- } value; |
-}; |
- |
-/** |
- * Posts a message on some port. The message will contain the |
- * Dart_CObject object graph rooted in 'message'. |
- * |
- * While the message is being sent the state of the graph of |
- * Dart_CObject structures rooted in 'message' should not be accessed, |
- * as the message generation will make temporary modifications to the |
- * data. When the message has been sent the graph will be fully |
- * restored. |
- * |
- * \param port_id The destination port. |
- * \param message The message to send. |
- * |
- * \return True if the message was posted. |
- */ |
-DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message); |
- |
#endif // INCLUDE_DART_API_H_ |