| 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 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2354 */ | 2354 */ |
| 2355 static Local<Array> New(int length = 0); | 2355 static Local<Array> New(int length = 0); |
| 2356 | 2356 |
| 2357 V8_INLINE(static Array* Cast(Value* obj)); | 2357 V8_INLINE(static Array* Cast(Value* obj)); |
| 2358 private: | 2358 private: |
| 2359 Array(); | 2359 Array(); |
| 2360 static void CheckCast(Value* obj); | 2360 static void CheckCast(Value* obj); |
| 2361 }; | 2361 }; |
| 2362 | 2362 |
| 2363 | 2363 |
| 2364 template<typename T> |
| 2365 class ReturnValue { |
| 2366 public: |
| 2367 template <class S> V8_INLINE(ReturnValue(const ReturnValue<S>& that)) |
| 2368 : value_(that.value_) { |
| 2369 TYPE_CHECK(T, S); |
| 2370 } |
| 2371 // Handle setters |
| 2372 template <typename S> V8_INLINE(void Set(const Persistent<S>& handle)); |
| 2373 template <typename S> V8_INLINE(void Set(const Handle<S> handle)); |
| 2374 // Fast primitive setters |
| 2375 V8_INLINE(void Set(bool value)); |
| 2376 V8_INLINE(void Set(double i)); |
| 2377 V8_INLINE(void Set(int32_t i)); |
| 2378 V8_INLINE(void Set(uint32_t i)); |
| 2379 // Fast JS primitive setters |
| 2380 V8_INLINE(void SetNull()); |
| 2381 V8_INLINE(void SetUndefined()); |
| 2382 V8_INLINE(void SetEmptyString()); |
| 2383 // Convenience getter for Isolate |
| 2384 V8_INLINE(Isolate* GetIsolate()); |
| 2385 |
| 2386 private: |
| 2387 template<class F> friend class ReturnValue; |
| 2388 template<class F> friend class FunctionCallbackInfo; |
| 2389 template<class F> friend class PropertyCallbackInfo; |
| 2390 V8_INLINE(internal::Object* GetDefaultValue()); |
| 2391 V8_INLINE(explicit ReturnValue(internal::Object** slot)); |
| 2392 internal::Object** value_; |
| 2393 }; |
| 2394 |
| 2395 |
| 2396 /** |
| 2397 * The argument information given to function call callbacks. This |
| 2398 * class provides access to information about the context of the call, |
| 2399 * including the receiver, the number and values of arguments, and |
| 2400 * the holder of the function. |
| 2401 */ |
| 2402 template<typename T> |
| 2403 class FunctionCallbackInfo { |
| 2404 public: |
| 2405 V8_INLINE(int Length() const); |
| 2406 V8_INLINE(Local<Value> operator[](int i) const); |
| 2407 V8_INLINE(Local<Function> Callee() const); |
| 2408 V8_INLINE(Local<Object> This() const); |
| 2409 V8_INLINE(Local<Object> Holder() const); |
| 2410 V8_INLINE(bool IsConstructCall() const); |
| 2411 V8_INLINE(Local<Value> Data() const); |
| 2412 V8_INLINE(Isolate* GetIsolate() const); |
| 2413 V8_INLINE(ReturnValue<T> GetReturnValue() const); |
| 2414 // This shouldn't be public, but the arm compiler needs it. |
| 2415 static const int kArgsLength = 6; |
| 2416 |
| 2417 protected: |
| 2418 friend class internal::FunctionCallbackArguments; |
| 2419 friend class internal::CustomArguments<FunctionCallbackInfo>; |
| 2420 static const int kReturnValueIndex = 0; |
| 2421 static const int kReturnValueDefaultValueIndex = -1; |
| 2422 static const int kIsolateIndex = -2; |
| 2423 static const int kDataIndex = -3; |
| 2424 static const int kCalleeIndex = -4; |
| 2425 static const int kHolderIndex = -5; |
| 2426 |
| 2427 V8_INLINE(FunctionCallbackInfo(internal::Object** implicit_args, |
| 2428 internal::Object** values, |
| 2429 int length, |
| 2430 bool is_construct_call)); |
| 2431 internal::Object** implicit_args_; |
| 2432 internal::Object** values_; |
| 2433 int length_; |
| 2434 bool is_construct_call_; |
| 2435 }; |
| 2436 |
| 2437 |
| 2438 /** |
| 2439 * The information passed to a property callback about the context |
| 2440 * of the property access. |
| 2441 */ |
| 2442 template<typename T> |
| 2443 class PropertyCallbackInfo { |
| 2444 public: |
| 2445 V8_INLINE(Isolate* GetIsolate() const); |
| 2446 V8_INLINE(Local<Value> Data() const); |
| 2447 V8_INLINE(Local<Object> This() const); |
| 2448 V8_INLINE(Local<Object> Holder() const); |
| 2449 V8_INLINE(ReturnValue<T> GetReturnValue() const); |
| 2450 // This shouldn't be public, but the arm compiler needs it. |
| 2451 static const int kArgsLength = 6; |
| 2452 |
| 2453 protected: |
| 2454 friend class MacroAssembler; |
| 2455 friend class internal::PropertyCallbackArguments; |
| 2456 friend class internal::CustomArguments<PropertyCallbackInfo>; |
| 2457 static const int kThisIndex = 0; |
| 2458 static const int kHolderIndex = -1; |
| 2459 static const int kDataIndex = -2; |
| 2460 static const int kReturnValueIndex = -3; |
| 2461 static const int kReturnValueDefaultValueIndex = -4; |
| 2462 static const int kIsolateIndex = -5; |
| 2463 |
| 2464 V8_INLINE(PropertyCallbackInfo(internal::Object** args)) |
| 2465 : args_(args) { } |
| 2466 internal::Object** args_; |
| 2467 }; |
| 2468 |
| 2469 |
| 2470 typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info); |
| 2471 |
| 2472 |
| 2364 /** | 2473 /** |
| 2365 * A JavaScript function object (ECMA-262, 15.3). | 2474 * A JavaScript function object (ECMA-262, 15.3). |
| 2366 */ | 2475 */ |
| 2367 class V8_EXPORT Function : public Object { | 2476 class V8_EXPORT Function : public Object { |
| 2368 public: | 2477 public: |
| 2478 /** |
| 2479 * Create a function in the current execution context |
| 2480 * for a given FunctionCallback. |
| 2481 */ |
| 2482 static Local<Function> New(Isolate* isolate, |
| 2483 FunctionCallback callback, |
| 2484 Local<Value> data = Local<Value>(), |
| 2485 int length = 0); |
| 2486 |
| 2369 Local<Object> NewInstance() const; | 2487 Local<Object> NewInstance() const; |
| 2370 Local<Object> NewInstance(int argc, Handle<Value> argv[]) const; | 2488 Local<Object> NewInstance(int argc, Handle<Value> argv[]) const; |
| 2371 Local<Value> Call(Handle<Object> recv, int argc, Handle<Value> argv[]); | 2489 Local<Value> Call(Handle<Object> recv, int argc, Handle<Value> argv[]); |
| 2372 void SetName(Handle<String> name); | 2490 void SetName(Handle<String> name); |
| 2373 Handle<Value> GetName() const; | 2491 Handle<Value> GetName() const; |
| 2374 | 2492 |
| 2375 /** | 2493 /** |
| 2376 * Name inferred from variable or property assignment of this function. | 2494 * Name inferred from variable or property assignment of this function. |
| 2377 * Used to facilitate debugging and profiling of JavaScript code written | 2495 * Used to facilitate debugging and profiling of JavaScript code written |
| 2378 * in an OO style, where many functions are anonymous but are assigned | 2496 * in an OO style, where many functions are anonymous but are assigned |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3027 AccessControl settings = DEFAULT); | 3145 AccessControl settings = DEFAULT); |
| 3028 | 3146 |
| 3029 private: | 3147 private: |
| 3030 Template(); | 3148 Template(); |
| 3031 | 3149 |
| 3032 friend class ObjectTemplate; | 3150 friend class ObjectTemplate; |
| 3033 friend class FunctionTemplate; | 3151 friend class FunctionTemplate; |
| 3034 }; | 3152 }; |
| 3035 | 3153 |
| 3036 | 3154 |
| 3037 template<typename T> | |
| 3038 class ReturnValue { | |
| 3039 public: | |
| 3040 template <class S> V8_INLINE(ReturnValue(const ReturnValue<S>& that)) | |
| 3041 : value_(that.value_) { | |
| 3042 TYPE_CHECK(T, S); | |
| 3043 } | |
| 3044 // Handle setters | |
| 3045 template <typename S> V8_INLINE(void Set(const Persistent<S>& handle)); | |
| 3046 template <typename S> V8_INLINE(void Set(const Handle<S> handle)); | |
| 3047 // Fast primitive setters | |
| 3048 V8_INLINE(void Set(bool value)); | |
| 3049 V8_INLINE(void Set(double i)); | |
| 3050 V8_INLINE(void Set(int32_t i)); | |
| 3051 V8_INLINE(void Set(uint32_t i)); | |
| 3052 // Fast JS primitive setters | |
| 3053 V8_INLINE(void SetNull()); | |
| 3054 V8_INLINE(void SetUndefined()); | |
| 3055 V8_INLINE(void SetEmptyString()); | |
| 3056 // Convenience getter for Isolate | |
| 3057 V8_INLINE(Isolate* GetIsolate()); | |
| 3058 | |
| 3059 private: | |
| 3060 template<class F> friend class ReturnValue; | |
| 3061 template<class F> friend class FunctionCallbackInfo; | |
| 3062 template<class F> friend class PropertyCallbackInfo; | |
| 3063 V8_INLINE(internal::Object* GetDefaultValue()); | |
| 3064 V8_INLINE(explicit ReturnValue(internal::Object** slot)); | |
| 3065 internal::Object** value_; | |
| 3066 }; | |
| 3067 | |
| 3068 | |
| 3069 /** | 3155 /** |
| 3070 * The argument information given to function call callbacks. This | |
| 3071 * class provides access to information about the context of the call, | |
| 3072 * including the receiver, the number and values of arguments, and | |
| 3073 * the holder of the function. | |
| 3074 */ | |
| 3075 template<typename T> | |
| 3076 class FunctionCallbackInfo { | |
| 3077 public: | |
| 3078 V8_INLINE(int Length() const); | |
| 3079 V8_INLINE(Local<Value> operator[](int i) const); | |
| 3080 V8_INLINE(Local<Function> Callee() const); | |
| 3081 V8_INLINE(Local<Object> This() const); | |
| 3082 V8_INLINE(Local<Object> Holder() const); | |
| 3083 V8_INLINE(bool IsConstructCall() const); | |
| 3084 V8_INLINE(Local<Value> Data() const); | |
| 3085 V8_INLINE(Isolate* GetIsolate() const); | |
| 3086 V8_INLINE(ReturnValue<T> GetReturnValue() const); | |
| 3087 // This shouldn't be public, but the arm compiler needs it. | |
| 3088 static const int kArgsLength = 6; | |
| 3089 | |
| 3090 protected: | |
| 3091 friend class internal::FunctionCallbackArguments; | |
| 3092 friend class internal::CustomArguments<FunctionCallbackInfo>; | |
| 3093 static const int kReturnValueIndex = 0; | |
| 3094 static const int kReturnValueDefaultValueIndex = -1; | |
| 3095 static const int kIsolateIndex = -2; | |
| 3096 static const int kDataIndex = -3; | |
| 3097 static const int kCalleeIndex = -4; | |
| 3098 static const int kHolderIndex = -5; | |
| 3099 | |
| 3100 V8_INLINE(FunctionCallbackInfo(internal::Object** implicit_args, | |
| 3101 internal::Object** values, | |
| 3102 int length, | |
| 3103 bool is_construct_call)); | |
| 3104 internal::Object** implicit_args_; | |
| 3105 internal::Object** values_; | |
| 3106 int length_; | |
| 3107 bool is_construct_call_; | |
| 3108 }; | |
| 3109 | |
| 3110 | |
| 3111 /** | |
| 3112 * The information passed to a property callback about the context | |
| 3113 * of the property access. | |
| 3114 */ | |
| 3115 template<typename T> | |
| 3116 class PropertyCallbackInfo { | |
| 3117 public: | |
| 3118 V8_INLINE(Isolate* GetIsolate() const); | |
| 3119 V8_INLINE(Local<Value> Data() const); | |
| 3120 V8_INLINE(Local<Object> This() const); | |
| 3121 V8_INLINE(Local<Object> Holder() const); | |
| 3122 V8_INLINE(ReturnValue<T> GetReturnValue() const); | |
| 3123 // This shouldn't be public, but the arm compiler needs it. | |
| 3124 static const int kArgsLength = 6; | |
| 3125 | |
| 3126 protected: | |
| 3127 friend class MacroAssembler; | |
| 3128 friend class internal::PropertyCallbackArguments; | |
| 3129 friend class internal::CustomArguments<PropertyCallbackInfo>; | |
| 3130 static const int kThisIndex = 0; | |
| 3131 static const int kHolderIndex = -1; | |
| 3132 static const int kDataIndex = -2; | |
| 3133 static const int kReturnValueIndex = -3; | |
| 3134 static const int kReturnValueDefaultValueIndex = -4; | |
| 3135 static const int kIsolateIndex = -5; | |
| 3136 | |
| 3137 V8_INLINE(PropertyCallbackInfo(internal::Object** args)) | |
| 3138 : args_(args) { } | |
| 3139 internal::Object** args_; | |
| 3140 }; | |
| 3141 | |
| 3142 | |
| 3143 typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info); | |
| 3144 | |
| 3145 /** | |
| 3146 * NamedProperty[Getter|Setter] are used as interceptors on object. | 3156 * NamedProperty[Getter|Setter] are used as interceptors on object. |
| 3147 * See ObjectTemplate::SetNamedPropertyHandler. | 3157 * See ObjectTemplate::SetNamedPropertyHandler. |
| 3148 */ | 3158 */ |
| 3149 typedef void (*NamedPropertyGetterCallback)( | 3159 typedef void (*NamedPropertyGetterCallback)( |
| 3150 Local<String> property, | 3160 Local<String> property, |
| 3151 const PropertyCallbackInfo<Value>& info); | 3161 const PropertyCallbackInfo<Value>& info); |
| 3152 | 3162 |
| 3153 | 3163 |
| 3154 /** | 3164 /** |
| 3155 * Returns the value if the setter intercepts the request. | 3165 * Returns the value if the setter intercepts the request. |
| (...skipping 3344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6500 */ | 6510 */ |
| 6501 | 6511 |
| 6502 | 6512 |
| 6503 } // namespace v8 | 6513 } // namespace v8 |
| 6504 | 6514 |
| 6505 | 6515 |
| 6506 #undef TYPE_CHECK | 6516 #undef TYPE_CHECK |
| 6507 | 6517 |
| 6508 | 6518 |
| 6509 #endif // V8_H_ | 6519 #endif // V8_H_ |
| OLD | NEW |