Mercurial > pymonkey
diff object.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 | baa4cb961330 |
children | fc04e5f1c675 |
line wrap: on
line diff
--- a/object.c Sun Jun 28 19:44:13 2009 -0700 +++ b/object.c Sun Jun 28 20:00:48 2009 -0700 @@ -65,3 +65,21 @@ 0, /* tp_alloc */ 0, /* tp_new */ }; + +PYM_JSObject *PYM_newJSObject(PYM_JSRuntimeObject *runtime, + JSObject *obj) { + PYM_JSObject *object = PyObject_New(PYM_JSObject, + &PYM_JSObjectType); + if (object == NULL) + return NULL; + + object->runtime = runtime; + Py_INCREF(object->runtime); + + object->obj = obj; + + JS_AddNamedRootRT(object->runtime->rt, &object->obj, + "Pymonkey-Generated Object"); + + return object; +}