Source

python-spidermonkey / spidermonkey / jsvalue.pxi

The default branch has multiple heads

cdef jsval py2js(Context cx, object py_obj, JSObject* parent) except 0:
    if py_is_void(cx, py_obj):
        return py2js_void(cx, py_obj, parent)
    elif py_is_int(cx, py_obj):
        return py2js_int(cx, py_obj, parent)
    elif py_is_double(cx, py_obj):
        return py2js_double(cx, py_obj, parent)
    elif py_is_string(cx, py_obj):
        return py2js_string(cx, py_obj, parent)
    elif py_is_array(cx, py_obj):
        return py2js_array(cx, py_obj, parent)
    elif py_is_hash(cx, py_obj):
        return py2js_hash(cx, py_obj, parent)
    elif py_is_function(cx, py_obj):
        return py2js_function(cx, py_obj, parent)
    #elif py_is_object(cx, py_obj):
    #    return py2js_object(cx, py_obj, parent)
    #elif py_is_class(cx, py_obj):
    #    return py2js_class(cx, py_obj, parent)
    else:
        raise TypeError("Unable to convert Python value to JavaScript: %r" % py_obj)

cdef object js2py(Context cx, jsval jsv):
    if js_is_void(cx, jsv):
        return js2py_void(cx, jsv)
    elif js_is_int(cx, jsv):
        return js2py_int(cx, jsv)
    elif js_is_double(cx, jsv):
        return js2py_double(cx, jsv)
    elif js_is_string(cx, jsv):
        return js2py_string(cx, jsv)
    elif js_is_array(cx, jsv):
        return js2py_array(cx, jsv)
    elif js_is_function(cx, jsv):
        return js2py_function(cx, jsv)
    elif js_is_object(cx, jsv):
        return js2py_object(cx, jsv)
    elif js_is_hash(cx, jsv):
        return js2py_hash(cx, jsv)
    else:
        raise TypeError("Unable to convert JavaScript value to Python: %r" % jsv)

cdef class Value:
    cdef jsval jsv

cdef Value js_create_value(jsval jsv):
    cdef Value v
    v = Value()
    v.jsv = jsv
    return v
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.