OLD | NEW |
---|---|
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 14046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14057 string_value1.length(), | 14057 string_value1.length(), |
14058 u_string2, | 14058 u_string2, |
14059 string_value2.length(), | 14059 string_value2.length(), |
14060 status); | 14060 status); |
14061 if (U_FAILURE(status)) return isolate->ThrowIllegalOperation(); | 14061 if (U_FAILURE(status)) return isolate->ThrowIllegalOperation(); |
14062 | 14062 |
14063 return *isolate->factory()->NewNumberFromInt(result); | 14063 return *isolate->factory()->NewNumberFromInt(result); |
14064 } | 14064 } |
14065 | 14065 |
14066 | 14066 |
14067 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringNormalize) { | |
14068 HandleScope scope(isolate); | |
14069 static const UNormalizationMode normForms[] = | |
Nebojša Ćirić
2013/10/24 19:54:18
normalizationForms[]
mnita
2013/10/25 15:22:10
Done.
| |
14070 { UNORM_NFC, UNORM_NFD, UNORM_NFKC, UNORM_NFKD }; | |
14071 | |
14072 ASSERT(args.length() == 2); | |
14073 | |
14074 CONVERT_ARG_HANDLE_CHECKED(String, stringValue, 0); | |
14075 CONVERT_NUMBER_CHECKED(int, form_id, Int32, args[1]); | |
14076 | |
14077 v8::String::Value string_value(v8::Utils::ToLocal(stringValue)); | |
14078 const UChar* u_value = reinterpret_cast<const UChar*>(*string_value); | |
14079 | |
14080 // TODO(mnita) check Normalizer2 (not available in ICU 46) | |
Nebojša Ćirić
2013/10/24 19:54:18
// TODO(mnita): switch to Normalizer2 when we swit
mnita
2013/10/25 15:22:10
Done.
| |
14081 UErrorCode status = U_ZERO_ERROR; | |
14082 icu::UnicodeString result; | |
14083 icu::Normalizer::normalize(u_value, normForms[form_id], 0, result, status); | |
14084 if (U_FAILURE(status)) return isolate->heap()->undefined_value(); | |
Nebojša Ćirić
2013/10/24 19:54:18
if () {
statement;
}
not
if () statement;
mnita
2013/10/25 15:22:10
Done.
| |
14085 | |
14086 return *isolate->factory()->NewStringFromTwoByte( | |
14087 Vector<const uint16_t>( | |
14088 reinterpret_cast<const uint16_t*>(result.getBuffer()), | |
14089 result.length())); | |
14090 } | |
14091 | |
14092 | |
14067 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateBreakIterator) { | 14093 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateBreakIterator) { |
14068 HandleScope scope(isolate); | 14094 HandleScope scope(isolate); |
14069 | 14095 |
14070 ASSERT(args.length() == 3); | 14096 ASSERT(args.length() == 3); |
14071 | 14097 |
14072 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 14098 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
14073 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 14099 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
14074 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 14100 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
14075 | 14101 |
14076 Handle<ObjectTemplateInfo> break_iterator_template = | 14102 Handle<ObjectTemplateInfo> break_iterator_template = |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14867 // Handle last resort GC and make sure to allow future allocations | 14893 // Handle last resort GC and make sure to allow future allocations |
14868 // to grow the heap without causing GCs (if possible). | 14894 // to grow the heap without causing GCs (if possible). |
14869 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14895 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14870 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14896 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14871 "Runtime::PerformGC"); | 14897 "Runtime::PerformGC"); |
14872 } | 14898 } |
14873 } | 14899 } |
14874 | 14900 |
14875 | 14901 |
14876 } } // namespace v8::internal | 14902 } } // namespace v8::internal |
OLD | NEW |