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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 if (state == 0) { | 153 if (state == 0) { |
154 HandleScope scope; | 154 HandleScope scope; |
155 Local<String> full_text = String::New(rl_line_buffer, rl_point); | 155 Local<String> full_text = String::New(rl_line_buffer, rl_point); |
156 Handle<Array> completions = | 156 Handle<Array> completions = |
157 Shell::GetCompletions(String::New(text), full_text); | 157 Shell::GetCompletions(isolate, String::New(text), full_text); |
158 current_completions = Persistent<Array>::New(isolate, completions); | 158 current_completions = Persistent<Array>::New(isolate, completions); |
159 current_index = 0; | 159 current_index = 0; |
160 } | 160 } |
161 if (current_index < current_completions->Length()) { | 161 if (current_index < current_completions->Length()) { |
162 HandleScope scope; | 162 HandleScope scope; |
163 Handle<Integer> index = Integer::New(current_index); | 163 Handle<Integer> index = Integer::New(current_index); |
164 Handle<Value> str_obj = current_completions->Get(index); | 164 Handle<Value> str_obj = current_completions->Get(index); |
165 current_index++; | 165 current_index++; |
166 String::Utf8Value str(str_obj); | 166 String::Utf8Value str(str_obj); |
167 return strdup(*str); | 167 return strdup(*str); |
168 } else { | 168 } else { |
169 current_completions.Dispose(isolate); | 169 current_completions.Dispose(isolate); |
170 current_completions.Clear(); | 170 current_completions.Clear(); |
171 return NULL; | 171 return NULL; |
172 } | 172 } |
173 } | 173 } |
174 #endif // V8_SHARED | 174 #endif // V8_SHARED |
175 | 175 |
176 | 176 |
177 } // namespace v8 | 177 } // namespace v8 |
OLD | NEW |