[pypy-svn] r65128 - pypy/branch/js-refactoring/pypy/lang/js
jandem at codespeak.net
jandem at codespeak.net
Thu May 7 11:49:34 CEST 2009
Author: jandem
Date: Thu May 7 11:49:33 2009
New Revision: 65128
Modified:
pypy/branch/js-refactoring/pypy/lang/js/console.py
Log:
Make readline() available to JS, to ask for user input.
Modified: pypy/branch/js-refactoring/pypy/lang/js/console.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/console.py (original)
+++ pypy/branch/js-refactoring/pypy/lang/js/console.py Thu May 7 11:49:33 2009
@@ -15,10 +15,10 @@
result = []
while 1:
s = os.read(0, 1)
- result.append(s)
if s == '\n':
break
-
+ else:
+ result.append(s)
if s == '':
if len(result) > 1:
break
@@ -46,6 +46,10 @@
self.interpreter.run(program)
return w_Undefined
+class W_ReadLine(W_NewBuiltin):
+ def Call(self, ctx, args=[], this=None):
+ return W_String(readline())
+
class JSConsole(object):
prompt_ok = 'js> '
prompt_more = '... '
@@ -56,6 +60,7 @@
interp.w_Global.Put(ctx, 'quit', W_Quit(ctx))
interp.w_Global.Put(ctx, 'load', W_Load(ctx, interp))
+ interp.w_Global.Put(ctx, 'readline', W_ReadLine(ctx))
self.interpreter = interp
More information about the Pypy-commit
mailing list