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