[g-a-devel]at-spi patch



attached.  Mostly of interest to internal libspi hackers.

-Bill
? at-spi-1.0.pc
? atspi-101201-1.diff
? atspi-111101-1.diff
? atspi-111201-1.diff
? atspi-121201-2.diff
? atspi-121201-1.diff
? docs/reference/cspi/tmpl/at-spi-cspi-unused.sgml
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/at-spi/ChangeLog,v
retrieving revision 1.117
diff -u -r1.117 ChangeLog
--- ChangeLog	2001/12/12 00:28:48	1.117
+++ ChangeLog	2001/12/12 16:08:00
@@ -1,5 +1,15 @@
 2001-12-12  Bill Haneman <bill haneman sun com>
 
+	* registryd/registry.c:
+	Changed use of strings and string hashes in listener event
+	matching and parse_event_string to use GQuark, which is guaranteed
+	unique.
+	
+	* registryd/registry.h:
+	Squashed annoying warning.
+
+2001-12-12  Bill Haneman <bill haneman sun com>
+
 	* idl/Accessibility_Value.idl:
 	Revert use of union back to CORBA_double, since the double type is
 	more efficient and can contain the other types without loss of
Index: TODO
===================================================================
RCS file: /cvs/gnome/at-spi/TODO,v
retrieving revision 1.5
diff -u -r1.5 TODO
--- TODO	2001/12/11 17:58:25	1.5
+++ TODO	2001/12/12 16:08:00
@@ -3,24 +3,19 @@
 idl: 
 	+ audit IDL for conformance with bonobo/doc/FAQ's [Java]
 	naming practice [Michael]
-        + possibly change Value.idl interface to return a value
-	union. [Bill] *DONE*
-	+ rename all IDL prepending Accessibility_ to each IDL filename
 
 cspi: 
-	+ API change required if above IDL change is made. [Bill]
 	+ ensure spi-listener-impl's list notification methods don't
 	  have a re-enterancy hazard. [Michael]
-	+ namespace all methods missing a prepending Acessible
+	+ namespace all methods missing a prepending Accessible
 	  or SPI_ prefix.
 	+ Put LGPL headers everywhere.
 
 registry:
 	+ move code into here from libspi [Michael]
-	+ kill the getDeviceWhatnot - and use queryInterface,
-	  don't inherit from the Listener interface - use aggregation
 	+ fire an event on dead application & re-factor the listen for
 	  broken code.
+        + consider use of GHashTable instead of GList for listeners [Bill]
 
 bridge:
 	+ move code into here from libspi
@@ -29,8 +24,6 @@
 	+ remove redundant casts throughout
 	+ determine if there are other headers we don't need to install
 	+ consider moving the non-impl. parts into registryd/ bridge/ etc.
-	+ change the weird string-hash event matching to something sane,
-	using GQuark. [Bill]
 	+ merge the DeviceEvent and KeyEvent structs to avoid the
 	bogus casting of these back and forth.
 	+ complete implementation of support for RelationSet and
@@ -40,6 +33,6 @@
 
 test:
 	+ update test-simple to do complete API tests
-	+ Add tests for AtkTable, and add table elements to the test window.
+	+ Expand tests for AtkTable
 	+ remove comment from test_value; ensure that it works.
 
Index: registryd/registry.c
===================================================================
RCS file: /cvs/gnome/at-spi/registryd/registry.c,v
retrieving revision 1.33
diff -u -r1.33 registry.c
--- registryd/registry.c	2001/12/11 17:58:27	1.33
+++ registryd/registry.c	2001/12/12 16:08:02
@@ -22,6 +22,8 @@
 
 /* registry.c: the main accessibility service registry implementation */
 
+#undef SPI_LISTENER_DEBUG
+
 #include <config.h>
 #ifdef SPI_DEBUG
 #  include <stdio.h>
@@ -49,15 +51,14 @@
 typedef struct {
   char *event_name;
   EventTypeCategory type_cat;
-  char * major;
-  char * minor;
-  char * detail;
-  guint hash;
+  GQuark major;  /* from string segment[1] */
+  GQuark minor;  /* from string segment[1]+segment[2] */
+  GQuark detail; /* from string segment[3] (not concatenated) */
 } EventTypeStruct;
 
 typedef struct {
   Accessibility_EventListener listener;
-  guint event_type_hash;
+  GQuark event_type_quark;
   EventTypeCategory event_type_cat;
 } SpiListenerStruct;
 
@@ -173,9 +174,9 @@
 }
 
 static gint
-compare_listener_hash (gconstpointer p1, gconstpointer p2)
+compare_listener_quarks (gconstpointer p1, gconstpointer p2)
 {
-  return (((SpiListenerStruct *)p2)->event_type_hash - ((SpiListenerStruct *)p1)->event_type_hash);
+  return (!((SpiListenerStruct *)p2)->event_type_quark == ((SpiListenerStruct *)p1)->event_type_quark);
 }
 
 static gint
@@ -213,37 +214,37 @@
 
   if (split_string[1])
     {
-      etype->major = g_strdup (split_string[1]);
       if (split_string[2])
         {
-          etype->minor = g_strdup (split_string[2]);
+          etype->minor = g_quark_from_string (s = g_strconcat (split_string[1], split_string[2], NULL));
+          g_free (s);
           if (split_string[3])
             {
-              etype->detail = g_strdup (split_string[3]);
+              etype->detail = g_quark_from_string (split_string[3]);
 	      s = g_strconcat (split_string[1], split_string[2], split_string[3], NULL);
-              etype->hash = g_str_hash (s);
+	      etype->major = g_quark_from_string (s);
 	      g_free (s);
             }
           else
             {
-              etype->detail = g_strdup ("");
+	      etype->detail = g_quark_from_static_string ("");
 	      s = g_strconcat (split_string[1], split_string[2], NULL);
-	      etype->hash = g_str_hash (s);
+	      etype->major = g_quark_from_string (s);
 	      g_free (s);
             }
         }
       else
         {
-          etype->minor = g_strdup ("");
-          etype->hash = g_str_hash ( split_string[1]);
+          etype->major = g_quark_from_string (split_string[1]);
+	  etype->minor = etype->major;
+	  etype->detail = etype->major;
         }
     }
   else
     {
-      etype->major = g_strdup ("");
-      etype->minor = g_strdup ("");
-      etype->detail = g_strdup ("");
-      etype->hash = g_str_hash ("");
+      etype->major = g_quark_from_static_string ("");
+      etype->minor = etype->major;
+      etype->detail = etype->major;
     }
 
   g_strfreev (split_string);
@@ -290,7 +291,7 @@
 
   /* parse, check major event type and add listener accordingly */
   parse_event_type (&etype, (char*) event_name);
-  ls->event_type_hash = etype.hash;
+  ls->event_type_quark = etype.major;
   ls->event_type_cat = etype.type_cat;
 
   switch (etype.type_cat)
@@ -391,14 +392,14 @@
   if (!listeners)
 	  return;
 
-  ls.event_type_hash = etype.hash;
-  list = g_list_find_custom (*listeners, &ls, compare_listener_hash);
+  ls.event_type_quark = etype.major;
+  list = g_list_find_custom (*listeners, &ls, compare_listener_quarks);
 
   while (list)
     {
       spi_listener_struct_free ((SpiListenerStruct *) list->data, ev);
       *listeners = g_list_delete_link (*listeners, list);
-      list = g_list_find_custom (*listeners, &ls, compare_listener_hash);
+      list = g_list_find_custom (*listeners, &ls, compare_listener_quarks);
     }
 }
 
@@ -524,26 +525,23 @@
   Accessibility_Event e_out;
   SpiListenerStruct  *ls;
   EventTypeStruct     etype;
-  guint               minor_hash;
+#ifdef SPI_DEBUG
   CORBA_string        s;
+#endif
 
   e_out = *e_in;
   parse_event_type (&etype, e_in->type);
 
-  s = g_strconcat (etype.major, etype.minor, NULL);
-  minor_hash = g_str_hash (s);
-  g_free (s);
-
   for (l = listeners; l; l = l->next)
     {
       ls = (SpiListenerStruct *) l->data;
 
-#ifdef SPI_SPI_LISTENER_DEBUG
-      fprintf (stderr, "event hashes: %lx %lx %lx\n", ls->event_type_hash, etype.hash, minor_hash);
+#ifdef SPI_LISTENER_DEBUG
+      fprintf (stderr, "event quarks: %lx %lx %lx\n", ls->event_type_quark, etype.major, etype.minor);
       fprintf (stderr, "event name: %s\n", etype.event_name);
 #endif
 
-      if ((ls->event_type_hash == etype.hash) || (ls->event_type_hash == minor_hash))
+      if ((ls->event_type_quark == etype.major) || (ls->event_type_quark == etype.minor))
         {
 #ifdef SPI_DEBUG
           fprintf (stderr, "notifying listener %d\n", g_list_index (listeners, l->data));
Index: registryd/registry.h
===================================================================
RCS file: /cvs/gnome/at-spi/registryd/registry.h,v
retrieving revision 1.12
diff -u -r1.12 registry.h
--- registryd/registry.h	2001/12/11 17:58:27	1.12
+++ registryd/registry.h	2001/12/12 16:08:02
@@ -42,7 +42,7 @@
   GList *object_listeners;
   GList *window_listeners;
   GList *toolkit_listeners;
-  struct SpiDeviceEventController *device_event_controller;
+  SpiDeviceEventController *device_event_controller;
   SpiDesktop *desktop;
   gboolean (*kbd_event_hook) (gpointer source);
 } SpiRegistry;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]