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

Side by Side Diff: src/runtime/runtime-i18n.cc

Issue 895053002: Move the contents of api-natives.js to c++ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « src/runtime/runtime-api.cc ('k') | test/cctest/test-api.cc » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 5
6 #ifdef V8_I18N_SUPPORT 6 #ifdef V8_I18N_SUPPORT
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/api-natives.h"
9 #include "src/arguments.h" 10 #include "src/arguments.h"
10 #include "src/i18n.h" 11 #include "src/i18n.h"
11 #include "src/runtime/runtime-utils.h" 12 #include "src/runtime/runtime-utils.h"
12 13
13 #include "unicode/brkiter.h" 14 #include "unicode/brkiter.h"
14 #include "unicode/calendar.h" 15 #include "unicode/calendar.h"
15 #include "unicode/coll.h" 16 #include "unicode/coll.h"
16 #include "unicode/curramt.h" 17 #include "unicode/curramt.h"
17 #include "unicode/datefmt.h" 18 #include "unicode/datefmt.h"
18 #include "unicode/dcfmtsym.h" 19 #include "unicode/dcfmtsym.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); 311 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
311 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); 312 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
312 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); 313 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
313 314
314 Handle<ObjectTemplateInfo> date_format_template = I18N::GetTemplate(isolate); 315 Handle<ObjectTemplateInfo> date_format_template = I18N::GetTemplate(isolate);
315 316
316 // Create an empty object wrapper. 317 // Create an empty object wrapper.
317 Handle<JSObject> local_object; 318 Handle<JSObject> local_object;
318 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 319 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
319 isolate, local_object, 320 isolate, local_object,
320 Execution::InstantiateObject(date_format_template)); 321 ApiNatives::InstantiateObject(date_format_template));
321 322
322 // Set date time formatter as internal field of the resulting JS object. 323 // Set date time formatter as internal field of the resulting JS object.
323 icu::SimpleDateFormat* date_format = 324 icu::SimpleDateFormat* date_format =
324 DateFormat::InitializeDateTimeFormat(isolate, locale, options, resolved); 325 DateFormat::InitializeDateTimeFormat(isolate, locale, options, resolved);
325 326
326 if (!date_format) return isolate->ThrowIllegalOperation(); 327 if (!date_format) return isolate->ThrowIllegalOperation();
327 328
328 local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format)); 329 local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format));
329 330
330 Factory* factory = isolate->factory(); 331 Factory* factory = isolate->factory();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); 406 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
406 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); 407 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
407 408
408 Handle<ObjectTemplateInfo> number_format_template = 409 Handle<ObjectTemplateInfo> number_format_template =
409 I18N::GetTemplate(isolate); 410 I18N::GetTemplate(isolate);
410 411
411 // Create an empty object wrapper. 412 // Create an empty object wrapper.
412 Handle<JSObject> local_object; 413 Handle<JSObject> local_object;
413 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 414 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
414 isolate, local_object, 415 isolate, local_object,
415 Execution::InstantiateObject(number_format_template)); 416 ApiNatives::InstantiateObject(number_format_template));
416 417
417 // Set number formatter as internal field of the resulting JS object. 418 // Set number formatter as internal field of the resulting JS object.
418 icu::DecimalFormat* number_format = 419 icu::DecimalFormat* number_format =
419 NumberFormat::InitializeNumberFormat(isolate, locale, options, resolved); 420 NumberFormat::InitializeNumberFormat(isolate, locale, options, resolved);
420 421
421 if (!number_format) return isolate->ThrowIllegalOperation(); 422 if (!number_format) return isolate->ThrowIllegalOperation();
422 423
423 local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format)); 424 local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format));
424 425
425 Factory* factory = isolate->factory(); 426 Factory* factory = isolate->factory();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 511
511 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); 512 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
512 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); 513 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
513 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); 514 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
514 515
515 Handle<ObjectTemplateInfo> collator_template = I18N::GetTemplate(isolate); 516 Handle<ObjectTemplateInfo> collator_template = I18N::GetTemplate(isolate);
516 517
517 // Create an empty object wrapper. 518 // Create an empty object wrapper.
518 Handle<JSObject> local_object; 519 Handle<JSObject> local_object;
519 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 520 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
520 isolate, local_object, Execution::InstantiateObject(collator_template)); 521 isolate, local_object, ApiNatives::InstantiateObject(collator_template));
521 522
522 // Set collator as internal field of the resulting JS object. 523 // Set collator as internal field of the resulting JS object.
523 icu::Collator* collator = 524 icu::Collator* collator =
524 Collator::InitializeCollator(isolate, locale, options, resolved); 525 Collator::InitializeCollator(isolate, locale, options, resolved);
525 526
526 if (!collator) return isolate->ThrowIllegalOperation(); 527 if (!collator) return isolate->ThrowIllegalOperation();
527 528
528 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator)); 529 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator));
529 530
530 Factory* factory = isolate->factory(); 531 Factory* factory = isolate->factory();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); 610 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
610 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); 611 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
611 612
612 Handle<ObjectTemplateInfo> break_iterator_template = 613 Handle<ObjectTemplateInfo> break_iterator_template =
613 I18N::GetTemplate2(isolate); 614 I18N::GetTemplate2(isolate);
614 615
615 // Create an empty object wrapper. 616 // Create an empty object wrapper.
616 Handle<JSObject> local_object; 617 Handle<JSObject> local_object;
617 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 618 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
618 isolate, local_object, 619 isolate, local_object,
619 Execution::InstantiateObject(break_iterator_template)); 620 ApiNatives::InstantiateObject(break_iterator_template));
620 621
621 // Set break iterator as internal field of the resulting JS object. 622 // Set break iterator as internal field of the resulting JS object.
622 icu::BreakIterator* break_iterator = BreakIterator::InitializeBreakIterator( 623 icu::BreakIterator* break_iterator = BreakIterator::InitializeBreakIterator(
623 isolate, locale, options, resolved); 624 isolate, locale, options, resolved);
624 625
625 if (!break_iterator) return isolate->ThrowIllegalOperation(); 626 if (!break_iterator) return isolate->ThrowIllegalOperation();
626 627
627 local_object->SetInternalField(0, reinterpret_cast<Smi*>(break_iterator)); 628 local_object->SetInternalField(0, reinterpret_cast<Smi*>(break_iterator));
628 // Make sure that the pointer to adopted text is NULL. 629 // Make sure that the pointer to adopted text is NULL.
629 local_object->SetInternalField(1, reinterpret_cast<Smi*>(NULL)); 630 local_object->SetInternalField(1, reinterpret_cast<Smi*>(NULL));
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 } else if (status >= UBRK_WORD_IDEO && status < UBRK_WORD_IDEO_LIMIT) { 743 } else if (status >= UBRK_WORD_IDEO && status < UBRK_WORD_IDEO_LIMIT) {
743 return *isolate->factory()->NewStringFromStaticChars("ideo"); 744 return *isolate->factory()->NewStringFromStaticChars("ideo");
744 } else { 745 } else {
745 return *isolate->factory()->NewStringFromStaticChars("unknown"); 746 return *isolate->factory()->NewStringFromStaticChars("unknown");
746 } 747 }
747 } 748 }
748 } 749 }
749 } // namespace v8::internal 750 } // namespace v8::internal
750 751
751 #endif // V8_I18N_SUPPORT 752 #endif // V8_I18N_SUPPORT
OLDNEW
« no previous file with comments | « src/runtime/runtime-api.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698