OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
494 | 494 |
495 void RegisterExtension(Extension* that) { | 495 void RegisterExtension(Extension* that) { |
496 RegisteredExtension* extension = new RegisteredExtension(that); | 496 RegisteredExtension* extension = new RegisteredExtension(that); |
497 RegisteredExtension::Register(extension); | 497 RegisteredExtension::Register(extension); |
498 } | 498 } |
499 | 499 |
500 | 500 |
501 Extension::Extension(const char* name, | 501 Extension::Extension(const char* name, |
502 const char* source, | 502 const char* source, |
503 int dep_count, | 503 int dep_count, |
504 const char** deps) | 504 const char** deps, |
505 int source_length) | |
505 : name_(name), | 506 : name_(name), |
506 source_(source), | 507 source_length_(source_length >= 0 ? |
Aaron Boodman
2011/09/14 20:33:18
Nested ternary operators are hard to read and this
miket_OOO
2011/09/14 20:47:16
You're right; it works great as-is but it's fragil
| |
508 source_length : (source ? strlen(source) : 0)), | |
509 source_(source, source_length_), | |
507 dep_count_(dep_count), | 510 dep_count_(dep_count), |
508 deps_(deps), | 511 deps_(deps), |
509 auto_enable_(false) { } | 512 auto_enable_(false) { } |
510 | 513 |
511 | 514 |
512 v8::Handle<Primitive> Undefined() { | 515 v8::Handle<Primitive> Undefined() { |
513 i::Isolate* isolate = i::Isolate::Current(); | 516 i::Isolate* isolate = i::Isolate::Current(); |
514 if (!EnsureInitializedForIsolate(isolate, "v8::Undefined()")) { | 517 if (!EnsureInitializedForIsolate(isolate, "v8::Undefined()")) { |
515 return v8::Handle<v8::Primitive>(); | 518 return v8::Handle<v8::Primitive>(); |
516 } | 519 } |
(...skipping 3275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3792 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsExternalAscii()")) { | 3795 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsExternalAscii()")) { |
3793 return false; | 3796 return false; |
3794 } | 3797 } |
3795 return i::StringShape(*str).IsExternalAscii(); | 3798 return i::StringShape(*str).IsExternalAscii(); |
3796 } | 3799 } |
3797 | 3800 |
3798 | 3801 |
3799 void v8::String::VerifyExternalStringResource( | 3802 void v8::String::VerifyExternalStringResource( |
3800 v8::String::ExternalStringResource* value) const { | 3803 v8::String::ExternalStringResource* value) const { |
3801 i::Handle<i::String> str = Utils::OpenHandle(this); | 3804 i::Handle<i::String> str = Utils::OpenHandle(this); |
3802 v8::String::ExternalStringResource* expected; | 3805 const v8::String::ExternalStringResource* expected; |
3803 if (i::StringShape(*str).IsExternalTwoByte()) { | 3806 if (i::StringShape(*str).IsExternalTwoByte()) { |
3804 void* resource = i::Handle<i::ExternalTwoByteString>::cast(str)->resource(); | 3807 const void* resource = |
3805 expected = reinterpret_cast<ExternalStringResource*>(resource); | 3808 i::Handle<i::ExternalTwoByteString>::cast(str)->resource(); |
3809 expected = reinterpret_cast<const ExternalStringResource*>(resource); | |
3806 } else { | 3810 } else { |
3807 expected = NULL; | 3811 expected = NULL; |
3808 } | 3812 } |
3809 CHECK_EQ(expected, value); | 3813 CHECK_EQ(expected, value); |
3810 } | 3814 } |
3811 | 3815 |
3812 | 3816 |
3813 v8::String::ExternalAsciiStringResource* | 3817 const v8::String::ExternalAsciiStringResource* |
3814 v8::String::GetExternalAsciiStringResource() const { | 3818 v8::String::GetExternalAsciiStringResource() const { |
3815 i::Handle<i::String> str = Utils::OpenHandle(this); | 3819 i::Handle<i::String> str = Utils::OpenHandle(this); |
3816 if (IsDeadCheck(str->GetIsolate(), | 3820 if (IsDeadCheck(str->GetIsolate(), |
3817 "v8::String::GetExternalAsciiStringResource()")) { | 3821 "v8::String::GetExternalAsciiStringResource()")) { |
3818 return NULL; | 3822 return NULL; |
3819 } | 3823 } |
3820 if (i::StringShape(*str).IsExternalAscii()) { | 3824 if (i::StringShape(*str).IsExternalAscii()) { |
3821 void* resource = i::Handle<i::ExternalAsciiString>::cast(str)->resource(); | 3825 const void* resource = |
3822 return reinterpret_cast<ExternalAsciiStringResource*>(resource); | 3826 i::Handle<i::ExternalAsciiString>::cast(str)->resource(); |
3827 return reinterpret_cast<const ExternalAsciiStringResource*>(resource); | |
3823 } else { | 3828 } else { |
3824 return NULL; | 3829 return NULL; |
3825 } | 3830 } |
3826 } | 3831 } |
3827 | 3832 |
3828 | 3833 |
3829 double Number::Value() const { | 3834 double Number::Value() const { |
3830 if (IsDeadCheck(i::Isolate::Current(), "v8::Number::Value()")) return 0; | 3835 if (IsDeadCheck(i::Isolate::Current(), "v8::Number::Value()")) return 0; |
3831 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 3836 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
3832 return obj->Number(); | 3837 return obj->Number(); |
(...skipping 2243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6076 | 6081 |
6077 | 6082 |
6078 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 6083 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
6079 HandleScopeImplementer* scope_implementer = | 6084 HandleScopeImplementer* scope_implementer = |
6080 reinterpret_cast<HandleScopeImplementer*>(storage); | 6085 reinterpret_cast<HandleScopeImplementer*>(storage); |
6081 scope_implementer->IterateThis(v); | 6086 scope_implementer->IterateThis(v); |
6082 return storage + ArchiveSpacePerThread(); | 6087 return storage + ArchiveSpacePerThread(); |
6083 } | 6088 } |
6084 | 6089 |
6085 } } // namespace v8::internal | 6090 } } // namespace v8::internal |
OLD | NEW |