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

Side by Side Diff: include/v8.h

Issue 459413002: Support symbol-named properties in API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Include a bit that was missing from the previous patch Created 6 years, 4 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 | « no previous file | src/accessors.h » ('j') | src/api.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** \mainpage V8 API Reference Guide 5 /** \mainpage V8 API Reference Guide
6 * 6 *
7 * V8 is Google's open source JavaScript engine. 7 * V8 is Google's open source JavaScript engine.
8 * 8 *
9 * This set of documents provides reference material generated from the 9 * This set of documents provides reference material generated from the
10 * V8 header file, include/v8.h. 10 * V8 header file, include/v8.h.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 class Date; 70 class Date;
71 class DeclaredAccessorDescriptor; 71 class DeclaredAccessorDescriptor;
72 class External; 72 class External;
73 class Function; 73 class Function;
74 class FunctionTemplate; 74 class FunctionTemplate;
75 class HeapProfiler; 75 class HeapProfiler;
76 class ImplementationUtilities; 76 class ImplementationUtilities;
77 class Int32; 77 class Int32;
78 class Integer; 78 class Integer;
79 class Isolate; 79 class Isolate;
80 class Name;
80 class Number; 81 class Number;
81 class NumberObject; 82 class NumberObject;
82 class Object; 83 class Object;
83 class ObjectOperationDescriptor; 84 class ObjectOperationDescriptor;
84 class ObjectTemplate; 85 class ObjectTemplate;
85 class Platform; 86 class Platform;
86 class Primitive; 87 class Primitive;
87 class RawOperationDescriptor; 88 class RawOperationDescriptor;
88 class Script; 89 class Script;
89 class Signature; 90 class Signature;
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 * Returns true if this value is true. 1361 * Returns true if this value is true.
1361 */ 1362 */
1362 bool IsTrue() const; 1363 bool IsTrue() const;
1363 1364
1364 /** 1365 /**
1365 * Returns true if this value is false. 1366 * Returns true if this value is false.
1366 */ 1367 */
1367 bool IsFalse() const; 1368 bool IsFalse() const;
1368 1369
1369 /** 1370 /**
1371 * Returns true if this value is a symbol or a string.
1372 * This is an experimental feature.
1373 */
1374 bool IsName() const;
1375
1376 /**
1370 * Returns true if this value is an instance of the String type. 1377 * Returns true if this value is an instance of the String type.
1371 * See ECMA-262 8.4. 1378 * See ECMA-262 8.4.
1372 */ 1379 */
1373 V8_INLINE bool IsString() const; 1380 V8_INLINE bool IsString() const;
1374 1381
1375 /** 1382 /**
1376 * Returns true if this value is a symbol. 1383 * Returns true if this value is a symbol.
1377 * This is an experimental feature. 1384 * This is an experimental feature.
1378 */ 1385 */
1379 bool IsSymbol() const; 1386 bool IsSymbol() const;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 * or false value. 1594 * or false value.
1588 */ 1595 */
1589 class V8_EXPORT Boolean : public Primitive { 1596 class V8_EXPORT Boolean : public Primitive {
1590 public: 1597 public:
1591 bool Value() const; 1598 bool Value() const;
1592 V8_INLINE static Handle<Boolean> New(Isolate* isolate, bool value); 1599 V8_INLINE static Handle<Boolean> New(Isolate* isolate, bool value);
1593 }; 1600 };
1594 1601
1595 1602
1596 /** 1603 /**
1604 * A superclass for symbols and strings.
1605 */
1606 class V8_EXPORT Name : public Primitive {
1607 public:
1608 V8_INLINE static Name* Cast(v8::Value* obj);
1609 private:
1610 static void CheckCast(v8::Value* obj);
1611 };
1612
1613
1614 /**
1597 * A JavaScript string value (ECMA-262, 4.3.17). 1615 * A JavaScript string value (ECMA-262, 4.3.17).
1598 */ 1616 */
1599 class V8_EXPORT String : public Primitive { 1617 class V8_EXPORT String : public Name {
1600 public: 1618 public:
1601 enum Encoding { 1619 enum Encoding {
1602 UNKNOWN_ENCODING = 0x1, 1620 UNKNOWN_ENCODING = 0x1,
1603 TWO_BYTE_ENCODING = 0x0, 1621 TWO_BYTE_ENCODING = 0x0,
1604 ASCII_ENCODING = 0x4, 1622 ASCII_ENCODING = 0x4,
1605 ONE_BYTE_ENCODING = 0x4 1623 ONE_BYTE_ENCODING = 0x4
1606 }; 1624 };
1607 /** 1625 /**
1608 * Returns the number of characters in this string. 1626 * Returns the number of characters in this string.
1609 */ 1627 */
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 void VerifyExternalStringResource(ExternalStringResource* val) const; 1946 void VerifyExternalStringResource(ExternalStringResource* val) const;
1929 static void CheckCast(v8::Value* obj); 1947 static void CheckCast(v8::Value* obj);
1930 }; 1948 };
1931 1949
1932 1950
1933 /** 1951 /**
1934 * A JavaScript symbol (ECMA-262 edition 6) 1952 * A JavaScript symbol (ECMA-262 edition 6)
1935 * 1953 *
1936 * This is an experimental feature. Use at your own risk. 1954 * This is an experimental feature. Use at your own risk.
1937 */ 1955 */
1938 class V8_EXPORT Symbol : public Primitive { 1956 class V8_EXPORT Symbol : public Name {
1939 public: 1957 public:
1940 // Returns the print name string of the symbol, or undefined if none. 1958 // Returns the print name string of the symbol, or undefined if none.
1941 Local<Value> Name() const; 1959 Local<Value> Name() const;
1942 1960
1943 // Create a symbol. If name is not empty, it will be used as the description. 1961 // Create a symbol. If name is not empty, it will be used as the description.
1944 static Local<Symbol> New( 1962 static Local<Symbol> New(
1945 Isolate *isolate, Local<String> name = Local<String>()); 1963 Isolate *isolate, Local<String> name = Local<String>());
1946 1964
1947 // Access global symbol registry. 1965 // Access global symbol registry.
1948 // Note that symbols created this way are never collected, so 1966 // Note that symbols created this way are never collected, so
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
2072 }; 2090 };
2073 2091
2074 /** 2092 /**
2075 * Accessor[Getter|Setter] are used as callback functions when 2093 * Accessor[Getter|Setter] are used as callback functions when
2076 * setting|getting a particular property. See Object and ObjectTemplate's 2094 * setting|getting a particular property. See Object and ObjectTemplate's
2077 * method SetAccessor. 2095 * method SetAccessor.
2078 */ 2096 */
2079 typedef void (*AccessorGetterCallback)( 2097 typedef void (*AccessorGetterCallback)(
2080 Local<String> property, 2098 Local<String> property,
2081 const PropertyCallbackInfo<Value>& info); 2099 const PropertyCallbackInfo<Value>& info);
2100 typedef void (*AccessorNameGetterCallback)(
2101 Local<Name> property,
2102 const PropertyCallbackInfo<Value>& info);
2082 2103
2083 2104
2084 typedef void (*AccessorSetterCallback)( 2105 typedef void (*AccessorSetterCallback)(
2085 Local<String> property, 2106 Local<String> property,
2086 Local<Value> value, 2107 Local<Value> value,
2087 const PropertyCallbackInfo<void>& info); 2108 const PropertyCallbackInfo<void>& info);
2109 typedef void (*AccessorNameSetterCallback)(
2110 Local<Name> property,
2111 Local<Value> value,
2112 const PropertyCallbackInfo<void>& info);
2088 2113
2089 2114
2090 /** 2115 /**
2091 * Access control specifications. 2116 * Access control specifications.
2092 * 2117 *
2093 * Some accessors should be accessible across contexts. These 2118 * Some accessors should be accessible across contexts. These
2094 * accessors have an explicit access control parameter which specifies 2119 * accessors have an explicit access control parameter which specifies
2095 * the kind of cross-context access that should be allowed. 2120 * the kind of cross-context access that should be allowed.
2096 * 2121 *
2097 * TODO(dcarney): Remove PROHIBITS_OVERWRITING as it is now unused. 2122 * TODO(dcarney): Remove PROHIBITS_OVERWRITING as it is now unused.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2152 bool Has(uint32_t index); 2177 bool Has(uint32_t index);
2153 2178
2154 bool Delete(uint32_t index); 2179 bool Delete(uint32_t index);
2155 2180
2156 bool SetAccessor(Handle<String> name, 2181 bool SetAccessor(Handle<String> name,
2157 AccessorGetterCallback getter, 2182 AccessorGetterCallback getter,
2158 AccessorSetterCallback setter = 0, 2183 AccessorSetterCallback setter = 0,
2159 Handle<Value> data = Handle<Value>(), 2184 Handle<Value> data = Handle<Value>(),
2160 AccessControl settings = DEFAULT, 2185 AccessControl settings = DEFAULT,
2161 PropertyAttribute attribute = None); 2186 PropertyAttribute attribute = None);
2187 bool SetAccessor(Handle<Name> name,
2188 AccessorNameGetterCallback getter,
2189 AccessorNameSetterCallback setter = 0,
2190 Handle<Value> data = Handle<Value>(),
2191 AccessControl settings = DEFAULT,
2192 PropertyAttribute attribute = None);
2162 2193
2163 // This function is not yet stable and should not be used at this time. 2194 // This function is not yet stable and should not be used at this time.
2164 bool SetDeclaredAccessor(Local<String> name, 2195 bool SetDeclaredAccessor(Local<Name> name,
2165 Local<DeclaredAccessorDescriptor> descriptor, 2196 Local<DeclaredAccessorDescriptor> descriptor,
2166 PropertyAttribute attribute = None, 2197 PropertyAttribute attribute = None,
2167 AccessControl settings = DEFAULT); 2198 AccessControl settings = DEFAULT);
2168 2199
2169 void SetAccessorProperty(Local<String> name, 2200 void SetAccessorProperty(Local<Name> name,
2170 Local<Function> getter, 2201 Local<Function> getter,
2171 Handle<Function> setter = Handle<Function>(), 2202 Handle<Function> setter = Handle<Function>(),
2172 PropertyAttribute attribute = None, 2203 PropertyAttribute attribute = None,
2173 AccessControl settings = DEFAULT); 2204 AccessControl settings = DEFAULT);
2174 2205
2175 /** 2206 /**
2176 * Functionality for private properties. 2207 * Functionality for private properties.
2177 * This is an experimental feature, use at your own risk. 2208 * This is an experimental feature, use at your own risk.
2178 * Note: Private properties are inherited. Do not rely on this, since it may 2209 * Note: Private properties are inherited. Do not rely on this, since it may
2179 * change. 2210 * change.
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
3161 3192
3162 // --- Templates --- 3193 // --- Templates ---
3163 3194
3164 3195
3165 /** 3196 /**
3166 * The superclass of object and function templates. 3197 * The superclass of object and function templates.
3167 */ 3198 */
3168 class V8_EXPORT Template : public Data { 3199 class V8_EXPORT Template : public Data {
3169 public: 3200 public:
3170 /** Adds a property to each instance created by this template.*/ 3201 /** Adds a property to each instance created by this template.*/
3171 void Set(Handle<String> name, Handle<Data> value, 3202 void Set(Handle<Name> name, Handle<Data> value,
3172 PropertyAttribute attributes = None); 3203 PropertyAttribute attributes = None);
3173 V8_INLINE void Set(Isolate* isolate, const char* name, Handle<Data> value); 3204 V8_INLINE void Set(Isolate* isolate, const char* name, Handle<Data> value);
3174 3205
3175 void SetAccessorProperty( 3206 void SetAccessorProperty(
3176 Local<String> name, 3207 Local<Name> name,
3177 Local<FunctionTemplate> getter = Local<FunctionTemplate>(), 3208 Local<FunctionTemplate> getter = Local<FunctionTemplate>(),
3178 Local<FunctionTemplate> setter = Local<FunctionTemplate>(), 3209 Local<FunctionTemplate> setter = Local<FunctionTemplate>(),
3179 PropertyAttribute attribute = None, 3210 PropertyAttribute attribute = None,
3180 AccessControl settings = DEFAULT); 3211 AccessControl settings = DEFAULT);
3181 3212
3182 /** 3213 /**
3183 * Whenever the property with the given name is accessed on objects 3214 * Whenever the property with the given name is accessed on objects
3184 * created from this Template the getter and setter callbacks 3215 * created from this Template the getter and setter callbacks
3185 * are called instead of getting and setting the property directly 3216 * are called instead of getting and setting the property directly
3186 * on the JavaScript object. 3217 * on the JavaScript object.
(...skipping 21 matching lines...) Expand all
3208 */ 3239 */
3209 void SetNativeDataProperty(Local<String> name, 3240 void SetNativeDataProperty(Local<String> name,
3210 AccessorGetterCallback getter, 3241 AccessorGetterCallback getter,
3211 AccessorSetterCallback setter = 0, 3242 AccessorSetterCallback setter = 0,
3212 // TODO(dcarney): gcc can't handle Local below 3243 // TODO(dcarney): gcc can't handle Local below
3213 Handle<Value> data = Handle<Value>(), 3244 Handle<Value> data = Handle<Value>(),
3214 PropertyAttribute attribute = None, 3245 PropertyAttribute attribute = None,
3215 Local<AccessorSignature> signature = 3246 Local<AccessorSignature> signature =
3216 Local<AccessorSignature>(), 3247 Local<AccessorSignature>(),
3217 AccessControl settings = DEFAULT); 3248 AccessControl settings = DEFAULT);
3249 void SetNativeDataProperty(Local<Name> name,
3250 AccessorNameGetterCallback getter,
3251 AccessorNameSetterCallback setter = 0,
3252 // TODO(dcarney): gcc can't handle Local below
3253 Handle<Value> data = Handle<Value>(),
3254 PropertyAttribute attribute = None,
3255 Local<AccessorSignature> signature =
3256 Local<AccessorSignature>(),
3257 AccessControl settings = DEFAULT);
3218 3258
3219 // This function is not yet stable and should not be used at this time. 3259 // This function is not yet stable and should not be used at this time.
3220 bool SetDeclaredAccessor(Local<String> name, 3260 bool SetDeclaredAccessor(Local<Name> name,
3221 Local<DeclaredAccessorDescriptor> descriptor, 3261 Local<DeclaredAccessorDescriptor> descriptor,
3222 PropertyAttribute attribute = None, 3262 PropertyAttribute attribute = None,
3223 Local<AccessorSignature> signature = 3263 Local<AccessorSignature> signature =
3224 Local<AccessorSignature>(), 3264 Local<AccessorSignature>(),
3225 AccessControl settings = DEFAULT); 3265 AccessControl settings = DEFAULT);
3226 3266
3227 private: 3267 private:
3228 Template(); 3268 Template();
3229 3269
3230 friend class ObjectTemplate; 3270 friend class ObjectTemplate;
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
3577 * thrown and no callback is invoked. 3617 * thrown and no callback is invoked.
3578 */ 3618 */
3579 void SetAccessor(Handle<String> name, 3619 void SetAccessor(Handle<String> name,
3580 AccessorGetterCallback getter, 3620 AccessorGetterCallback getter,
3581 AccessorSetterCallback setter = 0, 3621 AccessorSetterCallback setter = 0,
3582 Handle<Value> data = Handle<Value>(), 3622 Handle<Value> data = Handle<Value>(),
3583 AccessControl settings = DEFAULT, 3623 AccessControl settings = DEFAULT,
3584 PropertyAttribute attribute = None, 3624 PropertyAttribute attribute = None,
3585 Handle<AccessorSignature> signature = 3625 Handle<AccessorSignature> signature =
3586 Handle<AccessorSignature>()); 3626 Handle<AccessorSignature>());
3627 void SetAccessor(Handle<Name> name,
3628 AccessorNameGetterCallback getter,
3629 AccessorNameSetterCallback setter = 0,
3630 Handle<Value> data = Handle<Value>(),
3631 AccessControl settings = DEFAULT,
3632 PropertyAttribute attribute = None,
3633 Handle<AccessorSignature> signature =
3634 Handle<AccessorSignature>());
3587 3635
3588 /** 3636 /**
3589 * Sets a named property handler on the object template. 3637 * Sets a named property handler on the object template.
3590 * 3638 *
3591 * Whenever a named property is accessed on objects created from 3639 * Whenever a property whose name is a string is accessed on objects created
3592 * this object template, the provided callback is invoked instead of 3640 * from this object template, the provided callback is invoked instead of
3593 * accessing the property directly on the JavaScript object. 3641 * accessing the property directly on the JavaScript object.
3594 * 3642 *
3595 * \param getter The callback to invoke when getting a property. 3643 * \param getter The callback to invoke when getting a property.
3596 * \param setter The callback to invoke when setting a property. 3644 * \param setter The callback to invoke when setting a property.
3597 * \param query The callback to invoke to check if a property is present, 3645 * \param query The callback to invoke to check if a property is present,
3598 * and if present, get its attributes. 3646 * and if present, get its attributes.
3599 * \param deleter The callback to invoke when deleting a property. 3647 * \param deleter The callback to invoke when deleting a property.
3600 * \param enumerator The callback to invoke to enumerate all the named 3648 * \param enumerator The callback to invoke to enumerate all the named
3601 * properties of an object. 3649 * properties of an object.
3602 * \param data A piece of data that will be passed to the callbacks 3650 * \param data A piece of data that will be passed to the callbacks
(...skipping 2728 matching lines...) Expand 10 before | Expand all | Expand 10 after
6331 if (!I::HasHeapObjectTag(obj)) return false; 6379 if (!I::HasHeapObjectTag(obj)) return false;
6332 return (I::GetInstanceType(obj) < I::kFirstNonstringType); 6380 return (I::GetInstanceType(obj) < I::kFirstNonstringType);
6333 } 6381 }
6334 6382
6335 6383
6336 template <class T> Value* Value::Cast(T* value) { 6384 template <class T> Value* Value::Cast(T* value) {
6337 return static_cast<Value*>(value); 6385 return static_cast<Value*>(value);
6338 } 6386 }
6339 6387
6340 6388
6389 Name* Name::Cast(v8::Value* value) {
6390 #ifdef V8_ENABLE_CHECKS
6391 CheckCast(value);
6392 #endif
6393 return static_cast<Name*>(value);
6394 }
6395
6396
6341 Symbol* Symbol::Cast(v8::Value* value) { 6397 Symbol* Symbol::Cast(v8::Value* value) {
6342 #ifdef V8_ENABLE_CHECKS 6398 #ifdef V8_ENABLE_CHECKS
6343 CheckCast(value); 6399 CheckCast(value);
6344 #endif 6400 #endif
6345 return static_cast<Symbol*>(value); 6401 return static_cast<Symbol*>(value);
6346 } 6402 }
6347 6403
6348 6404
6349 Number* Number::Cast(v8::Value* value) { 6405 Number* Number::Cast(v8::Value* value) {
6350 #ifdef V8_ENABLE_CHECKS 6406 #ifdef V8_ENABLE_CHECKS
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
6732 */ 6788 */
6733 6789
6734 6790
6735 } // namespace v8 6791 } // namespace v8
6736 6792
6737 6793
6738 #undef TYPE_CHECK 6794 #undef TYPE_CHECK
6739 6795
6740 6796
6741 #endif // V8_H_ 6797 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/accessors.h » ('j') | src/api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698