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

Unified Diff: src/d8-readline.cc

Issue 12494010: Unbreak readline support. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/d8.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8-readline.cc
diff --git a/src/d8-readline.cc b/src/d8-readline.cc
index 89892631f76ca0a9811c83038dbfed39d6789f3a..cc7a3a6ec4a3a22e9eac66475c0452dee19a39cd 100644
--- a/src/d8-readline.cc
+++ b/src/d8-readline.cc
@@ -49,7 +49,7 @@ class ReadLineEditor: public LineEditor {
public:
ReadLineEditor() : LineEditor(LineEditor::READLINE, "readline") { }
virtual Handle<String> Prompt(const char* prompt);
- virtual bool Open();
+ virtual bool Open(Isolate* isolate);
virtual bool Close();
virtual void AddHistory(const char* str);
@@ -62,6 +62,8 @@ class ReadLineEditor: public LineEditor {
static char* CompletionGenerator(const char* text, int state);
#endif // V8_SHARED
static char kWordBreakCharacters[];
+
+ Isolate* isolate_;
};
@@ -75,7 +77,9 @@ const char* ReadLineEditor::kHistoryFileName = ".d8_history";
const int ReadLineEditor::kMaxHistoryEntries = 1000;
-bool ReadLineEditor::Open() {
+bool ReadLineEditor::Open(Isolate* isolate) {
+ isolate_ = isolate;
+
rl_initialize();
#ifdef V8_SHARED
@@ -144,12 +148,14 @@ char** ReadLineEditor::AttemptedCompletion(const char* text,
char* ReadLineEditor::CompletionGenerator(const char* text, int state) {
static unsigned current_index;
static Persistent<Array> current_completions;
+ Isolate* isolate = read_line_editor.isolate_;
+ Locker lock(isolate);
if (state == 0) {
HandleScope scope;
Local<String> full_text = String::New(rl_line_buffer, rl_point);
Handle<Array> completions =
Shell::GetCompletions(String::New(text), full_text);
- current_completions = Persistent<Array>::New(completions);
+ current_completions = Persistent<Array>::New(isolate, completions);
current_index = 0;
}
if (current_index < current_completions->Length()) {
@@ -160,7 +166,7 @@ char* ReadLineEditor::CompletionGenerator(const char* text, int state) {
String::Utf8Value str(str_obj);
return strdup(*str);
} else {
- current_completions.Dispose();
+ current_completions.Dispose(isolate);
current_completions.Clear();
return NULL;
}
« no previous file with comments | « src/d8.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698