Mercurial > pymonkey
comparison context.c @ 11:551ba05fe6ad
factored out Runtime, Context, and utils into separate files.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sun, 28 Jun 2009 17:28:57 -0700 |
parents | |
children | 6d95cfaa1e0b |
comparison
equal
deleted
inserted
replaced
10:29eaa1fceff1 | 11:551ba05fe6ad |
---|---|
1 #include "context.h" | |
2 | |
3 static void | |
4 PYM_JSContextDealloc(PYM_JSContextObject *self) | |
5 { | |
6 if (self->cx) { | |
7 JS_DestroyContext(self->cx); | |
8 self->cx = NULL; | |
9 } | |
10 | |
11 Py_DECREF(self->runtime); | |
12 self->runtime = NULL; | |
13 | |
14 self->ob_type->tp_free((PyObject *) self); | |
15 } | |
16 | |
17 static PyObject * | |
18 PYM_getRuntime(PYM_JSContextObject *self, PyObject *args) | |
19 { | |
20 Py_INCREF(self->runtime); | |
21 return (PyObject *) self->runtime; | |
22 } | |
23 | |
24 static PyMethodDef PYM_JSContextMethods[] = { | |
25 {"get_runtime", (PyCFunction) PYM_getRuntime, METH_VARARGS, | |
26 "Get the JavaScript runtime associated with this context."}, | |
27 {NULL, NULL, 0, NULL} | |
28 }; | |
29 | |
30 PyTypeObject PYM_JSContextType = { | |
31 PyObject_HEAD_INIT(NULL) | |
32 0, /*ob_size*/ | |
33 "pymonkey.Context", /*tp_name*/ | |
34 sizeof(PYM_JSRuntimeObject), /*tp_basicsize*/ | |
35 0, /*tp_itemsize*/ | |
36 /*tp_dealloc*/ | |
37 (destructor) PYM_JSContextDealloc, | |
38 0, /*tp_print*/ | |
39 0, /*tp_getattr*/ | |
40 0, /*tp_setattr*/ | |
41 0, /*tp_compare*/ | |
42 0, /*tp_repr*/ | |
43 0, /*tp_as_number*/ | |
44 0, /*tp_as_sequence*/ | |
45 0, /*tp_as_mapping*/ | |
46 0, /*tp_hash */ | |
47 0, /*tp_call*/ | |
48 0, /*tp_str*/ | |
49 0, /*tp_getattro*/ | |
50 0, /*tp_setattro*/ | |
51 0, /*tp_as_buffer*/ | |
52 Py_TPFLAGS_DEFAULT, /*tp_flags*/ | |
53 /* tp_doc */ | |
54 "JavaScript Context.", | |
55 0, /* tp_traverse */ | |
56 0, /* tp_clear */ | |
57 0, /* tp_richcompare */ | |
58 0, /* tp_weaklistoffset */ | |
59 0, /* tp_iter */ | |
60 0, /* tp_iternext */ | |
61 PYM_JSContextMethods, /* tp_methods */ | |
62 0, /* tp_members */ | |
63 0, /* tp_getset */ | |
64 0, /* tp_base */ | |
65 0, /* tp_dict */ | |
66 0, /* tp_descr_get */ | |
67 0, /* tp_descr_set */ | |
68 0, /* tp_dictoffset */ | |
69 0, /* tp_init */ | |
70 0, /* tp_alloc */ | |
71 0, /* tp_new */ | |
72 }; |