| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 // --- W e a k H a n d l e s | 122 // --- W e a k H a n d l e s |
| 123 | 123 |
| 124 | 124 |
| 125 /** | 125 /** |
| 126 * A weak reference callback function. | 126 * A weak reference callback function. |
| 127 * | 127 * |
| 128 * \param object the weak global object to be reclaimed by the garbage collector | 128 * \param object the weak global object to be reclaimed by the garbage collector |
| 129 * \param parameter the value passed in when making the weak global object | 129 * \param parameter the value passed in when making the weak global object |
| 130 */ | 130 */ |
| 131 typedef void (*WeakReferenceCallback)(Persistent<Object> object, | 131 typedef void (*WeakReferenceCallback)(Persistent<Value> object, |
| 132 void* parameter); | 132 void* parameter); |
| 133 | 133 |
| 134 | 134 |
| 135 // --- H a n d l e s --- | 135 // --- H a n d l e s --- |
| 136 | 136 |
| 137 #define TYPE_CHECK(T, S) \ | 137 #define TYPE_CHECK(T, S) \ |
| 138 while (false) { \ | 138 while (false) { \ |
| 139 *(static_cast<T**>(0)) = static_cast<S*>(0); \ | 139 *(static_cast<T**>(0)) = static_cast<S*>(0); \ |
| 140 } | 140 } |
| 141 | 141 |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 * The origin, within a file, of a script. | 505 * The origin, within a file, of a script. |
| 506 */ | 506 */ |
| 507 class EXPORT ScriptOrigin { | 507 class EXPORT ScriptOrigin { |
| 508 public: | 508 public: |
| 509 ScriptOrigin(Handle<Value> resource_name, | 509 ScriptOrigin(Handle<Value> resource_name, |
| 510 Handle<Integer> resource_line_offset = Handle<Integer>(), | 510 Handle<Integer> resource_line_offset = Handle<Integer>(), |
| 511 Handle<Integer> resource_column_offset = Handle<Integer>()) | 511 Handle<Integer> resource_column_offset = Handle<Integer>()) |
| 512 : resource_name_(resource_name), | 512 : resource_name_(resource_name), |
| 513 resource_line_offset_(resource_line_offset), | 513 resource_line_offset_(resource_line_offset), |
| 514 resource_column_offset_(resource_column_offset) { } | 514 resource_column_offset_(resource_column_offset) { } |
| 515 inline Handle<Value> ResourceName(); | 515 inline Handle<Value> ResourceName() const; |
| 516 inline Handle<Integer> ResourceLineOffset(); | 516 inline Handle<Integer> ResourceLineOffset() const; |
| 517 inline Handle<Integer> ResourceColumnOffset(); | 517 inline Handle<Integer> ResourceColumnOffset() const; |
| 518 private: | 518 private: |
| 519 Handle<Value> resource_name_; | 519 Handle<Value> resource_name_; |
| 520 Handle<Integer> resource_line_offset_; | 520 Handle<Integer> resource_line_offset_; |
| 521 Handle<Integer> resource_column_offset_; | 521 Handle<Integer> resource_column_offset_; |
| 522 }; | 522 }; |
| 523 | 523 |
| 524 | 524 |
| 525 /** | 525 /** |
| 526 * A compiled JavaScript script. | 526 * A compiled JavaScript script. |
| 527 */ | 527 */ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 552 | 552 |
| 553 | 553 |
| 554 /** | 554 /** |
| 555 * An error message. | 555 * An error message. |
| 556 */ | 556 */ |
| 557 class EXPORT Message { | 557 class EXPORT Message { |
| 558 public: | 558 public: |
| 559 Local<String> Get(); | 559 Local<String> Get(); |
| 560 Local<String> GetSourceLine(); | 560 Local<String> GetSourceLine(); |
| 561 | 561 |
| 562 // TODO(1241256): Rewrite (or remove) this method. We don't want to | 562 Handle<Value> GetScriptResourceName(); |
| 563 // deal with ownership of the returned string and we want to use | |
| 564 // JavaScript data structures exclusively. | |
| 565 char* GetUnderline(char* source_line, char underline_char); | |
| 566 | |
| 567 Handle<String> GetScriptResourceName(); | |
| 568 | |
| 569 // TODO(1240903): Remove this when no longer used in WebKit V8 | |
| 570 // bindings. | |
| 571 Handle<Value> GetSourceData(); | |
| 572 | 563 |
| 573 /** | 564 /** |
| 574 * Returns the number, 1-based, of the line where the error occurred. | 565 * Returns the number, 1-based, of the line where the error occurred. |
| 575 */ | 566 */ |
| 576 int GetLineNumber(); | 567 int GetLineNumber(); |
| 577 | 568 |
| 578 /** | 569 /** |
| 579 * Returns the index within the script of the first character where | 570 * Returns the index within the script of the first character where |
| 580 * the error occurred. | 571 * the error occurred. |
| 581 */ | 572 */ |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 /** | 660 /** |
| 670 * Returns true if this value is external. | 661 * Returns true if this value is external. |
| 671 */ | 662 */ |
| 672 bool IsExternal(); | 663 bool IsExternal(); |
| 673 | 664 |
| 674 /** | 665 /** |
| 675 * Returns true if this value is a 32-bit signed integer. | 666 * Returns true if this value is a 32-bit signed integer. |
| 676 */ | 667 */ |
| 677 bool IsInt32(); | 668 bool IsInt32(); |
| 678 | 669 |
| 670 /** |
| 671 * Returns true if this value is a Date. |
| 672 */ |
| 673 bool IsDate(); |
| 674 |
| 679 Local<Boolean> ToBoolean(); | 675 Local<Boolean> ToBoolean(); |
| 680 Local<Number> ToNumber(); | 676 Local<Number> ToNumber(); |
| 681 Local<String> ToString(); | 677 Local<String> ToString(); |
| 682 Local<String> ToDetailString(); | 678 Local<String> ToDetailString(); |
| 683 Local<Object> ToObject(); | 679 Local<Object> ToObject(); |
| 684 Local<Integer> ToInteger(); | 680 Local<Integer> ToInteger(); |
| 685 Local<Uint32> ToUint32(); | 681 Local<Uint32> ToUint32(); |
| 686 Local<Int32> ToInt32(); | 682 Local<Int32> ToInt32(); |
| 687 | 683 |
| 688 /** | 684 /** |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 Uint32(); | 980 Uint32(); |
| 985 }; | 981 }; |
| 986 | 982 |
| 987 | 983 |
| 988 /** | 984 /** |
| 989 * An instance of the built-in Date constructor (ECMA-262, 15.9). | 985 * An instance of the built-in Date constructor (ECMA-262, 15.9). |
| 990 */ | 986 */ |
| 991 class EXPORT Date : public Value { | 987 class EXPORT Date : public Value { |
| 992 public: | 988 public: |
| 993 static Local<Value> New(double time); | 989 static Local<Value> New(double time); |
| 990 |
| 991 /** |
| 992 * A specialization of Value::NumberValue that is more efficient |
| 993 * because we know the structure of this object. |
| 994 */ |
| 995 double NumberValue(); |
| 996 |
| 997 static Date* Cast(v8::Value* obj); |
| 994 }; | 998 }; |
| 995 | 999 |
| 996 | 1000 |
| 997 enum PropertyAttribute { | 1001 enum PropertyAttribute { |
| 998 None = 0, | 1002 None = 0, |
| 999 ReadOnly = 1 << 0, | 1003 ReadOnly = 1 << 0, |
| 1000 DontEnum = 1 << 1, | 1004 DontEnum = 1 << 1, |
| 1001 DontDelete = 1 << 2 | 1005 DontDelete = 1 << 2 |
| 1002 }; | 1006 }; |
| 1003 | 1007 |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1738 Handle<Boolean> EXPORT False(); | 1742 Handle<Boolean> EXPORT False(); |
| 1739 | 1743 |
| 1740 | 1744 |
| 1741 /** | 1745 /** |
| 1742 * A set of constraints that specifies the limits of the runtime's | 1746 * A set of constraints that specifies the limits of the runtime's |
| 1743 * memory use. | 1747 * memory use. |
| 1744 */ | 1748 */ |
| 1745 class EXPORT ResourceConstraints { | 1749 class EXPORT ResourceConstraints { |
| 1746 public: | 1750 public: |
| 1747 ResourceConstraints(); | 1751 ResourceConstraints(); |
| 1748 int max_young_space_size() { return max_young_space_size_; } | 1752 int max_young_space_size() const { return max_young_space_size_; } |
| 1749 void set_max_young_space_size(int value) { max_young_space_size_ = value; } | 1753 void set_max_young_space_size(int value) { max_young_space_size_ = value; } |
| 1750 int max_old_space_size() { return max_old_space_size_; } | 1754 int max_old_space_size() const { return max_old_space_size_; } |
| 1751 void set_max_old_space_size(int value) { max_old_space_size_ = value; } | 1755 void set_max_old_space_size(int value) { max_old_space_size_ = value; } |
| 1752 uint32_t* stack_limit() { return stack_limit_; } | 1756 uint32_t* stack_limit() const { return stack_limit_; } |
| 1753 void set_stack_limit(uint32_t* value) { stack_limit_ = value; } | 1757 void set_stack_limit(uint32_t* value) { stack_limit_ = value; } |
| 1754 private: | 1758 private: |
| 1755 int max_young_space_size_; | 1759 int max_young_space_size_; |
| 1756 int max_old_space_size_; | 1760 int max_old_space_size_; |
| 1757 uint32_t* stack_limit_; | 1761 uint32_t* stack_limit_; |
| 1758 }; | 1762 }; |
| 1759 | 1763 |
| 1760 | 1764 |
| 1761 bool SetResourceConstraints(ResourceConstraints* constraints); | 1765 bool SetResourceConstraints(ResourceConstraints* constraints); |
| 1762 | 1766 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1973 TryCatch(); | 1977 TryCatch(); |
| 1974 | 1978 |
| 1975 /** | 1979 /** |
| 1976 * Unregisters and deletes this try/catch block. | 1980 * Unregisters and deletes this try/catch block. |
| 1977 */ | 1981 */ |
| 1978 ~TryCatch(); | 1982 ~TryCatch(); |
| 1979 | 1983 |
| 1980 /** | 1984 /** |
| 1981 * Returns true if an exception has been caught by this try/catch block. | 1985 * Returns true if an exception has been caught by this try/catch block. |
| 1982 */ | 1986 */ |
| 1983 bool HasCaught(); | 1987 bool HasCaught() const; |
| 1984 | 1988 |
| 1985 /** | 1989 /** |
| 1986 * Returns the exception caught by this try/catch block. If no exception has | 1990 * Returns the exception caught by this try/catch block. If no exception has |
| 1987 * been caught an empty handle is returned. | 1991 * been caught an empty handle is returned. |
| 1988 * | 1992 * |
| 1989 * The returned handle is valid until this TryCatch block has been destroyed. | 1993 * The returned handle is valid until this TryCatch block has been destroyed. |
| 1990 */ | 1994 */ |
| 1991 Local<Value> Exception(); | 1995 Local<Value> Exception() const; |
| 1992 | 1996 |
| 1993 /** | 1997 /** |
| 1994 * Returns the message associated with this exception. If there is | 1998 * Returns the message associated with this exception. If there is |
| 1995 * no message associated an empty handle is returned. | 1999 * no message associated an empty handle is returned. |
| 1996 * | 2000 * |
| 1997 * The returned handle is valid until this TryCatch block has been | 2001 * The returned handle is valid until this TryCatch block has been |
| 1998 * destroyed. | 2002 * destroyed. |
| 1999 */ | 2003 */ |
| 2000 Local<v8::Message> Message(); | 2004 Local<v8::Message> Message() const; |
| 2001 | 2005 |
| 2002 /** | 2006 /** |
| 2003 * Clears any exceptions that may have been caught by this try/catch block. | 2007 * Clears any exceptions that may have been caught by this try/catch block. |
| 2004 * After this method has been called, HasCaught() will return false. | 2008 * After this method has been called, HasCaught() will return false. |
| 2005 * | 2009 * |
| 2006 * It is not necessary to clear a try/catch block before using it again; if | 2010 * It is not necessary to clear a try/catch block before using it again; if |
| 2007 * another exception is thrown the previously caught exception will just be | 2011 * another exception is thrown the previously caught exception will just be |
| 2008 * overwritten. However, it is often a good idea since it makes it easier | 2012 * overwritten. However, it is often a good idea since it makes it easier |
| 2009 * to determine which operation threw a given exception. | 2013 * to determine which operation threw a given exception. |
| 2010 */ | 2014 */ |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2366 return holder_; | 2370 return holder_; |
| 2367 } | 2371 } |
| 2368 | 2372 |
| 2369 | 2373 |
| 2370 template <class T> | 2374 template <class T> |
| 2371 Local<T> HandleScope::Close(Handle<T> value) { | 2375 Local<T> HandleScope::Close(Handle<T> value) { |
| 2372 void** after = RawClose(reinterpret_cast<void**>(*value)); | 2376 void** after = RawClose(reinterpret_cast<void**>(*value)); |
| 2373 return Local<T>(reinterpret_cast<T*>(after)); | 2377 return Local<T>(reinterpret_cast<T*>(after)); |
| 2374 } | 2378 } |
| 2375 | 2379 |
| 2376 Handle<Value> ScriptOrigin::ResourceName() { | 2380 Handle<Value> ScriptOrigin::ResourceName() const { |
| 2377 return resource_name_; | 2381 return resource_name_; |
| 2378 } | 2382 } |
| 2379 | 2383 |
| 2380 | 2384 |
| 2381 Handle<Integer> ScriptOrigin::ResourceLineOffset() { | 2385 Handle<Integer> ScriptOrigin::ResourceLineOffset() const { |
| 2382 return resource_line_offset_; | 2386 return resource_line_offset_; |
| 2383 } | 2387 } |
| 2384 | 2388 |
| 2385 | 2389 |
| 2386 Handle<Integer> ScriptOrigin::ResourceColumnOffset() { | 2390 Handle<Integer> ScriptOrigin::ResourceColumnOffset() const { |
| 2387 return resource_column_offset_; | 2391 return resource_column_offset_; |
| 2388 } | 2392 } |
| 2389 | 2393 |
| 2390 | 2394 |
| 2391 Handle<Boolean> Boolean::New(bool value) { | 2395 Handle<Boolean> Boolean::New(bool value) { |
| 2392 return value ? True() : False(); | 2396 return value ? True() : False(); |
| 2393 } | 2397 } |
| 2394 | 2398 |
| 2395 | 2399 |
| 2396 void Template::Set(const char* name, v8::Handle<Data> value) { | 2400 void Template::Set(const char* name, v8::Handle<Data> value) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2412 | 2416 |
| 2413 } // namespace v8 | 2417 } // namespace v8 |
| 2414 | 2418 |
| 2415 | 2419 |
| 2416 #undef EXPORT | 2420 #undef EXPORT |
| 2417 #undef EXPORT_INLINE | 2421 #undef EXPORT_INLINE |
| 2418 #undef TYPE_CHECK | 2422 #undef TYPE_CHECK |
| 2419 | 2423 |
| 2420 | 2424 |
| 2421 #endif // V8_H_ | 2425 #endif // V8_H_ |
| OLD | NEW |