Source

python-spidermonkey / spidermonkey / jshelpers.c

The default branch has multiple heads

void
js_context_attach(JSContext* cx, PyObject* obj)
{
    Py_INCREF(obj);
    JS_SetContextPrivate(cx, (void*) obj);
}

PyObject* 
js_context_fetch(JSContext* cx)
{
    PyObject* obj = (PyObject*) JS_GetContextPrivate(cx);
    Py_INCREF(obj);
    return obj;
}

PyObject*
js_context_destroy(JSContext* cx)
{
    PyObject* ret = (PyObject*) JS_GetContextPrivate(cx);
    return ret;
}

void
js_object_attach(JSContext* cx, JSObject* js_obj, PyObject* py_obj)
{
    Py_INCREF(py_obj);
    JS_SetPrivate(cx, js_obj, (void*) py_obj);
}

PyObject*
js_object_fetch(JSContext* cx, JSObject* js_obj)
{
    PyObject* py_obj = (PyObject*) JS_GetPrivate(cx, js_obj);
    Py_INCREF(py_obj);
    return py_obj;
}

PyObject*
js_object_destroy(JSContext* cx, JSObject* js_obj)
{
    return (PyObject*) JS_GetPrivate(cx, js_obj);
}

static JSClass js_global_class =
{
    "RootObjectClass",
    0,
    JS_PropertyStub,
    JS_PropertyStub,
    JS_PropertyStub,
    JS_PropertyStub,
    JS_EnumerateStub,
    JS_ResolveStub,
    JS_ConvertStub,
    JS_FinalizeStub,
    JSCLASS_NO_OPTIONAL_MEMBERS
};

JSObject *
js_make_global_object(JSContext *cx)
{
    return JS_NewObject(cx, &global_class, 0, 0);
}
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.