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 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1661 int options = NO_OPTIONS) const; | 1661 int options = NO_OPTIONS) const; |
1662 // UTF-8 encoded characters. | 1662 // UTF-8 encoded characters. |
1663 int WriteUtf8(char* buffer, | 1663 int WriteUtf8(char* buffer, |
1664 int length = -1, | 1664 int length = -1, |
1665 int* nchars_ref = NULL, | 1665 int* nchars_ref = NULL, |
1666 int options = NO_OPTIONS) const; | 1666 int options = NO_OPTIONS) const; |
1667 | 1667 |
1668 /** | 1668 /** |
1669 * A zero length string. | 1669 * A zero length string. |
1670 */ | 1670 */ |
1671 static v8::Local<v8::String> Empty(); | |
1672 V8_INLINE static v8::Local<v8::String> Empty(Isolate* isolate); | 1671 V8_INLINE static v8::Local<v8::String> Empty(Isolate* isolate); |
1673 | 1672 |
1674 /** | 1673 /** |
1675 * Returns true if the string is external | 1674 * Returns true if the string is external |
1676 */ | 1675 */ |
1677 bool IsExternal() const; | 1676 bool IsExternal() const; |
1678 | 1677 |
1679 /** | 1678 /** |
1680 * Returns true if the string is both external and ASCII | 1679 * Returns true if the string is both external and ASCII |
1681 */ | 1680 */ |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1956 }; | 1955 }; |
1957 | 1956 |
1958 | 1957 |
1959 /** | 1958 /** |
1960 * A JavaScript number value (ECMA-262, 4.3.20) | 1959 * A JavaScript number value (ECMA-262, 4.3.20) |
1961 */ | 1960 */ |
1962 class V8_EXPORT Number : public Primitive { | 1961 class V8_EXPORT Number : public Primitive { |
1963 public: | 1962 public: |
1964 double Value() const; | 1963 double Value() const; |
1965 static Local<Number> New(Isolate* isolate, double value); | 1964 static Local<Number> New(Isolate* isolate, double value); |
1966 // Will be deprecated soon. | |
1967 static Local<Number> New(double value); | |
1968 V8_INLINE static Number* Cast(v8::Value* obj); | 1965 V8_INLINE static Number* Cast(v8::Value* obj); |
1969 private: | 1966 private: |
1970 Number(); | 1967 Number(); |
1971 static void CheckCast(v8::Value* obj); | 1968 static void CheckCast(v8::Value* obj); |
1972 }; | 1969 }; |
1973 | 1970 |
1974 | 1971 |
1975 /** | 1972 /** |
1976 * A JavaScript value representing a signed integer. | 1973 * A JavaScript value representing a signed integer. |
1977 */ | 1974 */ |
1978 class V8_EXPORT Integer : public Number { | 1975 class V8_EXPORT Integer : public Number { |
1979 public: | 1976 public: |
1980 static Local<Integer> New(Isolate* isolate, int32_t value); | 1977 static Local<Integer> New(Isolate* isolate, int32_t value); |
1981 static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value); | 1978 static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value); |
1982 // Will be deprecated soon. | |
1983 static Local<Integer> New(int32_t value, Isolate*); | |
1984 static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*); | |
1985 static Local<Integer> New(int32_t value); | |
1986 static Local<Integer> NewFromUnsigned(uint32_t value); | |
1987 int64_t Value() const; | 1979 int64_t Value() const; |
1988 V8_INLINE static Integer* Cast(v8::Value* obj); | 1980 V8_INLINE static Integer* Cast(v8::Value* obj); |
1989 private: | 1981 private: |
1990 Integer(); | 1982 Integer(); |
1991 static void CheckCast(v8::Value* obj); | 1983 static void CheckCast(v8::Value* obj); |
1992 }; | 1984 }; |
1993 | 1985 |
1994 | 1986 |
1995 /** | 1987 /** |
1996 * A JavaScript value representing a 32-bit signed integer. | 1988 * A JavaScript value representing a 32-bit signed integer. |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2330 Handle<Value> argv[]); | 2322 Handle<Value> argv[]); |
2331 | 2323 |
2332 /** | 2324 /** |
2333 * Call an Object as a constructor if a callback is set by the | 2325 * Call an Object as a constructor if a callback is set by the |
2334 * ObjectTemplate::SetCallAsFunctionHandler method. | 2326 * ObjectTemplate::SetCallAsFunctionHandler method. |
2335 * Note: This method behaves like the Function::NewInstance method. | 2327 * Note: This method behaves like the Function::NewInstance method. |
2336 */ | 2328 */ |
2337 Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]); | 2329 Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]); |
2338 | 2330 |
2339 static Local<Object> New(Isolate* isolate); | 2331 static Local<Object> New(Isolate* isolate); |
2340 // Will be deprecated soon. | 2332 |
2341 static Local<Object> New(); | |
2342 V8_INLINE static Object* Cast(Value* obj); | 2333 V8_INLINE static Object* Cast(Value* obj); |
2343 | 2334 |
2344 private: | 2335 private: |
2345 Object(); | 2336 Object(); |
2346 static void CheckCast(Value* obj); | 2337 static void CheckCast(Value* obj); |
2347 Local<Value> SlowGetInternalField(int index); | 2338 Local<Value> SlowGetInternalField(int index); |
2348 void* SlowGetAlignedPointerFromInternalField(int index); | 2339 void* SlowGetAlignedPointerFromInternalField(int index); |
2349 }; | 2340 }; |
2350 | 2341 |
2351 | 2342 |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3346 */ | 3337 */ |
3347 class V8_EXPORT FunctionTemplate : public Template { | 3338 class V8_EXPORT FunctionTemplate : public Template { |
3348 public: | 3339 public: |
3349 /** Creates a function template.*/ | 3340 /** Creates a function template.*/ |
3350 static Local<FunctionTemplate> New( | 3341 static Local<FunctionTemplate> New( |
3351 Isolate* isolate, | 3342 Isolate* isolate, |
3352 FunctionCallback callback = 0, | 3343 FunctionCallback callback = 0, |
3353 Handle<Value> data = Handle<Value>(), | 3344 Handle<Value> data = Handle<Value>(), |
3354 Handle<Signature> signature = Handle<Signature>(), | 3345 Handle<Signature> signature = Handle<Signature>(), |
3355 int length = 0); | 3346 int length = 0); |
3356 // Will be deprecated soon. | |
3357 static Local<FunctionTemplate> New( | |
3358 FunctionCallback callback = 0, | |
3359 Handle<Value> data = Handle<Value>(), | |
3360 Handle<Signature> signature = Handle<Signature>(), | |
3361 int length = 0); | |
3362 | 3347 |
3363 /** Returns the unique function instance in the current execution context.*/ | 3348 /** Returns the unique function instance in the current execution context.*/ |
3364 Local<Function> GetFunction(); | 3349 Local<Function> GetFunction(); |
3365 | 3350 |
3366 /** | 3351 /** |
3367 * Set the call-handler callback for a FunctionTemplate. This | 3352 * Set the call-handler callback for a FunctionTemplate. This |
3368 * callback is called whenever the function created from this | 3353 * callback is called whenever the function created from this |
3369 * FunctionTemplate is called. | 3354 * FunctionTemplate is called. |
3370 */ | 3355 */ |
3371 void SetCallHandler(FunctionCallback callback, | 3356 void SetCallHandler(FunctionCallback callback, |
(...skipping 2419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5791 } | 5776 } |
5792 | 5777 |
5793 template<typename T> | 5778 template<typename T> |
5794 void ReturnValue<T>::Set(int32_t i) { | 5779 void ReturnValue<T>::Set(int32_t i) { |
5795 TYPE_CHECK(T, Integer); | 5780 TYPE_CHECK(T, Integer); |
5796 typedef internal::Internals I; | 5781 typedef internal::Internals I; |
5797 if (V8_LIKELY(I::IsValidSmi(i))) { | 5782 if (V8_LIKELY(I::IsValidSmi(i))) { |
5798 *value_ = I::IntToSmi(i); | 5783 *value_ = I::IntToSmi(i); |
5799 return; | 5784 return; |
5800 } | 5785 } |
5801 Set(Integer::New(i, GetIsolate())); | 5786 Set(Integer::New(GetIsolate(), i)); |
5802 } | 5787 } |
5803 | 5788 |
5804 template<typename T> | 5789 template<typename T> |
5805 void ReturnValue<T>::Set(uint32_t i) { | 5790 void ReturnValue<T>::Set(uint32_t i) { |
5806 TYPE_CHECK(T, Integer); | 5791 TYPE_CHECK(T, Integer); |
5807 // Can't simply use INT32_MAX here for whatever reason. | 5792 // Can't simply use INT32_MAX here for whatever reason. |
5808 bool fits_into_int32_t = (i & (1U << 31)) == 0; | 5793 bool fits_into_int32_t = (i & (1U << 31)) == 0; |
5809 if (V8_LIKELY(fits_into_int32_t)) { | 5794 if (V8_LIKELY(fits_into_int32_t)) { |
5810 Set(static_cast<int32_t>(i)); | 5795 Set(static_cast<int32_t>(i)); |
5811 return; | 5796 return; |
5812 } | 5797 } |
5813 Set(Integer::NewFromUnsigned(i, GetIsolate())); | 5798 Set(Integer::NewFromUnsigned(GetIsolate(), i)); |
5814 } | 5799 } |
5815 | 5800 |
5816 template<typename T> | 5801 template<typename T> |
5817 void ReturnValue<T>::Set(bool value) { | 5802 void ReturnValue<T>::Set(bool value) { |
5818 TYPE_CHECK(T, Boolean); | 5803 TYPE_CHECK(T, Boolean); |
5819 typedef internal::Internals I; | 5804 typedef internal::Internals I; |
5820 int root_index; | 5805 int root_index; |
5821 if (value) { | 5806 if (value) { |
5822 root_index = I::kTrueValueRootIndex; | 5807 root_index = I::kTrueValueRootIndex; |
5823 } else { | 5808 } else { |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6461 */ | 6446 */ |
6462 | 6447 |
6463 | 6448 |
6464 } // namespace v8 | 6449 } // namespace v8 |
6465 | 6450 |
6466 | 6451 |
6467 #undef TYPE_CHECK | 6452 #undef TYPE_CHECK |
6468 | 6453 |
6469 | 6454 |
6470 #endif // V8_H_ | 6455 #endif // V8_H_ |
OLD | NEW |