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

Side by Side Diff: include/v8.h

Issue 10442129: Implement implicit instance checks for API accessors. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Daniel Clifford. Created 8 years, 6 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/api.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 class Uint32; 93 class Uint32;
94 class External; 94 class External;
95 class Primitive; 95 class Primitive;
96 class Boolean; 96 class Boolean;
97 class BooleanObject; 97 class BooleanObject;
98 class Integer; 98 class Integer;
99 class Function; 99 class Function;
100 class Date; 100 class Date;
101 class ImplementationUtilities; 101 class ImplementationUtilities;
102 class Signature; 102 class Signature;
103 class AccessorSignature;
103 template <class T> class Handle; 104 template <class T> class Handle;
104 template <class T> class Local; 105 template <class T> class Local;
105 template <class T> class Persistent; 106 template <class T> class Persistent;
106 class FunctionTemplate; 107 class FunctionTemplate;
107 class ObjectTemplate; 108 class ObjectTemplate;
108 class Data; 109 class Data;
109 class AccessorInfo; 110 class AccessorInfo;
110 class StackTrace; 111 class StackTrace;
111 class StackFrame; 112 class StackFrame;
112 class Isolate; 113 class Isolate;
(...skipping 2169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2282 */ 2283 */
2283 bool HasInstance(Handle<Value> object); 2284 bool HasInstance(Handle<Value> object);
2284 2285
2285 private: 2286 private:
2286 FunctionTemplate(); 2287 FunctionTemplate();
2287 void AddInstancePropertyAccessor(Handle<String> name, 2288 void AddInstancePropertyAccessor(Handle<String> name,
2288 AccessorGetter getter, 2289 AccessorGetter getter,
2289 AccessorSetter setter, 2290 AccessorSetter setter,
2290 Handle<Value> data, 2291 Handle<Value> data,
2291 AccessControl settings, 2292 AccessControl settings,
2292 PropertyAttribute attributes); 2293 PropertyAttribute attributes,
2294 Handle<AccessorSignature> signature);
2293 void SetNamedInstancePropertyHandler(NamedPropertyGetter getter, 2295 void SetNamedInstancePropertyHandler(NamedPropertyGetter getter,
2294 NamedPropertySetter setter, 2296 NamedPropertySetter setter,
2295 NamedPropertyQuery query, 2297 NamedPropertyQuery query,
2296 NamedPropertyDeleter remover, 2298 NamedPropertyDeleter remover,
2297 NamedPropertyEnumerator enumerator, 2299 NamedPropertyEnumerator enumerator,
2298 Handle<Value> data); 2300 Handle<Value> data);
2299 void SetIndexedInstancePropertyHandler(IndexedPropertyGetter getter, 2301 void SetIndexedInstancePropertyHandler(IndexedPropertyGetter getter,
2300 IndexedPropertySetter setter, 2302 IndexedPropertySetter setter,
2301 IndexedPropertyQuery query, 2303 IndexedPropertyQuery query,
2302 IndexedPropertyDeleter remover, 2304 IndexedPropertyDeleter remover,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2340 * \param settings Access control settings for the accessor. This is a bit 2342 * \param settings Access control settings for the accessor. This is a bit
2341 * field consisting of one of more of 2343 * field consisting of one of more of
2342 * DEFAULT = 0, ALL_CAN_READ = 1, or ALL_CAN_WRITE = 2. 2344 * DEFAULT = 0, ALL_CAN_READ = 1, or ALL_CAN_WRITE = 2.
2343 * The default is to not allow cross-context access. 2345 * The default is to not allow cross-context access.
2344 * ALL_CAN_READ means that all cross-context reads are allowed. 2346 * ALL_CAN_READ means that all cross-context reads are allowed.
2345 * ALL_CAN_WRITE means that all cross-context writes are allowed. 2347 * ALL_CAN_WRITE means that all cross-context writes are allowed.
2346 * The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all 2348 * The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all
2347 * cross-context access. 2349 * cross-context access.
2348 * \param attribute The attributes of the property for which an accessor 2350 * \param attribute The attributes of the property for which an accessor
2349 * is added. 2351 * is added.
2352 * \param signature The signature describes valid receivers for the accessor
2353 * and is used to perform implicit instance checks against them. If the
2354 * receiver is incompatible (i.e. is not an instance of the constructor as
2355 * defined by FunctionTemplate::HasInstance()), an implicit TypeError is
2356 * thrown and no callback is invoked.
2350 */ 2357 */
2351 void SetAccessor(Handle<String> name, 2358 void SetAccessor(Handle<String> name,
2352 AccessorGetter getter, 2359 AccessorGetter getter,
2353 AccessorSetter setter = 0, 2360 AccessorSetter setter = 0,
2354 Handle<Value> data = Handle<Value>(), 2361 Handle<Value> data = Handle<Value>(),
2355 AccessControl settings = DEFAULT, 2362 AccessControl settings = DEFAULT,
2356 PropertyAttribute attribute = None); 2363 PropertyAttribute attribute = None,
2364 Handle<AccessorSignature> signature =
2365 Handle<AccessorSignature>());
2357 2366
2358 /** 2367 /**
2359 * Sets a named property handler on the object template. 2368 * Sets a named property handler on the object template.
2360 * 2369 *
2361 * Whenever a named property is accessed on objects created from 2370 * Whenever a named property is accessed on objects created from
2362 * this object template, the provided callback is invoked instead of 2371 * this object template, the provided callback is invoked instead of
2363 * accessing the property directly on the JavaScript object. 2372 * accessing the property directly on the JavaScript object.
2364 * 2373 *
2365 * \param getter The callback to invoke when getting a property. 2374 * \param getter The callback to invoke when getting a property.
2366 * \param setter The callback to invoke when setting a property. 2375 * \param setter The callback to invoke when setting a property.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 void SetInternalFieldCount(int value); 2459 void SetInternalFieldCount(int value);
2451 2460
2452 private: 2461 private:
2453 ObjectTemplate(); 2462 ObjectTemplate();
2454 static Local<ObjectTemplate> New(Handle<FunctionTemplate> constructor); 2463 static Local<ObjectTemplate> New(Handle<FunctionTemplate> constructor);
2455 friend class FunctionTemplate; 2464 friend class FunctionTemplate;
2456 }; 2465 };
2457 2466
2458 2467
2459 /** 2468 /**
2460 * A Signature specifies which receivers and arguments a function can 2469 * A Signature specifies which receivers and arguments are valid
2461 * legally be called with. 2470 * parameters to a function.
2462 */ 2471 */
2463 class V8EXPORT Signature : public Data { 2472 class V8EXPORT Signature : public Data {
2464 public: 2473 public:
2465 static Local<Signature> New(Handle<FunctionTemplate> receiver = 2474 static Local<Signature> New(Handle<FunctionTemplate> receiver =
2466 Handle<FunctionTemplate>(), 2475 Handle<FunctionTemplate>(),
2467 int argc = 0, 2476 int argc = 0,
2468 Handle<FunctionTemplate> argv[] = 0); 2477 Handle<FunctionTemplate> argv[] = 0);
2469 private: 2478 private:
2470 Signature(); 2479 Signature();
2471 }; 2480 };
2472 2481
2473 2482
2474 /** 2483 /**
2484 * An AccessorSignature specifies which receivers are valid parameters
2485 * to an accessor callback.
2486 */
2487 class V8EXPORT AccessorSignature : public Data {
2488 public:
2489 static Local<AccessorSignature> New(Handle<FunctionTemplate> receiver =
2490 Handle<FunctionTemplate>());
2491 private:
2492 AccessorSignature();
2493 };
2494
2495
2496 /**
2475 * A utility for determining the type of objects based on the template 2497 * A utility for determining the type of objects based on the template
2476 * they were constructed from. 2498 * they were constructed from.
2477 */ 2499 */
2478 class V8EXPORT TypeSwitch : public Data { 2500 class V8EXPORT TypeSwitch : public Data {
2479 public: 2501 public:
2480 static Local<TypeSwitch> New(Handle<FunctionTemplate> type); 2502 static Local<TypeSwitch> New(Handle<FunctionTemplate> type);
2481 static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]); 2503 static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]);
2482 int match(Handle<Value> value); 2504 int match(Handle<Value> value);
2483 private: 2505 private:
2484 TypeSwitch(); 2506 TypeSwitch();
(...skipping 1989 matching lines...) Expand 10 before | Expand all | Expand 10 after
4474 4496
4475 4497
4476 } // namespace v8 4498 } // namespace v8
4477 4499
4478 4500
4479 #undef V8EXPORT 4501 #undef V8EXPORT
4480 #undef TYPE_CHECK 4502 #undef TYPE_CHECK
4481 4503
4482 4504
4483 #endif // V8_H_ 4505 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698