OLD | NEW |
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 2860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2871 * Checks whether a callback is set by the | 2871 * Checks whether a callback is set by the |
2872 * ObjectTemplate::SetCallAsFunctionHandler method. | 2872 * ObjectTemplate::SetCallAsFunctionHandler method. |
2873 * When an Object is callable this method returns true. | 2873 * When an Object is callable this method returns true. |
2874 */ | 2874 */ |
2875 bool IsCallable(); | 2875 bool IsCallable(); |
2876 | 2876 |
2877 /** | 2877 /** |
2878 * Call an Object as a function if a callback is set by the | 2878 * Call an Object as a function if a callback is set by the |
2879 * ObjectTemplate::SetCallAsFunctionHandler method. | 2879 * ObjectTemplate::SetCallAsFunctionHandler method. |
2880 */ | 2880 */ |
2881 Local<Value> CallAsFunction(Handle<Value> recv, | 2881 V8_DEPRECATE_SOON("Use maybe version", |
2882 int argc, | 2882 Local<Value> CallAsFunction(Handle<Value> recv, int argc, |
2883 Handle<Value> argv[]); | 2883 Handle<Value> argv[])); |
2884 MaybeLocal<Value> CallAsFunction(Local<Context> context, Handle<Value> recv, | 2884 MaybeLocal<Value> CallAsFunction(Local<Context> context, Handle<Value> recv, |
2885 int argc, Handle<Value> argv[]); | 2885 int argc, Handle<Value> argv[]); |
2886 | 2886 |
2887 /** | 2887 /** |
2888 * Call an Object as a constructor if a callback is set by the | 2888 * Call an Object as a constructor if a callback is set by the |
2889 * ObjectTemplate::SetCallAsFunctionHandler method. | 2889 * ObjectTemplate::SetCallAsFunctionHandler method. |
2890 * Note: This method behaves like the Function::NewInstance method. | 2890 * Note: This method behaves like the Function::NewInstance method. |
2891 */ | 2891 */ |
2892 Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]); | 2892 V8_DEPRECATE_SOON("Use maybe version", |
| 2893 Local<Value> CallAsConstructor(int argc, |
| 2894 Handle<Value> argv[])); |
2893 MaybeLocal<Value> CallAsConstructor(Local<Context> context, int argc, | 2895 MaybeLocal<Value> CallAsConstructor(Local<Context> context, int argc, |
2894 Local<Value> argv[]); | 2896 Local<Value> argv[]); |
2895 | 2897 |
2896 /** | 2898 /** |
2897 * Return the isolate to which the Object belongs to. | 2899 * Return the isolate to which the Object belongs to. |
2898 */ | 2900 */ |
2899 V8_DEPRECATE_SOON("Keep track of isolate correctly", Isolate* GetIsolate()); | 2901 V8_DEPRECATE_SOON("Keep track of isolate correctly", Isolate* GetIsolate()); |
2900 | 2902 |
2901 static Local<Object> New(Isolate* isolate); | 2903 static Local<Object> New(Isolate* isolate); |
2902 | 2904 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3059 public: | 3061 public: |
3060 /** | 3062 /** |
3061 * Create a function in the current execution context | 3063 * Create a function in the current execution context |
3062 * for a given FunctionCallback. | 3064 * for a given FunctionCallback. |
3063 */ | 3065 */ |
3064 static Local<Function> New(Isolate* isolate, | 3066 static Local<Function> New(Isolate* isolate, |
3065 FunctionCallback callback, | 3067 FunctionCallback callback, |
3066 Local<Value> data = Local<Value>(), | 3068 Local<Value> data = Local<Value>(), |
3067 int length = 0); | 3069 int length = 0); |
3068 | 3070 |
3069 Local<Object> NewInstance() const; | 3071 V8_DEPRECATE_SOON("Use maybe version", |
3070 Local<Object> NewInstance(int argc, Handle<Value> argv[]) const; | 3072 Local<Object> NewInstance(int argc, |
3071 Local<Value> Call(Handle<Value> recv, int argc, Handle<Value> argv[]); | 3073 Handle<Value> argv[])) const; |
| 3074 MaybeLocal<Object> NewInstance(Local<Context> context, int argc, |
| 3075 Handle<Value> argv[]) const; |
| 3076 |
| 3077 V8_DEPRECATE_SOON("Use maybe version", Local<Object> NewInstance()) const; |
| 3078 MaybeLocal<Object> NewInstance(Local<Context> context) const { |
| 3079 return NewInstance(context, 0, nullptr); |
| 3080 } |
| 3081 |
| 3082 V8_DEPRECATE_SOON("Use maybe version", |
| 3083 Local<Value> Call(Handle<Value> recv, int argc, |
| 3084 Handle<Value> argv[])); |
| 3085 MaybeLocal<Value> Call(Local<Context> context, Handle<Value> recv, int argc, |
| 3086 Handle<Value> argv[]); |
| 3087 |
3072 void SetName(Handle<String> name); | 3088 void SetName(Handle<String> name); |
3073 Handle<Value> GetName() const; | 3089 Handle<Value> GetName() const; |
3074 | 3090 |
3075 /** | 3091 /** |
3076 * Name inferred from variable or property assignment of this function. | 3092 * Name inferred from variable or property assignment of this function. |
3077 * Used to facilitate debugging and profiling of JavaScript code written | 3093 * Used to facilitate debugging and profiling of JavaScript code written |
3078 * in an OO style, where many functions are anonymous but are assigned | 3094 * in an OO style, where many functions are anonymous but are assigned |
3079 * to object properties. | 3095 * to object properties. |
3080 */ | 3096 */ |
3081 Handle<Value> GetInferredName() const; | 3097 Handle<Value> GetInferredName() const; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3127 * An instance of the built-in Promise constructor (ES6 draft). | 3143 * An instance of the built-in Promise constructor (ES6 draft). |
3128 * This API is experimental. Only works with --harmony flag. | 3144 * This API is experimental. Only works with --harmony flag. |
3129 */ | 3145 */ |
3130 class V8_EXPORT Promise : public Object { | 3146 class V8_EXPORT Promise : public Object { |
3131 public: | 3147 public: |
3132 class V8_EXPORT Resolver : public Object { | 3148 class V8_EXPORT Resolver : public Object { |
3133 public: | 3149 public: |
3134 /** | 3150 /** |
3135 * Create a new resolver, along with an associated promise in pending state. | 3151 * Create a new resolver, along with an associated promise in pending state. |
3136 */ | 3152 */ |
3137 static Local<Resolver> New(Isolate* isolate); | 3153 static V8_DEPRECATE_SOON("Use maybe version", |
| 3154 Local<Resolver> New(Isolate* isolate)); |
| 3155 static MaybeLocal<Resolver> New(Local<Context> context); |
3138 | 3156 |
3139 /** | 3157 /** |
3140 * Extract the associated promise. | 3158 * Extract the associated promise. |
3141 */ | 3159 */ |
3142 Local<Promise> GetPromise(); | 3160 Local<Promise> GetPromise(); |
3143 | 3161 |
3144 /** | 3162 /** |
3145 * Resolve/reject the associated promise with a given value. | 3163 * Resolve/reject the associated promise with a given value. |
3146 * Ignored if the promise is no longer pending. | 3164 * Ignored if the promise is no longer pending. |
3147 */ | 3165 */ |
3148 void Resolve(Handle<Value> value); | 3166 V8_DEPRECATE_SOON("Use maybe version", void Resolve(Handle<Value> value)); |
3149 void Reject(Handle<Value> value); | 3167 Maybe<bool> Resolve(Local<Context> context, Handle<Value> value); |
| 3168 |
| 3169 V8_DEPRECATE_SOON("Use maybe version", void Reject(Handle<Value> value)); |
| 3170 Maybe<bool> Reject(Local<Context> context, Handle<Value> value); |
3150 | 3171 |
3151 V8_INLINE static Resolver* Cast(Value* obj); | 3172 V8_INLINE static Resolver* Cast(Value* obj); |
3152 | 3173 |
3153 private: | 3174 private: |
3154 Resolver(); | 3175 Resolver(); |
3155 static void CheckCast(Value* obj); | 3176 static void CheckCast(Value* obj); |
3156 }; | 3177 }; |
3157 | 3178 |
3158 /** | 3179 /** |
3159 * Register a resolution/rejection handler with a promise. | 3180 * Register a resolution/rejection handler with a promise. |
3160 * The handler is given the respective resolution/rejection value as | 3181 * The handler is given the respective resolution/rejection value as |
3161 * an argument. If the promise is already resolved/rejected, the handler is | 3182 * an argument. If the promise is already resolved/rejected, the handler is |
3162 * invoked at the end of turn. | 3183 * invoked at the end of turn. |
3163 */ | 3184 */ |
3164 Local<Promise> Chain(Handle<Function> handler); | 3185 V8_DEPRECATE_SOON("Use maybe version", |
3165 Local<Promise> Catch(Handle<Function> handler); | 3186 Local<Promise> Chain(Handle<Function> handler)); |
3166 Local<Promise> Then(Handle<Function> handler); | 3187 MaybeLocal<Promise> Chain(Local<Context> context, Handle<Function> handler); |
| 3188 |
| 3189 V8_DEPRECATE_SOON("Use maybe version", |
| 3190 Local<Promise> Catch(Handle<Function> handler)); |
| 3191 MaybeLocal<Promise> Catch(Local<Context> context, Handle<Function> handler); |
| 3192 |
| 3193 V8_DEPRECATE_SOON("Use maybe version", |
| 3194 Local<Promise> Then(Handle<Function> handler)); |
| 3195 MaybeLocal<Promise> Then(Local<Context> context, Handle<Function> handler); |
3167 | 3196 |
3168 /** | 3197 /** |
3169 * Returns true if the promise has at least one derived promise, and | 3198 * Returns true if the promise has at least one derived promise, and |
3170 * therefore resolve/reject handlers (including default handler). | 3199 * therefore resolve/reject handlers (including default handler). |
3171 */ | 3200 */ |
3172 bool HasHandler(); | 3201 bool HasHandler(); |
3173 | 3202 |
3174 V8_INLINE static Promise* Cast(Value* obj); | 3203 V8_INLINE static Promise* Cast(Value* obj); |
3175 | 3204 |
3176 private: | 3205 private: |
(...skipping 4624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7801 */ | 7830 */ |
7802 | 7831 |
7803 | 7832 |
7804 } // namespace v8 | 7833 } // namespace v8 |
7805 | 7834 |
7806 | 7835 |
7807 #undef TYPE_CHECK | 7836 #undef TYPE_CHECK |
7808 | 7837 |
7809 | 7838 |
7810 #endif // V8_H_ | 7839 #endif // V8_H_ |
OLD | NEW |