2 ent-nullary-op.h -- Global Nullary Operations
3 Copyright (C) 2006, 2007, 2008 Sebastian Freundt
5 Author: Sebastian Freundt <hroptatyr@sxemacs.org>
7 * This file is part of SXEmacs.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the author nor the names of any contributors
21 * may be used to endorse or promote products derived from this
22 * software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
33 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
34 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 /* Synched up with: Not in FSF. */
39 #ifndef INCLUDED_ent_nullary_op_h_
40 #define INCLUDED_ent_nullary_op_h_
42 #define ENT_DEBUG_NULLOP(args...) ENT_DEBUG("[NULLOP]: " args)
44 /*************************/
45 /* new ASE optable magic */
46 /*************************/
47 /* the nullary optable */
48 typedef enum ase_nullary_operation_e ase_nullary_operation_t;
49 typedef Lisp_Object ase_nullary_operation_f;
51 enum ase_nullary_operation_e {
53 ASE_NULLARY_FIRST_OP = ASE_NULLARY_OP_ZERO,
55 ASE_NULLARY_LAST_OP = ASE_NULLARY_OP_ONE,
59 extern ase_nullary_operation_f
60 ase_nullary_optable[N_ASE_NULLARY_OPS][ASE_OPTABLE_SIZE];
62 extern ase_nullary_operation_f ase_nullary_operation_undefined;
66 ase_nullary_operation_t op,
67 ase_object_type_t t, ase_nullary_operation_f opf);
69 ent_nullop_unregister(ase_nullary_operation_t op, ase_object_type_t t);
70 extern_inline Lisp_Object
71 _ent_nullop(ase_nullary_operation_t op, ase_object_type_t lt);
72 extern_inline Lisp_Object
73 ent_nullop(ase_nullary_operation_t op, Lisp_Object l);
77 ent_nullop_register(ase_nullary_operation_t op,
78 ase_object_type_t t, ase_nullary_operation_f opf)
80 ase_nullary_optable[op][t] = opf;
84 ent_nullop_unregister(ase_nullary_operation_t op, ase_object_type_t t)
86 ase_nullary_optable[op][t] = ase_nullary_operation_undefined;
90 extern void ase_nullary_optable_init(void);
92 extern_inline Lisp_Object
93 _ent_nullop(ase_nullary_operation_t op, ase_object_type_t lt)
95 ase_nullary_operation_f opf =
96 ase_nullary_optable[op][lt];
100 extern_inline Lisp_Object
101 ent_nullop(ase_nullary_operation_t op, Lisp_Object l)
103 ase_object_type_t lt = ase_optable_index(l);
105 return _ent_nullop(op, lt);
108 #define _ent_nullop_zero(_t) _ent_nullop(ASE_NULLARY_OP_ZERO, _t)
109 #define ent_nullop_zero(_o) ent_nullop(ASE_NULLARY_OP_ZERO, _o)
110 #define _ent_nullop_one(_t) _ent_nullop(ASE_NULLARY_OP_ONE, _t)
111 #define ent_nullop_one(_o) ent_nullop(ASE_NULLARY_OP_ONE, _o)
116 extern void syms_of_ent_nullary_op(void);
117 extern void vars_of_ent_nullary_op(void);
119 #endif /* INCLUDED_ent_nullary_op_h_ */