comparison 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
comparison
equal deleted inserted replaced
18:f3223debd70b 19:fbb9a61fa030
30 if (obj == NULL) { 30 if (obj == NULL) {
31 PyErr_SetString(PYM_error, "JS_NewObject() failed"); 31 PyErr_SetString(PYM_error, "JS_NewObject() failed");
32 return NULL; 32 return NULL;
33 } 33 }
34 34
35 // If this fails, we don't need to worry about cleaning up
36 // obj because it'll get cleaned up at the next GC.
35 return (PyObject *) PYM_newJSObject(self->runtime, obj); 37 return (PyObject *) PYM_newJSObject(self->runtime, obj);
36 } 38 }
37 39
38 static PyObject * 40 static PyObject *
39 PYM_getProperty(PYM_JSContextObject *self, PyObject *args) 41 PYM_getProperty(PYM_JSContextObject *self, PyObject *args)
182 0, /* tp_dictoffset */ 184 0, /* tp_dictoffset */
183 0, /* tp_init */ 185 0, /* tp_init */
184 0, /* tp_alloc */ 186 0, /* tp_alloc */
185 0, /* tp_new */ 187 0, /* tp_new */
186 }; 188 };
189
190 extern PYM_JSContextObject *
191 PYM_newJSContextObject(PYM_JSRuntimeObject *runtime, JSContext *cx)
192 {
193 PYM_JSContextObject *context = PyObject_New(PYM_JSContextObject,
194 &PYM_JSContextType);
195 if (context == NULL)
196 return NULL;
197
198 context->runtime = runtime;
199 Py_INCREF(runtime);
200
201 context->cx = cx;
202
203 return context;
204 }