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);
static char* CompletionGenerator(const char* text, int state);
#endif // V8_SHARED
static char kWordBreakCharacters[];
+
+ Isolate* isolate_;
};
const int ReadLineEditor::kMaxHistoryEntries = 1000;
-bool ReadLineEditor::Open() {
+bool ReadLineEditor::Open(Isolate* isolate) {
+ isolate_ = isolate;
+
rl_initialize();
#ifdef V8_SHARED
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()) {
String::Utf8Value str(str_obj);
return strdup(*str);
} else {
- current_completions.Dispose();
+ current_completions.Dispose(isolate);
current_completions.Clear();
return NULL;
}
Handle<String> name = String::New("(d8)");
LineEditor* console = LineEditor::Get();
printf("V8 version %s [console: %s]\n", V8::GetVersion(), console->name());
- console->Open();
+ console->Open(isolate);
while (true) {
HandleScope inner_scope;
Handle<String> input = console->Prompt(Shell::kPrompt);
virtual ~LineEditor() { }
virtual Handle<String> Prompt(const char* prompt) = 0;
- virtual bool Open() { return true; }
+ virtual bool Open(Isolate* isolate) { return true; }
virtual bool Close() { return true; }
virtual void AddHistory(const char* str) { }