| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_URI_H_ | 5 #ifndef V8_URI_H_ |
| 6 #define V8_URI_H_ | 6 #define V8_URI_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
| 11 #include "src/string-search.h" | 11 #include "src/string-search.h" |
| 12 #include "src/utils.h" | 12 #include "src/utils.h" |
| 13 | 13 |
| 14 namespace v8 { | 14 namespace v8 { |
| 15 namespace internal { | 15 namespace internal { |
| 16 | 16 |
| 17 | 17 |
| 18 template <typename Char> | 18 template <typename Char> |
| 19 static INLINE(Vector<const Char> GetCharVector(Handle<String> string)); | 19 static INLINE(Vector<const Char> GetCharVector(Handle<String> string)); |
| 20 | 20 |
| 21 | 21 |
| 22 template <> | 22 template <> |
| 23 Vector<const uint8_t> GetCharVector(Handle<String> string) { | 23 Vector<const uint8_t> GetCharVector(Handle<String> string) { |
| 24 String::FlatContent flat = string->GetFlatContent(); | 24 String::FlatContent flat = string->GetFlatContent(); |
| 25 DCHECK(flat.IsAscii()); | 25 DCHECK(flat.IsOneByte()); |
| 26 return flat.ToOneByteVector(); | 26 return flat.ToOneByteVector(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 | 29 |
| 30 template <> | 30 template <> |
| 31 Vector<const uc16> GetCharVector(Handle<String> string) { | 31 Vector<const uc16> GetCharVector(Handle<String> string) { |
| 32 String::FlatContent flat = string->GetFlatContent(); | 32 String::FlatContent flat = string->GetFlatContent(); |
| 33 DCHECK(flat.IsTwoByte()); | 33 DCHECK(flat.IsTwoByte()); |
| 34 return flat.ToUC16Vector(); | 34 return flat.ToUC16Vector(); |
| 35 } | 35 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 66 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, | 66 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 67 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | 67 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 68 -1, 10, 11, 12, 13, 14, 15 }; | 68 -1, 10, 11, 12, 13, 14, 15 }; |
| 69 | 69 |
| 70 | 70 |
| 71 template<typename Char> | 71 template<typename Char> |
| 72 MaybeHandle<String> URIUnescape::Unescape(Isolate* isolate, | 72 MaybeHandle<String> URIUnescape::Unescape(Isolate* isolate, |
| 73 Handle<String> source) { | 73 Handle<String> source) { |
| 74 int index; | 74 int index; |
| 75 { DisallowHeapAllocation no_allocation; | 75 { DisallowHeapAllocation no_allocation; |
| 76 StringSearch<uint8_t, Char> search(isolate, STATIC_ASCII_VECTOR("%")); | 76 StringSearch<uint8_t, Char> search(isolate, STATIC_CHAR_VECTOR("%")); |
| 77 index = search.Search(GetCharVector<Char>(source), 0); | 77 index = search.Search(GetCharVector<Char>(source), 0); |
| 78 if (index < 0) return source; | 78 if (index < 0) return source; |
| 79 } | 79 } |
| 80 return UnescapeSlow<Char>(isolate, source, index); | 80 return UnescapeSlow<Char>(isolate, source, index); |
| 81 } | 81 } |
| 82 | 82 |
| 83 | 83 |
| 84 template <typename Char> | 84 template <typename Char> |
| 85 MaybeHandle<String> URIUnescape::UnescapeSlow( | 85 MaybeHandle<String> URIUnescape::UnescapeSlow( |
| 86 Isolate* isolate, Handle<String> string, int start_index) { | 86 Isolate* isolate, Handle<String> string, int start_index) { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 } | 283 } |
| 284 | 284 |
| 285 return dest; | 285 return dest; |
| 286 } | 286 } |
| 287 | 287 |
| 288 } } // namespace v8::internal | 288 } } // namespace v8::internal |
| 289 | 289 |
| 290 #endif // V8_URI_H_ | 290 #endif // V8_URI_H_ |
| OLD | NEW |