| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 189 |
| 190 // Get the current position in the builder. | 190 // Get the current position in the builder. |
| 191 int position() const { | 191 int position() const { |
| 192 ASSERT(!is_finalized()); | 192 ASSERT(!is_finalized()); |
| 193 return position_; | 193 return position_; |
| 194 } | 194 } |
| 195 | 195 |
| 196 // Set the current position in the builder. | 196 // Set the current position in the builder. |
| 197 void SetPosition(int position) { | 197 void SetPosition(int position) { |
| 198 ASSERT(!is_finalized()); | 198 ASSERT(!is_finalized()); |
| 199 ASSERT_WITH_SECURITY_IMPLICATION(position < size()); | 199 SECURITY_DCHECK(position < size()); |
| 200 position_ = position; | 200 position_ = position; |
| 201 } | 201 } |
| 202 | 202 |
| 203 // Reset the position. | 203 // Reset the position. |
| 204 void Reset() { position_ = 0; } | 204 void Reset() { position_ = 0; } |
| 205 | 205 |
| 206 // Add a single character to the builder. It is not allowed to add | 206 // Add a single character to the builder. It is not allowed to add |
| 207 // 0-characters; use the Finalize() method to terminate the string | 207 // 0-characters; use the Finalize() method to terminate the string |
| 208 // instead. | 208 // instead. |
| 209 void AddCharacter(char c) { | 209 void AddCharacter(char c) { |
| 210 ASSERT(c != '\0'); | 210 ASSERT(c != '\0'); |
| 211 ASSERT(!is_finalized() && position_ < buffer_.length()); | 211 ASSERT(!is_finalized() && position_ < buffer_.length()); |
| 212 buffer_[position_++] = c; | 212 buffer_[position_++] = c; |
| 213 } | 213 } |
| 214 | 214 |
| 215 // Add an entire string to the builder. Uses strlen() internally to | 215 // Add an entire string to the builder. Uses strlen() internally to |
| 216 // compute the length of the input string. | 216 // compute the length of the input string. |
| 217 void AddString(const char* s) { AddSubstring(s, StrLength(s)); } | 217 void AddString(const char* s) { AddSubstring(s, StrLength(s)); } |
| 218 | 218 |
| 219 // Add the first 'n' characters of the given string 's' to the | 219 // Add the first 'n' characters of the given string 's' to the |
| 220 // builder. The input string must have enough characters. | 220 // builder. The input string must have enough characters. |
| 221 void AddSubstring(const char* s, int n) { | 221 void AddSubstring(const char* s, int n) { |
| 222 ASSERT(!is_finalized() && position_ + n < buffer_.length()); | 222 ASSERT(!is_finalized() && position_ + n < buffer_.length()); |
| 223 ASSERT_WITH_SECURITY_IMPLICATION(static_cast<size_t>(n) <= strlen(s)); | 223 SECURITY_DCHECK(static_cast<size_t>(n) <= strlen(s)); |
| 224 memcpy(&buffer_[position_], s, n * kCharSize); | 224 memcpy(&buffer_[position_], s, n * kCharSize); |
| 225 position_ += n; | 225 position_ += n; |
| 226 } | 226 } |
| 227 | 227 |
| 228 // Add character padding to the builder. If count is non-positive, | 228 // Add character padding to the builder. If count is non-positive, |
| 229 // nothing is added to the builder. | 229 // nothing is added to the builder. |
| 230 void AddPadding(char c, int count) { | 230 void AddPadding(char c, int count) { |
| 231 for (int i = 0; i < count; i++) { | 231 for (int i = 0; i < count; i++) { |
| 232 AddCharacter(c); | 232 AddCharacter(c); |
| 233 } | 233 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 template <class Dest, class Source> | 292 template <class Dest, class Source> |
| 293 inline Dest BitCast(Source* source) { | 293 inline Dest BitCast(Source* source) { |
| 294 return BitCast<Dest>(reinterpret_cast<uintptr_t>(source)); | 294 return BitCast<Dest>(reinterpret_cast<uintptr_t>(source)); |
| 295 } | 295 } |
| 296 | 296 |
| 297 } // namespace double_conversion | 297 } // namespace double_conversion |
| 298 | 298 |
| 299 } // namespace WTF | 299 } // namespace WTF |
| 300 | 300 |
| 301 #endif // DOUBLE_CONVERSION_UTILS_H_ | 301 #endif // DOUBLE_CONVERSION_UTILS_H_ |
| OLD | NEW |