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

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

Issue 17028013: build fix for d8-readline for 15142 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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;
154 Handle<Array> completions;
153 if (state == 0) { 155 if (state == 0) {
154 HandleScope scope;
155 Local<String> full_text = String::New(rl_line_buffer, rl_point); 156 Local<String> full_text = String::New(rl_line_buffer, rl_point);
156 Handle<Array> completions = 157 completions = Shell::GetCompletions(isolate, String::New(text), full_text);
157 Shell::GetCompletions(isolate, String::New(text), full_text); 158 current_completions.Reset(isolate, completions);
158 current_completions = Persistent<Array>::New(isolate, completions);
159 current_index = 0; 159 current_index = 0;
160 } else {
161 completions = Local<Array>::New(isolate, current_completions);
160 } 162 }
161 if (current_index < current_completions->Length()) { 163 if (current_index < completions->Length()) {
162 HandleScope scope;
163 Handle<Integer> index = Integer::New(current_index); 164 Handle<Integer> index = Integer::New(current_index);
164 Handle<Value> str_obj = current_completions->Get(index); 165 Handle<Value> str_obj = completions->Get(index);
165 current_index++; 166 current_index++;
166 String::Utf8Value str(str_obj); 167 String::Utf8Value str(str_obj);
167 return strdup(*str); 168 return strdup(*str);
168 } else { 169 } else {
169 current_completions.Dispose(isolate); 170 current_completions.Dispose(isolate);
170 current_completions.Clear(); 171 current_completions.Clear();
171 return NULL; 172 return NULL;
172 } 173 }
173 } 174 }
174 #endif // V8_SHARED 175 #endif // V8_SHARED
175 176
176 177
177 } // namespace v8 178 } // 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