[pypy-svn] r29369 - in pypy/dist/pypy/translator/js: . modules tools

fijal at codespeak.net fijal at codespeak.net
Mon Jun 26 21:08:01 CEST 2006


Author: fijal
Date: Mon Jun 26 21:08:00 2006
New Revision: 29369

Modified:
   pypy/dist/pypy/translator/js/jsbuiltin.py
   pypy/dist/pypy/translator/js/metavm.py
   pypy/dist/pypy/translator/js/modules/dom.py
   pypy/dist/pypy/translator/js/tools/start_bnb.py
Log:
Slightly fixed types.


Modified: pypy/dist/pypy/translator/js/jsbuiltin.py
==============================================================================
--- pypy/dist/pypy/translator/js/jsbuiltin.py	(original)
+++ pypy/dist/pypy/translator/js/jsbuiltin.py	Mon Jun 26 21:08:00 2006
@@ -4,7 +4,7 @@
 from pypy.translator.oosupport.metavm import InstructionList, PushAllArgs
 from pypy.translator.js.metavm import SetBuiltinField, ListGetitem, ListSetitem, \
     GetBuiltinField, CallBuiltin, Call, SetTimeout, ListContains,\
-    NewBuiltin, SetOnKeydown
+    NewBuiltin, SetOnEvent
 
 from pypy.rpython.ootypesystem import ootype
 
@@ -17,7 +17,7 @@
             'll_newlist' : lambda g,op: g.ilasm.load_const("[]"),
             'll_alloc_and_set' : CallBuiltin('alloc_and_set'),
             'get_document' : lambda g,op: g.ilasm.load_const('document'),
-            'set_on_keydown' : SetOnKeydown,
+            'set_on_keydown' : SetOnEvent('onkeydown'),
             'setTimeout' : SetTimeout,
             #'xmlSetCallback' : XmlSetCallback,
             'll_int_str' : lambda g,op: Call._render_builtin_method(g, 'toString' , [op.args[2]]),

Modified: pypy/dist/pypy/translator/js/metavm.py
==============================================================================
--- pypy/dist/pypy/translator/js/metavm.py	(original)
+++ pypy/dist/pypy/translator/js/metavm.py	Mon Jun 26 21:08:00 2006
@@ -205,7 +205,10 @@
         generator.load(op.args[2])
         generator.call_external('setTimeout',[0]*2)
 
-class _SetOnKeydown(MicroInstruction):
+class SetOnEvent(MicroInstruction):
+    def __init__(self, field):
+        self.field = field
+    
     # FIXME: Dirty hack for javascript callback stuff
     def render(self, generator, op):
         val = op.args[1].value
@@ -223,11 +226,9 @@
         #generator.load(op.args[2])
         generator.load_str("document")
         generator.load_str(real_name)
-        generator.set_field(None, 'onkeydown')
+        generator.set_field(None, self.field)
         #generator.call_external('setTimeout',[0]*2)
 
-SetOnKeydown = _SetOnKeydown()
-
 ##class _XmlSetCallback(MicroInstruction):
 ##    # FIXME: Another dirty hack. To remove soon
 ##    def render(self, generator, op):

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	Mon Jun 26 21:08:00 2006
@@ -18,11 +18,18 @@
         self.top = "0"
         self.visibility = 'visible'
 
+class Key(object):
+    _rpython_hints = {'_suggested_external' : True}
+        
+    def __init__(self, s):
+        self.charCode = s
+        self.keyCode = s
+
 def set_on_keydown(func):
     if one():
-        func("str")
+        func(Key("str"))
     else:
-        func("str2")
+        func(Key("str2"))
 
 set_on_keydown.suggested_primitive = True
 

Modified: pypy/dist/pypy/translator/js/tools/start_bnb.py
==============================================================================
--- pypy/dist/pypy/translator/js/tools/start_bnb.py	(original)
+++ pypy/dist/pypy/translator/js/tools/start_bnb.py	Mon Jun 26 21:08:00 2006
@@ -132,7 +132,7 @@
     #    sm.show_sprite(msg['s'])
 
 def keydown(key):
-    logDebug(key)
+    logDebug(key.keyCode)
 
 def bnb_dispatcher(msgs):
     BnbRootInstance.get_message(bnb_dispatcher)



More information about the Pypy-commit mailing list