| 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 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 DART_EXPORT bool Dart_IsInstance(Dart_Handle object); | 1135 DART_EXPORT bool Dart_IsInstance(Dart_Handle object); |
| 1136 DART_EXPORT bool Dart_IsNumber(Dart_Handle object); | 1136 DART_EXPORT bool Dart_IsNumber(Dart_Handle object); |
| 1137 DART_EXPORT bool Dart_IsInteger(Dart_Handle object); | 1137 DART_EXPORT bool Dart_IsInteger(Dart_Handle object); |
| 1138 DART_EXPORT bool Dart_IsDouble(Dart_Handle object); | 1138 DART_EXPORT bool Dart_IsDouble(Dart_Handle object); |
| 1139 DART_EXPORT bool Dart_IsBoolean(Dart_Handle object); | 1139 DART_EXPORT bool Dart_IsBoolean(Dart_Handle object); |
| 1140 DART_EXPORT bool Dart_IsString(Dart_Handle object); | 1140 DART_EXPORT bool Dart_IsString(Dart_Handle object); |
| 1141 DART_EXPORT bool Dart_IsStringLatin1(Dart_Handle object); /* (ISO-8859-1) */ | 1141 DART_EXPORT bool Dart_IsStringLatin1(Dart_Handle object); /* (ISO-8859-1) */ |
| 1142 DART_EXPORT bool Dart_IsExternalString(Dart_Handle object); | 1142 DART_EXPORT bool Dart_IsExternalString(Dart_Handle object); |
| 1143 DART_EXPORT bool Dart_IsList(Dart_Handle object); | 1143 DART_EXPORT bool Dart_IsList(Dart_Handle object); |
| 1144 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object); | 1144 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object); |
| 1145 DART_EXPORT bool Dart_IsType(Dart_Handle handle); |
| 1145 DART_EXPORT bool Dart_IsClass(Dart_Handle handle); | 1146 DART_EXPORT bool Dart_IsClass(Dart_Handle handle); |
| 1146 DART_EXPORT bool Dart_IsAbstractClass(Dart_Handle handle); | |
| 1147 DART_EXPORT bool Dart_IsFunction(Dart_Handle handle); | 1147 DART_EXPORT bool Dart_IsFunction(Dart_Handle handle); |
| 1148 DART_EXPORT bool Dart_IsVariable(Dart_Handle handle); | 1148 DART_EXPORT bool Dart_IsVariable(Dart_Handle handle); |
| 1149 DART_EXPORT bool Dart_IsTypeVariable(Dart_Handle handle); | 1149 DART_EXPORT bool Dart_IsTypeVariable(Dart_Handle handle); |
| 1150 DART_EXPORT bool Dart_IsClosure(Dart_Handle object); | 1150 DART_EXPORT bool Dart_IsClosure(Dart_Handle object); |
| 1151 | 1151 |
| 1152 | 1152 |
| 1153 /* | 1153 /* |
| 1154 * ========= | 1154 * ========= |
| 1155 * Instances | 1155 * Instances |
| 1156 * ========= | 1156 * ========= |
| 1157 */ | 1157 */ |
| 1158 | 1158 |
| 1159 /* | 1159 /* |
| 1160 * For the purposes of the embedding api, not all objects returned are | 1160 * For the purposes of the embedding api, not all objects returned are |
| 1161 * Dart language objects. Within the api, we use the term 'Instance' | 1161 * Dart language objects. Within the api, we use the term 'Instance' |
| 1162 * to indicate handles which refer to true Dart language objects. | 1162 * to indicate handles which refer to true Dart language objects. |
| 1163 * | 1163 * |
| 1164 * TODO(turnidge): Reorganize the "Object" section above, pulling down | 1164 * TODO(turnidge): Reorganize the "Object" section above, pulling down |
| 1165 * any functions that more properly belong here. */ | 1165 * any functions that more properly belong here. */ |
| 1166 | 1166 |
| 1167 /** | 1167 /** |
| 1168 * Gets the type of a Dart language object. |
| 1169 * |
| 1170 * \param instance Some Dart object. |
| 1171 * |
| 1172 * \return If no error occurs, the type is returned. Otherwise an |
| 1173 * error handle is returned. |
| 1174 */ |
| 1175 DART_EXPORT Dart_Handle Dart_InstanceGetType(Dart_Handle instance); |
| 1176 |
| 1177 /** |
| 1178 * TODO(asiva): Deprecate this method once all use cases have switched |
| 1179 * to using Dart_InstanceGetType |
| 1168 * Gets the class for some Dart language object. | 1180 * Gets the class for some Dart language object. |
| 1169 * | 1181 * |
| 1170 * \param instance Some Dart object. | 1182 * \param instance Some Dart object. |
| 1171 * | 1183 * |
| 1172 * \return If no error occurs, the class is returned. Otherwise an | 1184 * \return If no error occurs, the class is returned. Otherwise an |
| 1173 * error handle is returned. | 1185 * error handle is returned. |
| 1174 */ | 1186 */ |
| 1175 DART_EXPORT Dart_Handle Dart_InstanceGetClass(Dart_Handle instance); | 1187 DART_EXPORT Dart_Handle Dart_InstanceGetClass(Dart_Handle instance); |
| 1176 | 1188 |
| 1177 | 1189 |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1729 * Invoking Constructors, Methods, Closures and Field accessors | 1741 * Invoking Constructors, Methods, Closures and Field accessors |
| 1730 * ============================================================ | 1742 * ============================================================ |
| 1731 */ | 1743 */ |
| 1732 | 1744 |
| 1733 /** | 1745 /** |
| 1734 * Invokes a constructor, creating a new object. | 1746 * Invokes a constructor, creating a new object. |
| 1735 * | 1747 * |
| 1736 * This function allows hidden constructors (constructors with leading | 1748 * This function allows hidden constructors (constructors with leading |
| 1737 * underscores) to be called. | 1749 * underscores) to be called. |
| 1738 * | 1750 * |
| 1739 * \param clazz A class or an interface. | 1751 * \param type Type of object to be constructed. |
| 1740 * \param constructor_name The name of the constructor to invoke. Use | 1752 * \param constructor_name The name of the constructor to invoke. Use |
| 1741 * Dart_Null() to invoke the unnamed constructor. This name should | 1753 * Dart_Null() to invoke the unnamed constructor. This name should |
| 1742 * not include the name of the class. | 1754 * not include the name of the class. |
| 1743 * \param number_of_arguments Size of the arguments array. | 1755 * \param number_of_arguments Size of the arguments array. |
| 1744 * \param arguments An array of arguments to the constructor. | 1756 * \param arguments An array of arguments to the constructor. |
| 1745 * | 1757 * |
| 1746 * \return If the constructor is called and completes successfully, | 1758 * \return If the constructor is called and completes successfully, |
| 1747 * then the new object. If an error occurs during execution, then an | 1759 * then the new object. If an error occurs during execution, then an |
| 1748 * error handle is returned. | 1760 * error handle is returned. |
| 1749 */ | 1761 */ |
| 1750 DART_EXPORT Dart_Handle Dart_New(Dart_Handle clazz, | 1762 DART_EXPORT Dart_Handle Dart_New(Dart_Handle type, |
| 1751 Dart_Handle constructor_name, | 1763 Dart_Handle constructor_name, |
| 1752 int number_of_arguments, | 1764 int number_of_arguments, |
| 1753 Dart_Handle* arguments); | 1765 Dart_Handle* arguments); |
| 1754 | 1766 |
| 1755 /** | 1767 /** |
| 1756 * Invokes a method or function. | 1768 * Invokes a method or function. |
| 1757 * | 1769 * |
| 1758 * The 'target' parameter may be an object, class, or library. If | 1770 * The 'target' parameter may be an object, type, or library. If |
| 1759 * 'target' is an object, then this function will invoke an instance | 1771 * 'target' is an object, then this function will invoke an instance |
| 1760 * method. If 'target' is a class, then this function will invoke a | 1772 * method. If 'target' is a type, then this function will invoke a |
| 1761 * static method. If 'target' is a library, then this function will | 1773 * static method. If 'target' is a library, then this function will |
| 1762 * invoke a top-level function from that library. | 1774 * invoke a top-level function from that library. |
| 1775 * NOTE: This API call cannot be used to invoke methods of a type object. |
| 1763 * | 1776 * |
| 1764 * This function ignores visibility (leading underscores in names). | 1777 * This function ignores visibility (leading underscores in names). |
| 1765 * | 1778 * |
| 1766 * May generate an unhandled exception error. | 1779 * May generate an unhandled exception error. |
| 1767 * | 1780 * |
| 1768 * \param target An object, class, or library. | 1781 * \param target An object, type, or library. |
| 1769 * \param name The name of the function or method to invoke. | 1782 * \param name The name of the function or method to invoke. |
| 1770 * \param number_of_arguments Size of the arguments array. | 1783 * \param number_of_arguments Size of the arguments array. |
| 1771 * \param arguments An array of arguments to the function. | 1784 * \param arguments An array of arguments to the function. |
| 1772 * | 1785 * |
| 1773 * \return If the function or method is called and completes | 1786 * \return If the function or method is called and completes |
| 1774 * successfully, then the return value is returned. If an error | 1787 * successfully, then the return value is returned. If an error |
| 1775 * occurs during execution, then an error handle is returned. | 1788 * occurs during execution, then an error handle is returned. |
| 1776 */ | 1789 */ |
| 1777 DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target, | 1790 DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target, |
| 1778 Dart_Handle name, | 1791 Dart_Handle name, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1789 * invoking the closure is returned. If an error occurs during | 1802 * invoking the closure is returned. If an error occurs during |
| 1790 * execution, then an error handle is returned. | 1803 * execution, then an error handle is returned. |
| 1791 */ | 1804 */ |
| 1792 DART_EXPORT Dart_Handle Dart_InvokeClosure(Dart_Handle closure, | 1805 DART_EXPORT Dart_Handle Dart_InvokeClosure(Dart_Handle closure, |
| 1793 int number_of_arguments, | 1806 int number_of_arguments, |
| 1794 Dart_Handle* arguments); | 1807 Dart_Handle* arguments); |
| 1795 | 1808 |
| 1796 /** | 1809 /** |
| 1797 * Gets the value of a field. | 1810 * Gets the value of a field. |
| 1798 * | 1811 * |
| 1799 * The 'container' parameter may be an object, class, or library. If | 1812 * The 'container' parameter may be an object, type, or library. If |
| 1800 * 'container' is an object, then this function will access an | 1813 * 'container' is an object, then this function will access an |
| 1801 * instance field. If 'container' is a class, then this function will | 1814 * instance field. If 'container' is a type, then this function will |
| 1802 * access a static field. If 'container' is a library, then this | 1815 * access a static field. If 'container' is a library, then this |
| 1803 * function will access a top-level variable. | 1816 * function will access a top-level variable. |
| 1817 * NOTE: This API call cannot be used to access fields of a type object. |
| 1804 * | 1818 * |
| 1805 * This function ignores field visibility (leading underscores in names). | 1819 * This function ignores field visibility (leading underscores in names). |
| 1806 * | 1820 * |
| 1807 * May generate an unhandled exception error. | 1821 * May generate an unhandled exception error. |
| 1808 * | 1822 * |
| 1809 * \param container An object, class, or library. | 1823 * \param container An object, type, or library. |
| 1810 * \param name A field name. | 1824 * \param name A field name. |
| 1811 * | 1825 * |
| 1812 * \return If no error occurs, then the value of the field is | 1826 * \return If no error occurs, then the value of the field is |
| 1813 * returned. Otherwise an error handle is returned. | 1827 * returned. Otherwise an error handle is returned. |
| 1814 */ | 1828 */ |
| 1815 DART_EXPORT Dart_Handle Dart_GetField(Dart_Handle container, | 1829 DART_EXPORT Dart_Handle Dart_GetField(Dart_Handle container, |
| 1816 Dart_Handle name); | 1830 Dart_Handle name); |
| 1817 | 1831 |
| 1818 /** | 1832 /** |
| 1819 * Sets the value of a field. | 1833 * Sets the value of a field. |
| 1820 * | 1834 * |
| 1821 * The 'container' parameter may actually be an object, class, or | 1835 * The 'container' parameter may actually be an object, type, or |
| 1822 * library. If 'container' is an object, then this function will | 1836 * library. If 'container' is an object, then this function will |
| 1823 * access an instance field. If 'container' is a class, then this | 1837 * access an instance field. If 'container' is a type, then this |
| 1824 * function will access a static field. If 'container' is a library, | 1838 * function will access a static field. If 'container' is a library, |
| 1825 * then this function will access a top-level variable. | 1839 * then this function will access a top-level variable. |
| 1840 * NOTE: This API call cannot be used to access fields of a type object. |
| 1826 * | 1841 * |
| 1827 * This function ignores field visibility (leading underscores in names). | 1842 * This function ignores field visibility (leading underscores in names). |
| 1828 * | 1843 * |
| 1829 * May generate an unhandled exception error. | 1844 * May generate an unhandled exception error. |
| 1830 * | 1845 * |
| 1831 * \param container An object, class, or library. | 1846 * \param container An object, type, or library. |
| 1832 * \param name A field name. | 1847 * \param name A field name. |
| 1833 * \param value The new field value. | 1848 * \param value The new field value. |
| 1834 * | 1849 * |
| 1835 * \return A valid handle if no error occurs. | 1850 * \return A valid handle if no error occurs. |
| 1836 */ | 1851 */ |
| 1837 DART_EXPORT Dart_Handle Dart_SetField(Dart_Handle container, | 1852 DART_EXPORT Dart_Handle Dart_SetField(Dart_Handle container, |
| 1838 Dart_Handle name, | 1853 Dart_Handle name, |
| 1839 Dart_Handle value); | 1854 Dart_Handle value); |
| 1840 | 1855 |
| 1841 | 1856 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2079 * Lookup a class or interface by name from a Library. | 2094 * Lookup a class or interface by name from a Library. |
| 2080 * | 2095 * |
| 2081 * \param library The library containing the class or interface. | 2096 * \param library The library containing the class or interface. |
| 2082 * \param class_name The name of the class or interface. | 2097 * \param class_name The name of the class or interface. |
| 2083 * | 2098 * |
| 2084 * \return If no error occurs, the class or interface is | 2099 * \return If no error occurs, the class or interface is |
| 2085 * returned. Otherwise an error handle is returned. | 2100 * returned. Otherwise an error handle is returned. |
| 2086 */ | 2101 */ |
| 2087 DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, | 2102 DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, |
| 2088 Dart_Handle class_name); | 2103 Dart_Handle class_name); |
| 2089 /* TODO(turnidge): Consider returning Dart_Null() when the class is | 2104 /* TODO(asiva): The above method needs to be removed once all uses |
| 2090 * not found to distinguish that from a true error case. */ | 2105 * of it are removed from the embedder code. */ |
| 2091 | 2106 |
| 2092 /** | 2107 /** |
| 2093 * Returns the url from which a library was loaded. | 2108 * Returns the url from which a library was loaded. |
| 2094 */ | 2109 */ |
| 2095 DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library); | 2110 DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library); |
| 2096 | 2111 |
| 2097 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url); | 2112 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url); |
| 2098 /* TODO(turnidge): Consider returning Dart_Null() when the library is | 2113 /* TODO(turnidge): Consider returning Dart_Null() when the library is |
| 2099 * not found to distinguish that from a true error case. */ | 2114 * not found to distinguish that from a true error case. */ |
| 2100 | 2115 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2174 * | 2189 * |
| 2175 * \param object An object. | 2190 * \param object An object. |
| 2176 * \param peer A value to store in the peer field. | 2191 * \param peer A value to store in the peer field. |
| 2177 * | 2192 * |
| 2178 * \return Returns an error if 'object' is a subtype of Null, num, or | 2193 * \return Returns an error if 'object' is a subtype of Null, num, or |
| 2179 * bool. | 2194 * bool. |
| 2180 */ | 2195 */ |
| 2181 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); | 2196 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); |
| 2182 | 2197 |
| 2183 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ | 2198 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ |
| OLD | NEW |