OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 192 |
193 if (LIKELY(m_v8Object->IsString())) | 193 if (LIKELY(m_v8Object->IsString())) |
194 return true; | 194 return true; |
195 | 195 |
196 if (LIKELY(m_v8Object->IsInt32())) { | 196 if (LIKELY(m_v8Object->IsInt32())) { |
197 setString(int32ToWebCoreString(m_v8Object->Int32Value())); | 197 setString(int32ToWebCoreString(m_v8Object->Int32Value())); |
198 return true; | 198 return true; |
199 } | 199 } |
200 | 200 |
201 m_mode = DoNotExternalize; | 201 m_mode = DoNotExternalize; |
202 v8::TryCatch block; | |
203 m_v8Object = m_v8Object->ToString(); | 202 m_v8Object = m_v8Object->ToString(); |
204 // Handle the case where an exception is thrown as part of invoking toSt
ring on the object. | 203 // Returns false when an exception is thrown from toString. |
205 if (block.HasCaught()) { | 204 return !m_v8Object.IsEmpty(); |
206 block.ReThrow(); | |
207 return false; | |
208 } | |
209 return true; | |
210 } | 205 } |
211 | 206 |
212 void setString(const String& string) | 207 void setString(const String& string) |
213 { | 208 { |
214 m_string = string; | 209 m_string = string; |
215 m_v8Object.Clear(); // To signal that String is ready. | 210 m_v8Object.Clear(); // To signal that String is ready. |
216 } | 211 } |
217 | 212 |
218 template <class StringType> | 213 template <class StringType> |
219 StringType toString() const | 214 StringType toString() const |
(...skipping 28 matching lines...) Expand all Loading... |
248 if (m_v8Object.IsEmpty() || m_v8Object->IsNull() || m_v8Object->IsUndefined(
)) { | 243 if (m_v8Object.IsEmpty() || m_v8Object->IsNull() || m_v8Object->IsUndefined(
)) { |
249 setString(String()); | 244 setString(String()); |
250 return true; | 245 return true; |
251 } | 246 } |
252 return prepareBase(); | 247 return prepareBase(); |
253 } | 248 } |
254 | 249 |
255 } // namespace WebCore | 250 } // namespace WebCore |
256 | 251 |
257 #endif // V8StringResource_h | 252 #endif // V8StringResource_h |
OLD | NEW |