OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 Data data_; | 113 Data data_; |
114 unsigned length_; | 114 unsigned length_; |
115 }; | 115 }; |
116 | 116 |
117 class Utf8 { | 117 class Utf8 { |
118 public: | 118 public: |
119 static inline uchar Length(uchar chr); | 119 static inline uchar Length(uchar chr); |
120 static inline unsigned Encode(char* out, uchar c); | 120 static inline unsigned Encode(char* out, uchar c); |
121 static const byte* ReadBlock(Buffer<const char*> str, byte* buffer, | 121 static const byte* ReadBlock(Buffer<const char*> str, byte* buffer, |
122 unsigned capacity, unsigned* chars_read, unsigned* offset); | 122 unsigned capacity, unsigned* chars_read, unsigned* offset); |
| 123 static uchar CalculateValue(const byte* str, |
| 124 unsigned length, |
| 125 unsigned* cursor); |
123 static const uchar kBadChar = 0xFFFD; | 126 static const uchar kBadChar = 0xFFFD; |
124 static const unsigned kMaxEncodedSize = 4; | 127 static const unsigned kMaxEncodedSize = 4; |
125 static const unsigned kMaxOneByteChar = 0x7f; | 128 static const unsigned kMaxOneByteChar = 0x7f; |
126 static const unsigned kMaxTwoByteChar = 0x7ff; | 129 static const unsigned kMaxTwoByteChar = 0x7ff; |
127 static const unsigned kMaxThreeByteChar = 0xffff; | 130 static const unsigned kMaxThreeByteChar = 0xffff; |
128 static const unsigned kMaxFourByteChar = 0x1fffff; | 131 static const unsigned kMaxFourByteChar = 0x1fffff; |
129 | 132 |
130 private: | 133 private: |
131 template <unsigned s> friend class Utf8InputBuffer; | 134 template <unsigned s> friend class Utf8InputBuffer; |
132 friend class Test; | 135 friend class Test; |
133 static inline uchar ValueOf(const byte* str, | 136 static inline uchar ValueOf(const byte* str, |
134 unsigned length, | 137 unsigned length, |
135 unsigned* cursor); | 138 unsigned* cursor); |
136 static uchar CalculateValue(const byte* str, | |
137 unsigned length, | |
138 unsigned* cursor); | |
139 }; | 139 }; |
140 | 140 |
141 // --- C h a r a c t e r S t r e a m --- | 141 // --- C h a r a c t e r S t r e a m --- |
142 | 142 |
143 class CharacterStream { | 143 class CharacterStream { |
144 public: | 144 public: |
145 inline uchar GetNext(); | 145 inline uchar GetNext(); |
146 inline bool has_more() { return remaining_ != 0; } | 146 inline bool has_more() { return remaining_ != 0; } |
147 // Note that default implementation is not efficient. | 147 // Note that default implementation is not efficient. |
148 virtual void Seek(unsigned); | 148 virtual void Seek(unsigned); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 static const int kMaxWidth = 1; | 271 static const int kMaxWidth = 1; |
272 static int Convert(uchar c, | 272 static int Convert(uchar c, |
273 uchar n, | 273 uchar n, |
274 uchar* result, | 274 uchar* result, |
275 bool* allow_caching_ptr); | 275 bool* allow_caching_ptr); |
276 }; | 276 }; |
277 | 277 |
278 } // namespace unibrow | 278 } // namespace unibrow |
279 | 279 |
280 #endif // V8_UNICODE_H_ | 280 #endif // V8_UNICODE_H_ |
OLD | NEW |