comparison src/runtime.cpp @ 151:657afb7307eb

Added a pymonkey.get_debug_info() function and used it on test teardown to ensure that unit tests don't leak.
author Atul Varma <varmaa@toolness.com>
date Sat, 29 Aug 2009 14:06:03 -0700
parents f956a6dea16c
children dd32a92f6b4f
comparison
equal deleted inserted replaced
150:aea82140758c 151:657afb7307eb
35 * ***** END LICENSE BLOCK ***** */ 35 * ***** END LICENSE BLOCK ***** */
36 36
37 #include "runtime.h" 37 #include "runtime.h"
38 #include "context.h" 38 #include "context.h"
39 #include "utils.h" 39 #include "utils.h"
40
41 static unsigned int runtimeCount = 0;
42
43 unsigned int PYM_getJSRuntimeCount()
44 {
45 return runtimeCount;
46 }
40 47
41 static PyObject * 48 static PyObject *
42 PYM_JSRuntimeNew(PyTypeObject *type, PyObject *args, 49 PYM_JSRuntimeNew(PyTypeObject *type, PyObject *args,
43 PyObject *kwds) 50 PyObject *kwds)
44 { 51 {
77 } 84 }
78 } 85 }
79 } 86 }
80 } 87 }
81 88
89 if (self)
90 runtimeCount++;
91
82 return (PyObject *) self; 92 return (PyObject *) self;
83 } 93 }
84 94
85 static void 95 static void
86 PYM_JSRuntimeDealloc(PYM_JSRuntimeObject *self) 96 PYM_JSRuntimeDealloc(PYM_JSRuntimeObject *self)
104 JS_DestroyRuntime(self->rt); 114 JS_DestroyRuntime(self->rt);
105 self->rt = NULL; 115 self->rt = NULL;
106 } 116 }
107 117
108 self->ob_type->tp_free((PyObject *) self); 118 self->ob_type->tp_free((PyObject *) self);
119
120 runtimeCount--;
109 } 121 }
110 122
111 static PyObject * 123 static PyObject *
112 PYM_newContext(PYM_JSRuntimeObject *self, PyObject *args) 124 PYM_newContext(PYM_JSRuntimeObject *self, PyObject *args)
113 { 125 {