JSValue.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /*
  2. * Copyright (C) 2013 Apple Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
  14. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
  17. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  18. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  20. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  21. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #ifndef JSValue_h
  26. #define JSValue_h
  27. #if JSC_OBJC_API_ENABLED
  28. #import <CoreGraphics/CGGeometry.h>
  29. @class JSContext;
  30. /*!
  31. @interface
  32. @discussion A JSValue is a reference to a JavaScript value. Every JSValue
  33. originates from a JSContext and holds a strong reference to it.
  34. When a JSValue instance method creates a new JSValue, the new value
  35. originates from the same JSContext.
  36. All JSValues values also originate from a JSVirtualMachine
  37. (available indirectly via the context property). It is an error to pass a
  38. JSValue to a method or property of a JSValue or JSContext originating from a
  39. different JSVirtualMachine. Doing so will raise an Objective-C exception.
  40. */
  41. NS_CLASS_AVAILABLE(10_9, 7_0)
  42. @interface JSValue : NSObject
  43. /*!
  44. @property
  45. @abstract The JSContext that this value originates from.
  46. */
  47. @property (readonly, strong) JSContext *context;
  48. /*!
  49. @methodgroup Creating JavaScript Values
  50. */
  51. /*!
  52. @method
  53. @abstract Create a JSValue by converting an Objective-C object.
  54. @discussion The resulting JSValue retains the provided Objective-C object.
  55. @param value The Objective-C object to be converted.
  56. @result The new JSValue.
  57. */
  58. + (JSValue *)valueWithObject:(id)value inContext:(JSContext *)context;
  59. /*!
  60. @method
  61. @abstract Create a JavaScript value from a BOOL primitive.
  62. @param context The JSContext in which the resulting JSValue will be created.
  63. @result The new JSValue representing the equivalent boolean value.
  64. */
  65. + (JSValue *)valueWithBool:(BOOL)value inContext:(JSContext *)context;
  66. /*!
  67. @method
  68. @abstract Create a JavaScript value from a double primitive.
  69. @param context The JSContext in which the resulting JSValue will be created.
  70. @result The new JSValue representing the equivalent boolean value.
  71. */
  72. + (JSValue *)valueWithDouble:(double)value inContext:(JSContext *)context;
  73. /*!
  74. @method
  75. @abstract Create a JavaScript value from an <code>int32_t</code> primitive.
  76. @param context The JSContext in which the resulting JSValue will be created.
  77. @result The new JSValue representing the equivalent boolean value.
  78. */
  79. + (JSValue *)valueWithInt32:(int32_t)value inContext:(JSContext *)context;
  80. /*!
  81. @method
  82. @abstract Create a JavaScript value from a <code>uint32_t</code> primitive.
  83. @param context The JSContext in which the resulting JSValue will be created.
  84. @result The new JSValue representing the equivalent boolean value.
  85. */
  86. + (JSValue *)valueWithUInt32:(uint32_t)value inContext:(JSContext *)context;
  87. /*!
  88. @method
  89. @abstract Create a new, empty JavaScript object.
  90. @param context The JSContext in which the resulting object will be created.
  91. @result The new JavaScript object.
  92. */
  93. + (JSValue *)valueWithNewObjectInContext:(JSContext *)context;
  94. /*!
  95. @method
  96. @abstract Create a new, empty JavaScript array.
  97. @param context The JSContext in which the resulting array will be created.
  98. @result The new JavaScript array.
  99. */
  100. + (JSValue *)valueWithNewArrayInContext:(JSContext *)context;
  101. /*!
  102. @method
  103. @abstract Create a new JavaScript regular expression object.
  104. @param pattern The regular expression pattern.
  105. @param flags The regular expression flags.
  106. @param context The JSContext in which the resulting regular expression object will be created.
  107. @result The new JavaScript regular expression object.
  108. */
  109. + (JSValue *)valueWithNewRegularExpressionFromPattern:(NSString *)pattern flags:(NSString *)flags inContext:(JSContext *)context;
  110. /*!
  111. @method
  112. @abstract Create a new JavaScript error object.
  113. @param message The error message.
  114. @param context The JSContext in which the resulting error object will be created.
  115. @result The new JavaScript error object.
  116. */
  117. + (JSValue *)valueWithNewErrorFromMessage:(NSString *)message inContext:(JSContext *)context;
  118. /*!
  119. @method
  120. @abstract Create the JavaScript value <code>null</code>.
  121. @param context The JSContext to which the resulting JSValue belongs.
  122. @result The JSValue representing the JavaScript value <code>null</code>.
  123. */
  124. + (JSValue *)valueWithNullInContext:(JSContext *)context;
  125. /*!
  126. @method
  127. @abstract Create the JavaScript value <code>undefined</code>.
  128. @param context The JSContext to which the resulting JSValue belongs.
  129. @result The JSValue representing the JavaScript value <code>undefined</code>.
  130. */
  131. + (JSValue *)valueWithUndefinedInContext:(JSContext *)context;
  132. /*!
  133. @methodgroup Converting to Objective-C Types
  134. @discussion When converting between JavaScript values and Objective-C objects a copy is
  135. performed. Values of types listed below are copied to the corresponding
  136. types on conversion in each direction. For NSDictionaries, entries in the
  137. dictionary that are keyed by strings are copied onto a JavaScript object.
  138. For dictionaries and arrays, conversion is recursive, with the same object
  139. conversion being applied to all entries in the collection.
  140. <pre>
  141. @textblock
  142. Objective-C type | JavaScript type
  143. --------------------+---------------------
  144. nil | undefined
  145. NSNull | null
  146. NSString | string
  147. NSNumber | number, boolean
  148. NSDictionary | Object object
  149. NSArray | Array object
  150. NSDate | Date object
  151. NSBlock (1) | Function object (1)
  152. id (2) | Wrapper object (2)
  153. Class (3) | Constructor object (3)
  154. @/textblock
  155. </pre>
  156. (1) Instances of NSBlock with supported arguments types will be presented to
  157. JavaScript as a callable Function object. For more information on supported
  158. argument types see JSExport.h. If a JavaScript Function originating from an
  159. Objective-C block is converted back to an Objective-C object the block will
  160. be returned. All other JavaScript functions will be converted in the same
  161. manner as a JavaScript object of type Object.
  162. (2) For Objective-C instances that do not derive from the set of types listed
  163. above, a wrapper object to provide a retaining handle to the Objective-C
  164. instance from JavaScript. For more information on these wrapper objects, see
  165. JSExport.h. When a JavaScript wrapper object is converted back to Objective-C
  166. the Objective-C instance being retained by the wrapper is returned.
  167. (3) For Objective-C Class objects a constructor object containing exported
  168. class methods will be returned. See JSExport.h for more information on
  169. constructor objects.
  170. For all methods taking arguments of type id, arguments will be converted
  171. into a JavaScript value according to the above conversion.
  172. */
  173. /*!
  174. @method
  175. @abstract Convert this JSValue to an Objective-C object.
  176. @discussion The JSValue is converted to an Objective-C object according
  177. to the conversion rules specified above.
  178. @result The Objective-C representation of this JSValue.
  179. */
  180. - (id)toObject;
  181. /*!
  182. @method
  183. @abstract Convert a JSValue to an Objective-C object of a specific class.
  184. @discussion The JSValue is converted to an Objective-C object of the specified Class.
  185. If the result is not of the specified Class then <code>nil</code> will be returned.
  186. @result An Objective-C object of the specified Class or <code>nil</code>.
  187. */
  188. - (id)toObjectOfClass:(Class)expectedClass;
  189. /*!
  190. @method
  191. @abstract Convert a JSValue to a boolean.
  192. @discussion The JSValue is converted to a boolean according to the rules specified
  193. by the JavaScript language.
  194. @result The boolean result of the conversion.
  195. */
  196. - (BOOL)toBool;
  197. /*!
  198. @method
  199. @abstract Convert a JSValue to a double.
  200. @discussion The JSValue is converted to a number according to the rules specified
  201. by the JavaScript language.
  202. @result The double result of the conversion.
  203. */
  204. - (double)toDouble;
  205. /*!
  206. @method
  207. @abstract Convert a JSValue to an <code>int32_t</code>.
  208. @discussion The JSValue is converted to an integer according to the rules specified
  209. by the JavaScript language.
  210. @result The <code>int32_t</code> result of the conversion.
  211. */
  212. - (int32_t)toInt32;
  213. /*!
  214. @method
  215. @abstract Convert a JSValue to a <code>uint32_t</code>.
  216. @discussion The JSValue is converted to an integer according to the rules specified
  217. by the JavaScript language.
  218. @result The <code>uint32_t</code> result of the conversion.
  219. */
  220. - (uint32_t)toUInt32;
  221. /*!
  222. @method
  223. @abstract Convert a JSValue to a NSNumber.
  224. @discussion If the JSValue represents a boolean, a NSNumber value of YES or NO
  225. will be returned. For all other types the value will be converted to a number according
  226. to the rules specified by the JavaScript language.
  227. @result The NSNumber result of the conversion.
  228. */
  229. - (NSNumber *)toNumber;
  230. /*!
  231. @method
  232. @abstract Convert a JSValue to a NSString.
  233. @discussion The JSValue is converted to a string according to the rules specified
  234. by the JavaScript language.
  235. @result The NSString containing the result of the conversion.
  236. */
  237. - (NSString *)toString;
  238. /*!
  239. @method
  240. @abstract Convert a JSValue to a NSDate.
  241. @discussion The value is converted to a number representing a time interval
  242. since 1970 which is then used to create a new NSDate instance.
  243. @result The NSDate created using the converted time interval.
  244. */
  245. - (NSDate *)toDate;
  246. /*!
  247. @method
  248. @abstract Convert a JSValue to a NSArray.
  249. @discussion If the value is <code>null</code> or <code>undefined</code> then <code>nil</code> is returned.
  250. If the value is not an object then a JavaScript TypeError will be thrown.
  251. The property <code>length</code> is read from the object, converted to an unsigned
  252. integer, and an NSArray of this size is allocated. Properties corresponding
  253. to indicies within the array bounds will be copied to the array, with
  254. JSValues converted to equivalent Objective-C objects as specified.
  255. @result The NSArray containing the recursively converted contents of the
  256. converted JavaScript array.
  257. */
  258. - (NSArray *)toArray;
  259. /*!
  260. @method
  261. @abstract Convert a JSValue to a NSDictionary.
  262. @discussion If the value is <code>null</code> or <code>undefined</code> then <code>nil</code> is returned.
  263. If the value is not an object then a JavaScript TypeError will be thrown.
  264. All enumerable properties of the object are copied to the dictionary, with
  265. JSValues converted to equivalent Objective-C objects as specified.
  266. @result The NSDictionary containing the recursively converted contents of
  267. the converted JavaScript object.
  268. */
  269. - (NSDictionary *)toDictionary;
  270. /*!
  271. @functiongroup Checking JavaScript Types
  272. */
  273. /*!
  274. @property
  275. @abstract Check if a JSValue corresponds to the JavaScript value <code>undefined</code>.
  276. */
  277. @property (readonly) BOOL isUndefined;
  278. /*!
  279. @property
  280. @abstract Check if a JSValue corresponds to the JavaScript value <code>null</code>.
  281. */
  282. @property (readonly) BOOL isNull;
  283. /*!
  284. @property
  285. @abstract Check if a JSValue is a boolean.
  286. */
  287. @property (readonly) BOOL isBoolean;
  288. /*!
  289. @property
  290. @abstract Check if a JSValue is a number.
  291. @discussion In JavaScript, there is no differentiation between types of numbers.
  292. Semantically all numbers behave like doubles except in special cases like bit
  293. operations.
  294. */
  295. @property (readonly) BOOL isNumber;
  296. /*!
  297. @property
  298. @abstract Check if a JSValue is a string.
  299. */
  300. @property (readonly) BOOL isString;
  301. /*!
  302. @property
  303. @abstract Check if a JSValue is an object.
  304. */
  305. @property (readonly) BOOL isObject;
  306. /*!
  307. @property
  308. @abstract Check if a JSValue is an array.
  309. */
  310. @property (readonly) BOOL isArray JSC_API_AVAILABLE(macosx(10.11), ios(9.0));
  311. /*!
  312. @property
  313. @abstract Check if a JSValue is a date.
  314. */
  315. @property (readonly) BOOL isDate JSC_API_AVAILABLE(macosx(10.11), ios(9.0));
  316. /*!
  317. @method
  318. @abstract Compare two JSValues using JavaScript's <code>===</code> operator.
  319. */
  320. - (BOOL)isEqualToObject:(id)value;
  321. /*!
  322. @method
  323. @abstract Compare two JSValues using JavaScript's <code>==</code> operator.
  324. */
  325. - (BOOL)isEqualWithTypeCoercionToObject:(id)value;
  326. /*!
  327. @method
  328. @abstract Check if a JSValue is an instance of another object.
  329. @discussion This method has the same function as the JavaScript operator <code>instanceof</code>.
  330. If an object other than a JSValue is passed, it will first be converted according to
  331. the aforementioned rules.
  332. */
  333. - (BOOL)isInstanceOf:(id)value;
  334. /*!
  335. @methodgroup Calling Functions and Constructors
  336. */
  337. /*!
  338. @method
  339. @abstract Invoke a JSValue as a function.
  340. @discussion In JavaScript, if a function doesn't explicitly return a value then it
  341. implicitly returns the JavaScript value <code>undefined</code>.
  342. @param arguments The arguments to pass to the function.
  343. @result The return value of the function call.
  344. */
  345. - (JSValue *)callWithArguments:(NSArray *)arguments;
  346. /*!
  347. @method
  348. @abstract Invoke a JSValue as a constructor.
  349. @discussion This is equivalent to using the <code>new</code> syntax in JavaScript.
  350. @param arguments The arguments to pass to the constructor.
  351. @result The return value of the constructor call.
  352. */
  353. - (JSValue *)constructWithArguments:(NSArray *)arguments;
  354. /*!
  355. @method
  356. @abstract Invoke a method on a JSValue.
  357. @discussion Accesses the property named <code>method</code> from this value and
  358. calls the resulting value as a function, passing this JSValue as the <code>this</code>
  359. value along with the specified arguments.
  360. @param method The name of the method to be invoked.
  361. @param arguments The arguments to pass to the method.
  362. @result The return value of the method call.
  363. */
  364. - (JSValue *)invokeMethod:(NSString *)method withArguments:(NSArray *)arguments;
  365. @end
  366. /*!
  367. @category
  368. @discussion Objective-C methods exported to JavaScript may have argument and/or return
  369. values of struct types, provided that conversion to and from the struct is
  370. supported by JSValue. Support is provided for any types where JSValue
  371. contains both a class method <code>valueWith<Type>:inContext:</code>, and and instance
  372. method <code>to<Type></code>- where the string <code><Type></code> in these selector names match,
  373. with the first argument to the former being of the same struct type as the
  374. return type of the latter.
  375. Support is provided for structs of type CGPoint, NSRange, CGRect and CGSize.
  376. */
  377. @interface JSValue (StructSupport)
  378. /*!
  379. @method
  380. @abstract Create a JSValue from a CGPoint.
  381. @result A newly allocated JavaScript object containing properties
  382. named <code>x</code> and <code>y</code>, with values from the CGPoint.
  383. */
  384. + (JSValue *)valueWithPoint:(CGPoint)point inContext:(JSContext *)context;
  385. /*!
  386. @method
  387. @abstract Create a JSValue from a NSRange.
  388. @result A newly allocated JavaScript object containing properties
  389. named <code>location</code> and <code>length</code>, with values from the NSRange.
  390. */
  391. + (JSValue *)valueWithRange:(NSRange)range inContext:(JSContext *)context;
  392. /*!
  393. @method
  394. @abstract
  395. Create a JSValue from a CGRect.
  396. @result A newly allocated JavaScript object containing properties
  397. named <code>x</code>, <code>y</code>, <code>width</code>, and <code>height</code>, with values from the CGRect.
  398. */
  399. + (JSValue *)valueWithRect:(CGRect)rect inContext:(JSContext *)context;
  400. /*!
  401. @method
  402. @abstract Create a JSValue from a CGSize.
  403. @result A newly allocated JavaScript object containing properties
  404. named <code>width</code> and <code>height</code>, with values from the CGSize.
  405. */
  406. + (JSValue *)valueWithSize:(CGSize)size inContext:(JSContext *)context;
  407. /*!
  408. @method
  409. @abstract Convert a JSValue to a CGPoint.
  410. @discussion Reads the properties named <code>x</code> and <code>y</code> from
  411. this JSValue, and converts the results to double.
  412. @result The new CGPoint.
  413. */
  414. - (CGPoint)toPoint;
  415. /*!
  416. @method
  417. @abstract Convert a JSValue to an NSRange.
  418. @discussion Reads the properties named <code>location</code> and
  419. <code>length</code> from this JSValue and converts the results to double.
  420. @result The new NSRange.
  421. */
  422. - (NSRange)toRange;
  423. /*!
  424. @method
  425. @abstract Convert a JSValue to a CGRect.
  426. @discussion Reads the properties named <code>x</code>, <code>y</code>,
  427. <code>width</code>, and <code>height</code> from this JSValue and converts the results to double.
  428. @result The new CGRect.
  429. */
  430. - (CGRect)toRect;
  431. /*!
  432. @method
  433. @abstract Convert a JSValue to a CGSize.
  434. @discussion Reads the properties named <code>width</code> and
  435. <code>height</code> from this JSValue and converts the results to double.
  436. @result The new CGSize.
  437. */
  438. - (CGSize)toSize;
  439. @end
  440. /*!
  441. @category
  442. @discussion These methods enable querying properties on a JSValue.
  443. */
  444. @interface JSValue (PropertyAccess)
  445. /*!
  446. @method
  447. @abstract Access a property of a JSValue.
  448. @result The JSValue for the requested property or the JSValue <code>undefined</code>
  449. if the property does not exist.
  450. */
  451. - (JSValue *)valueForProperty:(NSString *)property;
  452. /*!
  453. @method
  454. @abstract Set a property on a JSValue.
  455. */
  456. - (void)setValue:(id)value forProperty:(NSString *)property;
  457. /*!
  458. @method
  459. @abstract Delete a property from a JSValue.
  460. @result YES if deletion is successful, NO otherwise.
  461. */
  462. - (BOOL)deleteProperty:(NSString *)property;
  463. /*!
  464. @method
  465. @abstract Check if a JSValue has a property.
  466. @discussion This method has the same function as the JavaScript operator <code>in</code>.
  467. @result Returns YES if property is present on the value.
  468. */
  469. - (BOOL)hasProperty:(NSString *)property;
  470. /*!
  471. @method
  472. @abstract Define properties with custom descriptors on JSValues.
  473. @discussion This method may be used to create a data or accessor property on an object.
  474. This method operates in accordance with the Object.defineProperty method in the
  475. JavaScript language.
  476. */
  477. - (void)defineProperty:(NSString *)property descriptor:(id)descriptor;
  478. /*!
  479. @method
  480. @abstract Access an indexed (numerical) property on a JSValue.
  481. @result The JSValue for the property at the specified index.
  482. Returns the JavaScript value <code>undefined</code> if no property exists at that index.
  483. */
  484. - (JSValue *)valueAtIndex:(NSUInteger)index;
  485. /*!
  486. @method
  487. @abstract Set an indexed (numerical) property on a JSValue.
  488. @discussion For JSValues that are JavaScript arrays, indices greater than
  489. UINT_MAX - 1 will not affect the length of the array.
  490. */
  491. - (void)setValue:(id)value atIndex:(NSUInteger)index;
  492. @end
  493. /*!
  494. @category
  495. @discussion Instances of JSValue implement the following methods in order to enable
  496. support for subscript access by key and index, for example:
  497. @textblock
  498. JSValue *objectA, *objectB;
  499. JSValue *v1 = object[@"X"]; // Get value for property "X" from 'object'.
  500. JSValue *v2 = object[42]; // Get value for index 42 from 'object'.
  501. object[@"Y"] = v1; // Assign 'v1' to property "Y" of 'object'.
  502. object[101] = v2; // Assign 'v2' to index 101 of 'object'.
  503. @/textblock
  504. An object key passed as a subscript will be converted to a JavaScript value,
  505. and then the value converted to a string used as a property name.
  506. */
  507. @interface JSValue (SubscriptSupport)
  508. - (JSValue *)objectForKeyedSubscript:(id)key;
  509. - (JSValue *)objectAtIndexedSubscript:(NSUInteger)index;
  510. - (void)setObject:(id)object forKeyedSubscript:(NSObject <NSCopying> *)key;
  511. - (void)setObject:(id)object atIndexedSubscript:(NSUInteger)index;
  512. @end
  513. /*!
  514. @category
  515. @discussion These functions are for bridging between the C API and the Objective-C API.
  516. */
  517. @interface JSValue (JSValueRefSupport)
  518. /*!
  519. @method
  520. @abstract Creates a JSValue, wrapping its C API counterpart.
  521. @result The Objective-C API equivalent of the specified JSValueRef.
  522. */
  523. + (JSValue *)valueWithJSValueRef:(JSValueRef)value inContext:(JSContext *)context;
  524. /*!
  525. @property
  526. @abstract Returns the C API counterpart wrapped by a JSContext.
  527. @result The C API equivalent of this JSValue.
  528. */
  529. @property (readonly) JSValueRef JSValueRef;
  530. @end
  531. #ifdef __cplusplus
  532. extern "C" {
  533. #endif
  534. /*!
  535. @group Property Descriptor Constants
  536. @discussion These keys may assist in creating a property descriptor for use with the
  537. defineProperty method on JSValue.
  538. Property descriptors must fit one of three descriptions:
  539. Data Descriptor:
  540. - A descriptor containing one or both of the keys <code>value</code> and <code>writable</code>,
  541. and optionally containing one or both of the keys <code>enumerable</code> and
  542. <code>configurable</code>. A data descriptor may not contain either the <code>get</code> or
  543. <code>set</code> key.
  544. A data descriptor may be used to create or modify the attributes of a
  545. data property on an object (replacing any existing accessor property).
  546. Accessor Descriptor:
  547. - A descriptor containing one or both of the keys <code>get</code> and <code>set</code>, and
  548. optionally containing one or both of the keys <code>enumerable</code> and
  549. <code>configurable</code>. An accessor descriptor may not contain either the <code>value</code>
  550. or <code>writable</code> key.
  551. An accessor descriptor may be used to create or modify the attributes of
  552. an accessor property on an object (replacing any existing data property).
  553. Generic Descriptor:
  554. - A descriptor containing one or both of the keys <code>enumerable</code> and
  555. <code>configurable</code>. A generic descriptor may not contain any of the keys
  556. <code>value</code>, <code>writable</code>, <code>get</code>, or <code>set</code>.
  557. A generic descriptor may be used to modify the attributes of an existing
  558. data or accessor property, or to create a new data property.
  559. */
  560. /*!
  561. @const
  562. */
  563. JS_EXPORT extern NSString * const JSPropertyDescriptorWritableKey;
  564. /*!
  565. @const
  566. */
  567. JS_EXPORT extern NSString * const JSPropertyDescriptorEnumerableKey;
  568. /*!
  569. @const
  570. */
  571. JS_EXPORT extern NSString * const JSPropertyDescriptorConfigurableKey;
  572. /*!
  573. @const
  574. */
  575. JS_EXPORT extern NSString * const JSPropertyDescriptorValueKey;
  576. /*!
  577. @const
  578. */
  579. JS_EXPORT extern NSString * const JSPropertyDescriptorGetKey;
  580. /*!
  581. @const
  582. */
  583. JS_EXPORT extern NSString * const JSPropertyDescriptorSetKey;
  584. #ifdef __cplusplus
  585. } // extern "C"
  586. #endif
  587. #endif
  588. #endif // JSValue_h