Revision: 13333
Author:   [email protected]
Date:     Tue Jan  8 07:24:17 2013
Log:      Enable readline on d8 while building a shared lib.

This patch enables readline on d8 except for completion support.
It sould be useful enough for history and line editing.

This is related to V8's issue 1781 (http://code.google.com/p/v8/issues/detail?id=1781), not chromium's.

BUG=1781

Review URL: https://chromiumcodereview.appspot.com/11776017
Patch from Luis Reis <[email protected]>.
http://code.google.com/p/v8/source/detail?r=13333

Modified:
 /branches/bleeding_edge/src/d8-readline.cc
 /branches/bleeding_edge/src/d8.cc
 /branches/bleeding_edge/src/d8.gyp
 /branches/bleeding_edge/src/d8.h

=======================================
--- /branches/bleeding_edge/src/d8-readline.cc  Fri Jan 20 03:59:00 2012
+++ /branches/bleeding_edge/src/d8-readline.cc  Tue Jan  8 07:24:17 2013
@@ -25,8 +25,8 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
 #include <cstdio>  // NOLINT
+#include <string.h> // NOLINT
 #include <readline/readline.h> // NOLINT
 #include <readline/history.h> // NOLINT

@@ -35,7 +35,6 @@

 #include "d8.h"

-
 // There are incompatibilities between different versions and different
// implementations of readline. This smooths out one known incompatibility.
 #if RL_READLINE_VERSION >= 0x0500
@@ -58,8 +57,10 @@
   static const int kMaxHistoryEntries;

  private:
+#ifndef V8_SHARED
   static char** AttemptedCompletion(const char* text, int start, int end);
   static char* CompletionGenerator(const char* text, int state);
+#endif  // V8_SHARED
   static char kWordBreakCharacters[];
 };

@@ -76,7 +77,15 @@

 bool ReadLineEditor::Open() {
   rl_initialize();
+
+#ifdef V8_SHARED
+  // Don't do completion on shared library mode
+  // http://cnswww.cns.cwru.edu/php/chet/readline/readline.html#SEC24
+  rl_bind_key('\t', rl_insert);
+#else
   rl_attempted_completion_function = AttemptedCompletion;
+#endif  // V8_SHARED
+
   rl_completer_word_break_characters = kWordBreakCharacters;
   rl_bind_key('\t', rl_complete);
   using_history();
@@ -122,6 +131,7 @@
 }


+#ifndef V8_SHARED
 char** ReadLineEditor::AttemptedCompletion(const char* text,
                                            int start,
                                            int end) {
@@ -155,6 +165,7 @@
     return NULL;
   }
 }
+#endif  // V8_SHARED


 }  // namespace v8
=======================================
--- /branches/bleeding_edge/src/d8.cc   Mon Jan  7 06:01:04 2013
+++ /branches/bleeding_edge/src/d8.cc   Tue Jan  8 07:24:17 2013
@@ -889,9 +889,7 @@

 Handle<Value> Shell::Quit(const Arguments& args) {
   int exit_code = args[0]->Int32Value();
-#ifndef V8_SHARED
   OnExit();
-#endif  // V8_SHARED
   exit(exit_code);
   return Undefined();
 }
@@ -1341,9 +1339,13 @@
   return strcmp(static_cast<const CounterAndKey*>(a)->key,
                 static_cast<const CounterAndKey*>(b)->key);
 }
+#endif  // V8_SHARED


 void Shell::OnExit() {
+  LineEditor* line_editor = LineEditor::Get();
+  if (line_editor) line_editor->Close();
+#ifndef V8_SHARED
   if (i::FLAG_dump_counters) {
     int number_of_counters = 0;
     for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) {
@@ -1378,8 +1380,9 @@
   }
   delete counters_file_;
   delete counter_map_;
+#endif  // V8_SHARED
 }
-#endif  // V8_SHARED
+


 static FILE* FOpen(const char* path, const char* mode) {
@@ -1504,7 +1507,6 @@
     ExecuteString(input, name, true, true);
   }
   printf("\n");
-  console->Close();
 }


@@ -1955,9 +1957,7 @@
   }
   V8::Dispose();

-#ifndef V8_SHARED
   OnExit();
-#endif  // V8_SHARED

   return result;
 }
=======================================
--- /branches/bleeding_edge/src/d8.gyp  Wed Mar  7 02:57:36 2012
+++ /branches/bleeding_edge/src/d8.gyp  Tue Jan  8 07:24:17 2013
@@ -45,6 +45,10 @@
         'd8.cc',
       ],
       'conditions': [
+        [ 'console=="readline"', {
+          'libraries': [ '-lreadline', ],
+          'sources': [ 'd8-readline.cc' ],
+        }],
         [ 'component!="shared_library"', {
'sources': [ 'd8-debug.cc', '<(SHARED_INTERMEDIATE_DIR)/d8-js.cc', ],
           'conditions': [
@@ -57,10 +61,6 @@
                 'd8_js2c',
               ],
             }],
-            [ 'console=="readline"', {
-              'libraries': [ '-lreadline', ],
-              'sources': [ 'd8-readline.cc' ],
-            }],
             ['(OS=="linux" or OS=="mac" or OS=="freebsd" or OS=="netbsd" \
                or OS=="openbsd" or OS=="solaris" or OS=="android")', {
               'sources': [ 'd8-posix.cc', ]
=======================================
--- /branches/bleeding_edge/src/d8.h    Thu Nov 22 00:35:21 2012
+++ /branches/bleeding_edge/src/d8.h    Tue Jan  8 07:24:17 2013
@@ -277,11 +277,11 @@
   static int RunMain(Isolate* isolate, int argc, char* argv[]);
   static int Main(int argc, char* argv[]);
   static void Exit(int exit_code);
+  static void OnExit();

 #ifndef V8_SHARED
   static Handle<Array> GetCompletions(Handle<String> text,
                                       Handle<String> full);
-  static void OnExit();
   static int* LookupCounter(const char* name);
   static void* CreateHistogram(const char* name,
                                int min,

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to