diff context.c @ 19:fbb9a61fa030

Moved context creation code into its own public function in context.c.
author Atul Varma <varmaa@toolness.com>
date Sun, 28 Jun 2009 20:08:59 -0700
parents f3223debd70b
children abede8af8cf5
line wrap: on
line diff
--- a/context.c	Sun Jun 28 20:00:48 2009 -0700
+++ b/context.c	Sun Jun 28 20:08:59 2009 -0700
@@ -32,6 +32,8 @@
     return NULL;
   }
 
+  // If this fails, we don't need to worry about cleaning up
+  // obj because it'll get cleaned up at the next GC.
   return (PyObject *) PYM_newJSObject(self->runtime, obj);
 }
 
@@ -184,3 +186,19 @@
   0,                           /* tp_alloc */
   0,                           /* tp_new */
 };
+
+extern PYM_JSContextObject *
+PYM_newJSContextObject(PYM_JSRuntimeObject *runtime, JSContext *cx)
+{
+  PYM_JSContextObject *context = PyObject_New(PYM_JSContextObject,
+                                              &PYM_JSContextType);
+  if (context == NULL)
+    return NULL;
+
+  context->runtime = runtime;
+  Py_INCREF(runtime);
+
+  context->cx = cx;
+
+  return context;
+}