source: trunk/third/at-spi/libspi/util.c @ 18688

Revision 18688, 3.0 KB checked in by ghudson, 21 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18687, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4 *
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
22 */
23
24#include <glib/gmessages.h>
25#include <glib/gslist.h>
26
27#include "spi-private.h"
28
29typedef struct {
30        GList **list;
31        GList  *iterator;
32} Iteration;
33
34static GSList *working_list = NULL; /* of Iteration */
35
36static char *spi_atk_bridge_null_string = "";
37
38/*
39 *   deletes an element from the list - in a re-entrant
40 * safe fashion; advances the element pointer to the next
41 * element.
42 */
43void
44spi_re_entrant_list_delete_link (GList * const *element_ptr)
45{
46  GSList    *l;
47  GList     *next;
48  GList     *element;
49  gboolean   first_item;
50
51  g_return_if_fail (element_ptr != NULL);
52
53  element = *element_ptr;
54  g_return_if_fail (element != NULL);
55
56  next = element->next;
57  first_item = (element->prev == NULL);
58
59  g_list_remove_link (NULL, element);
60
61  for (l = working_list; l; l = l->next)
62    {
63       Iteration *i = l->data;
64
65       if (i->iterator == element)
66         {
67           i->iterator = next;
68         }
69
70       if (first_item && *(i->list) == element)
71         {
72           *(i->list) = next;
73         }
74    }
75
76  g_list_free_1 (element);
77}
78
79void
80spi_re_entrant_list_foreach (GList         **list,
81                             SpiReEntrantFn  func,
82                             gpointer        user_data)
83{
84        Iteration i;
85
86        if (!list || !*list)
87          {
88            return;
89          }
90
91        i.list = list;
92        i.iterator = *list;
93
94        working_list = g_slist_prepend (working_list, &i);
95
96        while (i.iterator) {
97                GList *l = i.iterator;
98
99                func (&i.iterator, user_data);
100
101                if (i.iterator == l)
102                        i.iterator = i.iterator->next;
103        }
104
105        working_list = g_slist_remove (working_list, &i);
106}
107
108void
109spi_init_any_nil (CORBA_any *any)
110{
111  any->_type = TC_null;
112  any->_value = NULL;
113  any->_release = FALSE;
114}
115
116void
117spi_init_any_object (CORBA_any *any, CORBA_Object *o)
118{
119  CORBA_Environment ev;
120  CORBA_exception_init (&ev);
121 
122  any->_type = TC_CORBA_Object;
123  any->_value = o;
124  any->_release = FALSE;
125  CORBA_exception_free (&ev);
126}
127
128void
129spi_init_any_string (CORBA_any *any, char **string_pointer)
130
131  any->_type = (CORBA_TypeCode) TC_CORBA_string;
132  if (string_pointer && *string_pointer)
133    any->_value = string_pointer;
134  else
135    any->_value = &spi_atk_bridge_null_string;
136  any->_release = FALSE;
137}
Note: See TracBrowser for help on using the repository browser.