source: trunk/gcc/libobjc/selector.c@ 3180

Last change on this file since 3180 was 1392, checked in by bird, 22 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 12.1 KB
Line 
1/* GNU Objective C Runtime selector related functions
2 Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
3 Contributed by Kresten Krab Thorup
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify it under the
8terms of the GNU General Public License as published by the Free Software
9Foundation; either version 2, or (at your option) any later version.
10
11GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14details.
15
16You should have received a copy of the GNU General Public License along with
17GNU CC; see the file COPYING. If not, write to the Free Software
18Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20/* As a special exception, if you link this library with files compiled with
21 GCC to produce an executable, this does not cause the resulting executable
22 to be covered by the GNU General Public License. This exception does not
23 however invalidate any other reasons why the executable file might be
24 covered by the GNU General Public License. */
25
26#include "runtime.h"
27#include "sarray.h"
28#include "encoding.h"
29
30/* Initial selector hash table size. Value doesn't matter much */
31#define SELECTOR_HASH_SIZE 128
32
33/* Tables mapping selector names to uid and opposite */
34static struct sarray *__objc_selector_array = 0; /* uid -> sel !T:MUTEX */
35static struct sarray *__objc_selector_names = 0; /* uid -> name !T:MUTEX */
36static cache_ptr __objc_selector_hash = 0; /* name -> uid !T:MUTEX */
37
38static void register_selectors_from_list (MethodList_t);
39
40/* Number of selectors stored in each of the above tables */
41unsigned int __objc_selector_max_index = 0; /* !T:MUTEX */
42
43void __objc_init_selector_tables ()
44{
45 __objc_selector_array = sarray_new (SELECTOR_HASH_SIZE, 0);
46 __objc_selector_names = sarray_new (SELECTOR_HASH_SIZE, 0);
47 __objc_selector_hash
48 = hash_new (SELECTOR_HASH_SIZE,
49 (hash_func_type) hash_string,
50 (compare_func_type) compare_strings);
51}
52
53/* This routine is given a class and records all of the methods in its class
54 structure in the record table. */
55void
56__objc_register_selectors_from_class (Class class)
57{
58 MethodList_t method_list;
59
60 method_list = class->methods;
61 while (method_list)
62 {
63 register_selectors_from_list (method_list);
64 method_list = method_list->method_next;
65 }
66}
67
68
69/* This routine is given a list of methods and records each of the methods in
70 the record table. This is the routine that does the actual recording
71 work.
72
73 This one is only called for Class objects. For categories,
74 class_add_method_list is called.
75 */
76static void
77register_selectors_from_list (MethodList_t method_list)
78{