OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserv
ed. |
3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> | 3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> |
4 * Copyright (C) 2012 Google Inc. All rights reserved. | 4 * Copyright (C) 2012 Google Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 * | 20 * |
21 */ | 21 */ |
22 | 22 |
23 #include "config.h" | 23 #include "config.h" |
24 #include "AtomicString.h" | 24 #include "AtomicString.h" |
25 | 25 |
26 #include "StringHash.h" | 26 #include "StringHash.h" |
27 #include "wtf/HashSet.h" | 27 #include "wtf/HashSet.h" |
28 #include "wtf/WTFThreadData.h" | 28 #include "wtf/WTFThreadData.h" |
| 29 #include "wtf/dtoa.h" |
| 30 #include "wtf/text/IntegerToStringConversion.h" |
29 #include "wtf/unicode/UTF8.h" | 31 #include "wtf/unicode/UTF8.h" |
30 | 32 |
31 namespace WTF { | 33 namespace WTF { |
32 | 34 |
33 using namespace Unicode; | 35 using namespace Unicode; |
34 | 36 |
35 COMPILE_ASSERT(sizeof(AtomicString) == sizeof(String), atomic_string_and_string_
must_be_same_size); | 37 COMPILE_ASSERT(sizeof(AtomicString) == sizeof(String), atomic_string_and_string_
must_be_same_size); |
36 | 38 |
37 class AtomicStringTable { | 39 class AtomicStringTable { |
38 WTF_MAKE_NONCOPYABLE(AtomicStringTable); | 40 WTF_MAKE_NONCOPYABLE(AtomicStringTable); |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 buffer.hash = calculateStringHashAndLengthFromUTF8MaskingTop8Bits(characters
Start, charactersEnd, buffer.length, buffer.utf16Length); | 482 buffer.hash = calculateStringHashAndLengthFromUTF8MaskingTop8Bits(characters
Start, charactersEnd, buffer.length, buffer.utf16Length); |
481 | 483 |
482 if (!buffer.hash) | 484 if (!buffer.hash) |
483 return nullAtom; | 485 return nullAtom; |
484 | 486 |
485 AtomicString atomicString; | 487 AtomicString atomicString; |
486 atomicString.m_string = addToStringTable<HashAndUTF8Characters, HashAndUTF8C
haractersTranslator>(buffer); | 488 atomicString.m_string = addToStringTable<HashAndUTF8Characters, HashAndUTF8C
haractersTranslator>(buffer); |
487 return atomicString; | 489 return atomicString; |
488 } | 490 } |
489 | 491 |
| 492 AtomicString AtomicString::number(int number) |
| 493 { |
| 494 return numberToStringSigned<AtomicString>(number); |
| 495 } |
| 496 |
| 497 AtomicString AtomicString::number(unsigned number) |
| 498 { |
| 499 return numberToStringUnsigned<AtomicString>(number); |
| 500 } |
| 501 |
| 502 AtomicString AtomicString::number(long number) |
| 503 { |
| 504 return numberToStringSigned<AtomicString>(number); |
| 505 } |
| 506 |
| 507 AtomicString AtomicString::number(unsigned long number) |
| 508 { |
| 509 return numberToStringUnsigned<AtomicString>(number); |
| 510 } |
| 511 |
| 512 AtomicString AtomicString::number(long long number) |
| 513 { |
| 514 return numberToStringSigned<AtomicString>(number); |
| 515 } |
| 516 |
| 517 AtomicString AtomicString::number(unsigned long long number) |
| 518 { |
| 519 return numberToStringUnsigned<AtomicString>(number); |
| 520 } |
| 521 |
| 522 AtomicString AtomicString::number(double number, unsigned precision, TrailingZer
osTruncatingPolicy trailingZerosTruncatingPolicy) |
| 523 { |
| 524 NumberToStringBuffer buffer; |
| 525 return AtomicString(numberToFixedPrecisionString(number, precision, buffer,
trailingZerosTruncatingPolicy == TruncateTrailingZeros)); |
| 526 } |
| 527 |
490 #ifndef NDEBUG | 528 #ifndef NDEBUG |
491 void AtomicString::show() const | 529 void AtomicString::show() const |
492 { | 530 { |
493 m_string.show(); | 531 m_string.show(); |
494 } | 532 } |
495 #endif | 533 #endif |
496 | 534 |
497 } // namespace WTF | 535 } // namespace WTF |
OLD | NEW |