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

Side by Side Diff: src/api.cc

Issue 10917211: Introduce new API to expose external string resource regardless of encoding. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 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 | « include/v8.h ('k') | src/objects-inl.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 // 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 4071 matching lines...) Expand 10 before | Expand all | Expand 10 after
4082 if (i::StringShape(*str).IsExternalTwoByte()) { 4082 if (i::StringShape(*str).IsExternalTwoByte()) {
4083 const void* resource = 4083 const void* resource =
4084 i::Handle<i::ExternalTwoByteString>::cast(str)->resource(); 4084 i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
4085 expected = reinterpret_cast<const ExternalStringResource*>(resource); 4085 expected = reinterpret_cast<const ExternalStringResource*>(resource);
4086 } else { 4086 } else {
4087 expected = NULL; 4087 expected = NULL;
4088 } 4088 }
4089 CHECK_EQ(expected, value); 4089 CHECK_EQ(expected, value);
4090 } 4090 }
4091 4091
4092 void v8::String::VerifyExternalStringResourceBase(
4093 v8::String::ExternalStringResourceBase* value, Encoding encoding) const {
4094 i::Handle<i::String> str = Utils::OpenHandle(this);
4095 const v8::String::ExternalStringResourceBase* expected;
4096 Encoding expectedEncoding;
4097 if (i::StringShape(*str).IsExternalAscii()) {
4098 const void* resource =
4099 i::Handle<i::ExternalAsciiString>::cast(str)->resource();
4100 expected = reinterpret_cast<const ExternalStringResourceBase*>(resource);
4101 expectedEncoding = ASCII_ENCODING;
4102 } else if (i::StringShape(*str).IsExternalTwoByte()) {
4103 const void* resource =
4104 i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
4105 expected = reinterpret_cast<const ExternalStringResourceBase*>(resource);
4106 expectedEncoding = TWO_BYTE_ENCODING;
4107 } else {
4108 expected = NULL;
4109 expectedEncoding = str->IsAsciiRepresentation() ? ASCII_ENCODING
4110 : TWO_BYTE_ENCODING;
4111 }
4112 CHECK_EQ(expected, value);
4113 CHECK_EQ(expectedEncoding, encoding);
4114 }
4092 4115
4093 const v8::String::ExternalAsciiStringResource* 4116 const v8::String::ExternalAsciiStringResource*
4094 v8::String::GetExternalAsciiStringResource() const { 4117 v8::String::GetExternalAsciiStringResource() const {
4095 i::Handle<i::String> str = Utils::OpenHandle(this); 4118 i::Handle<i::String> str = Utils::OpenHandle(this);
4096 if (IsDeadCheck(str->GetIsolate(), 4119 if (IsDeadCheck(str->GetIsolate(),
4097 "v8::String::GetExternalAsciiStringResource()")) { 4120 "v8::String::GetExternalAsciiStringResource()")) {
4098 return NULL; 4121 return NULL;
4099 } 4122 }
4100 if (i::StringShape(*str).IsExternalAscii()) { 4123 if (i::StringShape(*str).IsExternalAscii()) {
4101 const void* resource = 4124 const void* resource =
(...skipping 2452 matching lines...) Expand 10 before | Expand all | Expand 10 after
6554 6577
6555 v->VisitPointers(blocks_.first(), first_block_limit_); 6578 v->VisitPointers(blocks_.first(), first_block_limit_);
6556 6579
6557 for (int i = 1; i < blocks_.length(); i++) { 6580 for (int i = 1; i < blocks_.length(); i++) {
6558 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 6581 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
6559 } 6582 }
6560 } 6583 }
6561 6584
6562 6585
6563 } } // namespace v8::internal 6586 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698