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

Side by Side Diff: runtime/include/dart_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
« no previous file with comments | « runtime/dart-runtime.gyp ('k') | runtime/include/dart_mirrors_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 * for details. All rights reserved. Use of this source code is governed by a 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. 4 * BSD-style license that can be found in the LICENSE file.
5 */ 5 */
6 6
7 #ifndef INCLUDE_DART_API_H_ 7 #ifndef INCLUDE_DART_API_H_
8 #define INCLUDE_DART_API_H_ 8 #define INCLUDE_DART_API_H_
9 9
10 /** \mainpage Dart Embedding API Reference 10 /** \mainpage Dart Embedding API Reference
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #else 58 #else
59 #define DART_EXPORT DART_EXTERN_C 59 #define DART_EXPORT DART_EXTERN_C
60 #endif 60 #endif
61 #else 61 #else
62 #error Tool chain not supported. 62 #error Tool chain not supported.
63 #endif 63 #endif
64 #endif 64 #endif
65 65
66 #include <assert.h> 66 #include <assert.h>
67 67
68 /* --- Handles --- */ 68 /*
69 * =======
70 * Handles
71 * =======
72 */
69 73
70 /** 74 /**
71 * An object reference managed by the Dart VM garbage collector. 75 * An object reference managed by the Dart VM garbage collector.
72 * 76 *
73 * Because the garbage collector may move objects, it is unsafe to 77 * Because the garbage collector may move objects, it is unsafe to
74 * refer to objects directly. Instead, we refer to objects through 78 * refer to objects directly. Instead, we refer to objects through
75 * handles, which are known to the garbage collector and updated 79 * handles, which are known to the garbage collector and updated
76 * automatically when the object is moved. Handles should be passed 80 * automatically when the object is moved. Handles should be passed
77 * by value (except in cases like out-parameters) and should never be 81 * by value (except in cases like out-parameters) and should never be
78 * allocated on the heap. 82 * allocated on the heap.
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 * 480 *
477 * \return Success if the weak reference set could be created. 481 * \return Success if the weak reference set could be created.
478 * Otherwise, returns an error handle. 482 * Otherwise, returns an error handle.
479 */ 483 */
480 DART_EXPORT Dart_Handle Dart_NewWeakReferenceSet( 484 DART_EXPORT Dart_Handle Dart_NewWeakReferenceSet(
481 Dart_WeakPersistentHandle* keys, 485 Dart_WeakPersistentHandle* keys,
482 intptr_t num_keys, 486 intptr_t num_keys,
483 Dart_WeakPersistentHandle* values, 487 Dart_WeakPersistentHandle* values,
484 intptr_t num_values); 488 intptr_t num_values);
485 489
486 /* --- Garbage Collection Callbacks --- */ 490
491 /*
492 * ============================
493 * Garbage Collection Callbacks
494 * ============================
495 */
487 496
488 /** 497 /**
489 * Callbacks signal the beginning and end of a garbage collection. 498 * Callbacks signal the beginning and end of a garbage collection.
490 * 499 *
491 * These signals are intended to be used by the embedder to manage the 500 * These signals are intended to be used by the embedder to manage the
492 * lifetime of native objects with a managed object peer. 501 * lifetime of native objects with a managed object peer.
493 */ 502 */
494 503
495 /** 504 /**
496 * A callback invoked at the beginning of a garbage collection. 505 * A callback invoked at the beginning of a garbage collection.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 * \param callback A function pointer to an epilogue callback 555 * \param callback A function pointer to an epilogue callback
547 * function. This function must have been added as an epilogue 556 * function. This function must have been added as an epilogue
548 * callback. 557 * callback.
549 * 558 *
550 * \return Success if the callback was removed. Otherwise, returns an 559 * \return Success if the callback was removed. Otherwise, returns an
551 * error handle. 560 * error handle.
552 */ 561 */
553 DART_EXPORT Dart_Handle Dart_RemoveGcEpilogueCallback( 562 DART_EXPORT Dart_Handle Dart_RemoveGcEpilogueCallback(
554 Dart_GcEpilogueCallback callback); 563 Dart_GcEpilogueCallback callback);
555 564
556 /* --- Initialization and Globals --- */ 565
566 /*
567 * ==========================
568 * Initialization and Globals
569 * ==========================
570 */
557 571
558 /** 572 /**
559 * Gets the version string for the Dart VM. 573 * Gets the version string for the Dart VM.
560 * 574 *
561 * The version of the Dart VM can be accessed without initializing the VM. 575 * The version of the Dart VM can be accessed without initializing the VM.
562 * 576 *
563 * \return The version string for the embedded Dart VM. 577 * \return The version string for the embedded Dart VM.
564 */ 578 */
565 DART_EXPORT const char* Dart_VersionString(); 579 DART_EXPORT const char* Dart_VersionString();
566 580
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 * 751 *
738 * \return True if VM flags set successfully. 752 * \return True if VM flags set successfully.
739 */ 753 */
740 DART_EXPORT bool Dart_SetVMFlags(int argc, const char** argv); 754 DART_EXPORT bool Dart_SetVMFlags(int argc, const char** argv);
741 755
742 /** 756 /**
743 * Returns true if the named VM flag is set. 757 * Returns true if the named VM flag is set.
744 */ 758 */
745 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name); 759 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name);
746 760
747 /* --- Isolates --- */ 761
762 /*
763 * ========
764 * Isolates
765 * ========
766 */
748 767
749 /** 768 /**
750 * Creates a new isolate. The new isolate becomes the current isolate. 769 * Creates a new isolate. The new isolate becomes the current isolate.
751 * 770 *
752 * A snapshot can be used to restore the VM quickly to a saved state 771 * A snapshot can be used to restore the VM quickly to a saved state
753 * and is useful for fast startup. If snapshot data is provided, the 772 * and is useful for fast startup. If snapshot data is provided, the
754 * isolate will be started using that snapshot data. 773 * isolate will be started using that snapshot data.
755 * 774 *
756 * Requires there to be no current isolate. 775 * Requires there to be no current isolate.
757 * 776 *
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 * \param buffer Returns a pointer to a buffer containing 877 * \param buffer Returns a pointer to a buffer containing
859 * the snapshot. This buffer is scope allocated and is only valid 878 * the snapshot. This buffer is scope allocated and is only valid
860 * until the next call to Dart_ExitScope. 879 * until the next call to Dart_ExitScope.
861 * \param size Returns the size of the buffer. 880 * \param size Returns the size of the buffer.
862 * 881 *
863 * \return A valid handle if no error occurs during the operation. 882 * \return A valid handle if no error occurs during the operation.
864 */ 883 */
865 DART_EXPORT Dart_Handle Dart_CreateScriptSnapshot(uint8_t** buffer, 884 DART_EXPORT Dart_Handle Dart_CreateScriptSnapshot(uint8_t** buffer,
866 intptr_t* size); 885 intptr_t* size);
867 886
868
869 /** 887 /**
870 * Schedules an interrupt for the specified isolate. 888 * Schedules an interrupt for the specified isolate.
871 * 889 *
872 * Note that the interrupt does not occur immediately. In fact, if 890 * Note that the interrupt does not occur immediately. In fact, if
873 * 'isolate' does not execute any further Dart code, then the 891 * 'isolate' does not execute any further Dart code, then the
874 * interrupt will not occur at all. If and when the isolate is 892 * interrupt will not occur at all. If and when the isolate is
875 * interrupted, the isolate interrupt callback will be invoked with 893 * interrupted, the isolate interrupt callback will be invoked with
876 * 'isolate' as the current isolate (see 894 * 'isolate' as the current isolate (see
877 * Dart_IsolateInterruptCallback). 895 * Dart_IsolateInterruptCallback).
878 * 896 *
879 * \param isolate The isolate to be interrupted. 897 * \param isolate The isolate to be interrupted.
880 */ 898 */
881 DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate); 899 DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate);
882 900
883
884 /** 901 /**
885 * Make isolate runnable. 902 * Make isolate runnable.
886 * 903 *
887 * When isolates are spawned this function is used to indicate that 904 * When isolates are spawned this function is used to indicate that
888 * the creation and initialization (including script loading) of the 905 * the creation and initialization (including script loading) of the
889 * isolate is complete and the isolate can start. 906 * isolate is complete and the isolate can start.
890 * This function does not expect there to be a current isolate. 907 * This function does not expect there to be a current isolate.
891 * 908 *
892 * \param isolate The isolate to be made runnable. 909 * \param isolate The isolate to be made runnable.
893 */ 910 */
894 DART_EXPORT bool Dart_IsolateMakeRunnable(Dart_Isolate isolate); 911 DART_EXPORT bool Dart_IsolateMakeRunnable(Dart_Isolate isolate);
895 912
896 913
897 /* --- Messages and Ports --- */ 914 /*
915 * ==================
916 * Messages and Ports
917 * ==================
918 */
898 919
899 /** 920 /**
900 * A port is used to send or receive inter-isolate messages 921 * A port is used to send or receive inter-isolate messages
901 */ 922 */
902 typedef int64_t Dart_Port; 923 typedef int64_t Dart_Port;
903 924
904 /** 925 /**
905 * ILLEGAL_PORT is a port number guaranteed never to be associated with a valid 926 * ILLEGAL_PORT is a port number guaranteed never to be associated with a valid
906 * port. 927 * port.
907 */ 928 */
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 */ 1010 */
990 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id); 1011 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id);
991 1012
992 /** 1013 /**
993 * Gets the ReceivePort for the provided port id, creating it if necessary. 1014 * Gets the ReceivePort for the provided port id, creating it if necessary.
994 * 1015 *
995 * Note that there is at most one ReceivePort for a given port id. 1016 * Note that there is at most one ReceivePort for a given port id.
996 */ 1017 */
997 DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id); 1018 DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id);
998 1019
999 /* --- Scopes ---- */ 1020
1021 /*
1022 * ======
1023 * Scopes
1024 * ======
1025 */
1000 1026
1001 /** 1027 /**
1002 * Enters a new scope. 1028 * Enters a new scope.
1003 * 1029 *
1004 * All new local handles will be created in this scope. Additionally, 1030 * All new local handles will be created in this scope. Additionally,
1005 * some functions may return "scope allocated" memory which is only 1031 * some functions may return "scope allocated" memory which is only
1006 * valid within this scope. 1032 * valid within this scope.
1007 * 1033 *
1008 * Requires there to be a current isolate. 1034 * Requires there to be a current isolate.
1009 */ 1035 */
(...skipping 25 matching lines...) Expand all
1035 * All the memory allocated this way will be reclaimed either on the 1061 * All the memory allocated this way will be reclaimed either on the
1036 * next call to Dart_ExitScope or when the native port handler exits. 1062 * next call to Dart_ExitScope or when the native port handler exits.
1037 * 1063 *
1038 * \param size Size of the memory to allocate. 1064 * \param size Size of the memory to allocate.
1039 * 1065 *
1040 * \return A pointer to the allocated memory. NULL if allocation 1066 * \return A pointer to the allocated memory. NULL if allocation
1041 * failed. Failure might due to is no current VM zone. 1067 * failed. Failure might due to is no current VM zone.
1042 */ 1068 */
1043 DART_EXPORT uint8_t* Dart_ScopeAllocate(intptr_t size); 1069 DART_EXPORT uint8_t* Dart_ScopeAllocate(intptr_t size);
1044 1070
1045 /* --- Objects ---- */ 1071
1072 /*
1073 * =======
1074 * Objects
1075 * =======
1076 */
1046 1077
1047 /** 1078 /**
1048 * Returns the null object. 1079 * Returns the null object.
1049 * 1080 *
1050 * Requires there to be a current isolate. 1081 * Requires there to be a current isolate.
1051 * 1082 *
1052 * \return A handle to the null object. 1083 * \return A handle to the null object.
1053 */ 1084 */
1054 DART_EXPORT Dart_Handle Dart_Null(); 1085 DART_EXPORT Dart_Handle Dart_Null();
1055 1086
(...skipping 30 matching lines...) Expand all
1086 * \param object An object. 1117 * \param object An object.
1087 * \param type A type. 1118 * \param type A type.
1088 * \param instanceof Return true if 'object' is an instance of type 'type'. 1119 * \param instanceof Return true if 'object' is an instance of type 'type'.
1089 * 1120 *
1090 * \return A valid handle if no error occurs during the operation. 1121 * \return A valid handle if no error occurs during the operation.
1091 */ 1122 */
1092 DART_EXPORT Dart_Handle Dart_ObjectIsType(Dart_Handle object, 1123 DART_EXPORT Dart_Handle Dart_ObjectIsType(Dart_Handle object,
1093 Dart_Handle type, 1124 Dart_Handle type,
1094 bool* instanceof); 1125 bool* instanceof);
1095 1126
1096 /* --- Instances ---- 1127
1128 /**
1129 * Query object type.
1130 *
1131 * \param object Some Object.
1132 *
1133 * \return true if Object is of the specified type.
1134 */
1135 DART_EXPORT bool Dart_IsInstance(Dart_Handle object);
1136 DART_EXPORT bool Dart_IsNumber(Dart_Handle object);
1137 DART_EXPORT bool Dart_IsInteger(Dart_Handle object);
1138 DART_EXPORT bool Dart_IsDouble(Dart_Handle object);
1139 DART_EXPORT bool Dart_IsBoolean(Dart_Handle object);
1140 DART_EXPORT bool Dart_IsString(Dart_Handle object);
1141 DART_EXPORT bool Dart_IsStringLatin1(Dart_Handle object); /* (ISO-8859-1) */
1142 DART_EXPORT bool Dart_IsExternalString(Dart_Handle object);
1143 DART_EXPORT bool Dart_IsList(Dart_Handle object);
1144 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object);
1145 DART_EXPORT bool Dart_IsClass(Dart_Handle handle);
1146 DART_EXPORT bool Dart_IsAbstractClass(Dart_Handle handle);
1147 DART_EXPORT bool Dart_IsFunction(Dart_Handle handle);
1148 DART_EXPORT bool Dart_IsVariable(Dart_Handle handle);
1149 DART_EXPORT bool Dart_IsTypeVariable(Dart_Handle handle);
1150 DART_EXPORT bool Dart_IsClosure(Dart_Handle object);
1151
1152
1153 /*
1154 * =========
1155 * Instances
1156 * =========
1157 */
1158
1159 /*
1097 * For the purposes of the embedding api, not all objects returned are 1160 * For the purposes of the embedding api, not all objects returned are
1098 * Dart language objects. Within the api, we use the term 'Instance' 1161 * Dart language objects. Within the api, we use the term 'Instance'
1099 * to indicate handles which refer to true Dart language objects. 1162 * to indicate handles which refer to true Dart language objects.
1100 * 1163 *
1101 * TODO(turnidge): Reorganize the "Object" section above, pulling down 1164 * TODO(turnidge): Reorganize the "Object" section above, pulling down
1102 * any functions that more properly belong here. */ 1165 * any functions that more properly belong here. */
1103 1166
1104 /** 1167 /**
1105 * Does this handle refer to some Dart language object?
1106 */
1107 DART_EXPORT bool Dart_IsInstance(Dart_Handle object);
1108
1109 /**
1110 * Gets the class for some Dart language object. 1168 * Gets the class for some Dart language object.
1111 * 1169 *
1112 * \param instance Some Dart object. 1170 * \param instance Some Dart object.
1113 * 1171 *
1114 * \return If no error occurs, the class is returned. Otherwise an 1172 * \return If no error occurs, the class is returned. Otherwise an
1115 * error handle is returned. 1173 * error handle is returned.
1116 */ 1174 */
1117 DART_EXPORT Dart_Handle Dart_InstanceGetClass(Dart_Handle instance); 1175 DART_EXPORT Dart_Handle Dart_InstanceGetClass(Dart_Handle instance);
1118 1176
1119 /* --- Numbers ---- */
1120 1177
1121 /** 1178 /*
1122 * Is this object a Number? 1179 * =============================
1180 * Numbers, Integers and Doubles
1181 * =============================
1123 */ 1182 */
1124 DART_EXPORT bool Dart_IsNumber(Dart_Handle object);
1125
1126 /* --- Integers ---- */
1127
1128 /**
1129 * Is this object an Integer?
1130 */
1131 DART_EXPORT bool Dart_IsInteger(Dart_Handle object);
1132 1183
1133 /** 1184 /**
1134 * Does this Integer fit into a 64-bit signed integer? 1185 * Does this Integer fit into a 64-bit signed integer?
1135 * 1186 *
1136 * \param integer An integer. 1187 * \param integer An integer.
1137 * \param fits Returns true if the integer fits into a 64-bit signed integer. 1188 * \param fits Returns true if the integer fits into a 64-bit signed integer.
1138 * 1189 *
1139 * \return A valid handle if no error occurs during the operation. 1190 * \return A valid handle if no error occurs during the operation.
1140 */ 1191 */
1141 DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer, 1192 DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 * \param integer An Integer. 1257 * \param integer An Integer.
1207 * \param value Returns the value of the Integer as a hexadecimal C 1258 * \param value Returns the value of the Integer as a hexadecimal C
1208 * string. This C string is scope allocated and is only valid until 1259 * string. This C string is scope allocated and is only valid until
1209 * the next call to Dart_ExitScope. 1260 * the next call to Dart_ExitScope.
1210 * 1261 *
1211 * \return A valid handle if no error occurs during the operation. 1262 * \return A valid handle if no error occurs during the operation.
1212 */ 1263 */
1213 DART_EXPORT Dart_Handle Dart_IntegerToHexCString(Dart_Handle integer, 1264 DART_EXPORT Dart_Handle Dart_IntegerToHexCString(Dart_Handle integer,
1214 const char** value); 1265 const char** value);
1215 1266
1216 /* --- Booleans ---- */ 1267 /**
1268 * Returns a Double with the provided value.
1269 *
1270 * \param value A double.
1271 *
1272 * \return The Double object if no error occurs. Otherwise returns
1273 * an error handle.
1274 */
1275 DART_EXPORT Dart_Handle Dart_NewDouble(double value);
1276
1277 /**
1278 * Gets the value of a Double
1279 *
1280 * \param double_obj A Double
1281 * \param value Returns the value of the Double.
1282 *
1283 * \return A valid handle if no error occurs during the operation.
1284 */
1285 DART_EXPORT Dart_Handle Dart_DoubleValue(Dart_Handle double_obj, double* value);
1286
1287
1288 /*
1289 * ========
1290 * Booleans
1291 * ========
1292 */
1217 1293
1218 /** 1294 /**
1219 * Returns the True object. 1295 * Returns the True object.
1220 * 1296 *
1221 * Requires there to be a current isolate. 1297 * Requires there to be a current isolate.
1222 * 1298 *
1223 * \return A handle to the True object. 1299 * \return A handle to the True object.
1224 */ 1300 */
1225 DART_EXPORT Dart_Handle Dart_True(); 1301 DART_EXPORT Dart_Handle Dart_True();
1226 1302
1227 /** 1303 /**
1228 * Returns the False object. 1304 * Returns the False object.
1229 * 1305 *
1230 * Requires there to be a current isolate. 1306 * Requires there to be a current isolate.
1231 * 1307 *
1232 * \return A handle to the False object. 1308 * \return A handle to the False object.
1233 */ 1309 */
1234 DART_EXPORT Dart_Handle Dart_False(); 1310 DART_EXPORT Dart_Handle Dart_False();
1235 1311
1236 /** 1312 /**
1237 * Is this object a Boolean?
1238 */
1239 DART_EXPORT bool Dart_IsBoolean(Dart_Handle object);
1240
1241 /**
1242 * Returns a Boolean with the provided value. 1313 * Returns a Boolean with the provided value.
1243 * 1314 *
1244 * \param value true or false. 1315 * \param value true or false.
1245 * 1316 *
1246 * \return The Boolean object if no error occurs. Otherwise returns 1317 * \return The Boolean object if no error occurs. Otherwise returns
1247 * an error handle. 1318 * an error handle.
1248 */ 1319 */
1249 DART_EXPORT Dart_Handle Dart_NewBoolean(bool value); 1320 DART_EXPORT Dart_Handle Dart_NewBoolean(bool value);
1250 1321
1251 /** 1322 /**
1252 * Gets the value of a Boolean 1323 * Gets the value of a Boolean
1253 * 1324 *
1254 * \param boolean_obj A Boolean 1325 * \param boolean_obj A Boolean
1255 * \param value Returns the value of the Boolean. 1326 * \param value Returns the value of the Boolean.
1256 * 1327 *
1257 * \return A valid handle if no error occurs during the operation. 1328 * \return A valid handle if no error occurs during the operation.
1258 */ 1329 */
1259 DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle boolean_obj, bool* value); 1330 DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle boolean_obj, bool* value);
1260 1331
1261 /* --- Doubles --- */
1262 1332
1263 /** 1333 /*
1264 * Is this object a Double? 1334 * =======
1335 * Strings
1336 * =======
1265 */ 1337 */
1266 DART_EXPORT bool Dart_IsDouble(Dart_Handle object);
1267
1268 /**
1269 * Returns a Double with the provided value.
1270 *
1271 * \param value A double.
1272 *
1273 * \return The Double object if no error occurs. Otherwise returns
1274 * an error handle.
1275 */
1276 DART_EXPORT Dart_Handle Dart_NewDouble(double value);
1277
1278 /**
1279 * Gets the value of a Double
1280 *
1281 * \param double_obj A Double
1282 * \param value Returns the value of the Double.
1283 *
1284 * \return A valid handle if no error occurs during the operation.
1285 */
1286 DART_EXPORT Dart_Handle Dart_DoubleValue(Dart_Handle double_obj, double* value);
1287
1288 /* --- Strings --- */
1289
1290 /**
1291 * Is this object a String?
1292 */
1293 DART_EXPORT bool Dart_IsString(Dart_Handle object);
1294
1295 /**
1296 * Is this object a Latin-1 (ISO-8859-1) String?
1297 */
1298 DART_EXPORT bool Dart_IsStringLatin1(Dart_Handle object);
1299 1338
1300 /** 1339 /**
1301 * Gets the length of a String. 1340 * Gets the length of a String.
1302 * 1341 *
1303 * \param str A String. 1342 * \param str A String.
1304 * \param length Returns the length of the String. 1343 * \param length Returns the length of the String.
1305 * 1344 *
1306 * \return A valid handle if no error occurs during the operation. 1345 * \return A valid handle if no error occurs during the operation.
1307 */ 1346 */
1308 DART_EXPORT Dart_Handle Dart_StringLength(Dart_Handle str, intptr_t* length); 1347 DART_EXPORT Dart_Handle Dart_StringLength(Dart_Handle str, intptr_t* length);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 * \param utf32_array An array of UTF-32 encoded characters. 1391 * \param utf32_array An array of UTF-32 encoded characters.
1353 * \param length The length of the codepoints array. 1392 * \param length The length of the codepoints array.
1354 * 1393 *
1355 * \return The String object if no error occurs. Otherwise returns 1394 * \return The String object if no error occurs. Otherwise returns
1356 * an error handle. 1395 * an error handle.
1357 */ 1396 */
1358 DART_EXPORT Dart_Handle Dart_NewStringFromUTF32(const int32_t* utf32_array, 1397 DART_EXPORT Dart_Handle Dart_NewStringFromUTF32(const int32_t* utf32_array,
1359 intptr_t length); 1398 intptr_t length);
1360 1399
1361 /** 1400 /**
1362 * Is this object an external String?
1363 *
1364 * An external String is a String which references a fixed array of
1365 * codepoints which is external to the Dart heap.
1366 */
1367 DART_EXPORT bool Dart_IsExternalString(Dart_Handle object);
1368
1369 /**
1370 * Retrieves the peer pointer associated with an external String. 1401 * Retrieves the peer pointer associated with an external String.
1371 */ 1402 */
1372 DART_EXPORT Dart_Handle Dart_ExternalStringGetPeer(Dart_Handle object, 1403 DART_EXPORT Dart_Handle Dart_ExternalStringGetPeer(Dart_Handle object,
1373 void** peer); 1404 void** peer);
1374 1405
1375 /** 1406 /**
1376 * Returns a String which references an external array of 1407 * Returns a String which references an external array of
1377 * Latin-1 (ISO-8859-1) encoded characters. 1408 * Latin-1 (ISO-8859-1) encoded characters.
1378 * 1409 *
1379 * \param latin1_array Array of Latin-1 encoded characters. This must not move. 1410 * \param latin1_array Array of Latin-1 encoded characters. This must not move.
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 * result = Dart_MakeExternalString(str, data, size, NULL, NULL); 1536 * result = Dart_MakeExternalString(str, data, size, NULL, NULL);
1506 * 1537 *
1507 */ 1538 */
1508 DART_EXPORT Dart_Handle Dart_MakeExternalString(Dart_Handle str, 1539 DART_EXPORT Dart_Handle Dart_MakeExternalString(Dart_Handle str,
1509 void* array, 1540 void* array,
1510 intptr_t length, 1541 intptr_t length,
1511 void* peer, 1542 void* peer,
1512 Dart_PeerFinalizer cback); 1543 Dart_PeerFinalizer cback);
1513 1544
1514 1545
1515 /* --- Lists --- */ 1546 /*
1516 1547 * =====
1517 /** 1548 * Lists
1518 * Is this object a List? 1549 * =====
1519 */ 1550 */
1520 DART_EXPORT bool Dart_IsList(Dart_Handle object);
1521 1551
1522 /** 1552 /**
1523 * Returns a List of the desired length. 1553 * Returns a List of the desired length.
1524 * 1554 *
1525 * \param length The length of the list. 1555 * \param length The length of the list.
1526 * 1556 *
1527 * \return The List object if no error occurs. Otherwise returns 1557 * \return The List object if no error occurs. Otherwise returns
1528 * an error handle. 1558 * an error handle.
1529 */ 1559 */
1530 DART_EXPORT Dart_Handle Dart_NewList(intptr_t length); 1560 DART_EXPORT Dart_Handle Dart_NewList(intptr_t length);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 intptr_t length); 1613 intptr_t length);
1584 1614
1585 /** 1615 /**
1586 * May generate an unhandled exception error. 1616 * May generate an unhandled exception error.
1587 */ 1617 */
1588 DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list, 1618 DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list,
1589 intptr_t offset, 1619 intptr_t offset,
1590 uint8_t* native_array, 1620 uint8_t* native_array,
1591 intptr_t length); 1621 intptr_t length);
1592 1622
1593 /* --- Typed Data --- */ 1623
1624 /*
1625 * ==========
1626 * Typed Data
1627 * ==========
1628 */
1594 1629
1595 typedef enum { 1630 typedef enum {
1596 Dart_TypedData_kByteData = 0, 1631 Dart_TypedData_kByteData = 0,
1597 Dart_TypedData_kInt8, 1632 Dart_TypedData_kInt8,
1598 Dart_TypedData_kUint8, 1633 Dart_TypedData_kUint8,
1599 Dart_TypedData_kUint8Clamped, 1634 Dart_TypedData_kUint8Clamped,
1600 Dart_TypedData_kInt16, 1635 Dart_TypedData_kInt16,
1601 Dart_TypedData_kUint16, 1636 Dart_TypedData_kUint16,
1602 Dart_TypedData_kInt32, 1637 Dart_TypedData_kInt32,
1603 Dart_TypedData_kUint32, 1638 Dart_TypedData_kUint32,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 * 1717 *
1683 * \param object The typed data object whose internal data address is to be 1718 * \param object The typed data object whose internal data address is to be
1684 * released. 1719 * released.
1685 * 1720 *
1686 * \return Success if the internal data address is released successfully. 1721 * \return Success if the internal data address is released successfully.
1687 * Otherwise, returns an error handle. 1722 * Otherwise, returns an error handle.
1688 */ 1723 */
1689 DART_EXPORT Dart_Handle Dart_TypedDataReleaseData(Dart_Handle object); 1724 DART_EXPORT Dart_Handle Dart_TypedDataReleaseData(Dart_Handle object);
1690 1725
1691 1726
1692 /* --- Closures --- */ 1727 /*
1693 1728 * ============================================================
1694 /** 1729 * Invoking Constructors, Methods, Closures and Field accessors
1695 * Is this object a Closure? 1730 * ============================================================
1696 */ 1731 */
1697 DART_EXPORT bool Dart_IsClosure(Dart_Handle object);
1698
1699 /**
1700 * Retrieves the function of a closure.
1701 *
1702 * \return A handle to the function of the closure, or an error handle if the
1703 * argument is not a closure.
1704 */
1705 DART_EXPORT Dart_Handle Dart_ClosureFunction(Dart_Handle closure);
1706
1707 /**
1708 * Invokes a Closure with the given arguments.
1709 *
1710 * May generate an unhandled exception error.
1711 *
1712 * \return If no error occurs during execution, then the result of
1713 * invoking the closure is returned. If an error occurs during
1714 * execution, then an error handle is returned.
1715 */
1716 DART_EXPORT Dart_Handle Dart_InvokeClosure(Dart_Handle closure,
1717 int number_of_arguments,
1718 Dart_Handle* arguments);
1719
1720 /* --- Classes and Interfaces --- */
1721
1722 /**
1723 * Is this a class handle?
1724 */
1725 DART_EXPORT bool Dart_IsClass(Dart_Handle handle);
1726
1727 /**
1728 * Is this an abstract class handle?
1729 */
1730 DART_EXPORT bool Dart_IsAbstractClass(Dart_Handle handle);
1731
1732 /**
1733 * Returns the class name for the provided class or interface.
1734 */
1735 DART_EXPORT Dart_Handle Dart_ClassName(Dart_Handle clazz);
1736
1737 /**
1738 * Returns the library for the provided class or interface.
1739 */
1740 DART_EXPORT Dart_Handle Dart_ClassGetLibrary(Dart_Handle clazz);
1741
1742 /**
1743 * Returns the number of interfaces directly implemented by some class
1744 * or interface.
1745 *
1746 * TODO(turnidge): Finish documentation.
1747 */
1748 DART_EXPORT Dart_Handle Dart_ClassGetInterfaceCount(Dart_Handle clazz,
1749 intptr_t* count);
1750
1751 /**
1752 * Returns the interface at some index in the list of interfaces some
1753 * class or inteface.
1754 *
1755 * TODO(turnidge): Finish documentation.
1756 */
1757 DART_EXPORT Dart_Handle Dart_ClassGetInterfaceAt(Dart_Handle clazz,
1758 intptr_t index);
1759
1760 /**
1761 * Is this class defined by a typedef?
1762 *
1763 * Typedef definitions from the main program are represented as a
1764 * special kind of class handle. See Dart_ClassGetTypedefReferent.
1765 *
1766 * TODO(turnidge): Finish documentation.
1767 */
1768 DART_EXPORT bool Dart_ClassIsTypedef(Dart_Handle clazz);
1769
1770 /**
1771 * Returns a handle to the type to which a typedef refers.
1772 *
1773 * It is an error to call this function on a handle for which
1774 * Dart_ClassIsTypedef is not true.
1775 *
1776 * TODO(turnidge): Finish documentation.
1777 */
1778 DART_EXPORT Dart_Handle Dart_ClassGetTypedefReferent(Dart_Handle clazz);
1779
1780 /**
1781 * Does this class represent the type of a function?
1782 */
1783 DART_EXPORT bool Dart_ClassIsFunctionType(Dart_Handle clazz);
1784
1785 /**
1786 * Returns a function handle representing the signature associated
1787 * with a function type.
1788 *
1789 * The return value is a function handle (See Dart_IsFunction, etc.).
1790 *
1791 * TODO(turnidge): Finish documentation.
1792 */
1793 DART_EXPORT Dart_Handle Dart_ClassGetFunctionTypeSignature(Dart_Handle clazz);
1794
1795 /* --- Function and Variable Declarations --- */
1796
1797 /**
1798 * Returns a list of the names of all functions or methods declared in
1799 * a library or class.
1800 *
1801 * \param target A library or class.
1802 *
1803 * \return If no error occurs, a list of strings is returned.
1804 * Otherwise an error handle is returned.
1805 */
1806 DART_EXPORT Dart_Handle Dart_GetFunctionNames(Dart_Handle target);
1807
1808 /**
1809 * Looks up a function or method declaration by name from a library or
1810 * class.
1811 *
1812 * \param target The library or class containing the function.
1813 * \param function_name The name of the function.
1814 *
1815 * \return If an error is encountered, returns an error handle.
1816 * Otherwise returns a function handle if the function is found of
1817 * Dart_Null() if the function is not found.
1818 */
1819 DART_EXPORT Dart_Handle Dart_LookupFunction(Dart_Handle target,
1820 Dart_Handle function_name);
1821
1822 /**
1823 * Is this a function or method declaration handle?
1824 */
1825 DART_EXPORT bool Dart_IsFunction(Dart_Handle handle);
1826
1827 /**
1828 * Returns the name for the provided function or method.
1829 *
1830 * \return A valid string handle if no error occurs during the
1831 * operation.
1832 */
1833 DART_EXPORT Dart_Handle Dart_FunctionName(Dart_Handle function);
1834
1835 /**
1836 * Returns a handle to the owner of a function.
1837 *
1838 * The owner of an instance method or a static method is its defining
1839 * class. The owner of a top-level function is its defining
1840 * library. The owner of the function of a non-implicit closure is the
1841 * function of the method or closure that defines the non-implicit
1842 * closure.
1843 *
1844 * \return A valid handle to the owner of the function, or an error
1845 * handle if the argument is not a valid handle to a function.
1846 */
1847 DART_EXPORT Dart_Handle Dart_FunctionOwner(Dart_Handle function);
1848
1849 /**
1850 * Determines whether a function handle refers to an abstract method.
1851 *
1852 * \param function A handle to a function or method declaration.
1853 * \param is_static Returns whether the handle refers to an abstract method.
1854 *
1855 * \return A valid handle if no error occurs during the operation.
1856 */
1857 DART_EXPORT Dart_Handle Dart_FunctionIsAbstract(Dart_Handle function,
1858 bool* is_abstract);
1859
1860 /**
1861 * Determines whether a function handle referes to a static function
1862 * of method.
1863 *
1864 * For the purposes of the embedding API, a top-level function is
1865 * implicitly declared static.
1866 *
1867 * \param function A handle to a function or method declaration.
1868 * \param is_static Returns whether the function or method is declared static.
1869 *
1870 * \return A valid handle if no error occurs during the operation.
1871 */
1872 DART_EXPORT Dart_Handle Dart_FunctionIsStatic(Dart_Handle function,
1873 bool* is_static);
1874
1875 /**
1876 * Determines whether a function handle referes to a constructor.
1877 *
1878 * \param function A handle to a function or method declaration.
1879 * \param is_static Returns whether the function or method is a constructor.
1880 *
1881 * \return A valid handle if no error occurs during the operation.
1882 */
1883 DART_EXPORT Dart_Handle Dart_FunctionIsConstructor(Dart_Handle function,
1884 bool* is_constructor);
1885 /* TODO(turnidge): Document behavior for factory constructors too. */
1886
1887 /**
1888 * Determines whether a function or method is a getter.
1889 *
1890 * \param function A handle to a function or method declaration.
1891 * \param is_static Returns whether the function or method is a getter.
1892 *
1893 * \return A valid handle if no error occurs during the operation.
1894 */
1895 DART_EXPORT Dart_Handle Dart_FunctionIsGetter(Dart_Handle function,
1896 bool* is_getter);
1897
1898 /**
1899 * Determines whether a function or method is a setter.
1900 *
1901 * \param function A handle to a function or method declaration.
1902 * \param is_static Returns whether the function or method is a setter.
1903 *
1904 * \return A valid handle if no error occurs during the operation.
1905 */
1906 DART_EXPORT Dart_Handle Dart_FunctionIsSetter(Dart_Handle function,
1907 bool* is_setter);
1908
1909 /**
1910 * Returns the return type of a function.
1911 *
1912 * \return A valid handle to a type or an error handle if the argument
1913 * is not valid.
1914 */
1915 DART_EXPORT Dart_Handle Dart_FunctionReturnType(Dart_Handle function);
1916
1917 /**
1918 * Determines the number of required and optional parameters.
1919 *
1920 * \param function A handle to a function or method declaration.
1921 * \param fixed_param_count Returns the number of required parameters.
1922 * \param opt_param_count Returns the number of optional parameters.
1923 *
1924 * \return A valid handle if no error occurs during the operation.
1925 */
1926 DART_EXPORT Dart_Handle Dart_FunctionParameterCounts(
1927 Dart_Handle function,
1928 int64_t* fixed_param_count,
1929 int64_t* opt_param_count);
1930
1931 /**
1932 * Returns a handle to the type of a function parameter.
1933 *
1934 * \return A valid handle to a type or an error handle if the argument
1935 * is not valid.
1936 */
1937 DART_EXPORT Dart_Handle Dart_FunctionParameterType(Dart_Handle function,
1938 int parameter_index);
1939
1940 /**
1941 * Returns a list of the names of all variables declared in a library
1942 * or class.
1943 *
1944 * \param target A library or class.
1945 *
1946 * \return If no error occurs, a list of strings is returned.
1947 * Otherwise an error handle is returned.
1948 */
1949 DART_EXPORT Dart_Handle Dart_GetVariableNames(Dart_Handle target);
1950
1951 /**
1952 * Looks up a variable declaration by name from a library or class.
1953 *
1954 * \param target The library or class containing the variable.
1955 * \param variable_name The name of the variable.
1956 *
1957 * \return If an error is encountered, returns an error handle.
1958 * Otherwise returns a variable handle if the variable is found or
1959 * Dart_Null() if the variable is not found.
1960 */
1961 DART_EXPORT Dart_Handle Dart_LookupVariable(Dart_Handle target,
1962 Dart_Handle variable_name);
1963
1964 /**
1965 * Is this a variable declaration handle?
1966 */
1967 DART_EXPORT bool Dart_IsVariable(Dart_Handle handle);
1968
1969 /**
1970 * Returns the name for the provided variable.
1971 */
1972 DART_EXPORT Dart_Handle Dart_VariableName(Dart_Handle variable);
1973
1974 /**
1975 * Determines whether a variable is declared static.
1976 *
1977 * For the purposes of the embedding API, a top-level variable is
1978 * implicitly declared static.
1979 *
1980 * \param variable A handle to a variable declaration.
1981 * \param is_static Returns whether the variable is declared static.
1982 *
1983 * \return A valid handle if no error occurs during the operation.
1984 */
1985 DART_EXPORT Dart_Handle Dart_VariableIsStatic(Dart_Handle variable,
1986 bool* is_static);
1987
1988 /**
1989 * Determines whether a variable is declared final.
1990 *
1991 * \param variable A handle to a variable declaration.
1992 * \param is_final Returns whether the variable is declared final.
1993 *
1994 * \return A valid handle if no error occurs during the operation.
1995 */
1996 DART_EXPORT Dart_Handle Dart_VariableIsFinal(Dart_Handle variable,
1997 bool* is_final);
1998
1999 /**
2000 * Returns the type of a variable.
2001 *
2002 * \return A valid handle to a type of or an error handle if the
2003 * argument is not valid.
2004 */
2005 DART_EXPORT Dart_Handle Dart_VariableType(Dart_Handle function);
2006
2007 /**
2008 * Returns a list of the names of all type variables declared in a class.
2009 *
2010 * The type variables list preserves the original declaration order.
2011 *
2012 * \param clazz A class.
2013 *
2014 * \return If no error occurs, a list of strings is returned.
2015 * Otherwise an error handle is returned.
2016 */
2017 DART_EXPORT Dart_Handle Dart_GetTypeVariableNames(Dart_Handle clazz);
2018
2019 /**
2020 * Looks up a type variable declaration by name from a class.
2021 *
2022 * \param clazz The class containing the type variable.
2023 * \param variable_name The name of the type variable.
2024 *
2025 * \return If an error is encountered, returns an error handle.
2026 * Otherwise returns a type variable handle if the type variable is
2027 * found or Dart_Null() if the type variable is not found.
2028 */
2029 DART_EXPORT Dart_Handle Dart_LookupTypeVariable(Dart_Handle clazz,
2030 Dart_Handle type_variable_name);
2031
2032 /**
2033 * Is this a type variable handle?
2034 */
2035 DART_EXPORT bool Dart_IsTypeVariable(Dart_Handle handle);
2036
2037 /**
2038 * Returns the name for the provided type variable.
2039 */
2040 DART_EXPORT Dart_Handle Dart_TypeVariableName(Dart_Handle type_variable);
2041
2042 /**
2043 * Returns the owner of a function.
2044 *
2045 * The owner of a type variable is its defining class.
2046 *
2047 * \return A valid handle to the owner of the type variable, or an error
2048 * handle if the argument is not a valid handle to a type variable.
2049 */
2050 DART_EXPORT Dart_Handle Dart_TypeVariableOwner(Dart_Handle type_variable);
2051
2052 /**
2053 * Returns the upper bound of a type variable.
2054 *
2055 * The upper bound of a type variable is ...
2056 *
2057 * \return A valid handle to a type, or an error handle if the
2058 * argument is not a valid handle.
2059 */
2060 DART_EXPORT Dart_Handle Dart_TypeVariableUpperBound(Dart_Handle type_variable);
2061 /* TODO(turnidge): Finish documentation. */
2062
2063 /* --- Constructors, Methods, and Fields --- */
2064 1732
2065 /** 1733 /**
2066 * Invokes a constructor, creating a new object. 1734 * Invokes a constructor, creating a new object.
2067 * 1735 *
2068 * This function allows hidden constructors (constructors with leading 1736 * This function allows hidden constructors (constructors with leading
2069 * underscores) to be called. 1737 * underscores) to be called.
2070 * 1738 *
2071 * \param clazz A class or an interface. 1739 * \param clazz A class or an interface.
2072 * \param constructor_name The name of the constructor to invoke. Use 1740 * \param constructor_name The name of the constructor to invoke. Use
2073 * Dart_Null() to invoke the unnamed constructor. This name should 1741 * Dart_Null() to invoke the unnamed constructor. This name should
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2106 * successfully, then the return value is returned. If an error 1774 * successfully, then the return value is returned. If an error
2107 * occurs during execution, then an error handle is returned. 1775 * occurs during execution, then an error handle is returned.
2108 */ 1776 */
2109 DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target, 1777 DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target,
2110 Dart_Handle name, 1778 Dart_Handle name,
2111 int number_of_arguments, 1779 int number_of_arguments,
2112 Dart_Handle* arguments); 1780 Dart_Handle* arguments);
2113 /* TODO(turnidge): Document how to invoke operators. */ 1781 /* TODO(turnidge): Document how to invoke operators. */
2114 1782
2115 /** 1783 /**
1784 * Invokes a Closure with the given arguments.
1785 *
1786 * May generate an unhandled exception error.
1787 *
1788 * \return If no error occurs during execution, then the result of
1789 * invoking the closure is returned. If an error occurs during
1790 * execution, then an error handle is returned.
1791 */
1792 DART_EXPORT Dart_Handle Dart_InvokeClosure(Dart_Handle closure,
1793 int number_of_arguments,
1794 Dart_Handle* arguments);
1795
1796 /**
2116 * Gets the value of a field. 1797 * Gets the value of a field.
2117 * 1798 *
2118 * The 'container' parameter may be an object, class, or library. If 1799 * The 'container' parameter may be an object, class, or library. If
2119 * 'container' is an object, then this function will access an 1800 * 'container' is an object, then this function will access an
2120 * instance field. If 'container' is a class, then this function will 1801 * instance field. If 'container' is a class, then this function will
2121 * access a static field. If 'container' is a library, then this 1802 * access a static field. If 'container' is a library, then this
2122 * function will access a top-level variable. 1803 * function will access a top-level variable.
2123 * 1804 *
2124 * This function ignores field visibility (leading underscores in names). 1805 * This function ignores field visibility (leading underscores in names).
2125 * 1806 *
(...skipping 24 matching lines...) Expand all
2150 * \param container An object, class, or library. 1831 * \param container An object, class, or library.
2151 * \param name A field name. 1832 * \param name A field name.
2152 * \param value The new field value. 1833 * \param value The new field value.
2153 * 1834 *
2154 * \return A valid handle if no error occurs. 1835 * \return A valid handle if no error occurs.
2155 */ 1836 */
2156 DART_EXPORT Dart_Handle Dart_SetField(Dart_Handle container, 1837 DART_EXPORT Dart_Handle Dart_SetField(Dart_Handle container,
2157 Dart_Handle name, 1838 Dart_Handle name,
2158 Dart_Handle value); 1839 Dart_Handle value);
2159 1840
2160 /** 1841
2161 * Creates a native wrapper class. 1842 /*
2162 * 1843 * ==========
2163 * TODO(turnidge): Document. 1844 * Exceptions
1845 * ==========
2164 */ 1846 */
2165 DART_EXPORT Dart_Handle Dart_CreateNativeWrapperClass(Dart_Handle library,
2166 Dart_Handle class_name,
2167 int field_count);
2168 1847
2169 /** 1848 /*
2170 * Gets the number of native instance fields in an object.
2171 */
2172 DART_EXPORT Dart_Handle Dart_GetNativeInstanceFieldCount(Dart_Handle obj,
2173 int* count);
2174
2175 /**
2176 * Gets the value of a native field.
2177 *
2178 * TODO(turnidge): Document.
2179 */
2180 DART_EXPORT Dart_Handle Dart_GetNativeInstanceField(Dart_Handle obj,
2181 int index,
2182 intptr_t* value);
2183 /**
2184 * Sets the value of a native field.
2185 *
2186 * TODO(turnidge): Document.
2187 */
2188 DART_EXPORT Dart_Handle Dart_SetNativeInstanceField(Dart_Handle obj,
2189 int index,
2190 intptr_t value);
2191
2192 /* --- Exceptions ----
2193 * TODO(turnidge): Remove these functions from the api and replace all 1849 * TODO(turnidge): Remove these functions from the api and replace all
2194 * uses with Dart_NewUnhandledExceptionError. */ 1850 * uses with Dart_NewUnhandledExceptionError. */
2195 1851
2196 /** 1852 /**
2197 * Throws an exception. 1853 * Throws an exception.
2198 * 1854 *
2199 * This function causes a Dart language exception to be thrown. This 1855 * This function causes a Dart language exception to be thrown. This
2200 * will proceeed in the standard way, walking up Dart frames until an 1856 * will proceeed in the standard way, walking up Dart frames until an
2201 * appropriate 'catch' block is found, executing 'finally' blocks, 1857 * appropriate 'catch' block is found, executing 'finally' blocks,
2202 * etc. 1858 * etc.
(...skipping 14 matching lines...) Expand all
2217 * successful, this function does not return. Note that this means 1873 * successful, this function does not return. Note that this means
2218 * that the destructors of any stack-allocated C++ objects will not be 1874 * that the destructors of any stack-allocated C++ objects will not be
2219 * called. If there are no Dart frames on the stack, an error occurs. 1875 * called. If there are no Dart frames on the stack, an error occurs.
2220 * 1876 *
2221 * \return An error handle if the exception was not thrown. 1877 * \return An error handle if the exception was not thrown.
2222 * Otherwise the function does not return. 1878 * Otherwise the function does not return.
2223 */ 1879 */
2224 DART_EXPORT Dart_Handle Dart_RethrowException(Dart_Handle exception, 1880 DART_EXPORT Dart_Handle Dart_RethrowException(Dart_Handle exception,
2225 Dart_Handle stacktrace); 1881 Dart_Handle stacktrace);
2226 1882
2227 /* --- Native functions --- */ 1883
1884 /*
1885 * ===========================
1886 * Native fields and functions
1887 * ===========================
1888 */
1889
1890 /**
1891 * Creates a native wrapper class.
1892 *
1893 * TODO(turnidge): Document.
1894 */
1895 DART_EXPORT Dart_Handle Dart_CreateNativeWrapperClass(Dart_Handle library,
1896 Dart_Handle class_name,
1897 int field_count);
1898
1899 /**
1900 * Gets the number of native instance fields in an object.
1901 */
1902 DART_EXPORT Dart_Handle Dart_GetNativeInstanceFieldCount(Dart_Handle obj,
1903 int* count);
1904
1905 /**
1906 * Gets the value of a native field.
1907 *
1908 * TODO(turnidge): Document.
1909 */
1910 DART_EXPORT Dart_Handle Dart_GetNativeInstanceField(Dart_Handle obj,
1911 int index,
1912 intptr_t* value);
1913
1914 /**
1915 * Sets the value of a native field.
1916 *
1917 * TODO(turnidge): Document.
1918 */
1919 DART_EXPORT Dart_Handle Dart_SetNativeInstanceField(Dart_Handle obj,
1920 int index,
1921 intptr_t value);
2228 1922
2229 /** 1923 /**
2230 * The arguments to a native function. 1924 * The arguments to a native function.
2231 * 1925 *
2232 * This object is passed to a native function to represent its 1926 * This object is passed to a native function to represent its
2233 * arguments and return value. It allows access to the arguments to a 1927 * arguments and return value. It allows access to the arguments to a
2234 * native function by index. It also allows the return value of a 1928 * native function by index. It also allows the return value of a
2235 * native function to be set. 1929 * native function to be set.
2236 */ 1930 */
2237 typedef struct _Dart_NativeArguments* Dart_NativeArguments; 1931 typedef struct _Dart_NativeArguments* Dart_NativeArguments;
(...skipping 29 matching lines...) Expand all
2267 * name/arity to a Dart_NativeFunction. If no function is found, the 1961 * name/arity to a Dart_NativeFunction. If no function is found, the
2268 * callback should return NULL. 1962 * callback should return NULL.
2269 * 1963 *
2270 * See Dart_SetNativeResolver. 1964 * See Dart_SetNativeResolver.
2271 */ 1965 */
2272 typedef Dart_NativeFunction (*Dart_NativeEntryResolver)(Dart_Handle name, 1966 typedef Dart_NativeFunction (*Dart_NativeEntryResolver)(Dart_Handle name,
2273 int num_of_arguments); 1967 int num_of_arguments);
2274 /* TODO(turnidge): Consider renaming to NativeFunctionResolver or 1968 /* TODO(turnidge): Consider renaming to NativeFunctionResolver or
2275 * NativeResolver. */ 1969 * NativeResolver. */
2276 1970
2277
2278 /* --- Metadata support --- */
2279
2280 /** 1971 /**
2281 * Get metadata associated with an object. 1972 * Sets the callback used to resolve native functions for a library.
2282 * 1973 *
2283 * \param obj Object for which the metadata is retrieved. 1974 * \param library A library.
1975 * \param resolver A native entry resolver.
2284 * 1976 *
2285 * \return If no error occurs, returns an array of metadata values. 1977 * \return A valid handle if the native resolver was set successfully.
2286 * Returns an empty array if there is no metadata for the object.
2287 * Returns an error if the evaluation of the metadata expressions fails.
2288 *
2289 */ 1978 */
2290 DART_EXPORT Dart_Handle Dart_GetMetadata(Dart_Handle obj); 1979 DART_EXPORT Dart_Handle Dart_SetNativeResolver(
1980 Dart_Handle library,
1981 Dart_NativeEntryResolver resolver);
1982 /* TODO(turnidge): Rename to Dart_LibrarySetNativeResolver? */
2291 1983
2292 1984
2293 /* --- Scripts and Libraries --- 1985 /*
2294 * TODO(turnidge): Finish documenting this section. */ 1986 * =====================
1987 * Scripts and Libraries
1988 * =====================
1989 */
1990 /* TODO(turnidge): Finish documenting this section. */
2295 1991
2296 typedef enum { 1992 typedef enum {
2297 Dart_kLibraryTag = 0, 1993 Dart_kLibraryTag = 0,
2298 Dart_kImportTag, 1994 Dart_kImportTag,
2299 Dart_kSourceTag, 1995 Dart_kSourceTag,
2300 Dart_kCanonicalizeUrl 1996 Dart_kCanonicalizeUrl
2301 } Dart_LibraryTag; 1997 } Dart_LibraryTag;
2302 1998
2303 /* TODO(turnidge): Document. */ 1999 /* TODO(turnidge): Document. */
2304 typedef Dart_Handle (*Dart_LibraryTagHandler)(Dart_LibraryTag tag, 2000 typedef Dart_Handle (*Dart_LibraryTagHandler)(Dart_LibraryTag tag,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2355 * 2051 *
2356 * If the root script has not yet been set for the current isolate, 2052 * If the root script has not yet been set for the current isolate,
2357 * this function returns Dart_Null(). This function never returns an 2053 * this function returns Dart_Null(). This function never returns an
2358 * error handle. 2054 * error handle.
2359 * 2055 *
2360 * \return Returns the root Library for the current isolate or Dart_Null(). 2056 * \return Returns the root Library for the current isolate or Dart_Null().
2361 */ 2057 */
2362 DART_EXPORT Dart_Handle Dart_RootLibrary(); 2058 DART_EXPORT Dart_Handle Dart_RootLibrary();
2363 2059
2364 /** 2060 /**
2365 * Forces all loaded classes and functions to be compiled eagerly in
2366 * the current isolate..
2367 *
2368 * TODO(turnidge): Document.
2369 */
2370 DART_EXPORT Dart_Handle Dart_CompileAll();
2371
2372 /**
2373 * Check that all function fingerprints are OK.
2374 *
2375 */
2376 DART_EXPORT Dart_Handle Dart_CheckFunctionFingerprints();
2377
2378 /**
2379 * Is this object a Library?
2380 */
2381 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object);
2382
2383 /**
2384 * Lookup a class or interface by name from a Library. 2061 * Lookup a class or interface by name from a Library.
2385 * 2062 *
2386 * \param library The library containing the class or interface. 2063 * \param library The library containing the class or interface.
2387 * \param class_name The name of the class or interface. 2064 * \param class_name The name of the class or interface.
2388 * 2065 *
2389 * \return If no error occurs, the class or interface is 2066 * \return If no error occurs, the class or interface is
2390 * returned. Otherwise an error handle is returned. 2067 * returned. Otherwise an error handle is returned.
2391 */ 2068 */
2392 DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, 2069 DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library,
2393 Dart_Handle class_name); 2070 Dart_Handle class_name);
2394 /* TODO(turnidge): Consider returning Dart_Null() when the class is 2071 /* TODO(turnidge): Consider returning Dart_Null() when the class is
2395 * not found to distinguish that from a true error case. */ 2072 * not found to distinguish that from a true error case. */
2396 2073
2397 /** 2074 /**
2398 * Returns the name of a library as declared in the #library directive.
2399 */
2400 DART_EXPORT Dart_Handle Dart_LibraryName(Dart_Handle library);
2401
2402 /**
2403 * Returns the url from which a library was loaded. 2075 * Returns the url from which a library was loaded.
2404 */ 2076 */
2405 DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library); 2077 DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library);
2406 2078
2407 /**
2408 * Returns a list of the names of all classes and interfaces declared
2409 * in a library.
2410 *
2411 * \return If no error occurs, a list of strings is returned.
2412 * Otherwise an error handle is returned.
2413 */
2414 DART_EXPORT Dart_Handle Dart_LibraryGetClassNames(Dart_Handle library);
2415
2416 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url); 2079 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url);
2417 /* TODO(turnidge): Consider returning Dart_Null() when the library is 2080 /* TODO(turnidge): Consider returning Dart_Null() when the library is
2418 * not found to distinguish that from a true error case. */ 2081 * not found to distinguish that from a true error case. */
2419 2082
2420 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, 2083 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url,
2421 Dart_Handle source); 2084 Dart_Handle source);
2422 2085
2423 /** 2086 /**
2424 * Imports a library into another library, optionally with a prefix. 2087 * Imports a library into another library, optionally with a prefix.
2425 * If no prefix is required, an empty string or Dart_Null() can be 2088 * If no prefix is required, an empty string or Dart_Null() can be
(...skipping 28 matching lines...) Expand all
2454 * Loads a patch source string into a library. 2117 * Loads a patch source string into a library.
2455 * 2118 *
2456 * \param library A library 2119 * \param library A library
2457 * \param url A url identifying the origin of the patch source 2120 * \param url A url identifying the origin of the patch source
2458 * \param source A string of Dart patch source 2121 * \param source A string of Dart patch source
2459 */ 2122 */
2460 DART_EXPORT Dart_Handle Dart_LoadPatch(Dart_Handle library, 2123 DART_EXPORT Dart_Handle Dart_LoadPatch(Dart_Handle library,
2461 Dart_Handle url, 2124 Dart_Handle url,
2462 Dart_Handle patch_source); 2125 Dart_Handle patch_source);
2463 2126
2464 /** 2127
2465 * Sets the callback used to resolve native functions for a library. 2128 /*
2466 * 2129 * =====
2467 * \param library A library. 2130 * Peers
2468 * \param resolver A native entry resolver. 2131 * =====
2469 *
2470 * \return A valid handle if the native resolver was set successfully.
2471 */ 2132 */
2472 DART_EXPORT Dart_Handle Dart_SetNativeResolver(
2473 Dart_Handle library,
2474 Dart_NativeEntryResolver resolver);
2475 /* TODO(turnidge): Rename to Dart_LibrarySetNativeResolver? */
2476
2477 /* --- Profiling support ---- */
2478
2479 /* External pprof support for gathering and dumping symbolic
2480 * information that can be used for better profile reports for
2481 * dynamically generated code. */
2482 DART_EXPORT void Dart_InitPprofSupport();
2483 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size);
2484
2485 /* Support for generating symbol maps for use by the Linux perf tool. */
2486 DART_EXPORT void Dart_InitPerfEventsSupport(void* perf_events_file);
2487
2488 /* --- Heap Profiler --- */
2489
2490 /**
2491 * Generates a heap profile.
2492 *
2493 * \param callback A function pointer that will be repeatedly invoked
2494 * with heap profile data.
2495 * \param stream A pointer that will be passed to the callback. This
2496 * is a convenient way to provide an open stream to the callback.
2497 *
2498 * \return Success if the heap profile is successful.
2499 */
2500 DART_EXPORT Dart_Handle Dart_HeapProfile(Dart_FileWriteCallback callback,
2501 void* stream);
2502
2503 /* --- Peers --- */
2504 2133
2505 /** 2134 /**
2506 * The peer field is a lazily allocated field intendend for storage of 2135 * The peer field is a lazily allocated field intendend for storage of
2507 * an uncommonly used values. Most instances types can have a peer 2136 * an uncommonly used values. Most instances types can have a peer
2508 * field allocated. The exceptions are subtypes of Null, num, and 2137 * field allocated. The exceptions are subtypes of Null, num, and
2509 * bool. 2138 * bool.
2510 */ 2139 */
2511 2140
2512 /** 2141 /**
2513 * Returns the value of peer field of 'object' in 'peer'. 2142 * Returns the value of peer field of 'object' in 'peer'.
(...skipping 12 matching lines...) Expand all
2526 * 'peer'. 2155 * 'peer'.
2527 * 2156 *
2528 * \param object An object. 2157 * \param object An object.
2529 * \param peer A value to store in the peer field. 2158 * \param peer A value to store in the peer field.
2530 * 2159 *
2531 * \return Returns an error if 'object' is a subtype of Null, num, or 2160 * \return Returns an error if 'object' is a subtype of Null, num, or
2532 * bool. 2161 * bool.
2533 */ 2162 */
2534 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); 2163 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer);
2535 2164
2536 /* --- Message sending/receiving from native code ---- */
2537
2538 /**
2539 * A Dart_CObject is used for representing Dart objects as native C
2540 * data outside the Dart heap. These objects are totally detached from
2541 * the Dart heap. Only a subset of the Dart objects have a
2542 * representation as a Dart_CObject.
2543 *
2544 * The string encoding in the 'value.as_string' is UTF-8.
2545 *
2546 * All the different types from dart:typed_data are exposed as type
2547 * kTypedData. The specific type from dart:typed_data is in the type
2548 * field of the as_typed_data structure. The length in the
2549 * as_typed_data structure is always in bytes.
2550 */
2551 typedef enum {
2552 Dart_CObject_kNull = 0,
2553 Dart_CObject_kBool,
2554 Dart_CObject_kInt32,
2555 Dart_CObject_kInt64,
2556 Dart_CObject_kBigint,
2557 Dart_CObject_kDouble,
2558 Dart_CObject_kString,
2559 Dart_CObject_kArray,
2560 Dart_CObject_kTypedData,
2561 Dart_CObject_kExternalTypedData,
2562 Dart_CObject_kUnsupported,
2563 Dart_CObject_kNumberOfTypes
2564 } Dart_CObject_Type;
2565
2566 typedef struct _Dart_CObject {
2567 Dart_CObject_Type type;
2568 union {
2569 bool as_bool;
2570 int32_t as_int32;
2571 int64_t as_int64;
2572 double as_double;
2573 char* as_string;
2574 char* as_bigint;
2575 struct {
2576 int length;
2577 struct _Dart_CObject** values;
2578 } as_array;
2579 struct {
2580 Dart_TypedData_Type type;
2581 int length;
2582 uint8_t* values;
2583 } as_typed_data;
2584 struct {
2585 Dart_TypedData_Type type;
2586 int length;
2587 uint8_t* data;
2588 void* peer;
2589 Dart_WeakPersistentHandleFinalizer callback;
2590 } as_external_typed_data;
2591 } value;
2592 } Dart_CObject;
2593
2594 /**
2595 * Posts a message on some port. The message will contain the
2596 * Dart_CObject object graph rooted in 'message'.
2597 *
2598 * While the message is being sent the state of the graph of
2599 * Dart_CObject structures rooted in 'message' should not be accessed,
2600 * as the message generation will make temporary modifications to the
2601 * data. When the message has been sent the graph will be fully
2602 * restored.
2603 *
2604 * \param port_id The destination port.
2605 * \param message The message to send.
2606 *
2607 * \return True if the message was posted.
2608 */
2609 DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message);
2610
2611 /**
2612 * A native message handler.
2613 *
2614 * This handler is associated with a native port by calling
2615 * Dart_NewNativePort.
2616 *
2617 * The message received is decoded into the message structure. The
2618 * lifetime of the message data is controlled by the caller. All the
2619 * data references from the message are allocated by the caller and
2620 * will be reclaimed when returning to it.
2621 */
2622
2623 typedef void (*Dart_NativeMessageHandler)(Dart_Port dest_port_id,
2624 Dart_Port reply_port_id,
2625 Dart_CObject* message);
2626
2627 /**
2628 * Creates a new native port. When messages are received on this
2629 * native port, then they will be dispatched to the provided native
2630 * message handler.
2631 *
2632 * \param name The name of this port in debugging messages.
2633 * \param handler The C handler to run when messages arrive on the port.
2634 * \param handle_concurrently Is it okay to process requests on this
2635 * native port concurrently?
2636 *
2637 * \return If successful, returns the port id for the native port. In
2638 * case of error, returns ILLEGAL_PORT.
2639 */
2640 DART_EXPORT Dart_Port Dart_NewNativePort(const char* name,
2641 Dart_NativeMessageHandler handler,
2642 bool handle_concurrently);
2643 /* TODO(turnidge): Currently handle_concurrently is ignored. */
2644
2645 /**
2646 * Closes the native port with the given id.
2647 *
2648 * The port must have been allocated by a call to Dart_NewNativePort.
2649 *
2650 * \param native_port_id The id of the native port to close.
2651 *
2652 * \return Returns true if the port was closed successfully.
2653 */
2654 DART_EXPORT bool Dart_CloseNativePort(Dart_Port native_port_id);
2655
2656 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ 2165 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */
OLDNEW
« no previous file with comments | « runtime/dart-runtime.gyp ('k') | runtime/include/dart_mirrors_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698