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

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: fix simarm and other minor 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | runtime/vm/dart_api_impl.cc » ('J')
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_PeerFinalizer)(void* peer); 98 typedef void (*Dart_PeerFinalizer)(Dart_Handle handle, void* peer);
99 99
100 /** 100 /**
101 * Is this an error handle? 101 * Is this an error handle?
102 * 102 *
103 * Requires there to be a current isolate. 103 * Requires there to be a current isolate.
104 */ 104 */
105 DART_EXPORT bool Dart_IsError(Dart_Handle handle); 105 DART_EXPORT bool Dart_IsError(Dart_Handle handle);
106 106
107 /** 107 /**
108 * Gets the error message from an error handle. 108 * Gets the error message from an error handle.
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 /** 1104 /**
1105 * May generate an unhandled exception error. 1105 * May generate an unhandled exception error.
1106 */ 1106 */
1107 DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list, 1107 DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list,
1108 intptr_t offset, 1108 intptr_t offset,
1109 uint8_t* native_array, 1109 uint8_t* native_array,
1110 intptr_t length); 1110 intptr_t length);
1111 1111
1112 // --- Byte Arrays --- 1112 // --- Byte Arrays ---
1113 1113
1114 DART_EXPORT Dart_Handle Dart_NewByteArray(intptr_t length);
1115
1116 /** 1114 /**
1117 * Is this object a ByteArray? 1115 * Is this object a ByteArray?
1118 */ 1116 */
1119 DART_EXPORT bool Dart_IsByteArray(Dart_Handle object); 1117 DART_EXPORT bool Dart_IsByteArray(Dart_Handle object);
1120 1118
1119 /**
1120 * Returns a ByteArray of the desired length.
1121 *
1122 * \param length The length of the array.
1123 *
1124 * \return The ByteArray object if no error occurs. Otherwise returns
1125 * an error handle.
1126 */
1127 DART_EXPORT Dart_Handle Dart_NewByteArray(intptr_t length);
1128
1129 /**
1130 * Returns a ByteArray which references an external array of 8-bit bytes.
1131 *
1132 * \param value An array of 8-bit bytes. This array must not move.
1133 * \param length The length of the array.
1134 *
1135 * \return The ByteArray object if no error occurs. Otherwise returns
1136 * an error handle.
1137 */
1138 DART_EXPORT Dart_Handle Dart_NewExternalByteArray(uint8_t* data,
1139 intptr_t length,
1140 void* peer,
1141 Dart_PeerFinalizer callback);
1142
1143 /**
1144 * Retrieves the peer pointer associated with an external ByteArray.
1145 */
1146 DART_EXPORT Dart_Handle Dart_ExternalByteArrayGetPeer(Dart_Handle object,
1147 void** peer);
1148
1121 // --- Closures --- 1149 // --- Closures ---
1122 1150
1123 /** 1151 /**
1124 * Is this object a Closure? 1152 * Is this object a Closure?
1125 */ 1153 */
1126 DART_EXPORT bool Dart_IsClosure(Dart_Handle object); 1154 DART_EXPORT bool Dart_IsClosure(Dart_Handle object);
1127 1155
1128 /** 1156 /**
1129 * Invokes a Closure with the given arguments. 1157 * Invokes a Closure with the given arguments.
1130 * 1158 *
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 * restored. 1484 * restored.
1457 * 1485 *
1458 * \param port_id The destination port. 1486 * \param port_id The destination port.
1459 * \param message The message to send. 1487 * \param message The message to send.
1460 * 1488 *
1461 * \return True if the message was posted. 1489 * \return True if the message was posted.
1462 */ 1490 */
1463 DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message); 1491 DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message);
1464 1492
1465 #endif // INCLUDE_DART_API_H_ 1493 #endif // INCLUDE_DART_API_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | runtime/vm/dart_api_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698