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 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 935 | 935 |
| 936 // --- Message sending/receiving from native code ---- | 936 // --- Message sending/receiving from native code ---- |
| 937 | 937 |
| 938 /** | 938 /** |
| 939 * A Dart_CObject is used for representing Dart objects as native C | 939 * A Dart_CObject is used for representing Dart objects as native C |
| 940 * data outside the Dart heap. These objects are totally detached from | 940 * data outside the Dart heap. These objects are totally detached from |
| 941 * the Dart heap. Only a subset of the Dart objects have a | 941 * the Dart heap. Only a subset of the Dart objects have a |
| 942 * representation as a Dart_CObject. | 942 * representation as a Dart_CObject. |
| 943 * | 943 * |
| 944 * The string encoding in the 'value.as_string' is UTF-8. | 944 * The string encoding in the 'value.as_string' is UTF-8. |
| 945 * | |
| 946 * All the different types from dart:typeddata are exposed as type | |
| 947 * kTypedData. The specific type from dart:typeddata is in the type | |
| 948 * field of the as_typed_data structure. The length in the | |
| 949 * as_typed_data structure is always in bytes. | |
| 945 */ | 950 */ |
| 946 typedef struct _Dart_CObject { | 951 typedef struct _Dart_CObject { |
| 947 enum Type { | 952 enum Type { |
| 948 kNull = 0, | 953 kNull = 0, |
| 949 kBool, | 954 kBool, |
| 950 kInt32, | 955 kInt32, |
| 951 kInt64, | 956 kInt64, |
| 952 kBigint, | 957 kBigint, |
| 953 kDouble, | 958 kDouble, |
| 954 kString, | 959 kString, |
| 955 kArray, | 960 kArray, |
| 956 kUint8Array, | 961 kTypedData, |
| 957 kExternalUint8Array, | 962 kExternalTypedData, |
| 958 kUnsupported, | 963 kUnsupported, |
| 959 kNumberOfTypes | 964 kNumberOfTypes |
| 960 } type; | 965 } type; |
| 966 | |
| 967 enum TypedDataType { | |
| 968 kInt8Array = 0, | |
| 969 kUint8Array, | |
|
siva
2013/04/15 23:28:45
Don't we also need the kUint8ClampedArray type her
| |
| 970 kInt16Array, | |
| 971 kUint16Array, | |
| 972 kNumberOfTypedDataTypes | |
| 973 }; | |
| 974 | |
| 961 union { | 975 union { |
| 962 bool as_bool; | 976 bool as_bool; |
| 963 int32_t as_int32; | 977 int32_t as_int32; |
| 964 int64_t as_int64; | 978 int64_t as_int64; |
| 965 double as_double; | 979 double as_double; |
| 966 char* as_string; | 980 char* as_string; |
| 967 char* as_bigint; | 981 char* as_bigint; |
| 968 struct { | 982 struct { |
| 969 int length; | 983 int length; |
| 970 struct _Dart_CObject** values; | 984 struct _Dart_CObject** values; |
| 971 } as_array; | 985 } as_array; |
| 972 struct { | 986 struct { |
| 987 TypedDataType type; | |
| 973 int length; | 988 int length; |
| 974 uint8_t* values; | 989 uint8_t* values; |
| 975 } as_byte_array; | 990 } as_typed_data; |
| 976 struct { | 991 struct { |
| 992 TypedDataType type; | |
| 977 int length; | 993 int length; |
| 978 uint8_t* data; | 994 uint8_t* data; |
| 979 void* peer; | 995 void* peer; |
| 980 Dart_WeakPersistentHandleFinalizer callback; | 996 Dart_WeakPersistentHandleFinalizer callback; |
| 981 } as_external_byte_array; | 997 } as_external_typed_data; |
| 982 } value; | 998 } value; |
| 983 } Dart_CObject; | 999 } Dart_CObject; |
| 984 | 1000 |
| 985 /** | 1001 /** |
| 986 * Posts a message on some port. The message will contain the | 1002 * Posts a message on some port. The message will contain the |
| 987 * Dart_CObject object graph rooted in 'message'. | 1003 * Dart_CObject object graph rooted in 'message'. |
| 988 * | 1004 * |
| 989 * While the message is being sent the state of the graph of | 1005 * While the message is being sent the state of the graph of |
| 990 * Dart_CObject structures rooted in 'message' should not be accessed, | 1006 * Dart_CObject structures rooted in 'message' should not be accessed, |
| 991 * as the message generation will make temporary modifications to the | 1007 * as the message generation will make temporary modifications to the |
| (...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2573 * | 2589 * |
| 2574 * \param object An object. | 2590 * \param object An object. |
| 2575 * \param peer A value to store in the peer field. | 2591 * \param peer A value to store in the peer field. |
| 2576 * | 2592 * |
| 2577 * \return Returns an error if 'object' is a subtype of Null, num, or | 2593 * \return Returns an error if 'object' is a subtype of Null, num, or |
| 2578 * bool. | 2594 * bool. |
| 2579 */ | 2595 */ |
| 2580 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); | 2596 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); |
| 2581 | 2597 |
| 2582 #endif // INCLUDE_DART_API_H_ | 2598 #endif // INCLUDE_DART_API_H_ |
| OLD | NEW |