Changeset 26892 in webkit for trunk/JavaScriptCore/kjs/value.h
- Timestamp:
- Oct 22, 2007, 11:39:46 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/value.h
r26690 r26892 1 1 /* 2 * This file is part of the KDE libraries3 2 * Copyright (C) 1999-2001 Harri Porten ([email protected]) 4 3 * Copyright (C) 2001 Peter Kelly ([email protected]) 5 * Copyright (C) 2003 -2005 Apple Computer, Inc.4 * Copyright (C) 2003, 2004, 2005, 2007 Apple Inc. All rights reserved. 6 5 * 7 6 * This library is free software; you can redistribute it and/or … … 29 28 #include "ustring.h" 30 29 #include <stddef.h> // for size_t 30 #include <wtf/AlwaysInline.h> 31 31 32 32 namespace KJS { … … 77 77 78 78 // Extracting integer values. 79 bool getInt32(int32_t&) const; 79 80 bool getUInt32(uint32_t&) const; 80 81 … … 102 103 103 104 private: 105 int32_t toInt32SlowCase(ExecState*, bool& ok) const; 106 uint32_t toUInt32SlowCase(ExecState*, bool& ok) const; 107 104 108 // Implementation details. 105 109 JSCell *asCell(); … … 137 141 138 142 // Extracting integer values. 143 virtual bool getInt32(int32_t&) const; 139 144 virtual bool getUInt32(uint32_t&) const; 140 145 … … 165 170 extern const double Inf; 166 171 167 168 172 inline JSValue *jsUndefined() 169 173 { … … 186 190 } 187 191 188 inline JSValue *jsNumber(double d)192 ALWAYS_INLINE JSValue* jsNumber(double d) 189 193 { 190 194 JSValue *v = JSImmediate::fromDouble(d); … … 329 333 } 330 334 335 inline bool JSValue::getInt32(int32_t& v) const 336 { 337 return JSImmediate::isImmediate(this) ? JSImmediate::toInt32(this, v) : asCell()->getInt32(v); 338 } 339 331 340 inline bool JSValue::getUInt32(uint32_t& v) const 332 341 { 333 if (JSImmediate::isImmediate(this)) { 334 double d = JSImmediate::toDouble(this); 335 if (!(d >= 0) || d > 0xFFFFFFFFUL) // true for NaN 336 return false; 337 v = static_cast<uint32_t>(d); 338 return JSImmediate::isNumber(this); 339 } 340 return asCell()->getUInt32(v); 342 return JSImmediate::isImmediate(this) ? JSImmediate::toUInt32(this, v) : asCell()->getUInt32(v); 341 343 } 342 344 … … 382 384 } 383 385 386 ALWAYS_INLINE int32_t JSValue::toInt32(ExecState* exec) const 387 { 388 int32_t i; 389 if (JSImmediate::isImmediate(this) && JSImmediate::toInt32(this, i)) 390 return i; 391 bool ok; 392 return toInt32SlowCase(exec, ok); 393 } 394 395 inline uint32_t JSValue::toUInt32(ExecState* exec) const 396 { 397 uint32_t i; 398 if (JSImmediate::isImmediate(this) && JSImmediate::toUInt32(this, i)) 399 return i; 400 bool ok; 401 return toUInt32SlowCase(exec, ok); 402 } 403 404 inline int32_t JSValue::toInt32(ExecState* exec, bool& ok) const 405 { 406 int32_t i; 407 if (JSImmediate::isImmediate(this) && JSImmediate::toInt32(this, i)) { 408 ok = true; 409 return i; 410 } 411 return toInt32SlowCase(exec, ok); 412 } 413 414 inline uint32_t JSValue::toUInt32(ExecState* exec, bool& ok) const 415 { 416 uint32_t i; 417 if (JSImmediate::isImmediate(this) && JSImmediate::toUInt32(this, i)) { 418 ok = true; 419 return i; 420 } 421 return toUInt32SlowCase(exec, ok); 422 } 423 384 424 } // namespace 385 425
Note:
See TracChangeset
for help on using the changeset viewer.