| OLD | NEW |
| 1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 static void CheckCast(v8::Value* obj); | 1062 static void CheckCast(v8::Value* obj); |
| 1063 }; | 1063 }; |
| 1064 | 1064 |
| 1065 | 1065 |
| 1066 /** | 1066 /** |
| 1067 * A JavaScript value representing a signed integer. | 1067 * A JavaScript value representing a signed integer. |
| 1068 */ | 1068 */ |
| 1069 class V8EXPORT Integer : public Number { | 1069 class V8EXPORT Integer : public Number { |
| 1070 public: | 1070 public: |
| 1071 static Local<Integer> New(int32_t value); | 1071 static Local<Integer> New(int32_t value); |
| 1072 static inline Local<Integer> NewFromUnsigned(uint32_t value); | 1072 static Local<Integer> NewFromUnsigned(uint32_t value); |
| 1073 int64_t Value() const; | 1073 int64_t Value() const; |
| 1074 static inline Integer* Cast(v8::Value* obj); | 1074 static inline Integer* Cast(v8::Value* obj); |
| 1075 private: | 1075 private: |
| 1076 Integer(); | 1076 Integer(); |
| 1077 static void CheckCast(v8::Value* obj); | 1077 static void CheckCast(v8::Value* obj); |
| 1078 }; | 1078 }; |
| 1079 | 1079 |
| 1080 | 1080 |
| 1081 /** | 1081 /** |
| 1082 * A JavaScript value representing a 32-bit signed integer. | 1082 * A JavaScript value representing a 32-bit signed integer. |
| (...skipping 1979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3062 | 3062 |
| 3063 | 3063 |
| 3064 Number* Number::Cast(v8::Value* value) { | 3064 Number* Number::Cast(v8::Value* value) { |
| 3065 #ifdef V8_ENABLE_CHECKS | 3065 #ifdef V8_ENABLE_CHECKS |
| 3066 CheckCast(value); | 3066 CheckCast(value); |
| 3067 #endif | 3067 #endif |
| 3068 return static_cast<Number*>(value); | 3068 return static_cast<Number*>(value); |
| 3069 } | 3069 } |
| 3070 | 3070 |
| 3071 | 3071 |
| 3072 Local<Integer> Integer::NewFromUnsigned(uint32_t value) { | |
| 3073 bool fits_into_int32_t = (value & (1 << 31)) == 0; | |
| 3074 if (fits_into_int32_t) { | |
| 3075 return Integer::New(static_cast<int32_t>(value)); | |
| 3076 } | |
| 3077 return Local<Integer>::Cast(Number::New(value)); | |
| 3078 } | |
| 3079 | |
| 3080 | |
| 3081 Integer* Integer::Cast(v8::Value* value) { | 3072 Integer* Integer::Cast(v8::Value* value) { |
| 3082 #ifdef V8_ENABLE_CHECKS | 3073 #ifdef V8_ENABLE_CHECKS |
| 3083 CheckCast(value); | 3074 CheckCast(value); |
| 3084 #endif | 3075 #endif |
| 3085 return static_cast<Integer*>(value); | 3076 return static_cast<Integer*>(value); |
| 3086 } | 3077 } |
| 3087 | 3078 |
| 3088 | 3079 |
| 3089 Date* Date::Cast(v8::Value* value) { | 3080 Date* Date::Cast(v8::Value* value) { |
| 3090 #ifdef V8_ENABLE_CHECKS | 3081 #ifdef V8_ENABLE_CHECKS |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3155 | 3146 |
| 3156 } // namespace v8 | 3147 } // namespace v8 |
| 3157 | 3148 |
| 3158 | 3149 |
| 3159 #undef V8EXPORT | 3150 #undef V8EXPORT |
| 3160 #undef V8EXPORT_INLINE | 3151 #undef V8EXPORT_INLINE |
| 3161 #undef TYPE_CHECK | 3152 #undef TYPE_CHECK |
| 3162 | 3153 |
| 3163 | 3154 |
| 3164 #endif // V8_H_ | 3155 #endif // V8_H_ |
| OLD | NEW |