OLD | NEW |
---|---|
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 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1405 /** | 1405 /** |
1406 * Returns true if this value is a NativeError. | 1406 * Returns true if this value is a NativeError. |
1407 */ | 1407 */ |
1408 bool IsNativeError() const; | 1408 bool IsNativeError() const; |
1409 | 1409 |
1410 /** | 1410 /** |
1411 * Returns true if this value is a RegExp. | 1411 * Returns true if this value is a RegExp. |
1412 */ | 1412 */ |
1413 bool IsRegExp() const; | 1413 bool IsRegExp() const; |
1414 | 1414 |
1415 /** | |
1416 * Returns true if this value is a Promise. | |
1417 * This is an experimental feature. Only works with --harmony flag. | |
Sven Panne
2014/03/11 11:44:05
Hopefully this works without --harmony, too (and r
rossberg
2014/03/11 16:08:40
Done.
| |
1418 */ | |
1419 bool IsPromise() const; | |
1415 | 1420 |
1416 /** | 1421 /** |
1417 * Returns true if this value is an ArrayBuffer. | 1422 * Returns true if this value is an ArrayBuffer. |
1418 * This is an experimental feature. | 1423 * This is an experimental feature. |
1419 */ | 1424 */ |
1420 bool IsArrayBuffer() const; | 1425 bool IsArrayBuffer() const; |
1421 | 1426 |
1422 /** | 1427 /** |
1423 * Returns true if this value is an ArrayBufferView. | 1428 * Returns true if this value is an ArrayBufferView. |
1424 * This is an experimental feature. | 1429 * This is an experimental feature. |
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2529 | 2534 |
2530 ScriptOrigin GetScriptOrigin() const; | 2535 ScriptOrigin GetScriptOrigin() const; |
2531 V8_INLINE static Function* Cast(Value* obj); | 2536 V8_INLINE static Function* Cast(Value* obj); |
2532 static const int kLineOffsetNotFound; | 2537 static const int kLineOffsetNotFound; |
2533 | 2538 |
2534 private: | 2539 private: |
2535 Function(); | 2540 Function(); |
2536 static void CheckCast(Value* obj); | 2541 static void CheckCast(Value* obj); |
2537 }; | 2542 }; |
2538 | 2543 |
2544 | |
2545 /** | |
2546 * An instance of the built-in Promise constructor (ES6 draft). | |
2547 * This API is experimental. Only works with --harmony flag. | |
2548 */ | |
2549 class V8_EXPORT Promise : public Object { | |
2550 public: | |
2551 /** | |
2552 * Create a new Promise in pending state. | |
2553 */ | |
2554 static Local<Promise> New(Isolate* isolate); | |
2555 | |
2556 /** | |
2557 * Resolve/reject a promise with a given value. | |
2558 * Ignored if the promise is not unresolved. | |
2559 */ | |
2560 void Resolve(Handle<Value> value); | |
2561 void Reject(Handle<Value> value); | |
2562 | |
yhirano
2014/03/11 11:46:42
Can we have Then, too?
rossberg
2014/03/11 16:08:40
Will that actually be useful on the API side? (I'm
| |
2563 /** | |
2564 * Register a resolution/rejection handler with a promise. | |
2565 * The handler is given the respective resolution/rejection value as | |
2566 * an argument. If the promise is already resolved/rejected, the handler is | |
2567 * invoked at the end of turn. | |
2568 */ | |
2569 Local<Promise> Chain(Handle<Function> handler); | |
2570 Local<Promise> Catch(Handle<Function> handler); | |
2571 | |
2572 V8_INLINE static Promise* Cast(Value* obj); | |
2573 | |
2574 private: | |
2575 Promise(); | |
2576 static void CheckCast(Value* obj); | |
2577 }; | |
2578 | |
2579 | |
2539 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT | 2580 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT |
2540 // The number of required internal fields can be defined by embedder. | 2581 // The number of required internal fields can be defined by embedder. |
2541 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 | 2582 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 |
2542 #endif | 2583 #endif |
2543 | 2584 |
2544 /** | 2585 /** |
2545 * An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5). | 2586 * An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5). |
2546 * This API is experimental and may change significantly. | 2587 * This API is experimental and may change significantly. |
2547 */ | 2588 */ |
2548 class V8_EXPORT ArrayBuffer : public Object { | 2589 class V8_EXPORT ArrayBuffer : public Object { |
(...skipping 3633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6182 | 6223 |
6183 | 6224 |
6184 Array* Array::Cast(v8::Value* value) { | 6225 Array* Array::Cast(v8::Value* value) { |
6185 #ifdef V8_ENABLE_CHECKS | 6226 #ifdef V8_ENABLE_CHECKS |
6186 CheckCast(value); | 6227 CheckCast(value); |
6187 #endif | 6228 #endif |
6188 return static_cast<Array*>(value); | 6229 return static_cast<Array*>(value); |
6189 } | 6230 } |
6190 | 6231 |
6191 | 6232 |
6233 Promise* Promise::Cast(v8::Value* value) { | |
6234 #ifdef V8_ENABLE_CHECKS | |
6235 CheckCast(value); | |
6236 #endif | |
6237 return static_cast<Promise*>(value); | |
6238 } | |
6239 | |
6240 | |
6192 ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) { | 6241 ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) { |
6193 #ifdef V8_ENABLE_CHECKS | 6242 #ifdef V8_ENABLE_CHECKS |
6194 CheckCast(value); | 6243 CheckCast(value); |
6195 #endif | 6244 #endif |
6196 return static_cast<ArrayBuffer*>(value); | 6245 return static_cast<ArrayBuffer*>(value); |
6197 } | 6246 } |
6198 | 6247 |
6199 | 6248 |
6200 ArrayBufferView* ArrayBufferView::Cast(v8::Value* value) { | 6249 ArrayBufferView* ArrayBufferView::Cast(v8::Value* value) { |
6201 #ifdef V8_ENABLE_CHECKS | 6250 #ifdef V8_ENABLE_CHECKS |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6457 */ | 6506 */ |
6458 | 6507 |
6459 | 6508 |
6460 } // namespace v8 | 6509 } // namespace v8 |
6461 | 6510 |
6462 | 6511 |
6463 #undef TYPE_CHECK | 6512 #undef TYPE_CHECK |
6464 | 6513 |
6465 | 6514 |
6466 #endif // V8_H_ | 6515 #endif // V8_H_ |
OLD | NEW |