Mercurial > pymonkey
comparison context.c @ 15:baa4cb961330
JS objects in python-land are now rooted while in python-land so that they're not gc'd while in python-land.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sun, 28 Jun 2009 18:39:43 -0700 |
parents | 9edcdb4ab12d |
children | 532b7ddca616 |
comparison
equal
deleted
inserted
replaced
14:9edcdb4ab12d | 15:baa4cb961330 |
---|---|
29 PYM_JSObject *object = PyObject_New(PYM_JSObject, | 29 PYM_JSObject *object = PyObject_New(PYM_JSObject, |
30 &PYM_JSObjectType); | 30 &PYM_JSObjectType); |
31 if (object == NULL) | 31 if (object == NULL) |
32 return NULL; | 32 return NULL; |
33 | 33 |
34 object->runtime = self->runtime; | |
35 Py_INCREF(object->runtime); | |
36 | |
34 object->obj = JS_NewObject(self->cx, &PYM_JS_ObjectClass, NULL, NULL); | 37 object->obj = JS_NewObject(self->cx, &PYM_JS_ObjectClass, NULL, NULL); |
35 if (object->obj == NULL) { | 38 if (object->obj == NULL) { |
36 PyErr_SetString(PYM_error, "JS_NewObject() failed"); | 39 PyErr_SetString(PYM_error, "JS_NewObject() failed"); |
37 Py_DECREF(object); | 40 Py_DECREF(object); |
38 return NULL; | 41 return NULL; |
39 } | 42 } |
43 | |
44 JS_AddNamedRootRT(object->runtime->rt, &object->obj, | |
45 "Pymonkey-Generated Object"); | |
40 | 46 |
41 return (PyObject *) object; | 47 return (PyObject *) object; |
42 } | 48 } |
43 | 49 |
44 static PyObject * | 50 static PyObject * |