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

Side by Side 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: Addressed review comments from asiva@ 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/dart_api_message.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef VM_DART_API_MESSAGE_H_
6 #define VM_DART_API_MESSAGE_H_
7
8 #include "vm/dart_api_state.h"
9 #include "vm/snapshot.h"
10
11 namespace dart {
12
13 // Use this C structure for reading internal objects in the serialized
14 // data. These are objects that we need to process in order to
15 // generate the Dart_CObject graph but that we don't want to expose in
16 // that graph.
17 // TODO(sjesse): Remove this when message serialization format is
18 // updated.
19 struct Dart_CObject_Internal : public Dart_CObject {
20 enum Type {
21 kTypeArguments = Dart_CObject::kNumberOfTypes,
22 kDynamicType,
23 };
24 };
25
26
27 // Reads a message snapshot into a C structure.
28 class ApiMessageReader : public BaseReader {
29 public:
30 ApiMessageReader(const uint8_t* buffer, intptr_t length, ReAlloc alloc);
31 ~ApiMessageReader() { }
32
33 Dart_CObject* ReadMessage();
34
35 private:
36 // Allocates a Dart_CObject object.
37 Dart_CObject* AllocateDartCObject();
38 // Allocates a Dart_CObject object with the specified type.
39 Dart_CObject* AllocateDartCObject(Dart_CObject::Type type);
40 // Allocates a Dart_CObject object for the null object.
41 Dart_CObject* AllocateDartCObjectNull();
42 // Allocates a Dart_CObject object for a boolean object.
43 Dart_CObject* AllocateDartCObjectBool(bool value);
44 // Allocates a Dart_CObject object for for a 32-bit integer.
45 Dart_CObject* AllocateDartCObjectInt32(int32_t value);
46 // Allocates a Dart_CObject object for a double.
47 Dart_CObject* AllocateDartCObjectDouble(double value);
48 // Allocates a Dart_CObject object for string data.
49 Dart_CObject* AllocateDartCObjectString(intptr_t length);
50 // Allocates a C array of Dart_CObject objects.
51 Dart_CObject* AllocateDartCObjectArray(intptr_t length);
52
53 void Init();
54
55 intptr_t LookupInternalClass(intptr_t class_header);
56 Dart_CObject* ReadInlinedObject(intptr_t object_id);
57 Dart_CObject* ReadObjectImpl(intptr_t header);
58 Dart_CObject* ReadIndexedObject(intptr_t object_id);
59 Dart_CObject* ReadObject();
60
61 // Add object to backward references.
62 void AddBackwardReference(intptr_t id, Dart_CObject* obj);
63
64 Dart_CObject_Internal* AsInternal(Dart_CObject* object) {
65 ASSERT(object->type >= Dart_CObject::kNumberOfTypes);
66 return reinterpret_cast<Dart_CObject_Internal*>(object);
67 }
68
69 // Allocation of the structures for the decoded message happens
70 // either in the supplied zone or using the supplied allocation
71 // function.
72 ReAlloc alloc_;
73 ApiGrowableArray<Dart_CObject*> backward_references_;
74
75 Dart_CObject type_arguments_marker;
76 Dart_CObject dynamic_type_marker;
77 };
78
79 } // namespace dart
80
81 #endif // VM_DART_API_MESSAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/dart_api_message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698