| OLD | NEW | 
|---|
| 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 2137 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2148  * native function by index. It also allows the return value of a | 2148  * native function by index. It also allows the return value of a | 
| 2149  * native function to be set. | 2149  * native function to be set. | 
| 2150  */ | 2150  */ | 
| 2151 typedef struct _Dart_NativeArguments* Dart_NativeArguments; | 2151 typedef struct _Dart_NativeArguments* Dart_NativeArguments; | 
| 2152 | 2152 | 
| 2153 /** | 2153 /** | 
| 2154  * Extracts current isolate data from the native arguments structure. | 2154  * Extracts current isolate data from the native arguments structure. | 
| 2155  */ | 2155  */ | 
| 2156 DART_EXPORT void* Dart_GetNativeIsolateData(Dart_NativeArguments args); | 2156 DART_EXPORT void* Dart_GetNativeIsolateData(Dart_NativeArguments args); | 
| 2157 | 2157 | 
|  | 2158 typedef enum { | 
|  | 2159   Dart_NativeArgument_kBool = 0, | 
|  | 2160   Dart_NativeArgument_kInt32, | 
|  | 2161   Dart_NativeArgument_kUint32, | 
|  | 2162   Dart_NativeArgument_kInt64, | 
|  | 2163   Dart_NativeArgument_kUint64, | 
|  | 2164   Dart_NativeArgument_kDouble, | 
|  | 2165   Dart_NativeArgument_kString, | 
|  | 2166   Dart_NativeArgument_kInstance, | 
|  | 2167   Dart_NativeArgument_kNativeFields, | 
|  | 2168 } Dart_NativeArgument_Type; | 
|  | 2169 | 
|  | 2170 typedef struct _Dart_NativeArgument_Descriptor { | 
|  | 2171   uint8_t type; | 
|  | 2172   uint8_t index; | 
|  | 2173 } Dart_NativeArgument_Descriptor; | 
|  | 2174 | 
|  | 2175 typedef union _Dart_NativeArgument_Value { | 
|  | 2176   bool as_bool; | 
|  | 2177   int32_t as_int32; | 
|  | 2178   uint32_t as_uint32; | 
|  | 2179   int64_t as_int64; | 
|  | 2180   uint64_t as_uint64; | 
|  | 2181   double as_double; | 
|  | 2182   struct { | 
|  | 2183     Dart_Handle dart_str; | 
|  | 2184     void* peer; | 
|  | 2185   } as_string; | 
|  | 2186   struct { | 
|  | 2187     intptr_t num_fields; | 
|  | 2188     intptr_t* values; | 
|  | 2189   } as_native_fields; | 
|  | 2190   Dart_Handle as_instance; | 
|  | 2191 } Dart_NativeArgument_Value; | 
|  | 2192 | 
|  | 2193 enum { | 
|  | 2194   kNativeArgNumberPos = 0, | 
|  | 2195   kNativeArgNumberSize = 8, | 
|  | 2196   kNativeArgTypePos = kNativeArgNumberPos + kNativeArgNumberSize, | 
|  | 2197   kNativeArgTypeSize = 8, | 
|  | 2198 }; | 
|  | 2199 | 
|  | 2200 #define BITMASK(size) ((1 << size) - 1) | 
|  | 2201 #define DART_NATIVE_ARG_DESCRIPTOR(type, position)                             \ | 
|  | 2202   (((type & BITMASK(kNativeArgTypeSize)) << kNativeArgTypePos) |               \ | 
|  | 2203     (position & BITMASK(kNativeArgNumberSize))) | 
|  | 2204 | 
|  | 2205 /** | 
|  | 2206  * Gets the native arguments based on the types passed in and populates | 
|  | 2207  * the passed arguments buffer with appropriate native values. | 
|  | 2208  * | 
|  | 2209  * \param args the Native arguments block passed into the native call. | 
|  | 2210  * \param num_arguments length of argument descriptor array and argument | 
|  | 2211  *   values array passed in. | 
|  | 2212  * \param arg_descriptors an array that describes the arguments that | 
|  | 2213  *   need to be retrieved. For each argument to be retrieved the descriptor | 
|  | 2214  *   contains the argument number (0, 1 etc.) and the argument type | 
|  | 2215  *   described using Dart_NativeArgument_Type, e.g: | 
|  | 2216  *   DART_NATIVE_ARG_DESCRIPTOR(Dart_NativeArgument_kBool, 1) indicates | 
|  | 2217  *   that the first argument is to be retrieved and it should be a boolean. | 
|  | 2218  * \param arg_values array into which the native arguments need to be | 
|  | 2219  *   extracted into, the array is allocated by the caller (it could be | 
|  | 2220  *   stack allocated to avoid the malloc/free performance overhead). | 
|  | 2221  * | 
|  | 2222  * \return Success if all the arguments could be extracted correctly, | 
|  | 2223  *   returns an error handle if there were any errors while extracting the | 
|  | 2224  *   arguments (mismatched number of arguments, incorrect types, etc.). | 
|  | 2225  */ | 
|  | 2226 DART_EXPORT Dart_Handle Dart_GetNativeArguments( | 
|  | 2227     Dart_NativeArguments args, | 
|  | 2228     int num_arguments, | 
|  | 2229     const Dart_NativeArgument_Descriptor* arg_descriptors, | 
|  | 2230     Dart_NativeArgument_Value* arg_values); | 
|  | 2231 | 
|  | 2232 | 
| 2158 /** | 2233 /** | 
| 2159  * Gets the native argument at some index. | 2234  * Gets the native argument at some index. | 
| 2160  */ | 2235  */ | 
| 2161 DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, | 2236 DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, | 
| 2162                                                int index); | 2237                                                int index); | 
| 2163 /* TODO(turnidge): Specify the behavior of an out-of-bounds access. */ | 2238 /* TODO(turnidge): Specify the behavior of an out-of-bounds access. */ | 
| 2164 | 2239 | 
| 2165 /** | 2240 /** | 
| 2166  * Gets the number of native arguments. | 2241  * Gets the number of native arguments. | 
| 2167  */ | 2242  */ | 
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2639  * NOTE: If multiple callbacks with the same name are registered, only the | 2714  * NOTE: If multiple callbacks with the same name are registered, only the | 
| 2640  * last callback registered will be remembered. | 2715  * last callback registered will be remembered. | 
| 2641  */ | 2716  */ | 
| 2642 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 2717 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 
| 2643     const char* name, | 2718     const char* name, | 
| 2644     Dart_ServiceRequestCallback callback, | 2719     Dart_ServiceRequestCallback callback, | 
| 2645     void* user_data); | 2720     void* user_data); | 
| 2646 | 2721 | 
| 2647 | 2722 | 
| 2648 #endif  /* INCLUDE_DART_API_H_ */  /* NOLINT */ | 2723 #endif  /* INCLUDE_DART_API_H_ */  /* NOLINT */ | 
| OLD | NEW | 
|---|