Mercurial > pymonkey
diff context.c @ 18:f3223debd70b
Refactoring; moved PYM_JSObject creation code into a new public function in object.c.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sun, 28 Jun 2009 20:00:48 -0700 |
parents | 0812422ec99e |
children | fbb9a61fa030 |
line wrap: on
line diff
--- a/context.c Sun Jun 28 19:44:13 2009 -0700 +++ b/context.c Sun Jun 28 20:00:48 2009 -0700 @@ -26,25 +26,13 @@ static PyObject * PYM_newObject(PYM_JSContextObject *self, PyObject *args) { - PYM_JSObject *object = PyObject_New(PYM_JSObject, - &PYM_JSObjectType); - if (object == NULL) - return NULL; - - object->runtime = self->runtime; - Py_INCREF(object->runtime); - - object->obj = JS_NewObject(self->cx, &PYM_JS_ObjectClass, NULL, NULL); - if (object->obj == NULL) { + JSObject *obj = JS_NewObject(self->cx, &PYM_JS_ObjectClass, NULL, NULL); + if (obj == NULL) { PyErr_SetString(PYM_error, "JS_NewObject() failed"); - Py_DECREF(object); return NULL; } - JS_AddNamedRootRT(object->runtime->rt, &object->obj, - "Pymonkey-Generated Object"); - - return (PyObject *) object; + return (PyObject *) PYM_newJSObject(self->runtime, obj); } static PyObject *