Example #1
0
def run_bnb():
    from pypy.translator.js.examples.bnb.bnb import BnbRoot
    from pypy.translator.js.lib import server
    addr = ('', 7070)
    httpd = server.create_server(handler=BnbRoot, server_address=addr)
    httpd.source = rpython2javascript(sys.modules[__name__], ['bnb'])
    httpd.serve_forever()
Example #2
0
def test_build():
    py.test.skip('Børken')
    global TRANSLATING
    TRANSLATING = True
    for var in globals():
        if var.startswith('code_'):
            # just build it
            #def f():
            assert rpython2javascript(sys.modules[__name__], [var], use_pdb=False)
    
    TRANSLATING = False
Example #3
0
def test_build():
    py.test.skip('Børken')
    global TRANSLATING
    TRANSLATING = True
    for var in globals():
        if var.startswith('code_'):
            # just build it
            #def f():
            assert rpython2javascript(sys.modules[__name__], [var],
                                      use_pdb=False)

    TRANSLATING = False
Example #4
0
    def run_jssource(self):
        js_name = py.path.local(__file__).dirpath("webdata").join("source.js")
        web_name = py.path.local(__file__).dirpath().join("webjs.py")
        if IMPORTED_PYPY and web_name.mtime() > js_name.mtime():
            from py.__.test.rsession import webjs

            javascript_source = rpython2javascript(webjs,
                FUNCTION_LIST, use_pdb=False)
            open(str(js_name), "w").write(javascript_source)
            self.serve_data("text/javascript", javascript_source)
        else:
            js_source = open(str(js_name), "r").read()
            self.serve_data("text/javascript", js_source)
Example #5
0
def js_source(functions, use_pdb=True):
    mod = new.module('_js_src')
    function_names = []
    for func in functions:
        name = func.__name__
        if hasattr(mod, name):
            raise ValueError("exported function name %r is duplicated"
                             % (name,))
        mod.__dict__[name] = func
        function_names.append(name)
    sys.modules['_js_src'] = mod
    try:
        return rpython2javascript(mod, function_names, use_pdb=use_pdb)
    finally:
        del sys.modules['_js_src']
Example #6
0
def test_console_2_build():
    from pypy.translator.js.examples.console import console, client
    assert rpython2javascript(client, console.FUNCTION_LIST,
                              use_pdb=True)
Example #7
0
def test_overmind_build():
    from pypy.translator.js.examples import overmind, over_client
    assert rpython2javascript(over_client, overmind.FUNCTION_LIST,
                              use_pdb=False)
Example #8
0
 def source_js(self):
     # this returns content-type (if not text/html)
     # and generated javascript code
     # None as argument means current module, while "show" is the
     # name of function to be exported (under same name)
     return "text/javascript", rpython2javascript(None, ["show"])
Example #9
0
def test_console_2_build():
    from pypy.translator.js.examples.console import console, client
    assert rpython2javascript(client, console.FUNCTION_LIST, use_pdb=True)
Example #10
0
    ping_handler.ping("PING", callback)

def callback(data):
    mochikit.logDebug("Got response: " + data["response"])
    log = dom.document.getElementById("log")
    mochikit.logDebug("got log element")
    try:
        s = "<p>" + data["response"] + "</p>"
    except KeyError:
        mochikit.logDebug("Can't find data")
        s = "<p>" + "Error" + "</p>"
    mochikit.logDebug("Adding: " + s)
    log.innerHTML += s
    mochikit.logDebug("added message")

def doping_onclick(event):
    mochikit.logDebug("calling pinger")
    jsping()

def ping_init():
    mochikit.createLoggingPane(True)
    button = dom.document.getElementById("doping")
    button.onclick = doping_onclick
    mochikit.logDebug("Ping button setup")

if __name__ == "__main__":
    # circular import
    from pypy.translator.js.examples.djangoping import client
    from pypy.translator.js.main import rpython2javascript
    print rpython2javascript(client, ["ping_init"])
Example #11
0
def test_module_none():
    assert rpython2javascript(None, "fff")
Example #12
0
def test_bookkeeper_cleanup():
    assert rpython2javascript(sys.modules[__name__], ["fun"])
    assert rpython2javascript(sys.modules[__name__], ["fun"])
Example #13
0
    mochikit.logDebug("Got response: " + data["response"])
    log = dom.document.getElementById("log")
    mochikit.logDebug("got log element")
    try:
        s = "<p>" + data["response"] + "</p>"
    except KeyError:
        mochikit.logDebug("Can't find data")
        s = "<p>" + "Error" + "</p>"
    mochikit.logDebug("Adding: " + s)
    log.innerHTML += s
    mochikit.logDebug("added message")


def doping_onclick(event):
    mochikit.logDebug("calling pinger")
    jsping()


def ping_init():
    mochikit.createLoggingPane(True)
    button = dom.document.getElementById("doping")
    button.onclick = doping_onclick
    mochikit.logDebug("Ping button setup")


if __name__ == "__main__":
    # circular import
    from pypy.translator.js.examples.djangoping import client
    from pypy.translator.js.main import rpython2javascript
    print rpython2javascript(client, ["ping_init"])
Example #14
0
def test_module_none():
    assert rpython2javascript(None, "fff")
Example #15
0
def test_bookkeeper_cleanup():
    assert rpython2javascript(sys.modules[__name__], ["fun"])
    assert rpython2javascript(sys.modules[__name__], ["fun"])
Example #16
0
 def source_js(self):
     return "text/javascript", rpython2javascript(None, ["addrow", "delrow"])
Example #17
0
def test_build():
    from pypy.translator.js.examples.djangoping import client
    assert rpython2javascript(client, ['ping_init'], use_pdb=False)
Example #18
0
def ping_js(request):
    js_src = rpython2javascript(client, ["ping_init"])
    response = HttpResponse(mimetype="text/javascript")
    response.write(js_src)
    return response
Example #19
0
def guestbook_client():
    """ compile the rpython guestbook_client code to js
    """
    import guestbook_client
    return rpython2javascript(guestbook_client, FUNCTION_LIST)
Example #20
0
def js_source():
    import client
    return rpython2javascript(client, FUNCTION_LIST)
Example #21
0
def test_overmind_build():
    from pypy.translator.js.examples import overmind, over_client
    assert rpython2javascript(over_client,
                              overmind.FUNCTION_LIST,
                              use_pdb=False)
Example #22
0
def test_bnb_build():
    from pypy.translator.js.examples.bnb import start_bnb
    assert rpython2javascript(start_bnb, ['bnb'], use_pdb=False)
Example #23
0
def test_build():
    from pypy.translator.js.examples.djangoping import client
    assert rpython2javascript(client, ['ping_init'], use_pdb=False)
Example #24
0
def test_guestbook_build():
    from pypy.translator.js.examples import guestbook, guestbook_client
    assert rpython2javascript(guestbook_client,
                              guestbook.FUNCTION_LIST,
                              use_pdb=False)
Example #25
0
def test_js_generate():
    from py.__.test.report import webjs
    from py.__.test.report.web import FUNCTION_LIST, IMPORTED_PYPY
    
    source = rpython2javascript(webjs, FUNCTION_LIST, use_pdb=False)
    assert source
Example #26
0
def test_console_build():
    from pypy.translator.js.examples import pythonconsole
    httpd = pythonconsole.Server(('', 0), pythonconsole.RequestHandler)
    pythonconsole.httpd = httpd
    # XXX obscure hack
    assert rpython2javascript(pythonconsole, ['setup_page'], use_pdb=False)
Example #27
0
def guestbook_client():
    """ compile the rpython guestbook_client code to js
    """
    import guestbook_client
    return rpython2javascript(guestbook_client, FUNCTION_LIST)
Example #28
0
def test_js_generate():
    from py.__.test.rsession import webjs
    from py.__.test.rsession.web import FUNCTION_LIST, IMPORTED_PYPY
    
    source = rpython2javascript(webjs, FUNCTION_LIST)
    assert source
Example #29
0
 def source_js(self):
     return "text/javascript", rpython2javascript(None,
                                                  ["addrow", "delrow"])
Example #30
0
def test_bnb_build():
    from pypy.translator.js.examples.bnb import start_bnb
    assert rpython2javascript(start_bnb, ['bnb'], use_pdb=False)
Example #31
0
def js_source(function_list):
    import over_client
    return rpython2javascript(over_client, FUNCTION_LIST)
Example #32
0
def test_guestbook_build():
    from pypy.translator.js.examples import guestbook, guestbook_client
    assert rpython2javascript(guestbook_client, guestbook.FUNCTION_LIST,
                              use_pdb=False)
Example #33
0
 def source_js(self):
     # this returns content-type (if not text/html)
     # and generated javascript code
     # None as argument means current module, while "show" is the
     # name of function to be exported (under same name)
     return "text/javascript", rpython2javascript(None, ["show"])
Example #34
0
def test_console_build():
    from pypy.translator.js.examples import pythonconsole
    httpd = pythonconsole.Server(('', 0), pythonconsole.RequestHandler)
    pythonconsole.httpd = httpd
    # XXX obscure hack
    assert rpython2javascript(pythonconsole, ['setup_page'], use_pdb=False)
Example #35
0
def js_source():
    import client

    return rpython2javascript(client, FUNCTION_LIST)