Mercurial > pymonkey
diff context.c @ 81:99138265d4b9
Added a context.clear_object_private() function.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sun, 09 Aug 2009 14:22:17 -0700 |
parents | efa0cfe6fc03 |
children | ac40f4e03e91 |
line wrap: on
line diff
--- a/context.c Fri Aug 07 18:59:10 2009 -0700 +++ b/context.c Sun Aug 09 14:22:17 2009 -0700 @@ -137,6 +137,26 @@ } static PyObject * +PYM_clearObjectPrivate(PYM_JSContextObject *self, PyObject *args) +{ + PYM_JSObject *object; + + if (!PyArg_ParseTuple(args, "O!", &PYM_JSObjectType, &object)) + return NULL; + + JSClass *klass = JS_GET_CLASS(cx, object->obj); + if (klass != &PYM_JS_ObjectClass) + Py_RETURN_NONE; + + if (!PYM_JS_setPrivatePyObject(self->cx, object->obj, Py_None)) { + PYM_jsExceptionToPython(self); + return NULL; + } + + Py_RETURN_NONE; +} + +static PyObject * PYM_newObject(PYM_JSContextObject *self, PyObject *args) { PyObject *privateObj = NULL; @@ -395,6 +415,8 @@ "Triggers the operation callback for the context."}, {"get_object_private", (PyCFunction) PYM_getObjectPrivate, METH_VARARGS, "Returns the private Python object stored in the JavaScript object."}, + {"clear_object_private", (PyCFunction) PYM_clearObjectPrivate, METH_VARARGS, + "Clears any private Python object stored in the JavaScript object."}, {NULL, NULL, 0, NULL} };