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

Unified Diff: runtime/vm/dart_api_message.h

Issue 9325022: Decode the Dart message into a Dart_CMessage structure before calling the native port callback (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Undo unneeded changes Created 8 years, 10 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
Index: runtime/vm/dart_api_message.h
diff --git a/runtime/vm/dart_api_message.h b/runtime/vm/dart_api_message.h
new file mode 100644
index 0000000000000000000000000000000000000000..b53082a55638ba5fef57e884c1f5d5575d44489e
--- /dev/null
+++ b/runtime/vm/dart_api_message.h
@@ -0,0 +1,67 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#ifndef VM_DART_API_MESSAGE_H_
+#define VM_DART_API_MESSAGE_H_
+
+#include "vm/dart_api_state.h"
+#include "vm/snapshot.h"
+
+namespace dart {
+
+// Reads a message snapshot into a C structure.
+class ApiMessageReader : public BaseReader {
+ public:
+ ApiMessageReader(const uint8_t* buffer, intptr_t length, ReAlloc alloc);
+ ~ApiMessageReader() { }
+
+ Dart_CObject* ReadMessage();
+
+ private:
+ // Allocates a Dart_CObject object.
+ Dart_CObject* AllocateDartCObject();
+ // Allocates a Dart_CObject object with the specified type.
+ Dart_CObject* AllocateDartCObject(Dart_CObject::Type type);
+ // Allocates a Dart_CObject object for the null object.
+ Dart_CObject* AllocateDartCObjectNull();
+ // Allocates a Dart_CObject object for a boolean object.
+ Dart_CObject* AllocateDartCObjectBool(bool value);
+ // Allocates a Dart_CObject object for for a 32-bit integer.
+ Dart_CObject* AllocateDartCObjectInt32(int32_t value);
+ // Allocates a Dart_CObject object for a double.
+ Dart_CObject* AllocateDartCObjectDouble(double value);
+ // Allocates a Dart_CObject object for string data.
+ Dart_CObject* AllocateDartCObjectString(intptr_t length);
+ // Allocates a C array of Dart_CObject objects.
+ Dart_CObject* AllocateDartCObjectArray(intptr_t length);
+
+ void Init();
+
+ intptr_t LookupInternalClass(intptr_t class_header);
+ Dart_CObject* ReadInlinedObject(intptr_t object_id);
+ Dart_CObject* ReadObjectImpl(intptr_t header);
+ Dart_CObject* ReadIndexedObject(intptr_t object_id);
+ Dart_CObject* ReadObject();
+
+ // Add object to backward references.
+ void AddBackwardReference(intptr_t id, Dart_CObject* obj);
+
+ Dart_CObject_Internal* AsInternal(Dart_CObject* object) {
siva 2012/02/09 00:45:29 Looks like Dart_CObject_Internal is still defined
Søren Gjesse 2012/02/09 08:44:01 Done.
+ ASSERT(object->type >= Dart_CObject::kNumberOfTypes);
+ return reinterpret_cast<Dart_CObject_Internal*>(object);
+ }
+
+ // Allocation of the structures for the decoded message happens
+ // either in the supplied zone or using the supplied allocation
+ // function.
+ ReAlloc alloc_;
+ ApiGrowableArray<Dart_CObject*> backward_references_;
+
+ Dart_CObject type_arguments_marker;
+ Dart_CObject dynamic_type_marker;
+};
+
+} // namespace dart
+
+#endif // VM_DART_API_MESSAGE_H_

Powered by Google App Engine
This is Rietveld 408576698