1af69d88dSmrg/*
2af69d88dSmrg * Mesa 3-D graphics library
3af69d88dSmrg *
4af69d88dSmrg * Copyright (C) 2010 LunarG Inc.
5af69d88dSmrg *
6af69d88dSmrg * Permission is hereby granted, free of charge, to any person obtaining a
7af69d88dSmrg * copy of this software and associated documentation files (the "Software"),
8af69d88dSmrg * to deal in the Software without restriction, including without limitation
9af69d88dSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10af69d88dSmrg * and/or sell copies of the Software, and to permit persons to whom the
11af69d88dSmrg * Software is furnished to do so, subject to the following conditions:
12af69d88dSmrg *
13af69d88dSmrg * The above copyright notice and this permission notice shall be included
14af69d88dSmrg * in all copies or substantial portions of the Software.
15af69d88dSmrg *
16af69d88dSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17af69d88dSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18af69d88dSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20af69d88dSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21af69d88dSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22af69d88dSmrg * DEALINGS IN THE SOFTWARE.
23af69d88dSmrg *
24af69d88dSmrg * Authors:
25af69d88dSmrg *    Chia-I Wu <olv@lunarg.com>
26af69d88dSmrg */
27af69d88dSmrg
28af69d88dSmrg#ifndef _TABLE_H_
29af69d88dSmrg#define _TABLE_H_
30af69d88dSmrg
3101e04c3fSmrg#include "c99_compat.h"
32af69d88dSmrg#include "entry.h"
33af69d88dSmrg
34af69d88dSmrg#define MAPI_TMP_TABLE
35af69d88dSmrg#include "mapi_tmp.h"
36af69d88dSmrg
37af69d88dSmrg#define MAPI_TABLE_NUM_SLOTS (MAPI_TABLE_NUM_STATIC + MAPI_TABLE_NUM_DYNAMIC)
38af69d88dSmrg#define MAPI_TABLE_SIZE (MAPI_TABLE_NUM_SLOTS * sizeof(mapi_func))
39af69d88dSmrg
4001e04c3fSmrgstruct _glapi_table;
4101e04c3fSmrg
42af69d88dSmrgextern const mapi_func table_noop_array[];
43af69d88dSmrg
4401e04c3fSmrg
4501e04c3fSmrgtypedef void (*nop_handler_proc)(const char *name);
4601e04c3fSmrg
4701e04c3fSmrg
4801e04c3fSmrgvoid
4901e04c3fSmrgtable_set_noop_handler(nop_handler_proc func);
5001e04c3fSmrg
5101e04c3fSmrg
52af69d88dSmrg/**
53af69d88dSmrg * Get the no-op dispatch table.
54af69d88dSmrg */
5501e04c3fSmrgstatic inline const struct _glapi_table *
56af69d88dSmrgtable_get_noop(void)
57af69d88dSmrg{
5801e04c3fSmrg   return (const struct _glapi_table *) table_noop_array;
59af69d88dSmrg}
60af69d88dSmrg
61af69d88dSmrg/**
62af69d88dSmrg * Set the function of a slot.
63af69d88dSmrg */
6401e04c3fSmrgstatic inline void
6501e04c3fSmrgtable_set_func(struct _glapi_table *tbl, int slot, mapi_func func)
66af69d88dSmrg{
67af69d88dSmrg   mapi_func *funcs = (mapi_func *) tbl;
68af69d88dSmrg   funcs[slot] = func;
69af69d88dSmrg}
70af69d88dSmrg
71af69d88dSmrg/**
72af69d88dSmrg * Return the function of a slot.
73af69d88dSmrg */
7401e04c3fSmrgstatic inline mapi_func
7501e04c3fSmrgtable_get_func(const struct _glapi_table *tbl, int slot)
76af69d88dSmrg{
77af69d88dSmrg   const mapi_func *funcs = (const mapi_func *) tbl;
78af69d88dSmrg   return funcs[slot];
79af69d88dSmrg}
80af69d88dSmrg
81af69d88dSmrg#endif /* _TABLE_H_ */
82