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