| 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 // --- Byte Arrays --- | 1634 // --- Scalar Lists --- |
| 1635 |
| 1636 typedef enum { |
| 1637 kByteArray = 0, |
| 1638 kInt8, |
| 1639 kUint8, |
| 1640 kUint8Clamped, |
| 1641 kInt16, |
| 1642 kUint16, |
| 1643 kInt32, |
| 1644 kUint32, |
| 1645 kInt64, |
| 1646 kUint64, |
| 1647 kFloat32, |
| 1648 kFloat64 |
| 1649 } Dart_Scalar_Type; |
| 1635 | 1650 |
| 1636 /** | 1651 /** |
| 1637 * Is this object a ByteArray? | 1652 * Is this object a ByteArray? |
| 1638 */ | 1653 */ |
| 1639 DART_EXPORT bool Dart_IsByteArray(Dart_Handle object); | 1654 DART_EXPORT bool Dart_IsByteArray(Dart_Handle object); |
| 1640 | 1655 |
| 1641 /** | 1656 /** |
| 1642 * Is this object an external ByteArray? | 1657 * Is this object an external ByteArray? |
| 1643 * | 1658 * |
| 1644 * An external ByteArray is a ByteArray which references a fixed array of | 1659 * An external ByteArray is a ByteArray which references a fixed array of |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 DART_EXPORT Dart_Handle Dart_ExternalByteArrayGetData(Dart_Handle object, | 1712 DART_EXPORT Dart_Handle Dart_ExternalByteArrayGetData(Dart_Handle object, |
| 1698 void** data); | 1713 void** data); |
| 1699 | 1714 |
| 1700 /** | 1715 /** |
| 1701 * Retrieves the peer pointer associated with an external ByteArray. | 1716 * Retrieves the peer pointer associated with an external ByteArray. |
| 1702 */ | 1717 */ |
| 1703 DART_EXPORT Dart_Handle Dart_ExternalByteArrayGetPeer(Dart_Handle object, | 1718 DART_EXPORT Dart_Handle Dart_ExternalByteArrayGetPeer(Dart_Handle object, |
| 1704 void** peer); | 1719 void** peer); |
| 1705 | 1720 |
| 1706 /** | 1721 /** |
| 1707 * Gets an int8_t at some byte offset in a ByteArray. | 1722 * Acquires access to the internal data address of a scalar list object. |
| 1708 * | 1723 * |
| 1709 * If the byte offset is out of bounds, an error occurs. | 1724 * \param array The scalar list object whose internal data address is to |
| 1725 * be accessed. |
| 1726 * \param type The scalar type of the object is returned here. |
| 1727 * \param data The internal data address is returned here. |
| 1728 * \param len Size of the byte array is returned here. |
| 1710 * | 1729 * |
| 1711 * \param array A ByteArray. | 1730 * Note: When the internal address of the object is acquired any calls to a |
| 1712 * \param offset A valid byte offset into the List. | 1731 * Dart API function that could potentially allocate an object or run |
| 1713 * \param value Returns the value of the int8_t. | 1732 * any Dart code will return an error. |
| 1714 * | 1733 * |
| 1715 * \return A valid handle if no error occurs during the operation. | 1734 * \return Success if the internal data address is acquired successfully. |
| 1735 * Otherwise, returns an error handle. |
| 1716 */ | 1736 */ |
| 1717 DART_EXPORT Dart_Handle Dart_ByteArrayGetInt8At(Dart_Handle array, | 1737 DART_EXPORT Dart_Handle Dart_ScalarListAcquireData(Dart_Handle array, |
| 1718 intptr_t offset, | 1738 Dart_Scalar_Type* type, |
| 1719 int8_t* value); | 1739 void** data, |
| 1740 intptr_t* len); |
| 1720 | 1741 |
| 1721 /** | 1742 /** |
| 1722 * Sets an int8_t at some byte offset in a ByteArray. | 1743 * Releases access to the internal data address that was acquired earlier using |
| 1744 * Dart_ByteArrayAcquireData. |
| 1723 * | 1745 * |
| 1724 * If the byte offset is out of bounds, an error occurs. | 1746 * \param array The scalar list object whose internal data address is to be |
| 1747 * released. |
| 1725 * | 1748 * |
| 1726 * \param array A ByteArray. | 1749 * \return Success if the internal data address is released successfully. |
| 1727 * \param offset A valid byte offset into the ByteArray. | 1750 * Otherwise, returns an error handle. |
| 1728 * \param value The int8_t to put into the ByteArray. | |
| 1729 * | |
| 1730 * \return A valid handle if no error occurs during the operation. | |
| 1731 */ | 1751 */ |
| 1732 DART_EXPORT Dart_Handle Dart_ByteArraySetInt8At(Dart_Handle array, | 1752 DART_EXPORT Dart_Handle Dart_ScalarListReleaseData(Dart_Handle array); |
| 1733 intptr_t offset, | |
| 1734 int8_t value); | |
| 1735 | 1753 |
| 1736 /** | |
| 1737 * Gets a uint8_t at some byte offset in a ByteArray. | |
| 1738 * | |
| 1739 * If the byte offset is out of bounds, an error occurs. | |
| 1740 * | |
| 1741 * \param array A ByteArray. | |
| 1742 * \param offset A valid byte offset into the List. | |
| 1743 * \param value Returns the value of the uint8_t. | |
| 1744 * | |
| 1745 * \return A valid handle if no error occurs during the operation. | |
| 1746 */ | |
| 1747 DART_EXPORT Dart_Handle Dart_ByteArrayGetUint8At(Dart_Handle array, | |
| 1748 intptr_t offset, | |
| 1749 uint8_t* value); | |
| 1750 | |
| 1751 /** | |
| 1752 * Sets a uint8_t at some byte offset in a ByteArray. | |
| 1753 * | |
| 1754 * If the byte offset is out of bounds, an error occurs. | |
| 1755 * | |
| 1756 * \param array A ByteArray. | |
| 1757 * \param offset A valid byte offset into the ByteArray. | |
| 1758 * \param value The uint8_t to put into the ByteArray. | |
| 1759 * | |
| 1760 * \return A valid handle if no error occurs during the operation. | |
| 1761 */ | |
| 1762 DART_EXPORT Dart_Handle Dart_ByteArraySetUint8At(Dart_Handle array, | |
| 1763 intptr_t offset, | |
| 1764 uint8_t value); | |
| 1765 | |
| 1766 /** | |
| 1767 * Gets an int16_t at some byte offset in a ByteArray. | |
| 1768 * | |
| 1769 * If the byte offset is out of bounds, an error occurs. | |
| 1770 * | |
| 1771 * \param array A ByteArray. | |
| 1772 * \param offset A valid byte offset into the List. | |
| 1773 * \param value Returns the value of the int16_t. | |
| 1774 * | |
| 1775 * \return A valid handle if no error occurs during the operation. | |
| 1776 */ | |
| 1777 DART_EXPORT Dart_Handle Dart_ByteArrayGetInt16At(Dart_Handle array, | |
| 1778 intptr_t offset, | |
| 1779 int16_t* value); | |
| 1780 | |
| 1781 /** | |
| 1782 * Sets an int16_t at some byte offset in a ByteArray. | |
| 1783 * | |
| 1784 * If the byte offset is out of bounds, an error occurs. | |
| 1785 * | |
| 1786 * \param array A ByteArray. | |
| 1787 * \param offset A valid byte offset into the ByteArray. | |
| 1788 * \param value The int16_t to put into the ByteArray. | |
| 1789 * | |
| 1790 * \return A valid handle if no error occurs during the operation. | |
| 1791 */ | |
| 1792 DART_EXPORT Dart_Handle Dart_ByteArraySetInt16At(Dart_Handle array, | |
| 1793 intptr_t offset, | |
| 1794 int16_t value); | |
| 1795 | |
| 1796 /** | |
| 1797 * Gets a uint16_t at some byte offset in a ByteArray. | |
| 1798 * | |
| 1799 * If the byte offset is out of bounds, an error occurs. | |
| 1800 * | |
| 1801 * \param array A ByteArray. | |
| 1802 * \param offset A valid byte offset into the List. | |
| 1803 * \param value Returns the value of the uint16_t. | |
| 1804 * | |
| 1805 * \return A valid handle if no error occurs during the operation. | |
| 1806 */ | |
| 1807 DART_EXPORT Dart_Handle Dart_ByteArrayGetUint16At(Dart_Handle array, | |
| 1808 intptr_t offset, | |
| 1809 uint16_t* value); | |
| 1810 | |
| 1811 /** | |
| 1812 * Sets a uint16_t at some byte offset in a ByteArray. | |
| 1813 * | |
| 1814 * If the byte offset is out of bounds, an error occurs. | |
| 1815 * | |
| 1816 * \param array A ByteArray. | |
| 1817 * \param offset A valid byte offset into the ByteArray. | |
| 1818 * \param value The uint16_t to put into the ByteArray. | |
| 1819 * | |
| 1820 * \return A valid handle if no error occurs during the operation. | |
| 1821 */ | |
| 1822 DART_EXPORT Dart_Handle Dart_ByteArraySetUint16At(Dart_Handle array, | |
| 1823 intptr_t offset, | |
| 1824 uint16_t value); | |
| 1825 | |
| 1826 /** | |
| 1827 * Gets an int32_t at some byte offset in a ByteArray. | |
| 1828 * | |
| 1829 * If the byte offset is out of bounds, an error occurs. | |
| 1830 * | |
| 1831 * \param array A ByteArray. | |
| 1832 * \param offset A valid byte offset into the List. | |
| 1833 * \param value Returns the value of the int32_t. | |
| 1834 * | |
| 1835 * \return A valid handle if no error occurs during the operation. | |
| 1836 */ | |
| 1837 DART_EXPORT Dart_Handle Dart_ByteArrayGetInt32At(Dart_Handle array, | |
| 1838 intptr_t offset, | |
| 1839 int32_t* value); | |
| 1840 | |
| 1841 /** | |
| 1842 * Sets an int32_t at some byte offset in a ByteArray. | |
| 1843 * | |
| 1844 * If the byte offset is out of bounds, an error occurs. | |
| 1845 * | |
| 1846 * \param array A ByteArray. | |
| 1847 * \param offset A valid byte offset into the ByteArray. | |
| 1848 * \param value The int32_t to put into the ByteArray. | |
| 1849 * | |
| 1850 * \return A valid handle if no error occurs during the operation. | |
| 1851 */ | |
| 1852 DART_EXPORT Dart_Handle Dart_ByteArraySetInt32At(Dart_Handle array, | |
| 1853 intptr_t offset, | |
| 1854 int32_t value); | |
| 1855 | |
| 1856 /** | |
| 1857 * Gets a uint32_t at some byte offset in a ByteArray. | |
| 1858 * | |
| 1859 * If the byte offset is out of bounds, an error occurs. | |
| 1860 * | |
| 1861 * \param array A ByteArray. | |
| 1862 * \param offset A valid byte offset into the List. | |
| 1863 * \param value Returns the value of the uint32_t. | |
| 1864 * | |
| 1865 * \return A valid handle if no error occurs during the operation. | |
| 1866 */ | |
| 1867 DART_EXPORT Dart_Handle Dart_ByteArrayGetUint32At(Dart_Handle array, | |
| 1868 intptr_t offset, | |
| 1869 uint32_t* value); | |
| 1870 | |
| 1871 /** | |
| 1872 * Sets a uint32_t at some byte offset in a ByteArray. | |
| 1873 * | |
| 1874 * If the byte offset is out of bounds, an error occurs. | |
| 1875 * | |
| 1876 * \param array A ByteArray. | |
| 1877 * \param offset A valid byte offset into the ByteArray. | |
| 1878 * \param value The uint32_t to put into the ByteArray. | |
| 1879 * | |
| 1880 * \return A valid handle if no error occurs during the operation. | |
| 1881 */ | |
| 1882 DART_EXPORT Dart_Handle Dart_ByteArraySetUint32At(Dart_Handle array, | |
| 1883 intptr_t offset, | |
| 1884 uint32_t value); | |
| 1885 | |
| 1886 /** | |
| 1887 * Gets an int64_t at some byte offset in a ByteArray. | |
| 1888 * | |
| 1889 * If the byte offset is out of bounds, an error occurs. | |
| 1890 * | |
| 1891 * \param array A ByteArray. | |
| 1892 * \param offset A valid byte offset into the List. | |
| 1893 * \param value Returns the value of the int64_t. | |
| 1894 * | |
| 1895 * \return A valid handle if no error occurs during the operation. | |
| 1896 */ | |
| 1897 DART_EXPORT Dart_Handle Dart_ByteArrayGetInt64At(Dart_Handle array, | |
| 1898 intptr_t offset, | |
| 1899 int64_t* value); | |
| 1900 | |
| 1901 /** | |
| 1902 * Sets an int64_t at some byte offset in a ByteArray. | |
| 1903 * | |
| 1904 * If the byte offset is out of bounds, an error occurs. | |
| 1905 * | |
| 1906 * \param array A ByteArray. | |
| 1907 * \param offset A valid byte offset into the ByteArray. | |
| 1908 * \param value The int64_t to put into the ByteArray. | |
| 1909 * | |
| 1910 * \return A valid handle if no error occurs during the operation. | |
| 1911 */ | |
| 1912 DART_EXPORT Dart_Handle Dart_ByteArraySetInt64At(Dart_Handle array, | |
| 1913 intptr_t offset, | |
| 1914 int64_t value); | |
| 1915 | |
| 1916 /** | |
| 1917 * Gets a uint64_t at some byte offset in a ByteArray. | |
| 1918 * | |
| 1919 * If the byte offset is out of bounds, an error occurs. | |
| 1920 * | |
| 1921 * \param array A ByteArray. | |
| 1922 * \param offset A valid byte offset into the List. | |
| 1923 * \param value Returns the value of the uint64_t. | |
| 1924 * | |
| 1925 * \return A valid handle if no error occurs during the operation. | |
| 1926 */ | |
| 1927 DART_EXPORT Dart_Handle Dart_ByteArrayGetUint64At(Dart_Handle array, | |
| 1928 intptr_t offset, | |
| 1929 uint64_t* value); | |
| 1930 | |
| 1931 /** | |
| 1932 * Sets a uint64_t at some byte offset in a ByteArray. | |
| 1933 * | |
| 1934 * If the byte offset is out of bounds, an error occurs. | |
| 1935 * | |
| 1936 * \param array A ByteArray. | |
| 1937 * \param offset A valid byte offset into the ByteArray. | |
| 1938 * \param value The uint64_t to put into the ByteArray. | |
| 1939 * | |
| 1940 * \return A valid handle if no error occurs during the operation. | |
| 1941 */ | |
| 1942 DART_EXPORT Dart_Handle Dart_ByteArraySetUint64At(Dart_Handle array, | |
| 1943 intptr_t offset, | |
| 1944 uint64_t value); | |
| 1945 | |
| 1946 /** | |
| 1947 * Gets a float at some byte offset in a ByteArray. | |
| 1948 * | |
| 1949 * If the byte offset is out of bounds, an error occurs. | |
| 1950 * | |
| 1951 * \param array A ByteArray. | |
| 1952 * \param offset A valid byte offset into the List. | |
| 1953 * \param value Returns the value of the float. | |
| 1954 * | |
| 1955 * \return A valid handle if no error occurs during the operation. | |
| 1956 */ | |
| 1957 DART_EXPORT Dart_Handle Dart_ByteArrayGetFloat32At(Dart_Handle array, | |
| 1958 intptr_t offset, | |
| 1959 float* value); | |
| 1960 | |
| 1961 /** | |
| 1962 * Sets a float at some byte offset in a ByteArray. | |
| 1963 * | |
| 1964 * If the byte offset is out of bounds, an error occurs. | |
| 1965 * | |
| 1966 * \param array A ByteArray. | |
| 1967 * \param offset A valid byte offset into the ByteArray. | |
| 1968 * \param value The float to put into the ByteArray. | |
| 1969 * | |
| 1970 * \return A valid handle if no error occurs during the operation. | |
| 1971 */ | |
| 1972 DART_EXPORT Dart_Handle Dart_ByteArraySetFloat32At(Dart_Handle array, | |
| 1973 intptr_t offset, | |
| 1974 float value); | |
| 1975 | |
| 1976 /** | |
| 1977 * Gets a double from some byte offset in a ByteArray. | |
| 1978 * | |
| 1979 * If the byte offset is out of bounds, an error occurs. | |
| 1980 * | |
| 1981 * \param array A ByteArray. | |
| 1982 * \param offset A valid byte offset into the List. | |
| 1983 * \param value Returns the value of the double. | |
| 1984 * | |
| 1985 * \return A valid handle if no error occurs during the operation. | |
| 1986 */ | |
| 1987 DART_EXPORT Dart_Handle Dart_ByteArrayGetFloat64At(Dart_Handle array, | |
| 1988 intptr_t offset, | |
| 1989 double* value); | |
| 1990 | |
| 1991 /** | |
| 1992 * Sets a double at some byte offset in a ByteArray. | |
| 1993 * | |
| 1994 * If the byte offset is out of bounds, an error occurs. | |
| 1995 * | |
| 1996 * \param array A ByteArray. | |
| 1997 * \param offset A valid byte offset into the ByteArray. | |
| 1998 * \param value The double to put into the ByteArray. | |
| 1999 * | |
| 2000 * \return A valid handle if no error occurs during the operation. | |
| 2001 */ | |
| 2002 DART_EXPORT Dart_Handle Dart_ByteArraySetFloat64At(Dart_Handle array, | |
| 2003 intptr_t offset, | |
| 2004 double value); | |
| 2005 | 1754 |
| 2006 // --- Closures --- | 1755 // --- Closures --- |
| 2007 | 1756 |
| 2008 /** | 1757 /** |
| 2009 * Is this object a Closure? | 1758 * Is this object a Closure? |
| 2010 */ | 1759 */ |
| 2011 DART_EXPORT bool Dart_IsClosure(Dart_Handle object); | 1760 DART_EXPORT bool Dart_IsClosure(Dart_Handle object); |
| 2012 | 1761 |
| 2013 /** | 1762 /** |
| 2014 * Retrieves the function of a closure. | 1763 * Retrieves the function of a closure. |
| (...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2827 * | 2576 * |
| 2828 * \param object An object. | 2577 * \param object An object. |
| 2829 * \param peer A value to store in the peer field. | 2578 * \param peer A value to store in the peer field. |
| 2830 * | 2579 * |
| 2831 * \return Returns an error if 'object' is a subtype of Null, num, or | 2580 * \return Returns an error if 'object' is a subtype of Null, num, or |
| 2832 * bool. | 2581 * bool. |
| 2833 */ | 2582 */ |
| 2834 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); | 2583 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); |
| 2835 | 2584 |
| 2836 #endif // INCLUDE_DART_API_H_ | 2585 #endif // INCLUDE_DART_API_H_ |
| OLD | NEW |