| 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 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 | 9 |
| 10 template <typename Char, typename Base> | 10 template <typename Char, typename Base> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 "native function externalizeString();" | 37 "native function externalizeString();" |
| 38 "native function isAsciiString();"; | 38 "native function isAsciiString();"; |
| 39 | 39 |
| 40 v8::Handle<v8::FunctionTemplate> | 40 v8::Handle<v8::FunctionTemplate> |
| 41 ExternalizeStringExtension::GetNativeFunctionTemplate( | 41 ExternalizeStringExtension::GetNativeFunctionTemplate( |
| 42 v8::Isolate* isolate, v8::Handle<v8::String> str) { | 42 v8::Isolate* isolate, v8::Handle<v8::String> str) { |
| 43 if (strcmp(*v8::String::Utf8Value(str), "externalizeString") == 0) { | 43 if (strcmp(*v8::String::Utf8Value(str), "externalizeString") == 0) { |
| 44 return v8::FunctionTemplate::New(isolate, | 44 return v8::FunctionTemplate::New(isolate, |
| 45 ExternalizeStringExtension::Externalize); | 45 ExternalizeStringExtension::Externalize); |
| 46 } else { | 46 } else { |
| 47 ASSERT(strcmp(*v8::String::Utf8Value(str), "isAsciiString") == 0); | 47 DCHECK(strcmp(*v8::String::Utf8Value(str), "isAsciiString") == 0); |
| 48 return v8::FunctionTemplate::New(isolate, | 48 return v8::FunctionTemplate::New(isolate, |
| 49 ExternalizeStringExtension::IsAscii); | 49 ExternalizeStringExtension::IsAscii); |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 | 53 |
| 54 void ExternalizeStringExtension::Externalize( | 54 void ExternalizeStringExtension::Externalize( |
| 55 const v8::FunctionCallbackInfo<v8::Value>& args) { | 55 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 56 if (args.Length() < 1 || !args[0]->IsString()) { | 56 if (args.Length() < 1 || !args[0]->IsString()) { |
| 57 args.GetIsolate()->ThrowException(v8::String::NewFromUtf8( | 57 args.GetIsolate()->ThrowException(v8::String::NewFromUtf8( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 args.GetIsolate(), | 116 args.GetIsolate(), |
| 117 "isAsciiString() requires a single string argument.")); | 117 "isAsciiString() requires a single string argument.")); |
| 118 return; | 118 return; |
| 119 } | 119 } |
| 120 bool is_one_byte = | 120 bool is_one_byte = |
| 121 Utils::OpenHandle(*args[0].As<v8::String>())->IsOneByteRepresentation(); | 121 Utils::OpenHandle(*args[0].As<v8::String>())->IsOneByteRepresentation(); |
| 122 args.GetReturnValue().Set(is_one_byte); | 122 args.GetReturnValue().Set(is_one_byte); |
| 123 } | 123 } |
| 124 | 124 |
| 125 } } // namespace v8::internal | 125 } } // namespace v8::internal |
| OLD | NEW |