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

Side by Side Diff: runtime/include/dart_native_api.h

Issue 16973003: Split dart_api.h into multiple parts: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
3 * for details. All rights reserved. Use of this source code is governed by a
4 * BSD-style license that can be found in the LICENSE file.
5 */
6
7 #ifndef INCLUDE_DART_NATIVE_API_H_
8 #define INCLUDE_DART_NATIVE_API_H_
9
10 #include "include/dart_api.h"
11
12 /*
13 * ==========================================
14 * Message sending/receiving from native code
15 * ==========================================
16 */
17
18 /**
19 * A Dart_CObject is used for representing Dart objects as native C
20 * data outside the Dart heap. These objects are totally detached from
21 * the Dart heap. Only a subset of the Dart objects have a
22 * representation as a Dart_CObject.
23 *
24 * The string encoding in the 'value.as_string' is UTF-8.
25 *
26 * All the different types from dart:typed_data are exposed as type
27 * kTypedData. The specific type from dart:typed_data is in the type
28 * field of the as_typed_data structure. The length in the
29 * as_typed_data structure is always in bytes.
30 */
31 typedef enum {
32 Dart_CObject_kNull = 0,
33 Dart_CObject_kBool,
34 Dart_CObject_kInt32,
35 Dart_CObject_kInt64,
36 Dart_CObject_kBigint,
37 Dart_CObject_kDouble,
38 Dart_CObject_kString,
39 Dart_CObject_kArray,
40 Dart_CObject_kTypedData,
41 Dart_CObject_kExternalTypedData,
42 Dart_CObject_kUnsupported,
43 Dart_CObject_kNumberOfTypes
44 } Dart_CObject_Type;
45
46 typedef struct _Dart_CObject {
47 Dart_CObject_Type type;
48 union {
49 bool as_bool;
50 int32_t as_int32;
51 int64_t as_int64;
52 double as_double;
53 char* as_string;
54 char* as_bigint;
55 struct {
56 int length;
57 struct _Dart_CObject** values;
58 } as_array;
59 struct {
60 Dart_TypedData_Type type;
61 int length;
62 uint8_t* values;
63 } as_typed_data;
64 struct {
65 Dart_TypedData_Type type;
66 int length;
67 uint8_t* data;
68 void* peer;
69 Dart_WeakPersistentHandleFinalizer callback;
70 } as_external_typed_data;
71 } value;
72 } Dart_CObject;
73
74 /**
75 * Posts a message on some port. The message will contain the
76 * Dart_CObject object graph rooted in 'message'.
77 *
78 * While the message is being sent the state of the graph of
79 * Dart_CObject structures rooted in 'message' should not be accessed,
80 * as the message generation will make temporary modifications to the
81 * data. When the message has been sent the graph will be fully
82 * restored.
83 *
84 * \param port_id The destination port.
85 * \param message The message to send.
86 *
87 * \return True if the message was posted.
88 */
89 DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message);
90
91 /**
92 * A native message handler.
93 *
94 * This handler is associated with a native port by calling
95 * Dart_NewNativePort.
96 *
97 * The message received is decoded into the message structure. The
98 * lifetime of the message data is controlled by the caller. All the
99 * data references from the message are allocated by the caller and
100 * will be reclaimed when returning to it.
101 */
102
103 typedef void (*Dart_NativeMessageHandler)(Dart_Port dest_port_id,
104 Dart_Port reply_port_id,
105 Dart_CObject* message);
106
107 /**
108 * Creates a new native port. When messages are received on this
109 * native port, then they will be dispatched to the provided native
110 * message handler.
111 *
112 * \param name The name of this port in debugging messages.
113 * \param handler The C handler to run when messages arrive on the port.
114 * \param handle_concurrently Is it okay to process requests on this
115 * native port concurrently?
116 *
117 * \return If successful, returns the port id for the native port. In
118 * case of error, returns ILLEGAL_PORT.
119 */
120 DART_EXPORT Dart_Port Dart_NewNativePort(const char* name,
121 Dart_NativeMessageHandler handler,
122 bool handle_concurrently);
123 /* TODO(turnidge): Currently handle_concurrently is ignored. */
124
125 /**
126 * Closes the native port with the given id.
127 *
128 * The port must have been allocated by a call to Dart_NewNativePort.
129 *
130 * \param native_port_id The id of the native port to close.
131 *
132 * \return Returns true if the port was closed successfully.
133 */
134 DART_EXPORT bool Dart_CloseNativePort(Dart_Port native_port_id);
135
136
137 /*
138 * =================
139 * Profiling support
140 * =================
141 */
142
143 /* External pprof support for gathering and dumping symbolic
144 * information that can be used for better profile reports for
145 * dynamically generated code. */
146 DART_EXPORT void Dart_InitPprofSupport();
147 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size);
148
149 /* Support for generating symbol maps for use by the Linux perf tool. */
150 DART_EXPORT void Dart_InitPerfEventsSupport(void* perf_events_file);
151
152
153 /*
154 * =============
155 * Heap Profiler
156 * =============
157 */
158
159 /**
160 * Generates a heap profile.
161 *
162 * \param callback A function pointer that will be repeatedly invoked
163 * with heap profile data.
164 * \param stream A pointer that will be passed to the callback. This
165 * is a convenient way to provide an open stream to the callback.
166 *
167 * \return Success if the heap profile is successful.
168 */
169 DART_EXPORT Dart_Handle Dart_HeapProfile(Dart_FileWriteCallback callback,
170 void* stream);
171
172
173 /*
174 * ==================
175 * Verification Tools
176 * ==================
177 */
178
179 /**
180 * Forces all loaded classes and functions to be compiled eagerly in
181 * the current isolate..
182 *
183 * TODO(turnidge): Document.
184 */
185 DART_EXPORT Dart_Handle Dart_CompileAll();
186
187 /**
188 * Check that all function fingerprints are OK.
189 *
190 */
191 DART_EXPORT Dart_Handle Dart_CheckFunctionFingerprints();
192
193 #endif /* INCLUDE_DART_NATIVE_API_H_ */ /* NOLINT */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698