| OLD | NEW |
| 1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 3482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3493 int representation = (instance_type & kFullStringRepresentationMask); | 3493 int representation = (instance_type & kFullStringRepresentationMask); |
| 3494 return representation == kExternalTwoByteRepresentationTag; | 3494 return representation == kExternalTwoByteRepresentationTag; |
| 3495 } | 3495 } |
| 3496 | 3496 |
| 3497 template <typename T> | 3497 template <typename T> |
| 3498 static inline T ReadField(Object* ptr, int offset) { | 3498 static inline T ReadField(Object* ptr, int offset) { |
| 3499 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; | 3499 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; |
| 3500 return *reinterpret_cast<T*>(addr); | 3500 return *reinterpret_cast<T*>(addr); |
| 3501 } | 3501 } |
| 3502 | 3502 |
| 3503 static inline bool CanCastToHeapObject(void*) { return false; } | 3503 static inline bool CanCastToHeapObject(void* o) { return false; } |
| 3504 static inline bool CanCastToHeapObject(Context*) { return true; } | 3504 static inline bool CanCastToHeapObject(Context* o) { return true; } |
| 3505 static inline bool CanCastToHeapObject(String*) { return true; } | 3505 static inline bool CanCastToHeapObject(String* o) { return true; } |
| 3506 static inline bool CanCastToHeapObject(Object*) { return true; } | 3506 static inline bool CanCastToHeapObject(Object* o) { return true; } |
| 3507 static inline bool CanCastToHeapObject(Message*) { return true; } | 3507 static inline bool CanCastToHeapObject(Message* o) { return true; } |
| 3508 static inline bool CanCastToHeapObject(StackTrace*) { return true; } | 3508 static inline bool CanCastToHeapObject(StackTrace* o) { return true; } |
| 3509 static inline bool CanCastToHeapObject(StackFrame*) { return true; } | 3509 static inline bool CanCastToHeapObject(StackFrame* o) { return true; } |
| 3510 | |
| 3511 }; | 3510 }; |
| 3512 | 3511 |
| 3513 } // namespace internal | 3512 } // namespace internal |
| 3514 | 3513 |
| 3515 | 3514 |
| 3516 template <class T> | 3515 template <class T> |
| 3517 Handle<T>::Handle() : val_(0) { } | 3516 Handle<T>::Handle() : val_(0) { } |
| 3518 | 3517 |
| 3519 | 3518 |
| 3520 template <class T> | 3519 template <class T> |
| 3521 Local<T>::Local() : Handle<T>() { } | 3520 Local<T>::Local() : Handle<T>() { } |
| 3522 | 3521 |
| 3523 | 3522 |
| 3524 template <class T> | 3523 template <class T> |
| 3525 Local<T> Local<T>::New(Handle<T> that) { | 3524 Local<T> Local<T>::New(Handle<T> that) { |
| 3526 if (that.IsEmpty()) return Local<T>(); | 3525 if (that.IsEmpty()) return Local<T>(); |
| 3527 T* that_ptr = *that; | 3526 T* that_ptr = *that; |
| 3528 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); | 3527 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); |
| 3529 if (internal::Internals::CanCastToHeapObject(that_ptr)) { | 3528 if (internal::Internals::CanCastToHeapObject(that_ptr)) { |
| 3530 return Local<T>(reinterpret_cast<T*>( | 3529 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( |
| 3531 HandleScope::CreateHandle(reinterpret_cast<internal::HeapObject*>(*p)))); | 3530 reinterpret_cast<internal::HeapObject*>(*p)))); |
| 3532 } | 3531 } |
| 3533 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p))); | 3532 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p))); |
| 3534 } | 3533 } |
| 3535 | 3534 |
| 3536 | 3535 |
| 3537 template <class T> | 3536 template <class T> |
| 3538 Persistent<T> Persistent<T>::New(Handle<T> that) { | 3537 Persistent<T> Persistent<T>::New(Handle<T> that) { |
| 3539 if (that.IsEmpty()) return Persistent<T>(); | 3538 if (that.IsEmpty()) return Persistent<T>(); |
| 3540 internal::Object** p = reinterpret_cast<internal::Object**>(*that); | 3539 internal::Object** p = reinterpret_cast<internal::Object**>(*that); |
| 3541 return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p))); | 3540 return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p))); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3855 | 3854 |
| 3856 | 3855 |
| 3857 } // namespace v8 | 3856 } // namespace v8 |
| 3858 | 3857 |
| 3859 | 3858 |
| 3860 #undef V8EXPORT | 3859 #undef V8EXPORT |
| 3861 #undef TYPE_CHECK | 3860 #undef TYPE_CHECK |
| 3862 | 3861 |
| 3863 | 3862 |
| 3864 #endif // V8_H_ | 3863 #endif // V8_H_ |
| OLD | NEW |