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

Side by Side Diff: src/d8-readline.cc

Issue 23537060: Fix d8-readline to use modern Persistent API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use better version of Reset Created 7 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 rl_attempted_completion_over = true; 143 rl_attempted_completion_over = true;
144 return result; 144 return result;
145 } 145 }
146 146
147 147
148 char* ReadLineEditor::CompletionGenerator(const char* text, int state) { 148 char* ReadLineEditor::CompletionGenerator(const char* text, int state) {
149 static unsigned current_index; 149 static unsigned current_index;
150 static Persistent<Array> current_completions; 150 static Persistent<Array> current_completions;
151 Isolate* isolate = read_line_editor.isolate_; 151 Isolate* isolate = read_line_editor.isolate_;
152 Locker lock(isolate); 152 Locker lock(isolate);
153 HandleScope scope; 153 HandleScope scope(isolate);
154 Handle<Array> completions; 154 Handle<Array> completions;
155 if (state == 0) { 155 if (state == 0) {
156 Local<String> full_text = String::New(rl_line_buffer, rl_point); 156 Local<String> full_text = String::New(rl_line_buffer, rl_point);
157 completions = Shell::GetCompletions(isolate, String::New(text), full_text); 157 completions = Shell::GetCompletions(isolate, String::New(text), full_text);
158 current_completions.Reset(isolate, completions); 158 current_completions.Reset(isolate, completions);
159 current_index = 0; 159 current_index = 0;
160 } else { 160 } else {
161 completions = Local<Array>::New(isolate, current_completions); 161 completions = Local<Array>::New(isolate, current_completions);
162 } 162 }
163 if (current_index < completions->Length()) { 163 if (current_index < completions->Length()) {
164 Handle<Integer> index = Integer::New(current_index); 164 Handle<Integer> index = Integer::New(current_index);
165 Handle<Value> str_obj = completions->Get(index); 165 Handle<Value> str_obj = completions->Get(index);
166 current_index++; 166 current_index++;
167 String::Utf8Value str(str_obj); 167 String::Utf8Value str(str_obj);
168 return strdup(*str); 168 return strdup(*str);
169 } else { 169 } else {
170 current_completions.Dispose(isolate); 170 current_completions.Reset();
171 current_completions.Clear();
172 return NULL; 171 return NULL;
173 } 172 }
174 } 173 }
175 #endif // V8_SHARED 174 #endif // V8_SHARED
176 175
177 176
178 } // namespace v8 177 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698