Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Side by Side Diff: include/v8.h

Issue 251100: Introduce v8::Integer::NewFromUnsigned method. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/checks.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 static void CheckCast(v8::Value* obj); 1056 static void CheckCast(v8::Value* obj);
1057 }; 1057 };
1058 1058
1059 1059
1060 /** 1060 /**
1061 * A JavaScript value representing a signed integer. 1061 * A JavaScript value representing a signed integer.
1062 */ 1062 */
1063 class V8EXPORT Integer : public Number { 1063 class V8EXPORT Integer : public Number {
1064 public: 1064 public:
1065 static Local<Integer> New(int32_t value); 1065 static Local<Integer> New(int32_t value);
1066 static inline Local<Integer> NewFromUnsigned(uint32_t value);
1066 int64_t Value() const; 1067 int64_t Value() const;
1067 static inline Integer* Cast(v8::Value* obj); 1068 static inline Integer* Cast(v8::Value* obj);
1068 private: 1069 private:
1069 Integer(); 1070 Integer();
1070 static void CheckCast(v8::Value* obj); 1071 static void CheckCast(v8::Value* obj);
1071 }; 1072 };
1072 1073
1073 1074
1074 /** 1075 /**
1075 * A JavaScript value representing a 32-bit signed integer. 1076 * A JavaScript value representing a 32-bit signed integer.
(...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after
3018 3019
3019 3020
3020 Number* Number::Cast(v8::Value* value) { 3021 Number* Number::Cast(v8::Value* value) {
3021 #ifdef V8_ENABLE_CHECKS 3022 #ifdef V8_ENABLE_CHECKS
3022 CheckCast(value); 3023 CheckCast(value);
3023 #endif 3024 #endif
3024 return static_cast<Number*>(value); 3025 return static_cast<Number*>(value);
3025 } 3026 }
3026 3027
3027 3028
3029 Local<Integer> Integer::NewFromUnsigned(uint32_t value) {
3030 // If highest bit is not set, chances are it's SMI.
3031 bool fits_into_int32_t = (value & (1 << 31)) == 0;
3032 if (fits_into_int32_t) {
3033 return Integer::New(static_cast<int32_t>(value));
3034 }
3035 return Local<Integer>::Cast(Number::New(value));
3036 }
3037
3038
3028 Integer* Integer::Cast(v8::Value* value) { 3039 Integer* Integer::Cast(v8::Value* value) {
3029 #ifdef V8_ENABLE_CHECKS 3040 #ifdef V8_ENABLE_CHECKS
3030 CheckCast(value); 3041 CheckCast(value);
3031 #endif 3042 #endif
3032 return static_cast<Integer*>(value); 3043 return static_cast<Integer*>(value);
3033 } 3044 }
3034 3045
3035 3046
3036 Date* Date::Cast(v8::Value* value) { 3047 Date* Date::Cast(v8::Value* value) {
3037 #ifdef V8_ENABLE_CHECKS 3048 #ifdef V8_ENABLE_CHECKS
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
3102 3113
3103 } // namespace v8 3114 } // namespace v8
3104 3115
3105 3116
3106 #undef V8EXPORT 3117 #undef V8EXPORT
3107 #undef V8EXPORT_INLINE 3118 #undef V8EXPORT_INLINE
3108 #undef TYPE_CHECK 3119 #undef TYPE_CHECK
3109 3120
3110 3121
3111 #endif // V8_H_ 3122 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/checks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698