2 * Mesa 3-D graphics library
5 * Copyright (C) 2010 LunarG Inc.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
26 * Chia-I Wu <olv@lunarg.com>
31 #ifndef MAPI_ABI_HEADER
32 #error "MAPI_ABI_HEADER must be defined"
39 #ifdef MAPI_TMP_DEFINES
40 # define MAPI_ABI_DEFINES
41 # include MAPI_ABI_HEADER
43 #ifndef MAPI_ABI_PREFIX
44 #error "MAPI_ABI_PREFIX must be defined"
46 #ifndef MAPI_ABI_PUBLIC
47 #error "MAPI_ABI_PUBLIC must be defined"
50 #error "MAPI_ABI_ATTR must be defined"
53 #undef MAPI_TMP_DEFINES
54 #endif /* MAPI_TMP_DEFINES */
58 * Generate fields of struct mapi_table.
61 # define MAPI_ABI_ENTRY(ret, name, params) \
62 ret (MAPI_ABI_ATTR *name) params;
63 # define MAPI_DYNAMIC_ENTRY(ret, name, params) \
64 ret (MAPI_ABI_ATTR *name) params;
65 # include MAPI_ABI_HEADER
67 #endif /* MAPI_TMP_TABLE */
71 * Declare public entries.
73 #ifdef MAPI_TMP_PUBLIC_DECLARES
74 # define MAPI_ABI_ENTRY(ret, name, params) \
75 MAPI_ABI_PUBLIC ret MAPI_ABI_ATTR U_CONCAT(MAPI_ABI_PREFIX, name) params;
76 # define MAPI_ALIAS_ENTRY(alias, ret, name, params) \
77 MAPI_ABI_ENTRY(ret, name, params);
78 # define MAPI_ABI_ENTRY_HIDDEN(ret, name, params) \
79 HIDDEN ret MAPI_ABI_ATTR U_CONCAT(MAPI_ABI_PREFIX, name) params;
80 # define MAPI_ALIAS_ENTRY_HIDDEN(alias, ret, name, params) \
81 MAPI_ABI_ENTRY_HIDDEN(ret, name, params)
82 # include MAPI_ABI_HEADER
83 #undef MAPI_TMP_PUBLIC_DECLARES
84 #endif /* MAPI_TMP_PUBLIC_DECLARES */
88 * Generate string pool and public stubs.
90 #ifdef MAPI_TMP_PUBLIC_STUBS
91 /* define the string pool */
92 static const char public_string_pool
[] =
93 # define MAPI_ABI_ENTRY(ret, name, params) \
94 U_STRINGIFY(name) "\0"
95 # define MAPI_ALIAS_ENTRY(alias, ret, name, params) \
96 MAPI_ABI_ENTRY(ret, name, params)
97 # include MAPI_ABI_HEADER
99 /* define public_sorted_indices */
100 # define MAPI_ABI_SORTED_INDICES public_sorted_indices
101 # include MAPI_ABI_HEADER
103 /* define public_stubs */
104 static const struct mapi_stub public_stubs
[] = {
105 # define MAPI_ABI_ENTRY(ret, name, params) \
106 { (mapi_func) U_CONCAT(MAPI_ABI_PREFIX, name), \
107 MAPI_SLOT_ ## name, (void *) MAPI_POOL_ ## name },
108 # define MAPI_ALIAS_ENTRY(alias, ret, name, params) \
109 MAPI_ABI_ENTRY(ret, name, params)
110 # include MAPI_ABI_HEADER
111 { NULL
, -1, (void *) -1 }
114 #undef MAPI_TMP_PUBLIC_STUBS
115 #endif /* MAPI_TMP_PUBLIC_STUBS */
119 * Generate public entries.
121 #ifdef MAPI_TMP_PUBLIC_ENTRIES
122 # define MAPI_ABI_ENTRY(ret, name, params) \
123 ret MAPI_ABI_ATTR U_CONCAT(MAPI_ABI_PREFIX, name) params
124 # define MAPI_ABI_CODE(ret, name, args) \
126 const struct mapi_table *tbl = u_current_get(); \
129 # define MAPI_ABI_CODE_RETURN(ret, name, args) \
131 const struct mapi_table *tbl = u_current_get(); \
132 return tbl->name args; \
134 # define MAPI_ALIAS_ENTRY(alias, ret, name, params) \
135 MAPI_ABI_ENTRY(ret, name, params)
136 # define MAPI_ALIAS_CODE(alias, ret, name, args) \
137 MAPI_ABI_CODE(ret, alias, args)
138 # define MAPI_ALIAS_CODE_RETURN(alias, ret, name, args) \
139 MAPI_ABI_CODE_RETURN(ret, alias, args)
140 # include MAPI_ABI_HEADER
141 #undef MAPI_TMP_PUBLIC_ENTRIES
142 #endif /* MAPI_TMP_PUBLIC_ENTRIES */
146 * Generate noop entries.
148 #ifdef MAPI_TMP_NOOP_ARRAY
150 # define MAPI_ABI_ENTRY(ret, name, params) \
151 static ret MAPI_ABI_ATTR U_CONCAT(noop_, name) params
152 # define MAPI_ABI_CODE(ret, name, args) \
154 noop_warn(U_CONCAT_STR(MAPI_ABI_PREFIX, name)); \
156 # define MAPI_ABI_CODE_RETURN(ret, name, args) \
158 noop_warn(U_CONCAT_STR(MAPI_ABI_PREFIX, name)); \
161 # include MAPI_ABI_HEADER
163 /* define the noop function array that may be casted to mapi_table */
164 const mapi_func table_noop_array
[] = {
165 # define MAPI_ABI_ENTRY(ret, name, params) \
166 (mapi_func) U_CONCAT(noop_, name),
167 # define MAPI_DYNAMIC_ENTRY(ret, name, params) \
168 (mapi_func) noop_generic,
169 # include MAPI_ABI_HEADER
170 (mapi_func
) noop_generic
175 const mapi_func table_noop_array
[] = {
176 # define MAPI_ABI_ENTRY(ret, name, params) \
177 (mapi_func) noop_generic,
178 # define MAPI_DYNAMIC_ENTRY(ret, name, params) \
179 (mapi_func) noop_generic,
180 # include MAPI_ABI_HEADER
181 (mapi_func
) noop_generic
185 #undef MAPI_TMP_NOOP_ARRAY
186 #endif /* MAPI_TMP_NOOP_ARRAY */