+static Accessibility_Registry registry = CORBA_OBJECT_NIL;
+static GHashTable *live_refs = NULL;
+
+static guint
+cspi_object_hash (gconstpointer key)
+{
+ CORBA_Object object = (CORBA_Object) key;
+ guint retval;
+
+ retval = CORBA_Object_hash (object, 0, &ev);
+
+ return retval;
+}
+
+static gboolean
+cspi_object_equal (gconstpointer a, gconstpointer b)
+{
+ CORBA_Object objecta = (CORBA_Object) a;
+ CORBA_Object objectb = (CORBA_Object) b;
+ gboolean retval;
+
+ retval = CORBA_Object_is_equivalent (objecta, objectb, &ev);
+
+ return retval;
+}
+
+static void
+cspi_object_release (gpointer value)
+{
+ Accessible *a = (Accessible *) value;
+
+#ifdef DEBUG_OBJECTS
+ g_print ("releasing %p => %p\n", a, a->objref);
+#endif
+
+ cspi_release_unref (a->objref);
+
+ memset (a, 0xaa, sizeof (Accessible));
+ a->ref_count = -1;
+
+#ifndef DEBUG_OBJECTS
+ free (a);
+#endif
+}
+
+SPIBoolean
+cspi_accessible_is_a (Accessible *obj,
+ const char *interface_name)
+{
+ SPIBoolean retval;
+ Bonobo_Unknown unknown;
+
+ if (obj == NULL)
+ {
+ return FALSE;
+ }
+
+ unknown = Bonobo_Unknown_queryInterface (CSPI_OBJREF (obj),
+ interface_name, cspi_ev ());
+
+ if (ev._major != CORBA_NO_EXCEPTION)
+ {
+ g_error ("Exception '%s' checking if is '%s'",
+ cspi_exception_get_text (),
+ interface_name);
+ }
+
+ if (unknown != CORBA_OBJECT_NIL)
+ {
+ retval = TRUE;
+ cspi_release_unref (unknown);
+ }
+ else
+ {
+ retval = FALSE;
+ }
+
+ return retval;
+}
+
+static GHashTable *
+cspi_get_live_refs (void)
+{
+ if (!live_refs)
+ {
+ live_refs = g_hash_table_new_full (cspi_object_hash,
+ cspi_object_equal,
+ NULL,
+ cspi_object_release);
+ }
+ return live_refs;
+}