diff runtime.c @ 23:951ad1b15587

The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
author Atul Varma <varmaa@toolness.com>
date Sun, 28 Jun 2009 22:58:04 -0700
parents 988a8998c75f
children 3f4982759e55
line wrap: on
line diff
--- a/runtime.c	Sun Jun 28 21:49:07 2009 -0700
+++ b/runtime.c	Sun Jun 28 22:58:04 2009 -0700
@@ -11,9 +11,14 @@
   self = (PYM_JSRuntimeObject *) type->tp_alloc(type, 0);
   if (self != NULL) {
     self->rt = NULL;
+    self->objects.ops = NULL;
 
-    self->objects = PyDict_New();
-    if (self->objects == NULL) {
+    if (!JS_DHashTableInit(&self->objects,
+                           JS_DHashGetStubOps(),
+                           NULL,
+                           sizeof(PYM_HashEntry),
+                           JS_DHASH_DEFAULT_CAPACITY(100))) {
+      PyErr_SetString(PYM_error, "JS_DHashTableInit() failed");
       type->tp_dealloc((PyObject *) self);
       self = NULL;
     }
@@ -34,9 +39,9 @@
 static void
 PYM_JSRuntimeDealloc(PYM_JSRuntimeObject *self)
 {
-  if (self->objects) {
-    Py_DECREF(self->objects);
-    self->objects = NULL;
+  if (self->objects.ops) {
+    JS_DHashTableFinish(&self->objects);
+    self->objects.ops = NULL;
   }
 
   if (self->rt) {