Mercurial > pymonkey
annotate object.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 | ca17531e8c81 |
children | f3223debd70b |
rev | line source |
---|---|
13 | 1 #include "object.h" |
2 | |
3 JSClass PYM_JS_ObjectClass = { | |
4 "PymonkeyObject", JSCLASS_GLOBAL_FLAGS, | |
5 JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, | |
6 JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub, | |
7 JSCLASS_NO_OPTIONAL_MEMBERS | |
8 }; | |
9 | |
10 static void | |
11 PYM_JSObjectDealloc(PYM_JSObject *self) | |
12 { | |
13 // JS_RemoveRoot() always returns JS_TRUE, so don't | |
14 // bother checking its return value. | |
15 | |
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.
Atul Varma <varmaa@toolness.com>
parents:
13
diff
changeset
|
16 if (self->obj) { |
baa4cb961330
JS objects in python-land are now rooted while in python-land so that they're not gc'd while in python-land.
Atul Varma <varmaa@toolness.com>
parents:
13
diff
changeset
|
17 JS_RemoveRootRT(self->runtime->rt, &self->obj); |
baa4cb961330
JS objects in python-land are now rooted while in python-land so that they're not gc'd while in python-land.
Atul Varma <varmaa@toolness.com>
parents:
13
diff
changeset
|
18 self->obj = NULL; |
baa4cb961330
JS objects in python-land are now rooted while in python-land so that they're not gc'd while in python-land.
Atul Varma <varmaa@toolness.com>
parents:
13
diff
changeset
|
19 } |
baa4cb961330
JS objects in python-land are now rooted while in python-land so that they're not gc'd while in python-land.
Atul Varma <varmaa@toolness.com>
parents:
13
diff
changeset
|
20 |
baa4cb961330
JS objects in python-land are now rooted while in python-land so that they're not gc'd while in python-land.
Atul Varma <varmaa@toolness.com>
parents:
13
diff
changeset
|
21 Py_DECREF(self->runtime); |
baa4cb961330
JS objects in python-land are now rooted while in python-land so that they're not gc'd while in python-land.
Atul Varma <varmaa@toolness.com>
parents:
13
diff
changeset
|
22 self->runtime = NULL; |
13 | 23 } |
24 | |
25 PyTypeObject PYM_JSObjectType = { | |
26 PyObject_HEAD_INIT(NULL) | |
27 0, /*ob_size*/ | |
28 "pymonkey.Object", /*tp_name*/ | |
29 sizeof(PYM_JSObject), /*tp_basicsize*/ | |
30 0, /*tp_itemsize*/ | |
31 /*tp_dealloc*/ | |
32 (destructor) PYM_JSObjectDealloc, | |
33 0, /*tp_print*/ | |
34 0, /*tp_getattr*/ | |
35 0, /*tp_setattr*/ | |
36 0, /*tp_compare*/ | |
37 0, /*tp_repr*/ | |
38 0, /*tp_as_number*/ | |
39 0, /*tp_as_sequence*/ | |
40 0, /*tp_as_mapping*/ | |
41 0, /*tp_hash */ | |
42 0, /*tp_call*/ | |
43 0, /*tp_str*/ | |
44 0, /*tp_getattro*/ | |
45 0, /*tp_setattro*/ | |
46 0, /*tp_as_buffer*/ | |
47 Py_TPFLAGS_DEFAULT, /*tp_flags*/ | |
48 /* tp_doc */ | |
49 "JavaScript Object.", | |
50 0, /* tp_traverse */ | |
51 0, /* tp_clear */ | |
52 0, /* tp_richcompare */ | |
53 0, /* tp_weaklistoffset */ | |
54 0, /* tp_iter */ | |
55 0, /* tp_iternext */ | |
56 0, /* tp_methods */ | |
57 0, /* tp_members */ | |
58 0, /* tp_getset */ | |
59 0, /* tp_base */ | |
60 0, /* tp_dict */ | |
61 0, /* tp_descr_get */ | |
62 0, /* tp_descr_set */ | |
63 0, /* tp_dictoffset */ | |
64 0, /* tp_init */ | |
65 0, /* tp_alloc */ | |
66 0, /* tp_new */ | |
67 }; |