Beispiel #1
0
 def decorator(func):
     defs = func.func_defaults
     if defs is None:
         defs = ()
     vars = func.func_code.co_varnames[:func.func_code.co_argcount]
     if isinstance(args, dict):
         arg_list = load_dict_args(vars, defs, args)
     else:
         arg_list = args
     arg_list.append(("callback", genericcallable(args=[retval])))
     func._method = (func.__name__, MethodDesc(arg_list, retval))
     return func
Beispiel #2
0
class Server(HTTPServer, BasicExternal):
    # Methods and signatures how they are rendered for JS
    _methods = {
        'some_callback':
        MethodDesc([('cmd', str), ('callback', genericcallable([{
            str: str
        }]))], {str: str})
    }

    _render_xmlhttp = True

    def __init__(self, *args, **kwargs):
        HTTPServer.__init__(self, *args, **kwargs)
        self.source = None
        self.locals = {}
Beispiel #3
0
Event._fields = {
    '_event': dom.Event,
}

Event._methods = {
    'preventDefault': MethodDesc([]),
}


def connect(src, signal, dest):
    print 'connecting signal %s' % (signal, )


register_external(connect,
                  args=[dom.EventTarget, str,
                        genericcallable([Event])],
                  result=int)


def disconnect(id):
    pass


register_external(disconnect, args=[int])


def disconnectAll(src, signal):
    print 'disconnecting all handlers for signal: %s' % (signal, )


register_external(disconnectAll, args=[dom.EventTarget, str])
Beispiel #4
0
add_import("flash.media.Sound")
class Sound(Button):
    _render_class = "flash.media.Sound"
    _fields = {
        'data': str,
    }

    _methods = {
        'load': MethodDesc([URLRequest]),
        'play': MethodDesc([]),
    }

def partial(i):
    pass
register_external(partial, args=[genericcallable([Event, str]), str], result=genericcallable([Event]), export_name="_consts_0.partial")

add_import("mx.core.SoundAsset")
class SoundAsset(Sound):
    _render_class = "mx.core.SoundAsset"

def load_resource(what):
    pass
register_external(load_resource, args=[str], result=str, export_name="load_resource")

def load_sprite(what):
    pass
register_external(load_sprite, args=[str], result=Image, export_name="load_sprite")

def load_sound_resource(what):
    pass
Beispiel #5
0
def test_genericcallable():
    py.test.skip("this two annotations should be equal - fix!")
    from pypy.rpython.extfunc import genericcallable
    s1 = annotation([genericcallable([str], int)])
    s2 = annotation([genericcallable([str], int)])
    assert s1 == s2
Beispiel #6
0
    pass
register_external(serializeJSON, args=None, result=str)

# MochiKit.Signal

class Event(BasicExternal):
    pass

Event._fields = {
    '_event': dom.Event,
}

Event._methods = {
    'preventDefault': MethodDesc([]),
}


def connect(src, signal, dest):
    print 'connecting signal %s' % (signal,)
register_external(connect, args=[dom.EventTarget, str, genericcallable([Event])],
                  result=int)

def disconnect(id):
    pass
register_external(disconnect, args=[int])

def disconnectAll(src, signal):
    print 'disconnecting all handlers for signal: %s' % (signal,)
register_external(disconnectAll, args=[dom.EventTarget, str])

Beispiel #7
0
class SomeNode(BasicExternal):
    _fields = {
        'some_callback': genericcallable([int], str),
    }
Beispiel #8
0
def test_genericcallable():
    py.test.skip("this two annotations should be equal - fix!")
    from pypy.rpython.extfunc import genericcallable
    s1 = annotation([genericcallable([str], int)])
    s2 = annotation([genericcallable([str], int)])
    assert s1 == s2
Beispiel #9
0
        html = url.read()
        self.document = Document(minidom.parseString(html))
    
    location = property(_getLocation, _setLocation)

scrollX = 0
scrollMaxX = 0
scrollY = 0
scrollMaxY = 0

def some_fun():
    pass

def setTimeout(func, delay):
    pass
register_external(setTimeout, args=[genericcallable([]), int], result=None)

window = Window()
window._render_name = 'window'
document = window.document
document._render_name = 'document'

# rtyper stuff

EventTarget._fields = {
    'onabort' : genericcallable([Event]),
    'onblur' : genericcallable([Event]),
    'onchange' : genericcallable([Event]),
    'onclick' : genericcallable([MouseEvent]),
    'onclose' : genericcallable([MouseEvent]),
    'ondblclick' : genericcallable([MouseEvent]),