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

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

Issue 9368049: Add external byte array API and finalize external strings and byte arrays. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments 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 | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef INCLUDE_DART_API_H_ 5 #ifndef INCLUDE_DART_API_H_
6 #define INCLUDE_DART_API_H_ 6 #define INCLUDE_DART_API_H_
7 7
8 /** \mainpage Dart Embedding API Reference 8 /** \mainpage Dart Embedding API Reference
9 * 9 *
10 * Dart is a class-based programming language for creating structured 10 * Dart is a class-based programming language for creating structured
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 * otherwise indicated, callers should assume that all functions in 88 * otherwise indicated, callers should assume that all functions in
89 * the Dart embedding api return local handles. 89 * the Dart embedding api return local handles.
90 * 90 *
91 * Persistent handles are allocated within the current isolate. They 91 * Persistent handles are allocated within the current isolate. They
92 * can be used to store objects across scopes. Persistent handles have 92 * can be used to store objects across scopes. Persistent handles have
93 * the lifetime of the current isolate unless they are explicitly 93 * the lifetime of the current isolate unless they are explicitly
94 * deallocated (see Dart_DeletePersistentHandle). 94 * deallocated (see Dart_DeletePersistentHandle).
95 */ 95 */
96 typedef struct _Dart_Handle* Dart_Handle; 96 typedef struct _Dart_Handle* Dart_Handle;
97 97
98 typedef void (*Dart_WeakPersistentHandleFinalizer)(Dart_Handle handle,
99 void* peer);
98 typedef void (*Dart_PeerFinalizer)(void* peer); 100 typedef void (*Dart_PeerFinalizer)(void* peer);
99 101
100 /** 102 /**
101 * Is this an error handle? 103 * Is this an error handle?
102 * 104 *
103 * Requires there to be a current isolate. 105 * Requires there to be a current isolate.
104 */ 106 */
105 DART_EXPORT bool Dart_IsError(Dart_Handle handle); 107 DART_EXPORT bool Dart_IsError(Dart_Handle handle);
106 108
107 /** 109 /**
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 * Allocates a weak persistent handle for an object. 235 * Allocates a weak persistent handle for an object.
234 * 236 *
235 * This handle has the lifetime of the current isolate unless it is 237 * This handle has the lifetime of the current isolate unless it is
236 * explicitly deallocated by calling Dart_DeletePersistentHandle. 238 * explicitly deallocated by calling Dart_DeletePersistentHandle.
237 * 239 *
238 * Requires there to be a current isolate. 240 * Requires there to be a current isolate.
239 */ 241 */
240 DART_EXPORT Dart_Handle Dart_NewWeakPersistentHandle( 242 DART_EXPORT Dart_Handle Dart_NewWeakPersistentHandle(
241 Dart_Handle object, 243 Dart_Handle object,
242 void* peer, 244 void* peer,
243 Dart_PeerFinalizer callback); 245 Dart_WeakPersistentHandleFinalizer callback);
244 246
245 /** 247 /**
246 * Is this object a weak persistent handle? 248 * Is this object a weak persistent handle?
247 * 249 *
248 * Requires there to be a current isolate. 250 * Requires there to be a current isolate.
249 */ 251 */
250 DART_EXPORT bool Dart_IsWeakPersistentHandle(Dart_Handle object); 252 DART_EXPORT bool Dart_IsWeakPersistentHandle(Dart_Handle object);
251 253
252 // --- Initialization and Globals --- 254 // --- Initialization and Globals ---
253 255
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 /** 1106 /**
1105 * May generate an unhandled exception error. 1107 * May generate an unhandled exception error.
1106 */ 1108 */
1107 DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list, 1109 DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list,
1108 intptr_t offset, 1110 intptr_t offset,
1109 uint8_t* native_array, 1111 uint8_t* native_array,
1110 intptr_t length); 1112 intptr_t length);
1111 1113
1112 // --- Byte Arrays --- 1114 // --- Byte Arrays ---
1113 1115
1114 DART_EXPORT Dart_Handle Dart_NewByteArray(intptr_t length);
1115
1116 /** 1116 /**
1117 * Is this object a ByteArray? 1117 * Is this object a ByteArray?
1118 */ 1118 */
1119 DART_EXPORT bool Dart_IsByteArray(Dart_Handle object); 1119 DART_EXPORT bool Dart_IsByteArray(Dart_Handle object);
1120 1120
1121 /**
1122 * Returns a ByteArray of the desired length.
1123 *
1124 * \param length The length of the array.
1125 *
1126 * \return The ByteArray object if no error occurs. Otherwise returns
1127 * an error handle.
1128 */
1129 DART_EXPORT Dart_Handle Dart_NewByteArray(intptr_t length);
1130
1131 /**
1132 * Returns a ByteArray which references an external array of 8-bit bytes.
1133 *
1134 * \param value An array of 8-bit bytes. This array must not move.
1135 * \param length The length of the array.
1136 *
1137 * \return The ByteArray object if no error occurs. Otherwise returns
1138 * an error handle.
1139 */
1140 DART_EXPORT Dart_Handle Dart_NewExternalByteArray(uint8_t* data,
1141 intptr_t length,
1142 void* peer,
1143 Dart_PeerFinalizer callback);
1144
1145 /**
1146 * Retrieves the peer pointer associated with an external ByteArray.
1147 */
1148 DART_EXPORT Dart_Handle Dart_ExternalByteArrayGetPeer(Dart_Handle object,
1149 void** peer);
1150
1121 // --- Closures --- 1151 // --- Closures ---
1122 1152
1123 /** 1153 /**
1124 * Is this object a Closure? 1154 * Is this object a Closure?
1125 */ 1155 */
1126 DART_EXPORT bool Dart_IsClosure(Dart_Handle object); 1156 DART_EXPORT bool Dart_IsClosure(Dart_Handle object);
1127 1157
1128 /** 1158 /**
1129 * Invokes a Closure with the given arguments. 1159 * Invokes a Closure with the given arguments.
1130 * 1160 *
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 * restored. 1486 * restored.
1457 * 1487 *
1458 * \param port_id The destination port. 1488 * \param port_id The destination port.
1459 * \param message The message to send. 1489 * \param message The message to send.
1460 * 1490 *
1461 * \return True if the message was posted. 1491 * \return True if the message was posted.
1462 */ 1492 */
1463 DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message); 1493 DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message);
1464 1494
1465 #endif // INCLUDE_DART_API_H_ 1495 #endif // INCLUDE_DART_API_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698