Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: include/dart_api.h

Issue 12255018: Add typed data interface to Dart API, this only changes the C++ API as dicussed in a previous email… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « bin/socket.cc ('k') | vm/dart_api_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 * Return type if this object is a TypedData object.
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_GetTypeOfTypedData(Dart_Handle object);
1655 1659
1656 /** 1660 /**
1657 * Is this object an external ByteArray? 1661 * Return type if this object is an external TypedData object.
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_GetTypeOfExternalTypedData(
1667 Dart_Handle object);
1663 1668
1664 /** 1669 /**
1665 * Returns a ByteArray of the desired length. 1670 * Returns a TypedData object of the desired length and type.
1666 * 1671 *
1667 * \param length The length of the array. 1672 * \param type The type of the TypedData object.
1673 * \param length The length of the TypedData object (length in type units).
1668 * 1674 *
1669 * \return The ByteArray object if no error occurs. Otherwise returns 1675 * \return The TypedData object if no error occurs. Otherwise returns
1670 * an error handle. 1676 * an error handle.
1671 */ 1677 */
1672 DART_EXPORT Dart_Handle Dart_NewByteArray(intptr_t length); 1678 DART_EXPORT Dart_Handle Dart_NewTypedData(Dart_TypedData_Type type,
1679 intptr_t length);
1673 1680
1674 /** 1681 /**
1675 * Returns a ByteArray which references an external array of 8-bit bytes. 1682 * Returns a TypedData object which references an external data array.
1676 * 1683 *
1677 * \param value An array of 8-bit bytes. This array must not move. 1684 * \param type The type of the data array.
1678 * \param length The length of the array. 1685 * \param value A data array. This array must not move.
1679 * \param peer An external pointer to associate with this byte array. 1686 * \param length The length of the data array (length in type units).
1687 * \param peer An external pointer to associate with this array.
1680 * 1688 *
1681 * \return The ByteArray object if no error occurs. Otherwise returns 1689 * \return The TypedData object if no error occurs. Otherwise returns
1682 * an error handle. The ByteArray object is returned in a 1690 * an error handle. The TypedData object is returned in a
1683 * WeakPersistentHandle which needs to be deleted in the specified callback 1691 * WeakPersistentHandle which needs to be deleted in the specified callback
1684 * using Dart_DeletePersistentHandle. 1692 * using Dart_DeletePersistentHandle.
1685 */ 1693 */
1686 DART_EXPORT Dart_Handle Dart_NewExternalByteArray( 1694 DART_EXPORT Dart_Handle Dart_NewExternalTypedData(
1687 uint8_t* data, 1695 Dart_TypedData_Type type,
1696 void* data,
1688 intptr_t length, 1697 intptr_t length,
1689 void* peer, 1698 void* peer,
1690 Dart_WeakPersistentHandleFinalizer callback); 1699 Dart_WeakPersistentHandleFinalizer callback);
1691 1700
1692 /** 1701 /**
1693 * Returns a clamped ByteArray which references an external array of 1702 * 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 */ 1703 */
1708 DART_EXPORT Dart_Handle Dart_NewExternalClampedByteArray( 1704 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); 1705 void** peer);
1725 1706
1726 /** 1707 /**
1727 * Acquires access to the internal data address of a scalar list object. 1708 * Acquires access to the internal data address of a TypedData object.
1728 * 1709 *
1729 * \param array The scalar list object whose internal data address is to 1710 * \param object The typed data object whose internal data address is to
1730 * be accessed. 1711 * be accessed.
1731 * \param type The scalar type of the object is returned here. 1712 * \param type The type of the object is returned here.
1732 * \param data The internal data address is returned here. 1713 * \param data The internal data address is returned here.
1733 * \param len Size of the byte array is returned here. 1714 * \param len Size of the typed array is returned here.
1734 * 1715 *
1735 * Note: When the internal address of the object is acquired any calls to a 1716 * 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 1717 * Dart API function that could potentially allocate an object or run
1737 * any Dart code will return an error. 1718 * any Dart code will return an error.
1738 * 1719 *
1739 * \return Success if the internal data address is acquired successfully. 1720 * \return Success if the internal data address is acquired successfully.
1740 * Otherwise, returns an error handle. 1721 * Otherwise, returns an error handle.
1741 */ 1722 */
1742 DART_EXPORT Dart_Handle Dart_ScalarListAcquireData(Dart_Handle array, 1723 DART_EXPORT Dart_Handle Dart_TypedDataAcquireData(Dart_Handle object,
1743 Dart_Scalar_Type* type, 1724 Dart_TypedData_Type* type,
1744 void** data, 1725 void** data,
1745 intptr_t* len); 1726 intptr_t* len);
1746 1727
1747 /** 1728 /**
1748 * Releases access to the internal data address that was acquired earlier using 1729 * Releases access to the internal data address that was acquired earlier using
1749 * Dart_ByteArrayAcquireData. 1730 * Dart_TypedDataAcquireData.
1750 * 1731 *
1751 * \param array The scalar list object whose internal data address is to be 1732 * \param object The typed data object whose internal data address is to be
1752 * released. 1733 * released.
1753 * 1734 *
1754 * \return Success if the internal data address is released successfully. 1735 * \return Success if the internal data address is released successfully.
1755 * Otherwise, returns an error handle. 1736 * Otherwise, returns an error handle.
1756 */ 1737 */
1757 DART_EXPORT Dart_Handle Dart_ScalarListReleaseData(Dart_Handle array); 1738 DART_EXPORT Dart_Handle Dart_TypedDataReleaseData(Dart_Handle array);
1758 1739
1759 1740
1760 // --- Closures --- 1741 // --- Closures ---
1761 1742
1762 /** 1743 /**
1763 * Is this object a Closure? 1744 * Is this object a Closure?
1764 */ 1745 */
1765 DART_EXPORT bool Dart_IsClosure(Dart_Handle object); 1746 DART_EXPORT bool Dart_IsClosure(Dart_Handle object);
1766 1747
1767 /** 1748 /**
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
2581 * 2562 *
2582 * \param object An object. 2563 * \param object An object.
2583 * \param peer A value to store in the peer field. 2564 * \param peer A value to store in the peer field.
2584 * 2565 *
2585 * \return Returns an error if 'object' is a subtype of Null, num, or 2566 * \return Returns an error if 'object' is a subtype of Null, num, or
2586 * bool. 2567 * bool.
2587 */ 2568 */
2588 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); 2569 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer);
2589 2570
2590 #endif // INCLUDE_DART_API_H_ 2571 #endif // INCLUDE_DART_API_H_
OLDNEW
« no previous file with comments | « bin/socket.cc ('k') | vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698