Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: include/v8.h

Issue 351573002: Make Object::IsFoo const. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Feedback. Rebased. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 /** \mainpage V8 API Reference Guide 5 /** \mainpage V8 API Reference Guide
6 * 6 *
7 * V8 is Google's open source JavaScript engine. 7 * V8 is Google's open source JavaScript engine.
8 * 8 *
9 * This set of documents provides reference material generated from the 9 * This set of documents provides reference material generated from the
10 * V8 header file, include/v8.h. 10 * V8 header file, include/v8.h.
(...skipping 6196 matching lines...) Expand 10 before | Expand all | Expand 10 after
6207 typedef internal::Internals I; 6207 typedef internal::Internals I;
6208 I::CheckInitialized(isolate); 6208 I::CheckInitialized(isolate);
6209 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); 6209 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex);
6210 return Local<String>(reinterpret_cast<String*>(slot)); 6210 return Local<String>(reinterpret_cast<String*>(slot));
6211 } 6211 }
6212 6212
6213 6213
6214 String::ExternalStringResource* String::GetExternalStringResource() const { 6214 String::ExternalStringResource* String::GetExternalStringResource() const {
6215 typedef internal::Object O; 6215 typedef internal::Object O;
6216 typedef internal::Internals I; 6216 typedef internal::Internals I;
6217 O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); 6217 O* obj = *reinterpret_cast<O* const*>(this);
6218 String::ExternalStringResource* result; 6218 String::ExternalStringResource* result;
6219 if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) { 6219 if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
6220 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); 6220 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
6221 result = reinterpret_cast<String::ExternalStringResource*>(value); 6221 result = reinterpret_cast<String::ExternalStringResource*>(value);
6222 } else { 6222 } else {
6223 result = NULL; 6223 result = NULL;
6224 } 6224 }
6225 #ifdef V8_ENABLE_CHECKS 6225 #ifdef V8_ENABLE_CHECKS
6226 VerifyExternalStringResource(result); 6226 VerifyExternalStringResource(result);
6227 #endif 6227 #endif
6228 return result; 6228 return result;
6229 } 6229 }
6230 6230
6231 6231
6232 String::ExternalStringResourceBase* String::GetExternalStringResourceBase( 6232 String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
6233 String::Encoding* encoding_out) const { 6233 String::Encoding* encoding_out) const {
6234 typedef internal::Object O; 6234 typedef internal::Object O;
6235 typedef internal::Internals I; 6235 typedef internal::Internals I;
6236 O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); 6236 O* obj = *reinterpret_cast<O* const*>(this);
6237 int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask; 6237 int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
6238 *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask); 6238 *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
6239 ExternalStringResourceBase* resource = NULL; 6239 ExternalStringResourceBase* resource = NULL;
6240 if (type == I::kExternalAsciiRepresentationTag || 6240 if (type == I::kExternalAsciiRepresentationTag ||
6241 type == I::kExternalTwoByteRepresentationTag) { 6241 type == I::kExternalTwoByteRepresentationTag) {
6242 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); 6242 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
6243 resource = static_cast<ExternalStringResourceBase*>(value); 6243 resource = static_cast<ExternalStringResourceBase*>(value);
6244 } 6244 }
6245 #ifdef V8_ENABLE_CHECKS 6245 #ifdef V8_ENABLE_CHECKS
6246 VerifyExternalStringResourceBase(resource, *encoding_out); 6246 VerifyExternalStringResourceBase(resource, *encoding_out);
6247 #endif 6247 #endif
6248 return resource; 6248 return resource;
6249 } 6249 }
6250 6250
6251 6251
6252 bool Value::IsUndefined() const { 6252 bool Value::IsUndefined() const {
6253 #ifdef V8_ENABLE_CHECKS 6253 #ifdef V8_ENABLE_CHECKS
6254 return FullIsUndefined(); 6254 return FullIsUndefined();
6255 #else 6255 #else
6256 return QuickIsUndefined(); 6256 return QuickIsUndefined();
6257 #endif 6257 #endif
6258 } 6258 }
6259 6259
6260 bool Value::QuickIsUndefined() const { 6260 bool Value::QuickIsUndefined() const {
6261 typedef internal::Object O; 6261 typedef internal::Object O;
6262 typedef internal::Internals I; 6262 typedef internal::Internals I;
6263 O* obj = *reinterpret_cast<O**>(const_cast<Value*>(this)); 6263 O* obj = *reinterpret_cast<O* const*>(this);
6264 if (!I::HasHeapObjectTag(obj)) return false; 6264 if (!I::HasHeapObjectTag(obj)) return false;
6265 if (I::GetInstanceType(obj) != I::kOddballType) return false; 6265 if (I::GetInstanceType(obj) != I::kOddballType) return false;
6266 return (I::GetOddballKind(obj) == I::kUndefinedOddballKind); 6266 return (I::GetOddballKind(obj) == I::kUndefinedOddballKind);
6267 } 6267 }
6268 6268
6269 6269
6270 bool Value::IsNull() const { 6270 bool Value::IsNull() const {
6271 #ifdef V8_ENABLE_CHECKS 6271 #ifdef V8_ENABLE_CHECKS
6272 return FullIsNull(); 6272 return FullIsNull();
6273 #else 6273 #else
6274 return QuickIsNull(); 6274 return QuickIsNull();
6275 #endif 6275 #endif
6276 } 6276 }
6277 6277
6278 bool Value::QuickIsNull() const { 6278 bool Value::QuickIsNull() const {
6279 typedef internal::Object O; 6279 typedef internal::Object O;
6280 typedef internal::Internals I; 6280 typedef internal::Internals I;
6281 O* obj = *reinterpret_cast<O**>(const_cast<Value*>(this)); 6281 O* obj = *reinterpret_cast<O* const*>(this);
6282 if (!I::HasHeapObjectTag(obj)) return false; 6282 if (!I::HasHeapObjectTag(obj)) return false;
6283 if (I::GetInstanceType(obj) != I::kOddballType) return false; 6283 if (I::GetInstanceType(obj) != I::kOddballType) return false;
6284 return (I::GetOddballKind(obj) == I::kNullOddballKind); 6284 return (I::GetOddballKind(obj) == I::kNullOddballKind);
6285 } 6285 }
6286 6286
6287 6287
6288 bool Value::IsString() const { 6288 bool Value::IsString() const {
6289 #ifdef V8_ENABLE_CHECKS 6289 #ifdef V8_ENABLE_CHECKS
6290 return FullIsString(); 6290 return FullIsString();
6291 #else 6291 #else
6292 return QuickIsString(); 6292 return QuickIsString();
6293 #endif 6293 #endif
6294 } 6294 }
6295 6295
6296 bool Value::QuickIsString() const { 6296 bool Value::QuickIsString() const {
6297 typedef internal::Object O; 6297 typedef internal::Object O;
6298 typedef internal::Internals I; 6298 typedef internal::Internals I;
6299 O* obj = *reinterpret_cast<O**>(const_cast<Value*>(this)); 6299 O* obj = *reinterpret_cast<O* const*>(this);
6300 if (!I::HasHeapObjectTag(obj)) return false; 6300 if (!I::HasHeapObjectTag(obj)) return false;
6301 return (I::GetInstanceType(obj) < I::kFirstNonstringType); 6301 return (I::GetInstanceType(obj) < I::kFirstNonstringType);
6302 } 6302 }
6303 6303
6304 6304
6305 template <class T> Value* Value::Cast(T* value) { 6305 template <class T> Value* Value::Cast(T* value) {
6306 return static_cast<Value*>(value); 6306 return static_cast<Value*>(value);
6307 } 6307 }
6308 6308
6309 6309
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
6701 */ 6701 */
6702 6702
6703 6703
6704 } // namespace v8 6704 } // namespace v8
6705 6705
6706 6706
6707 #undef TYPE_CHECK 6707 #undef TYPE_CHECK
6708 6708
6709 6709
6710 #endif // V8_H_ 6710 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698