[pypy-svn] r36684 - in pypy/dist/pypy/translator/js: . demo/jsdemo examples modules modules/test test

fijal at codespeak.net fijal at codespeak.net
Sat Jan 13 18:29:54 CET 2007


Author: fijal
Date: Sat Jan 13 18:29:51 2007
New Revision: 36684

Modified:
   pypy/dist/pypy/translator/js/demo/jsdemo/bnb.py
   pypy/dist/pypy/translator/js/demo/jsdemo/example.py
   pypy/dist/pypy/translator/js/demo/jsdemo/pythonconsole.py
   pypy/dist/pypy/translator/js/examples/start_bnb.py
   pypy/dist/pypy/translator/js/modules/dom.py
   pypy/dist/pypy/translator/js/modules/test/test_dom.py
   pypy/dist/pypy/translator/js/support.py
   pypy/dist/pypy/translator/js/test/test_bltn.py
Log:
Wack a bit more here and there. Right now almost all tests passes here.


Modified: pypy/dist/pypy/translator/js/demo/jsdemo/bnb.py
==============================================================================
--- pypy/dist/pypy/translator/js/demo/jsdemo/bnb.py	(original)
+++ pypy/dist/pypy/translator/js/demo/jsdemo/bnb.py	Sat Jan 13 18:29:51 2007
@@ -11,6 +11,8 @@
     PMSG_INLINE_FRAME, PMSG_DEF_ICON
 from pypy.translator.js.demo.jsdemo.msgstruct import *
 from cherrypy import session
+from pypy.annotation import model as annmodel
+from pypy.annotation.signature import annotation
 
 import re, time, sys, os, urllib, socket, copy, md5, random
 
@@ -67,6 +69,8 @@
         self.seen = set()
         return to_ret
 
+lambda_None = annmodel.SomeGenericCallable([], result=annotation(None))
+
 # Needed double inheritance for both server job
 # and semi-transparent communication proxy
 class BnbRoot(Root, BasicExternal):
@@ -87,12 +91,12 @@
     _render_xmlhttp = True
     
     _methods = {
-        'get_message'  : MethodDesc( [('player_id', -1), ('keys' , "aaa"), ('callback', (lambda : None))] , {'aa':[{'aa':'bb'}]}),
-        'add_player'   : MethodDesc( [('player_id', 0), ('callback', (lambda : None))] , {'aa':[{'aa':'bb'}]}),
-        'remove_player': MethodDesc( [('player_id', 0), ('callback', (lambda : None))] , {'aa':[{'aa':'bb'}]}),
-        'player_name'  : MethodDesc( [('player_id', 0), ('name', 'PyPy player'), ('callback', (lambda : None))] , {'aa':[{'aa':'bb'}]}),
+        'get_message'  : MethodDesc( [('player_id', int), ('keys' , str), ('callback', lambda_None)] , {str:[{str:str}]}),
+        'add_player'   : MethodDesc( [('player_id', int), ('callback', lambda_None)] , {str:[{str:str}]}),
+        'remove_player': MethodDesc( [('player_id', int), ('callback', lambda_None)] , {str:[{str:str}]}),
+        'player_name'  : MethodDesc( [('player_id', int), ('name', str), ('callback', lambda_None)] , {str:[{str:str}]}),
 #        'key'          : MethodDesc( [('player_id', 0), ('keynum', '0'), ('callback', (lambda : None))] , {'aa':[{'aa':'bb'}]}),
-        'initialize_session' : MethodDesc( [('callback', (lambda : None))], {'aa':'bb'}),
+        'initialize_session' : MethodDesc( [('callback', lambda_None)], {str:str}),
     }
     
     def add_player(self, player_id = 0):

Modified: pypy/dist/pypy/translator/js/demo/jsdemo/example.py
==============================================================================
--- pypy/dist/pypy/translator/js/demo/jsdemo/example.py	(original)
+++ pypy/dist/pypy/translator/js/demo/jsdemo/example.py	Sat Jan 13 18:29:51 2007
@@ -9,6 +9,8 @@
 from pypy.translator.js.modules.dom import setTimeout, document
 from pypy.rpython.ootypesystem.bltregistry import MethodDesc, BasicExternal
 from pypy.translator.js import commproxy
+from pypy.annotation import model as annmodel
+from pypy.annotation.signature import annotation
 
 commproxy.USE_MOCHIKIT = False
 
@@ -37,10 +39,12 @@
 def runjs():
     httpd.some_callback(callback)
 
+lambda_None = annmodel.SomeGenericCallable([], result=annotation(None))
+
 class Server(HTTPServer, BasicExternal):
     # Methods and signatures how they are rendered for JS
     _methods = {
-        'some_callback' : MethodDesc([('callback', lambda : None)], {'aa':'aa'})
+        'some_callback' : MethodDesc([('callback', lambda_None)], {str:str})
     }
     
     _render_xmlhttp = True

Modified: pypy/dist/pypy/translator/js/demo/jsdemo/pythonconsole.py
==============================================================================
--- pypy/dist/pypy/translator/js/demo/jsdemo/pythonconsole.py	(original)
+++ pypy/dist/pypy/translator/js/demo/jsdemo/pythonconsole.py	Sat Jan 13 18:29:51 2007
@@ -16,6 +16,10 @@
 from pypy.rpython.ootypesystem.bltregistry import MethodDesc, BasicExternal
 from pypy.translator.js import commproxy
 from pypy.translator.js.modules.mochikit import escapeHTML
+from pypy.annotation import model as annmodel
+from pypy.annotation.signature import annotation
+
+lambda_None = annmodel.SomeGenericCallable([], result=annotation(None))
 
 from pypy.translator.js.demo.jsdemo import support
 
@@ -91,9 +95,9 @@
 class Server(HTTPServer, BasicExternal):
     # Methods and signatures how they are rendered for JS
     _methods = {
-        'some_callback' : MethodDesc([('cmd', "aa"),
-                                      ('callback', lambda : None)],
-                                     {'aa': 'aa'})
+        'some_callback' : MethodDesc([('cmd', str),
+                                      ('callback', lambda_None)],
+                                     {str:str})
     }
     
     _render_xmlhttp = True

Modified: pypy/dist/pypy/translator/js/examples/start_bnb.py
==============================================================================
--- pypy/dist/pypy/translator/js/examples/start_bnb.py	(original)
+++ pypy/dist/pypy/translator/js/examples/start_bnb.py	Sat Jan 13 18:29:51 2007
@@ -13,9 +13,7 @@
 
 from pypy.translator.js.test.runtest import compile_function
 from pypy.translator.js.modules.dom import document
-from pypy.translator.js.modules.xmlhttp import XMLHttpRequest
 from pypy.translator.js.modules.mochikit import log, logWarning, createLoggingPane, logDebug
-from pypy.translator.js.modules.bltns import date
 from pypy.translator.js.demo.jsdemo.bnb import BnbRootInstance
 
 import time
@@ -41,7 +39,7 @@
     def register_frame(self):
         self.n_rendered_inline_frames += 1
         if self.n_rendered_inline_frames >= 10:
-            next_time = date()
+            next_time = time.time()
             self.fps = 10000/(next_time - self.starttime)
             self.n_rendered_inline_frames = 0
             self.starttime = next_time

Modified: pypy/dist/pypy/translator/js/modules/dom.py
==============================================================================
--- pypy/dist/pypy/translator/js/modules/dom.py	(original)
+++ pypy/dist/pypy/translator/js/modules/dom.py	Sat Jan 13 18:29:51 2007
@@ -26,6 +26,7 @@
 
 from pypy.annotation.signature import annotation
 from pypy.annotation import model as annmodel
+from pypy.translator.js.support import _callable
 
 # EventTarget is the base class for Nodes and Window
 class EventTarget(BasicExternal):
@@ -314,10 +315,6 @@
 
 # rtyper stuff
 
-def _callable(args, result=None):
-    return annmodel.SomeGenericCallable([annotation(i) for i in args],
-                                         annotation(result))
-
 EventTarget._fields = {
     'onabort' : _callable([Event]),
     'onblur' : _callable([Event]),

Modified: pypy/dist/pypy/translator/js/modules/test/test_dom.py
==============================================================================
--- pypy/dist/pypy/translator/js/modules/test/test_dom.py	(original)
+++ pypy/dist/pypy/translator/js/modules/test/test_dom.py	Sat Jan 13 18:29:51 2007
@@ -371,6 +371,6 @@
         if var.startswith('code_'):
             # just build it
             #def f():
-            assert rpython2javascript(sys.modules[__name__], [var], use_pdb=True)
+            assert rpython2javascript(sys.modules[__name__], [var], use_pdb=False)
     
     TRANSLATING = False

Modified: pypy/dist/pypy/translator/js/support.py
==============================================================================
--- pypy/dist/pypy/translator/js/support.py	(original)
+++ pypy/dist/pypy/translator/js/support.py	Sat Jan 13 18:29:51 2007
@@ -1,6 +1,13 @@
 from pypy.translator.gensupp import NameManager
 #from pypy.translator.js.optimize import is_optimized_function
 
+from pypy.annotation.signature import annotation
+from pypy.annotation import model as annmodel
+
+def _callable(args, result=None):
+    return annmodel.SomeGenericCallable([annotation(i) for i in args],
+                                         annotation(result))
+
 class JavascriptNameManager(NameManager):
     def __init__(self, db):
         NameManager.__init__(self)

Modified: pypy/dist/pypy/translator/js/test/test_bltn.py
==============================================================================
--- pypy/dist/pypy/translator/js/test/test_bltn.py	(original)
+++ pypy/dist/pypy/translator/js/test/test_bltn.py	Sat Jan 13 18:29:51 2007
@@ -5,6 +5,7 @@
 
 from pypy.rpython.ootypesystem.bltregistry import BasicExternal, MethodDesc
 from pypy.translator.js.test.runtest import compile_function, check_source_contains
+from pypy.translator.js.support import _callable
 
 # check rendering dom.document
 def test_simple_builtin():
@@ -21,12 +22,12 @@
     _render_xmlhttp = True
     
     _methods = {
-        'some_method' : MethodDesc([], 3),
+        'some_method' : MethodDesc([], int),
     }
     
 class SomeNode(BasicExternal):
     _fields = {
-        'some_callback' : MethodDesc([3], 3),
+        'some_callback' : _callable([int], int),
     }
 
 SomeProxyInstance = SomeProxy()



More information about the Pypy-commit mailing list