Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 * by value (except in cases like out-parameters) and should never be | 65 * by value (except in cases like out-parameters) and should never be |
| 66 * allocated on the heap. | 66 * allocated on the heap. |
| 67 * | 67 * |
| 68 * Most functions in the Dart Embedding API return a handle. When a | 68 * Most functions in the Dart Embedding API return a handle. When a |
| 69 * function completes normally, this will be a valid handle to an | 69 * function completes normally, this will be a valid handle to an |
| 70 * object in the Dart VM heap. This handle may represent the result of | 70 * object in the Dart VM heap. This handle may represent the result of |
| 71 * the operation or it may be a special valid handle used merely to | 71 * the operation or it may be a special valid handle used merely to |
| 72 * indicate successful completion. Note that a valid handle may in | 72 * indicate successful completion. Note that a valid handle may in |
| 73 * some cases refer to the null object. | 73 * some cases refer to the null object. |
| 74 * | 74 * |
| 75 * --- Error handles --- | |
| 76 * | |
| 75 * When a function encounters a problem that prevents it from | 77 * When a function encounters a problem that prevents it from |
| 76 * completing normally, it returns an error handle (See Dart_IsError). | 78 * completing normally, it returns an error handle (See Dart_IsError). |
| 77 * An error handle has an associated error message that gives more | 79 * An error handle has an associated error message that gives more |
| 78 * details about the problem (See Dart_GetError). | 80 * details about the problem (See Dart_GetError). |
| 79 * | 81 * |
| 80 * When an unhandled exception occurs, it is returned as an error | 82 * There are four kinds of error handles that can be produced, |
| 81 * handle that has additional information about the exception (See | 83 * depending on what goes wrong: |
| 82 * Dart_ErrorHasException). This error handle retains information | 84 * |
| 83 * about the exception and the stack trace (See | 85 * - Api error handles are produced when an api function is misused. |
| 84 * Dart_ErrorGetException, Dart_ErrorGetStacktrace, | 86 * This happens when a Dart embedding api function is called with |
| 85 * Dart_RethrowException). | 87 * invalid arguments or in an invalid context. |
| 88 * | |
| 89 * - Unhandled exception error handles are produced when, during the | |
| 90 * execution of Dart code, an exception is thrown but not caught. | |
| 91 * Prototypically this would occur during a call to Dart_Invoke, but | |
| 92 * it can occur in any function which triggers the execution of Dart | |
| 93 * code (for example, Dart_ToString). | |
| 94 * | |
| 95 * An unhandled exception error provides access to an exception and | |
| 96 * stacktrace via the functions Dart_ErrorGetException and | |
| 97 * Dart_ErrorGetStacktrace. | |
| 98 * | |
| 99 * - Compilation error handles are produced when, during the execution | |
| 100 * of Dart code, a compile-time error occurs. As above, this can | |
| 101 * occur in any function which triggers the execution of Dart code. | |
| 102 * | |
| 103 * - Fatal error handles are produced when the system wants to shut | |
| 104 * down the current isolate. | |
| 105 * | |
| 106 * --- Propagating errors --- | |
| 107 * | |
| 108 * When an error handle is returned from the top level invocation of | |
| 109 * Dart code in a program, the embedder must handle the error as they | |
| 110 * see fit. Often, the embedder will print the error message produced | |
| 111 * by Dart_Error and exit the program. | |
| 112 * | |
| 113 * When an error is returned while in the body of a native function, | |
| 114 * it can be propagated by calling Dart_PropagateError. Errors should | |
| 115 * be propagated unless there is a specific reason not to. If an | |
| 116 * error is not propagated then it is ignored. For example, if an | |
| 117 * unhandled exception error is ignored, that effectively "catches" | |
| 118 * the unhandled exception. Fatal errors must always be propagated. | |
| 119 * | |
| 120 * Note that a call to Dart_PropagateError never returns. Instead it | |
| 121 * transfers control non-locally using a setjmp-like mechanism. This | |
| 122 * can be inconvenient if you have resources that you need to clean up | |
| 123 * before propagating the error. When an error is propagated, any | |
| 124 * current scopes created by Dart_EnterScope will be exited. | |
| 125 * | |
| 126 * To deal with this inconvenience, we often return error handles | |
| 127 * rather than propagating them from helper functions. Consider the | |
| 128 * following contrived example: | |
| 129 * | |
| 130 * 1 Dart_Handle isLongStringHelper(Dart_Handle arg) { | |
| 131 * 2 intptr_t* length = 0; | |
| 132 * 3 result = Dart_StringLength(arg, &length); | |
| 133 * 4 if (Dart_IsError(result)) { | |
| 134 * 5 return result | |
| 135 * 6 } | |
| 136 * 7 return Dart_NewBoolean(length > 100); | |
| 137 * 8 } | |
| 138 * 9 | |
| 139 * 10 void NativeFunction_isLongString(Dart_NativeArguments args) { | |
| 140 * 11 Dart_EnterScope(); | |
| 141 * 12 AllocateMyResource(); | |
| 142 * 13 Dart_Handle arg = Dart_GetNativeArgument(args, 0); | |
| 143 * 14 Dart_Handle result = isLongStringHelper(arg); | |
| 144 * 15 if (Dart_IsError(result)) { | |
| 145 * 16 FreeMyResource(); | |
| 146 * 17 Dart_PropagateError(result); | |
|
Ivan Posva
2012/06/11 16:45:02
You might want to make it clear in the code here t
turnidge
2012/06/12 20:51:46
Done.
| |
| 147 * 18 } | |
| 148 * 19 Dart_SetReturnValue(result); | |
| 149 * 20 FreeMyResource(); | |
| 150 * 21 Dart_ExitScope(); | |
| 151 * 22 } | |
| 152 * | |
| 153 * In this example, we have a native function which calls a helper | |
| 154 * function to do its work. On line 5, the helper function could call | |
| 155 * Dart_PropagateError, but that would not give the native function a | |
| 156 * chance to call FreeMyResource(), causing a leak. Instead, the | |
| 157 * helper function returns the error handle to the caller, giving the | |
| 158 * caller a chance to clean up before propagating the error handle. | |
| 159 * | |
| 160 * --- Local and persistent handles --- | |
| 86 * | 161 * |
| 87 * Local handles are allocated within the current scope (see | 162 * Local handles are allocated within the current scope (see |
| 88 * Dart_EnterScope) and go away when the current scope exits. Unless | 163 * Dart_EnterScope) and go away when the current scope exits. Unless |
| 89 * otherwise indicated, callers should assume that all functions in | 164 * otherwise indicated, callers should assume that all functions in |
| 90 * the Dart embedding api return local handles. | 165 * the Dart embedding api return local handles. |
| 91 * | 166 * |
| 92 * Persistent handles are allocated within the current isolate. They | 167 * Persistent handles are allocated within the current isolate. They |
| 93 * can be used to store objects across scopes. Persistent handles have | 168 * can be used to store objects across scopes. Persistent handles have |
| 94 * the lifetime of the current isolate unless they are explicitly | 169 * the lifetime of the current isolate unless they are explicitly |
| 95 * deallocated (see Dart_DeletePersistentHandle). | 170 * deallocated (see Dart_DeletePersistentHandle). |
| 96 */ | 171 */ |
| 97 typedef struct _Dart_Handle* Dart_Handle; | 172 typedef struct _Dart_Handle* Dart_Handle; |
| 98 | 173 |
| 99 typedef void (*Dart_WeakPersistentHandleFinalizer)(Dart_Handle handle, | 174 typedef void (*Dart_WeakPersistentHandleFinalizer)(Dart_Handle handle, |
| 100 void* peer); | 175 void* peer); |
| 101 typedef void (*Dart_PeerFinalizer)(void* peer); | 176 typedef void (*Dart_PeerFinalizer)(void* peer); |
| 102 | 177 |
| 103 /** | 178 /** |
| 104 * Is this an error handle? | 179 * Is this an error handle? |
| 105 * | 180 * |
| 106 * Requires there to be a current isolate. | 181 * Requires there to be a current isolate. |
| 107 */ | 182 */ |
| 108 DART_EXPORT bool Dart_IsError(Dart_Handle handle); | 183 DART_EXPORT bool Dart_IsError(Dart_Handle handle); |
| 109 | 184 |
| 110 /** | 185 /** |
| 186 * Is this an api error handle? | |
| 187 * | |
| 188 * Api error handles are produced when an api function is misused. | |
| 189 * This happens when a Dart embedding api function is called with | |
| 190 * invalid arguments or in an invalid context. | |
| 191 * | |
| 192 * Requires there to be a current isolate. | |
| 193 */ | |
| 194 DART_EXPORT bool Dart_IsApiError(Dart_Handle handle); | |
| 195 | |
| 196 /** | |
| 197 * Is this an unhandled exception error handle? | |
| 198 * | |
| 199 * Unhandled exception error handles are produced when, during the | |
| 200 * execution of Dart code, an exception is thrown but not caught. | |
| 201 * This can occur in any function which triggers the execution of Dart | |
| 202 * code. | |
| 203 * | |
| 204 * See Dart_ErrorGetException and Dart_ErrorGetStacktrace. | |
| 205 * | |
| 206 * Requires there to be a current isolate. | |
| 207 */ | |
| 208 DART_EXPORT bool Dart_IsUnhandledExceptionError(Dart_Handle handle); | |
| 209 | |
| 210 /** | |
| 211 * Is this a compilation error handle? | |
| 212 * | |
| 213 * Compilation error handles are produced when, during the execution | |
| 214 * of Dart code, a compile-time error occurs. This can occur in any | |
| 215 * function which triggers the execution of Dart code. | |
| 216 * | |
| 217 * Requires there to be a current isolate. | |
| 218 */ | |
| 219 DART_EXPORT bool Dart_IsCompilationError(Dart_Handle handle); | |
| 220 | |
| 221 /** | |
| 222 * Is this a fatal error handle? | |
| 223 * | |
| 224 * Fatal error handles are produced when the system wants to shut down | |
| 225 * the current isolate. | |
| 226 * | |
| 227 * Requires there to be a current isolate. | |
| 228 */ | |
| 229 DART_EXPORT bool Dart_IsFatalError(Dart_Handle handle); | |
| 230 | |
| 231 /** | |
| 111 * Gets the error message from an error handle. | 232 * Gets the error message from an error handle. |
| 112 * | 233 * |
| 113 * Requires there to be a current isolate. | 234 * Requires there to be a current isolate. |
| 114 * | 235 * |
| 115 * \return A C string containing an error message if the handle is | 236 * \return A C string containing an error message if the handle is |
| 116 * error. An empty C string ("") if the handle is valid. This C | 237 * error. An empty C string ("") if the handle is valid. This C |
| 117 * String is scope allocated and is only valid until the next call | 238 * String is scope allocated and is only valid until the next call |
| 118 * to Dart_ExitScope. | 239 * to Dart_ExitScope. |
| 119 */ | 240 */ |
| 120 DART_EXPORT const char* Dart_GetError(Dart_Handle handle); | 241 DART_EXPORT const char* Dart_GetError(Dart_Handle handle); |
| 121 | 242 |
| 122 /** | 243 /** |
| 123 * Is this an error handle for an unhandled exception? | 244 * Is this an error handle for an unhandled exception? |
| 124 */ | 245 */ |
| 125 DART_EXPORT bool Dart_ErrorHasException(Dart_Handle handle); | 246 DART_EXPORT bool Dart_ErrorHasException(Dart_Handle handle); |
| 126 | 247 |
| 127 /** | 248 /** |
| 128 * Gets the exception Object from an unhandled exception error handle. | 249 * Gets the exception Object from an unhandled exception error handle. |
| 129 */ | 250 */ |
| 130 DART_EXPORT Dart_Handle Dart_ErrorGetException(Dart_Handle handle); | 251 DART_EXPORT Dart_Handle Dart_ErrorGetException(Dart_Handle handle); |
| 131 | 252 |
| 132 /** | 253 /** |
| 133 * Gets the stack trace Object from an unhandled exception error handle. | 254 * Gets the stack trace Object from an unhandled exception error handle. |
| 134 */ | 255 */ |
| 135 DART_EXPORT Dart_Handle Dart_ErrorGetStacktrace(Dart_Handle handle); | 256 DART_EXPORT Dart_Handle Dart_ErrorGetStacktrace(Dart_Handle handle); |
| 136 | 257 |
| 137 /** | 258 /** |
| 138 * Produces an error handle with the provided error message. | 259 * Produces an api error handle with the provided error message. |
| 139 * | 260 * |
| 140 * Requires there to be a current isolate. | 261 * Requires there to be a current isolate. |
| 141 * | 262 * |
| 142 * \param error A C string containing an error message. | 263 * \param format A printf style format specifier used to construct the |
| 264 * error message. | |
| 143 */ | 265 */ |
| 266 DART_EXPORT Dart_Handle Dart_NewApiError(const char* format, ...); | |
| 267 | |
| 268 /** | |
| 269 * Produces a new unhandled exception error handle. | |
| 270 * | |
| 271 * Requires there to be a current isolate. | |
| 272 * | |
| 273 * \param exception An instance of a Dart object to be thrown. | |
| 274 */ | |
| 275 DART_EXPORT Dart_Handle Dart_NewUnhandledExceptionError(Dart_Handle exception); | |
| 276 | |
| 277 // Deprecated. | |
| 278 // TODO(turnidge): Remove all uses and delete. | |
| 144 DART_EXPORT Dart_Handle Dart_Error(const char* format, ...); | 279 DART_EXPORT Dart_Handle Dart_Error(const char* format, ...); |
| 145 | 280 |
| 146 /** | 281 /** |
| 147 * Propagates an error. | 282 * Propagates an error. |
| 148 * | 283 * |
| 149 * It only makes sense to call this function when there are dart | 284 * If the provided handle is an unhandled exception error, this |
| 150 * frames on the stack. That is, this function should only be called | 285 * function will cause the unhandled exception to be rethrown. |
| 151 * in the C implementation of a native function which has been called | |
| 152 * from Dart code. If this function is called in the top-level | |
| 153 * embedder code, it will return an error, as there is no way to | |
| 154 * further propagate the error. | |
| 155 * | 286 * |
| 156 * The provided handle must be an error handle. (See Dart_IsError.) | 287 * If the error is not an unhandled exception error, we will unwind |
| 288 * the stack to the next C frame. Any intervening Dart frames will | |
| 289 * be discarded. | |
| 157 * | 290 * |
| 158 * If the provided handle is an unhandled exception, this function | 291 * In either case, when an error is propagated any current scopes |
| 159 * will cause the unhandled exception to be rethrown. Otherwise, the | 292 * created by Dart_EnterScope will be exited. |
| 160 * error will be propagated to the caller, discarding any active dart | |
| 161 * frames up to the next C frame. | |
| 162 * | 293 * |
| 163 * \param An error handle. | 294 * See the additonal discussion under "Propagating Errors" at the |
| 295 * beginning of this file. | |
| 296 * | |
| 297 * \param An error handle (See Dart_IsError) | |
| 164 * | 298 * |
| 165 * \return On success, this function does not return. On failure, an | 299 * \return On success, this function does not return. On failure, an |
| 166 * error handle is returned. | 300 * error handle is returned. |
| 167 */ | 301 */ |
| 168 DART_EXPORT Dart_Handle Dart_PropagateError(Dart_Handle handle); | 302 DART_EXPORT Dart_Handle Dart_PropagateError(Dart_Handle handle); |
| 303 // TODO(turnidge): Should this really return an error handle? | |
| 304 // Consider just terminating. | |
| 169 | 305 |
| 170 // Internal routine used for reporting error handles. | 306 // Internal routine used for reporting error handles. |
| 171 DART_EXPORT void _Dart_ReportErrorHandle(const char* file, | 307 DART_EXPORT void _Dart_ReportErrorHandle(const char* file, |
| 172 int line, | 308 int line, |
| 173 const char* handle_string, | 309 const char* handle_string, |
| 174 const char* error); | 310 const char* error); |
| 175 | 311 |
| 176 // TODO(turnidge): Move DART_CHECK_VALID to some sort of dart_utils | 312 // TODO(turnidge): Move DART_CHECK_VALID to some sort of dart_utils |
| 177 // header instead of this header. | 313 // header instead of this header. |
| 178 /** | 314 /** |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 897 * | 1033 * |
| 898 * \return A valid handle if no error occurs during the comparison. | 1034 * \return A valid handle if no error occurs during the comparison. |
| 899 */ | 1035 */ |
| 900 DART_EXPORT Dart_Handle Dart_ObjectEquals(Dart_Handle obj1, | 1036 DART_EXPORT Dart_Handle Dart_ObjectEquals(Dart_Handle obj1, |
| 901 Dart_Handle obj2, | 1037 Dart_Handle obj2, |
| 902 bool* equal); | 1038 bool* equal); |
| 903 | 1039 |
| 904 /** | 1040 /** |
| 905 * Is this object an instance of some type? | 1041 * Is this object an instance of some type? |
| 906 * | 1042 * |
| 907 * The result of the test is returned through the 'instanceif' parameter. | 1043 * The result of the test is returned through the 'instanceof' parameter. |
| 908 * The return value itself is used to indicate success or failure. | 1044 * The return value itself is used to indicate success or failure. |
| 909 * | 1045 * |
| 910 * \param object An object. | 1046 * \param object An object. |
| 911 * \param type A type. | 1047 * \param type A type. |
| 912 * \param instanceof Return true if 'object' is an instance of type 'type'. | 1048 * \param instanceof Return true if 'object' is an instance of type 'type'. |
| 913 * | 1049 * |
| 914 * \return A valid handle if no error occurs during the operation. | 1050 * \return A valid handle if no error occurs during the operation. |
| 915 */ | 1051 */ |
| 916 DART_EXPORT Dart_Handle Dart_ObjectIsType(Dart_Handle object, | 1052 DART_EXPORT Dart_Handle Dart_ObjectIsType(Dart_Handle object, |
| 917 Dart_Handle type, | 1053 Dart_Handle type, |
| 918 bool* instanceof); | 1054 bool* instanceof); |
| 919 | 1055 |
| 1056 // --- Instances ---- | |
| 1057 // For the purposes of the embedding api, not all objects returned are | |
| 1058 // Dart language objects. Within the api, we use the term 'Instance' | |
| 1059 // to indicate handles which refer to true Dart language objects. | |
| 1060 // | |
| 1061 // TODO(turnidge): Reorganize the "Object" section above, pulling down | |
| 1062 // any functions that more properly belong here. | |
| 1063 | |
| 1064 /** | |
| 1065 * Does this handle refer to some Dart language object? | |
| 1066 */ | |
| 1067 DART_EXPORT bool Dart_IsInstance(Dart_Handle object); | |
| 1068 | |
| 1069 /** | |
| 1070 * Gets the class for some Dart language object. | |
| 1071 * | |
| 1072 * \param instance Some Dart object. | |
| 1073 * | |
| 1074 * \return If no error occurs, the class is returned. Otherwise an | |
| 1075 * error handle is returned. | |
| 1076 */ | |
| 1077 DART_EXPORT Dart_Handle Dart_InstanceGetClass(Dart_Handle instance); | |
| 1078 | |
| 920 // --- Numbers ---- | 1079 // --- Numbers ---- |
| 921 | 1080 |
| 922 /** | 1081 /** |
| 923 * Is this object a Number? | 1082 * Is this object a Number? |
| 924 */ | 1083 */ |
| 925 DART_EXPORT bool Dart_IsNumber(Dart_Handle object); | 1084 DART_EXPORT bool Dart_IsNumber(Dart_Handle object); |
| 926 | 1085 |
| 927 // --- Integers ---- | 1086 // --- Integers ---- |
| 928 | 1087 |
| 929 /** | 1088 /** |
| (...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1740 DART_EXPORT Dart_Handle Dart_InvokeClosure(Dart_Handle closure, | 1899 DART_EXPORT Dart_Handle Dart_InvokeClosure(Dart_Handle closure, |
| 1741 int number_of_arguments, | 1900 int number_of_arguments, |
| 1742 Dart_Handle* arguments); | 1901 Dart_Handle* arguments); |
| 1743 | 1902 |
| 1744 // DEPRECATED: The API below is a temporary hack. | 1903 // DEPRECATED: The API below is a temporary hack. |
| 1745 DART_EXPORT int64_t Dart_ClosureSmrck(Dart_Handle object); | 1904 DART_EXPORT int64_t Dart_ClosureSmrck(Dart_Handle object); |
| 1746 | 1905 |
| 1747 // DEPRECATED: The API below is a temporary hack. | 1906 // DEPRECATED: The API below is a temporary hack. |
| 1748 DART_EXPORT void Dart_ClosureSetSmrck(Dart_Handle object, int64_t value); | 1907 DART_EXPORT void Dart_ClosureSetSmrck(Dart_Handle object, int64_t value); |
| 1749 | 1908 |
| 1909 // --- Classes and Interfaces --- | |
| 1910 | |
| 1911 /** | |
| 1912 * Is this a class handle? | |
| 1913 * | |
| 1914 * Most parts of the dart embedding api do not distinguish between | |
| 1915 * classes and interfaces. For example, Dart_GetClass can return a | |
| 1916 * class or an interface and Dart_New can instantiate a class or an | |
| 1917 * interface. The exceptions are Dart_IsClass and Dart_IsInterface, | |
| 1918 * which can be used to distinguish whether a handle refers to a class | |
| 1919 * or an interface. | |
| 1920 */ | |
| 1921 DART_EXPORT bool Dart_IsClass(Dart_Handle handle); | |
| 1922 | |
| 1923 /** | |
| 1924 * Is this an interface handle? | |
| 1925 * | |
| 1926 * Most parts of the dart embedding api do not distinguish between | |
| 1927 * classes and interfaces. For example, Dart_GetClass can return a | |
| 1928 * class or an interface and Dart_New can instantiate a class or an | |
| 1929 * interface. The exceptions are Dart_IsClass and Dart_IsInterface, | |
| 1930 * which can be used to distinguish whether a handle refers to a class | |
| 1931 * or an interface. | |
| 1932 */ | |
| 1933 DART_EXPORT bool Dart_IsInterface(Dart_Handle handle); | |
| 1934 | |
| 1935 /** | |
| 1936 * Returns the class name for the provided class or interface. | |
| 1937 */ | |
| 1938 DART_EXPORT Dart_Handle Dart_ClassName(Dart_Handle clazz); | |
| 1939 | |
| 1940 /** | |
| 1941 * Returns the library for the provided class or interface. | |
| 1942 */ | |
| 1943 DART_EXPORT Dart_Handle Dart_ClassGetLibrary(Dart_Handle clazz); | |
| 1944 | |
| 1945 /** | |
| 1946 * Returns the default factory class for the provided class or | |
| 1947 * interface. | |
| 1948 * | |
| 1949 * Only interfaces may have default fadctory classes. If the class or | |
| 1950 * interface has no default factory class, this function returns | |
| 1951 * Dart_Null(). | |
| 1952 */ | |
| 1953 DART_EXPORT Dart_Handle Dart_ClassGetDefault(Dart_Handle clazz); | |
| 1954 | |
| 1955 /** | |
| 1956 * Returns the number of interfaces directly implemented by some class | |
| 1957 * or interface. | |
| 1958 * | |
| 1959 * TODO(turnidge): Finish documentation. | |
| 1960 */ | |
| 1961 DART_EXPORT Dart_Handle Dart_ClassGetInterfaceCount(Dart_Handle clazz, | |
| 1962 intptr_t* count); | |
| 1963 | |
| 1964 /** | |
| 1965 * Returns the interface at some index in the list of interfaces some | |
| 1966 * class or inteface. | |
| 1967 * | |
| 1968 * TODO(turnidge): Finish documentation. | |
| 1969 */ | |
| 1970 DART_EXPORT Dart_Handle Dart_ClassGetInterfaceAt(Dart_Handle clazz, | |
| 1971 intptr_t index); | |
| 1972 | |
| 1750 // --- Constructors, Methods, and Fields --- | 1973 // --- Constructors, Methods, and Fields --- |
| 1751 | 1974 |
| 1752 /** | 1975 /** |
| 1753 * Invokes a constructor, creating a new object. | 1976 * Invokes a constructor, creating a new object. |
| 1754 * | 1977 * |
| 1755 * This function allows hidden constructors (constructors with leading | 1978 * This function allows hidden constructors (constructors with leading |
| 1756 * underscores) to be called. | 1979 * underscores) to be called. |
| 1757 * | 1980 * |
| 1758 * \param clazz A class or an interface. | 1981 * \param clazz A class or an interface. |
| 1759 * \param constructor_name The name of the constructor to invoke. Use | 1982 * \param constructor_name The name of the constructor to invoke. Use |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1870 /** | 2093 /** |
| 1871 * Sets the value of a native field. | 2094 * Sets the value of a native field. |
| 1872 * | 2095 * |
| 1873 * TODO(turnidge): Document. | 2096 * TODO(turnidge): Document. |
| 1874 */ | 2097 */ |
| 1875 DART_EXPORT Dart_Handle Dart_SetNativeInstanceField(Dart_Handle obj, | 2098 DART_EXPORT Dart_Handle Dart_SetNativeInstanceField(Dart_Handle obj, |
| 1876 int index, | 2099 int index, |
| 1877 intptr_t value); | 2100 intptr_t value); |
| 1878 | 2101 |
| 1879 // --- Exceptions ---- | 2102 // --- Exceptions ---- |
| 2103 // TODO(turnidge): Remove these functions from the api and replace all | |
| 2104 // uses with Dart_NewUnhandledExceptionError. | |
| 1880 | 2105 |
| 1881 /** | 2106 /** |
| 1882 * Throws an exception. | 2107 * Throws an exception. |
| 1883 * | 2108 * |
| 1884 * Throws an exception, unwinding all dart frames on the stack. If | 2109 * Throws an exception, unwinding all dart frames on the stack. If |
| 1885 * successful, this function does not return. Note that this means | 2110 * successful, this function does not return. Note that this means |
| 1886 * that the destructors of any stack-allocated C++ objects will not be | 2111 * that the destructors of any stack-allocated C++ objects will not be |
| 1887 * called. If there are no Dart frames on the stack, an error occurs. | 2112 * called. If there are no Dart frames on the stack, an error occurs. |
| 1888 * | 2113 * |
| 1889 * \return An error handle if the exception was not thrown. | 2114 * \return An error handle if the exception was not thrown. |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2071 /** | 2296 /** |
| 2072 * Returns the name of a library as declared in the #library directive. | 2297 * Returns the name of a library as declared in the #library directive. |
| 2073 */ | 2298 */ |
| 2074 DART_EXPORT Dart_Handle Dart_LibraryName(Dart_Handle library); | 2299 DART_EXPORT Dart_Handle Dart_LibraryName(Dart_Handle library); |
| 2075 | 2300 |
| 2076 /** | 2301 /** |
| 2077 * Returns the url from which a library was loaded. | 2302 * Returns the url from which a library was loaded. |
| 2078 */ | 2303 */ |
| 2079 DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library); | 2304 DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library); |
| 2080 | 2305 |
| 2306 /** | |
| 2307 * Returns a list of the names of all classes and interfaces declared | |
| 2308 * in a library. | |
| 2309 * | |
| 2310 * \return If no error occurs, a list of strings is returned. | |
| 2311 * Otherwise an erorr handle is returned. | |
| 2312 */ | |
| 2313 DART_EXPORT Dart_Handle Dart_LibraryGetClassNames(Dart_Handle library); | |
| 2314 | |
| 2081 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url); | 2315 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url); |
| 2082 // TODO(turnidge): Consider returning Dart_Null() when the library is | 2316 // TODO(turnidge): Consider returning Dart_Null() when the library is |
| 2083 // not found to distinguish that from a true error case. | 2317 // not found to distinguish that from a true error case. |
| 2084 | 2318 |
| 2085 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, | 2319 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, |
| 2086 Dart_Handle source); | 2320 Dart_Handle source); |
| 2087 | 2321 |
| 2088 | 2322 |
| 2089 DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library, | 2323 DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library, |
| 2090 Dart_Handle import); | 2324 Dart_Handle import); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 2113 // information that can be used for better profile reports for | 2347 // information that can be used for better profile reports for |
| 2114 // dynamically generated code. | 2348 // dynamically generated code. |
| 2115 DART_EXPORT void Dart_InitPprofSupport(); | 2349 DART_EXPORT void Dart_InitPprofSupport(); |
| 2116 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); | 2350 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); |
| 2117 | 2351 |
| 2118 // Support for generating flow graph compiler debugging output into a file. | 2352 // Support for generating flow graph compiler debugging output into a file. |
| 2119 typedef void (*FileWriterFunction)(const char* buffer, int64_t num_bytes); | 2353 typedef void (*FileWriterFunction)(const char* buffer, int64_t num_bytes); |
| 2120 DART_EXPORT void Dart_InitFlowGraphPrinting(FileWriterFunction function); | 2354 DART_EXPORT void Dart_InitFlowGraphPrinting(FileWriterFunction function); |
| 2121 | 2355 |
| 2122 #endif // INCLUDE_DART_API_H_ | 2356 #endif // INCLUDE_DART_API_H_ |
| OLD | NEW |