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

Side by Side Diff: src/extensions/experimental/break-iterator.cc

Issue 6794050: Revert "[Arguments] Merge (7442,7496] from bleeding_edge." (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/arguments
Patch Set: Created 9 years, 8 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 28 matching lines...) Expand all
39 icu::BreakIterator* BreakIterator::UnpackBreakIterator( 39 icu::BreakIterator* BreakIterator::UnpackBreakIterator(
40 v8::Handle<v8::Object> obj) { 40 v8::Handle<v8::Object> obj) {
41 if (break_iterator_template_->HasInstance(obj)) { 41 if (break_iterator_template_->HasInstance(obj)) {
42 return static_cast<icu::BreakIterator*>( 42 return static_cast<icu::BreakIterator*>(
43 obj->GetPointerFromInternalField(0)); 43 obj->GetPointerFromInternalField(0));
44 } 44 }
45 45
46 return NULL; 46 return NULL;
47 } 47 }
48 48
49 icu::UnicodeString* BreakIterator::ResetAdoptedText( 49 UnicodeString* BreakIterator::ResetAdoptedText(
50 v8::Handle<v8::Object> obj, v8::Handle<v8::Value> value) { 50 v8::Handle<v8::Object> obj, v8::Handle<v8::Value> value) {
51 // Get the previous value from the internal field. 51 // Get the previous value from the internal field.
52 icu::UnicodeString* text = static_cast<icu::UnicodeString*>( 52 UnicodeString* text = static_cast<UnicodeString*>(
53 obj->GetPointerFromInternalField(1)); 53 obj->GetPointerFromInternalField(1));
54 delete text; 54 delete text;
55 55
56 // Assign new value to the internal pointer. 56 // Assign new value to the internal pointer.
57 v8::String::Value text_value(value); 57 v8::String::Value text_value(value);
58 text = new icu::UnicodeString( 58 text = new UnicodeString(
59 reinterpret_cast<const UChar*>(*text_value), text_value.length()); 59 reinterpret_cast<const UChar*>(*text_value), text_value.length());
60 obj->SetPointerInInternalField(1, text); 60 obj->SetPointerInInternalField(1, text);
61 61
62 // Return new unicode string pointer. 62 // Return new unicode string pointer.
63 return text; 63 return text;
64 } 64 }
65 65
66 void BreakIterator::DeleteBreakIterator(v8::Persistent<v8::Value> object, 66 void BreakIterator::DeleteBreakIterator(v8::Persistent<v8::Value> object,
67 void* param) { 67 void* param) {
68 v8::Persistent<v8::Object> persistent_object = 68 v8::Persistent<v8::Object> persistent_object =
69 v8::Persistent<v8::Object>::Cast(object); 69 v8::Persistent<v8::Object>::Cast(object);
70 70
71 // First delete the hidden C++ object. 71 // First delete the hidden C++ object.
72 // Unpacking should never return NULL here. That would only happen if 72 // Unpacking should never return NULL here. That would only happen if
73 // this method is used as the weak callback for persistent handles not 73 // this method is used as the weak callback for persistent handles not
74 // pointing to a break iterator. 74 // pointing to a break iterator.
75 delete UnpackBreakIterator(persistent_object); 75 delete UnpackBreakIterator(persistent_object);
76 76
77 delete static_cast<icu::UnicodeString*>( 77 delete static_cast<UnicodeString*>(
78 persistent_object->GetPointerFromInternalField(1)); 78 persistent_object->GetPointerFromInternalField(1));
79 79
80 // Then dispose of the persistent handle to JS object. 80 // Then dispose of the persistent handle to JS object.
81 persistent_object.Dispose(); 81 persistent_object.Dispose();
82 } 82 }
83 83
84 // Throws a JavaScript exception. 84 // Throws a JavaScript exception.
85 static v8::Handle<v8::Value> ThrowUnexpectedObjectError() { 85 static v8::Handle<v8::Value> ThrowUnexpectedObjectError() {
86 // Returns undefined, and schedules an exception to be thrown. 86 // Returns undefined, and schedules an exception to be thrown.
87 return v8::ThrowException(v8::Exception::Error( 87 return v8::ThrowException(v8::Exception::Error(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 138
139 v8::Handle<v8::Value> BreakIterator::BreakIteratorBreakType( 139 v8::Handle<v8::Value> BreakIterator::BreakIteratorBreakType(
140 const v8::Arguments& args) { 140 const v8::Arguments& args) {
141 icu::BreakIterator* break_iterator = UnpackBreakIterator(args.Holder()); 141 icu::BreakIterator* break_iterator = UnpackBreakIterator(args.Holder());
142 if (!break_iterator) { 142 if (!break_iterator) {
143 return ThrowUnexpectedObjectError(); 143 return ThrowUnexpectedObjectError();
144 } 144 }
145 145
146 // TODO(cira): Remove cast once ICU fixes base BreakIterator class. 146 // TODO(cira): Remove cast once ICU fixes base BreakIterator class.
147 icu::RuleBasedBreakIterator* rule_based_iterator = 147 int32_t status =
148 static_cast<icu::RuleBasedBreakIterator*>(break_iterator); 148 static_cast<RuleBasedBreakIterator*>(break_iterator)->getRuleStatus();
149 int32_t status = rule_based_iterator->getRuleStatus();
150 // Keep return values in sync with JavaScript BreakType enum. 149 // Keep return values in sync with JavaScript BreakType enum.
151 if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) { 150 if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) {
152 return v8::Int32::New(UBRK_WORD_NONE); 151 return v8::Int32::New(UBRK_WORD_NONE);
153 } else if (status >= UBRK_WORD_NUMBER && status < UBRK_WORD_NUMBER_LIMIT) { 152 } else if (status >= UBRK_WORD_NUMBER && status < UBRK_WORD_NUMBER_LIMIT) {
154 return v8::Int32::New(UBRK_WORD_NUMBER); 153 return v8::Int32::New(UBRK_WORD_NUMBER);
155 } else if (status >= UBRK_WORD_LETTER && status < UBRK_WORD_LETTER_LIMIT) { 154 } else if (status >= UBRK_WORD_LETTER && status < UBRK_WORD_LETTER_LIMIT) {
156 return v8::Int32::New(UBRK_WORD_LETTER); 155 return v8::Int32::New(UBRK_WORD_LETTER);
157 } else if (status >= UBRK_WORD_KANA && status < UBRK_WORD_KANA_LIMIT) { 156 } else if (status >= UBRK_WORD_KANA && status < UBRK_WORD_KANA_LIMIT) {
158 return v8::Int32::New(UBRK_WORD_KANA); 157 return v8::Int32::New(UBRK_WORD_KANA);
159 } else if (status >= UBRK_WORD_IDEO && status < UBRK_WORD_IDEO_LIMIT) { 158 } else if (status >= UBRK_WORD_IDEO && status < UBRK_WORD_IDEO_LIMIT) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // Make sure that the pointer to adopted text is NULL. 240 // Make sure that the pointer to adopted text is NULL.
242 wrapper->SetPointerInInternalField(1, NULL); 241 wrapper->SetPointerInInternalField(1, NULL);
243 242
244 // Make object handle weak so we can delete iterator once GC kicks in. 243 // Make object handle weak so we can delete iterator once GC kicks in.
245 wrapper.MakeWeak(NULL, DeleteBreakIterator); 244 wrapper.MakeWeak(NULL, DeleteBreakIterator);
246 245
247 return wrapper; 246 return wrapper;
248 } 247 }
249 248
250 } } // namespace v8::internal 249 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/extensions/experimental/break-iterator.h ('k') | src/extensions/experimental/i18n-extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698