OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 #include "src/extensions/externalize-string-extension.h" | 5 #include "src/extensions/externalize-string-extension.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/handles.h" | 8 #include "src/handles.h" |
9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 Char* const data_; | 29 Char* const data_; |
30 const size_t length_; | 30 const size_t length_; |
31 }; | 31 }; |
32 | 32 |
33 | 33 |
34 typedef SimpleStringResource<char, v8::String::ExternalOneByteStringResource> | 34 typedef SimpleStringResource<char, v8::String::ExternalOneByteStringResource> |
35 SimpleOneByteStringResource; | 35 SimpleOneByteStringResource; |
36 typedef SimpleStringResource<uc16, v8::String::ExternalStringResource> | 36 typedef SimpleStringResource<uc16, v8::String::ExternalStringResource> |
37 SimpleTwoByteStringResource; | 37 SimpleTwoByteStringResource; |
38 | 38 |
39 | |
40 const char* const ExternalizeStringExtension::kSource = | 39 const char* const ExternalizeStringExtension::kSource = |
41 "native function externalizeString();" | 40 "native function externalizeString();" |
42 "native function isOneByteString();"; | 41 "native function isOneByteString();" |
| 42 "function x() { return 1; }"; |
43 | 43 |
44 v8::Local<v8::FunctionTemplate> | 44 v8::Local<v8::FunctionTemplate> |
45 ExternalizeStringExtension::GetNativeFunctionTemplate( | 45 ExternalizeStringExtension::GetNativeFunctionTemplate( |
46 v8::Isolate* isolate, v8::Local<v8::String> str) { | 46 v8::Isolate* isolate, v8::Local<v8::String> str) { |
47 if (strcmp(*v8::String::Utf8Value(str), "externalizeString") == 0) { | 47 if (strcmp(*v8::String::Utf8Value(str), "externalizeString") == 0) { |
48 return v8::FunctionTemplate::New(isolate, | 48 return v8::FunctionTemplate::New(isolate, |
49 ExternalizeStringExtension::Externalize); | 49 ExternalizeStringExtension::Externalize); |
50 } else { | 50 } else { |
51 DCHECK(strcmp(*v8::String::Utf8Value(str), "isOneByteString") == 0); | 51 DCHECK(strcmp(*v8::String::Utf8Value(str), "isOneByteString") == 0); |
52 return v8::FunctionTemplate::New(isolate, | 52 return v8::FunctionTemplate::New(isolate, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 NewStringType::kNormal).ToLocalChecked()); | 133 NewStringType::kNormal).ToLocalChecked()); |
134 return; | 134 return; |
135 } | 135 } |
136 bool is_one_byte = | 136 bool is_one_byte = |
137 Utils::OpenHandle(*args[0].As<v8::String>())->IsOneByteRepresentation(); | 137 Utils::OpenHandle(*args[0].As<v8::String>())->IsOneByteRepresentation(); |
138 args.GetReturnValue().Set(is_one_byte); | 138 args.GetReturnValue().Set(is_one_byte); |
139 } | 139 } |
140 | 140 |
141 } // namespace internal | 141 } // namespace internal |
142 } // namespace v8 | 142 } // namespace v8 |
OLD | NEW |