diff 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
line wrap: on
line diff
--- a/context.c	Sun Jun 28 18:28:35 2009 -0700
+++ b/context.c	Sun Jun 28 18:39:43 2009 -0700
@@ -31,6 +31,9 @@
   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) {
     PyErr_SetString(PYM_error, "JS_NewObject() failed");
@@ -38,6 +41,9 @@
     return NULL;
   }
 
+  JS_AddNamedRootRT(object->runtime->rt, &object->obj,
+                    "Pymonkey-Generated Object");
+
   return (PyObject *) object;
 }