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

Unified Diff: runtime/include/dart_api.h

Issue 9159066: Allocate a Dart_CMessage structure when decoding a message into C structures (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | runtime/vm/snapshot.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | runtime/vm/snapshot.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698