Chromium Code Reviews| Index: runtime/include/dart_api.h |
| diff --git a/runtime/include/dart_api.h b/runtime/include/dart_api.h |
| index 0ca7c064a5b3873258272262911f5442ef718945..31acf3ba1f44e1ff5f364f6b3b5788863d6fa830 100755 |
| --- a/runtime/include/dart_api.h |
| +++ b/runtime/include/dart_api.h |
| @@ -1363,6 +1363,25 @@ DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); |
| // --- Message encoding/decoding ---- |
| /** |
| + * A memory allocation function. |
| + * |
| + * Allocate a new piece of memory or change the size (ra-allocates) of |
| + * a previously allocated piece of memory. |
| + * |
| + * \param ptr NULL for new allocation and pointer to a previously |
| + * allocated piece of memory for re-allocation. |
| + * \param old_size 0 for new allocation and size of previously allocated |
| + * piece of memory for re-allocation. |
| + * \param new_size |
| + * |
| + * \return Address of newly allocated or re-allocated piece of |
| + * memory of size new_size. NULL if allocation fails. |
| + */ |
| +typedef uint8_t* (*Allocator)(uint8_t* ptr, |
| + intptr_t old_size, |
| + intptr_t new_size); |
| + |
| +/** |
| * 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 |
| @@ -1395,7 +1414,31 @@ struct Dart_CObject { |
| * A Dart_CMessage is used for encoding and decoding messages from native code. |
| */ |
| struct Dart_CMessage { |
| - Dart_CObject** message; |
| + Dart_CObject* object; |
| + intptr_t allocated_length; |
| + Dart_CObject** allocated; |
|
siva
2012/02/01 01:48:36
Do we need the allocated and allocated_length fiel
Søren Gjesse
2012/02/01 12:12:23
We don't need it if we decide to handle the decodi
|
| + uint8_t* original_message; |
| + intptr_t original_message_length; |
|
siva
2012/02/01 01:48:36
Do we need the original message and length etc. ov
Søren Gjesse
2012/02/01 12:12:23
The reason they are here is that if we allow for t
|
| }; |
| +/** |
| + * Decodes a Dart message into a Dart_CMessage structure. |
| + * |
| + * \param message Pointer to the raw encoded message. |
| + * \param length Length of the raw encoded message. |
| + * \param allocator The memory allocation function to use to allocate |
| + * the Dart_CMessage structure and the Dart_CObject structures making |
| + * up the decoded message. If NULL is passed standard stdlib |
| + * malloc/realloc/free is used. |
| + */ |
| + |
| +DART_EXPORT Dart_CMessage* Dart_DecodeMessage(uint8_t* message, |
| + intptr_t length, |
| + Allocator allocator); |
|
turnidge
2012/01/31 22:20:42
Do we need this to be a public api? If the Dart_N
siva
2012/02/01 01:48:36
I agree with Todd, the native message handler coul
Søren Gjesse
2012/02/01 12:12:23
Maybe we don't. We could start out with delivering
Søren Gjesse
2012/02/01 12:12:23
I am fine with this - we can always add embedder c
|
| +// TODO(sgjesse): Remove length parameter if that is part of the |
| +// message header. |
| +// TODO(sgjesse): Should this function have flags for: |
| +// Don't fill in allocated (caller uses zone like allocation) |
| +// Don't Never point into original_message for e.g. byte arrays. |
| + |
| #endif // INCLUDE_DART_API_H_ |