| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // or AtomicStrings as appropriate, using multiple typecast operators. | 162 // or AtomicStrings as appropriate, using multiple typecast operators. |
| 163 enum V8StringResourceMode { | 163 enum V8StringResourceMode { |
| 164 DefaultMode, | 164 DefaultMode, |
| 165 WithNullCheck, | 165 WithNullCheck, |
| 166 WithUndefinedOrNullCheck | 166 WithUndefinedOrNullCheck |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 template <V8StringResourceMode Mode = DefaultMode> | 169 template <V8StringResourceMode Mode = DefaultMode> |
| 170 class V8StringResource { | 170 class V8StringResource { |
| 171 public: | 171 public: |
| 172 V8StringResource() |
| 173 : m_mode(Externalize) |
| 174 { |
| 175 } |
| 176 |
| 172 V8StringResource(v8::Handle<v8::Value> object) | 177 V8StringResource(v8::Handle<v8::Value> object) |
| 173 : m_v8Object(object) | 178 : m_v8Object(object) |
| 174 , m_mode(Externalize) | 179 , m_mode(Externalize) |
| 175 , m_string() | |
| 176 { | 180 { |
| 177 } | 181 } |
| 178 | 182 |
| 183 void operator=(v8::Handle<v8::Value> object) |
| 184 { |
| 185 m_v8Object = object; |
| 186 } |
| 187 |
| 179 bool prepare() | 188 bool prepare() |
| 180 { | 189 { |
| 181 if (m_v8Object.IsEmpty()) | 190 if (m_v8Object.IsEmpty()) |
| 182 return true; | 191 return true; |
| 183 | 192 |
| 184 if (!isValid()) { | 193 if (!isValid()) { |
| 185 setString(String()); | 194 setString(String()); |
| 186 return true; | 195 return true; |
| 187 } | 196 } |
| 188 | 197 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 250 } |
| 242 | 251 |
| 243 template<> inline bool V8StringResource<WithUndefinedOrNullCheck>::isValid() con
st | 252 template<> inline bool V8StringResource<WithUndefinedOrNullCheck>::isValid() con
st |
| 244 { | 253 { |
| 245 return !m_v8Object->IsNull() && !m_v8Object->IsUndefined(); | 254 return !m_v8Object->IsNull() && !m_v8Object->IsUndefined(); |
| 246 } | 255 } |
| 247 | 256 |
| 248 } // namespace WebCore | 257 } // namespace WebCore |
| 249 | 258 |
| 250 #endif // V8StringResource_h | 259 #endif // V8StringResource_h |
| OLD | NEW |