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

Side by Side Diff: src/factory.cc

Issue 10828229: Add basic support for Latin1 strings to the API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 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
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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 Handle<String> Factory::NewStringFromAscii(Vector<const char> string, 199 Handle<String> Factory::NewStringFromAscii(Vector<const char> string,
200 PretenureFlag pretenure) { 200 PretenureFlag pretenure) {
201 CALL_HEAP_FUNCTION( 201 CALL_HEAP_FUNCTION(
202 isolate(), 202 isolate(),
203 isolate()->heap()->AllocateStringFromAscii(string, pretenure), 203 isolate()->heap()->AllocateStringFromAscii(string, pretenure),
204 String); 204 String);
205 } 205 }
206 206
207 Handle<String> Factory::NewStringFromUtf8(Vector<const char> string, 207 Handle<String> Factory::NewStringFromUtf8(Vector<const char> string,
208 PretenureFlag pretenure) { 208 PretenureFlag pretenure,
209 String::AsciiHint ascii_hint) {
209 CALL_HEAP_FUNCTION( 210 CALL_HEAP_FUNCTION(
210 isolate(), 211 isolate(),
211 isolate()->heap()->AllocateStringFromUtf8(string, pretenure), 212 isolate()->heap()->AllocateStringFromUtf8(
213 string, pretenure, ascii_hint),
212 String); 214 String);
213 } 215 }
214 216
217
218 Handle<String> Factory::NewStringFromLatin1(Vector<const char> string,
219 PretenureFlag pretenure,
220 String::AsciiHint ascii_hint) {
221 CALL_HEAP_FUNCTION(
222 isolate(),
223 isolate()->heap()->AllocateStringFromLatin1(
224 string, pretenure, ascii_hint),
225 String);
226 }
227
215 228
216 Handle<String> Factory::NewStringFromTwoByte(Vector<const uc16> string, 229 Handle<String> Factory::NewStringFromTwoByte(Vector<const uc16> string,
217 PretenureFlag pretenure) { 230 PretenureFlag pretenure) {
218 CALL_HEAP_FUNCTION( 231 CALL_HEAP_FUNCTION(
219 isolate(), 232 isolate(),
220 isolate()->heap()->AllocateStringFromTwoByte(string, pretenure), 233 isolate()->heap()->AllocateStringFromTwoByte(string, pretenure),
221 String); 234 String);
222 } 235 }
223 236
224 237
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 space -= Min(space, strlen(arg)); 724 space -= Min(space, strlen(arg));
712 p = &buffer[kBufferSize] - space; 725 p = &buffer[kBufferSize] - space;
713 } 726 }
714 } 727 }
715 } 728 }
716 if (space > 0) { 729 if (space > 0) {
717 *p = '\0'; 730 *p = '\0';
718 } else { 731 } else {
719 buffer[kBufferSize - 1] = '\0'; 732 buffer[kBufferSize - 1] = '\0';
720 } 733 }
721 Handle<String> error_string = NewStringFromUtf8(CStrVector(buffer), TENURED); 734 Handle<String> error_string =
Erik Corry 2012/08/10 11:28:51 Inadvertent edit?
Yang 2012/08/10 13:14:45 Yes. Done.
735 NewStringFromUtf8(CStrVector(buffer), TENURED);
722 return error_string; 736 return error_string;
723 } 737 }
724 738
725 739
726 Handle<Object> Factory::NewError(const char* maker, 740 Handle<Object> Factory::NewError(const char* maker,
727 const char* type, 741 const char* type,
728 Handle<JSArray> args) { 742 Handle<JSArray> args) {
729 Handle<String> make_str = LookupAsciiSymbol(maker); 743 Handle<String> make_str = LookupAsciiSymbol(maker);
730 Handle<Object> fun_obj( 744 Handle<Object> fun_obj(
731 isolate()->js_builtins_object()->GetPropertyNoExceptionThrown(*make_str)); 745 isolate()->js_builtins_object()->GetPropertyNoExceptionThrown(*make_str));
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 1415
1402 1416
1403 Handle<Object> Factory::ToBoolean(bool value) { 1417 Handle<Object> Factory::ToBoolean(bool value) {
1404 return Handle<Object>(value 1418 return Handle<Object>(value
1405 ? isolate()->heap()->true_value() 1419 ? isolate()->heap()->true_value()
1406 : isolate()->heap()->false_value()); 1420 : isolate()->heap()->false_value());
1407 } 1421 }
1408 1422
1409 1423
1410 } } // namespace v8::internal 1424 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698