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 20 matching lines...) Expand all Loading... |
31 * | 31 * |
32 * This set of documents provides reference material generated from the | 32 * This set of documents provides reference material generated from the |
33 * V8 header file, include/v8.h. | 33 * V8 header file, include/v8.h. |
34 * | 34 * |
35 * For other documentation see http://code.google.com/apis/v8/ | 35 * For other documentation see http://code.google.com/apis/v8/ |
36 */ | 36 */ |
37 | 37 |
38 #ifndef V8_H_ | 38 #ifndef V8_H_ |
39 #define V8_H_ | 39 #define V8_H_ |
40 | 40 |
41 #include <limits.h> | |
42 #include "v8stdint.h" | 41 #include "v8stdint.h" |
43 | 42 |
44 #ifdef _WIN32 | 43 #ifdef _WIN32 |
45 | 44 |
46 // Setup for Windows DLL export/import. When building the V8 DLL the | 45 // Setup for Windows DLL export/import. When building the V8 DLL the |
47 // BUILDING_V8_SHARED needs to be defined. When building a program which uses | 46 // BUILDING_V8_SHARED needs to be defined. When building a program which uses |
48 // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 | 47 // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 |
49 // static library or building a program which uses the V8 static library neither | 48 // static library or building a program which uses the V8 static library neither |
50 // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined. | 49 // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined. |
51 #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED) | 50 #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED) |
(...skipping 5624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5676 if (V8_LIKELY(I::IsValidSmi(i))) { | 5675 if (V8_LIKELY(I::IsValidSmi(i))) { |
5677 *value_ = I::IntToSmi(i); | 5676 *value_ = I::IntToSmi(i); |
5678 return; | 5677 return; |
5679 } | 5678 } |
5680 Set(Integer::New(i, GetIsolate())); | 5679 Set(Integer::New(i, GetIsolate())); |
5681 } | 5680 } |
5682 | 5681 |
5683 template<typename T> | 5682 template<typename T> |
5684 void ReturnValue<T>::Set(uint32_t i) { | 5683 void ReturnValue<T>::Set(uint32_t i) { |
5685 typedef internal::Internals I; | 5684 typedef internal::Internals I; |
5686 if (V8_LIKELY(i <= INT32_MAX)) { | 5685 // Can't simply use INT32_MAX here for whatever reason. |
| 5686 bool fits_into_int32_t = (i & (1 << 31)) == 0; |
| 5687 if (V8_LIKELY(fits_into_int32_t)) { |
5687 Set(static_cast<int32_t>(i)); | 5688 Set(static_cast<int32_t>(i)); |
5688 return; | 5689 return; |
5689 } | 5690 } |
5690 Set(Integer::NewFromUnsigned(i, GetIsolate())); | 5691 Set(Integer::NewFromUnsigned(i, GetIsolate())); |
5691 } | 5692 } |
5692 | 5693 |
5693 template<typename T> | 5694 template<typename T> |
5694 void ReturnValue<T>::Set(bool value) { | 5695 void ReturnValue<T>::Set(bool value) { |
5695 typedef internal::Internals I; | 5696 typedef internal::Internals I; |
5696 int root_index; | 5697 int root_index; |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6293 | 6294 |
6294 | 6295 |
6295 } // namespace v8 | 6296 } // namespace v8 |
6296 | 6297 |
6297 | 6298 |
6298 #undef V8EXPORT | 6299 #undef V8EXPORT |
6299 #undef TYPE_CHECK | 6300 #undef TYPE_CHECK |
6300 | 6301 |
6301 | 6302 |
6302 #endif // V8_H_ | 6303 #endif // V8_H_ |
OLD | NEW |