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 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1624 intptr_t length); | 1624 intptr_t length); |
| 1625 | 1625 |
| 1626 /** | 1626 /** |
| 1627 * May generate an unhandled exception error. | 1627 * May generate an unhandled exception error. |
| 1628 */ | 1628 */ |
| 1629 DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list, | 1629 DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list, |
| 1630 intptr_t offset, | 1630 intptr_t offset, |
| 1631 uint8_t* native_array, | 1631 uint8_t* native_array, |
| 1632 intptr_t length); | 1632 intptr_t length); |
| 1633 | 1633 |
| 1634 // --- Scalar Lists --- | 1634 // --- Typed Data --- |
| 1635 | 1635 |
| 1636 typedef enum { | 1636 typedef enum { |
| 1637 kByteArray = 0, | 1637 kByteData = 0, |
| 1638 kInt8, | 1638 kInt8, |
| 1639 kUint8, | 1639 kUint8, |
| 1640 kUint8Clamped, | 1640 kUint8Clamped, |
| 1641 kInt16, | 1641 kInt16, |
| 1642 kUint16, | 1642 kUint16, |
| 1643 kInt32, | 1643 kInt32, |
| 1644 kUint32, | 1644 kUint32, |
| 1645 kInt64, | 1645 kInt64, |
| 1646 kUint64, | 1646 kUint64, |
| 1647 kFloat32, | 1647 kFloat32, |
| 1648 kFloat64 | 1648 kFloat64, |
| 1649 } Dart_Scalar_Type; | 1649 kInvalid |
| 1650 } Dart_TypedData_Type; | |
| 1650 | 1651 |
| 1651 /** | 1652 /** |
| 1652 * Is this object a ByteArray? | 1653 * Is this object a TypedData? |
| 1654 * | |
| 1655 * \return kInvalid if the object is not a TypedData object or the appropriate | |
| 1656 * Dart_TypedData_Type. | |
| 1653 */ | 1657 */ |
| 1654 DART_EXPORT bool Dart_IsByteArray(Dart_Handle object); | 1658 DART_EXPORT Dart_TypedData_Type Dart_IsTypedData(Dart_Handle object); |
|
Anton Muhin
2013/02/14 12:53:05
It's somewhat weird to have a method named _Is ret
siva
2013/02/14 19:45:42
Renamed to Dart_GetTypeOfTypedData and Dart_GetTyp
| |
| 1655 | 1659 |
| 1656 /** | 1660 /** |
| 1657 * Is this object an external ByteArray? | 1661 * Is this object an external TypedData? |
| 1658 * | 1662 * |
| 1659 * An external ByteArray is a ByteArray which references a fixed array of | 1663 * \return kInvalid if the object is not an external TypedData object or |
| 1660 * bytes which is external to the Dart heap. | 1664 * the appropriate Dart_TypedData_Type. |
| 1661 */ | 1665 */ |
| 1662 DART_EXPORT bool Dart_IsByteArrayExternal(Dart_Handle object); | 1666 DART_EXPORT Dart_TypedData_Type Dart_IsExternalTypedData(Dart_Handle object); |
| 1663 | 1667 |
| 1664 /** | 1668 /** |
| 1665 * Returns a ByteArray of the desired length. | 1669 * Returns a TypedData object of the desired length and type. |
| 1666 * | 1670 * |
| 1667 * \param length The length of the array. | 1671 * \param type The type of the TypedData object. |
| 1672 * \param length The length of the TypedData object (length in type units). | |
| 1668 * | 1673 * |
| 1669 * \return The ByteArray object if no error occurs. Otherwise returns | 1674 * \return The TypedData object if no error occurs. Otherwise returns |
| 1670 * an error handle. | 1675 * an error handle. |
| 1671 */ | 1676 */ |
| 1672 DART_EXPORT Dart_Handle Dart_NewByteArray(intptr_t length); | 1677 DART_EXPORT Dart_Handle Dart_NewTypedData(Dart_TypedData_Type type, |
| 1678 intptr_t length); | |
| 1673 | 1679 |
| 1674 /** | 1680 /** |
| 1675 * Returns a ByteArray which references an external array of 8-bit bytes. | 1681 * Returns a TypedData object which references an external data array. |
| 1676 * | 1682 * |
| 1677 * \param value An array of 8-bit bytes. This array must not move. | 1683 * \param value A data array. This array must not move. |
| 1678 * \param length The length of the array. | 1684 * \param type The type of the data array. |
| 1679 * \param peer An external pointer to associate with this byte array. | 1685 * \param length The length of the data array (length in type units). |
| 1686 * \param peer An external pointer to associate with this array. | |
| 1680 * | 1687 * |
| 1681 * \return The ByteArray object if no error occurs. Otherwise returns | 1688 * \return The TypedData object if no error occurs. Otherwise returns |
| 1682 * an error handle. The ByteArray object is returned in a | 1689 * an error handle. The TypedData object is returned in a |
| 1683 * WeakPersistentHandle which needs to be deleted in the specified callback | 1690 * WeakPersistentHandle which needs to be deleted in the specified callback |
| 1684 * using Dart_DeletePersistentHandle. | 1691 * using Dart_DeletePersistentHandle. |
| 1685 */ | 1692 */ |
| 1686 DART_EXPORT Dart_Handle Dart_NewExternalByteArray( | 1693 DART_EXPORT Dart_Handle Dart_NewExternalTypedData( |
| 1687 uint8_t* data, | 1694 void* data, |
| 1695 Dart_TypedData_Type type, | |
|
Anton Muhin
2013/02/14 12:53:05
absolutely minor, feel free to disregard, but I'd
siva
2013/02/14 19:45:42
Made type the first parameter.
On 2013/02/14 12:5
| |
| 1688 intptr_t length, | 1696 intptr_t length, |
| 1689 void* peer, | 1697 void* peer, |
| 1690 Dart_WeakPersistentHandleFinalizer callback); | 1698 Dart_WeakPersistentHandleFinalizer callback); |
| 1691 | 1699 |
| 1692 /** | 1700 /** |
| 1693 * Returns a clamped ByteArray which references an external array of | 1701 * Retrieves the peer pointer associated with an external TypedData object. |
| 1694 * 8-bit bytes. | |
| 1695 * A clamped ByteArray differs from ByteArray above in the indexed store | |
| 1696 * operation where negative values are clamped to 0 and values above 255 are | |
| 1697 * clamped to 255. | |
| 1698 * | |
| 1699 * \param value An array of 8-bit bytes. This array must not move. | |
| 1700 * \param length The length of the array. | |
| 1701 * \param peer An external pointer to associate with this byte array. | |
| 1702 * | |
| 1703 * \return The clamped ByteArray object if no error occurs. Otherwise returns | |
| 1704 * an error handle. The clamped ByteArray object is returned in a | |
| 1705 * WeakPersistentHandle which needs to be deleted in the specified callback | |
| 1706 * using Dart_DeletePersistentHandle. | |
| 1707 */ | 1702 */ |
| 1708 DART_EXPORT Dart_Handle Dart_NewExternalClampedByteArray( | 1703 DART_EXPORT Dart_Handle Dart_ExternalTypedDataGetPeer(Dart_Handle object, |
| 1709 uint8_t* data, | |
| 1710 intptr_t length, | |
| 1711 void* peer, | |
| 1712 Dart_WeakPersistentHandleFinalizer callback); | |
| 1713 | |
| 1714 /** | |
| 1715 * Retrieves the data pointer associated with an external ByteArray. | |
| 1716 */ | |
| 1717 DART_EXPORT Dart_Handle Dart_ExternalByteArrayGetData(Dart_Handle object, | |
| 1718 void** data); | |
| 1719 | |
| 1720 /** | |
| 1721 * Retrieves the peer pointer associated with an external ByteArray. | |
| 1722 */ | |
| 1723 DART_EXPORT Dart_Handle Dart_ExternalByteArrayGetPeer(Dart_Handle object, | |
| 1724 void** peer); | 1704 void** peer); |
| 1725 | 1705 |
| 1726 /** | 1706 /** |
| 1727 * Acquires access to the internal data address of a scalar list object. | 1707 * Acquires access to the internal data address of a TypedData object. |
| 1728 * | 1708 * |
| 1729 * \param array The scalar list object whose internal data address is to | 1709 * \param object The typed data object whose internal data address is to |
| 1730 * be accessed. | 1710 * be accessed. |
| 1731 * \param type The scalar type of the object is returned here. | 1711 * \param type The type of the object is returned here. |
| 1732 * \param data The internal data address is returned here. | 1712 * \param data The internal data address is returned here. |
| 1733 * \param len Size of the byte array is returned here. | 1713 * \param len Size of the typed array is returned here. |
| 1734 * | 1714 * |
| 1735 * Note: When the internal address of the object is acquired any calls to a | 1715 * Note: When the internal address of the object is acquired any calls to a |
| 1736 * Dart API function that could potentially allocate an object or run | 1716 * Dart API function that could potentially allocate an object or run |
| 1737 * any Dart code will return an error. | 1717 * any Dart code will return an error. |
| 1738 * | 1718 * |
| 1739 * \return Success if the internal data address is acquired successfully. | 1719 * \return Success if the internal data address is acquired successfully. |
| 1740 * Otherwise, returns an error handle. | 1720 * Otherwise, returns an error handle. |
| 1741 */ | 1721 */ |
| 1742 DART_EXPORT Dart_Handle Dart_ScalarListAcquireData(Dart_Handle array, | 1722 DART_EXPORT Dart_Handle Dart_TypedDataAcquireData(Dart_Handle object, |
| 1743 Dart_Scalar_Type* type, | 1723 Dart_TypedData_Type* type, |
| 1744 void** data, | 1724 void** data, |
| 1745 intptr_t* len); | 1725 intptr_t* len); |
| 1746 | 1726 |
| 1747 /** | 1727 /** |
| 1748 * Releases access to the internal data address that was acquired earlier using | 1728 * Releases access to the internal data address that was acquired earlier using |
| 1749 * Dart_ByteArrayAcquireData. | 1729 * Dart_TypedDataAcquireData. |
| 1750 * | 1730 * |
| 1751 * \param array The scalar list object whose internal data address is to be | 1731 * \param object The typed data object whose internal data address is to be |
| 1752 * released. | 1732 * released. |
| 1753 * | 1733 * |
| 1754 * \return Success if the internal data address is released successfully. | 1734 * \return Success if the internal data address is released successfully. |
| 1755 * Otherwise, returns an error handle. | 1735 * Otherwise, returns an error handle. |
| 1756 */ | 1736 */ |
| 1757 DART_EXPORT Dart_Handle Dart_ScalarListReleaseData(Dart_Handle array); | 1737 DART_EXPORT Dart_Handle Dart_TypedDataReleaseData(Dart_Handle array); |
| 1758 | 1738 |
| 1759 | 1739 |
| 1760 // --- Closures --- | 1740 // --- Closures --- |
| 1761 | 1741 |
| 1762 /** | 1742 /** |
| 1763 * Is this object a Closure? | 1743 * Is this object a Closure? |
| 1764 */ | 1744 */ |
| 1765 DART_EXPORT bool Dart_IsClosure(Dart_Handle object); | 1745 DART_EXPORT bool Dart_IsClosure(Dart_Handle object); |
| 1766 | 1746 |
| 1767 /** | 1747 /** |
| (...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2581 * | 2561 * |
| 2582 * \param object An object. | 2562 * \param object An object. |
| 2583 * \param peer A value to store in the peer field. | 2563 * \param peer A value to store in the peer field. |
| 2584 * | 2564 * |
| 2585 * \return Returns an error if 'object' is a subtype of Null, num, or | 2565 * \return Returns an error if 'object' is a subtype of Null, num, or |
| 2586 * bool. | 2566 * bool. |
| 2587 */ | 2567 */ |
| 2588 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); | 2568 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); |
| 2589 | 2569 |
| 2590 #endif // INCLUDE_DART_API_H_ | 2570 #endif // INCLUDE_DART_API_H_ |
| OLD | NEW |