Whitespace cleanup in src/ent
[sxemacs] / src / ent / ent-unary-op.h
1 /*
2   ent-unary-op.h -- Global Unary Operations
3   Copyright (C) 2006, 2007, 2008 Sebastian Freundt
4
5   Author:  Sebastian Freundt <hroptatyr@sxemacs.org>
6
7   * This file is part of SXEmacs.
8   *
9   * Redistribution and use in source and binary forms, with or without
10   * modification, are permitted provided that the following conditions
11   * are met:
12   *
13   * 1. Redistributions of source code must retain the above copyright
14   *    notice, this list of conditions and the following disclaimer.
15   *
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.
19   *
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.
23   *
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.
35   */
36
37 /* Synched up with: Not in FSF. */
38
39 #ifndef INCLUDED_ent_unary_op_h_
40 #define INCLUDED_ent_unary_op_h_
41
42 #define ENT_DEBUG_UNOP(args...)         ENT_DEBUG("[UNOP]: " args)
43
44 /*************************/
45 /* new ASE optable magic */
46 /*************************/
47 /* the unary optable */
48 typedef enum ase_unary_operation_e ase_unary_operation_t;
49 typedef Lisp_Object(*ase_unary_operation_f)(Lisp_Object);
50
51 enum ase_unary_operation_e {
52         ASE_UNARY_OP_NEG,
53         ASE_UNARY_FIRST_OP = ASE_UNARY_OP_NEG,
54         ASE_UNARY_OP_INV,
55         ASE_UNARY_LAST_OP = ASE_UNARY_OP_INV,
56         N_ASE_UNARY_OPS
57 };
58
59 extern ase_unary_operation_f ase_unary_optable
60 [N_ASE_UNARY_OPS][ASE_OPTABLE_SIZE];
61
62 extern Lisp_Object ase_unary_operation_undefined(Lisp_Object l);
63 extern_inline void
64 ent_unop_register(
65         ase_unary_operation_t op,
66         ase_object_type_t t,
67         ase_unary_operation_f opf);
68 extern_inline void
69 ent_unop_unregister(ase_unary_operation_t op, ase_object_type_t t);
70 extern_inline Lisp_Object
71 _ent_unop(ase_unary_operation_t op, ase_object_type_t lt, Lisp_Object l);
72 extern_inline Lisp_Object
73 ent_unop(ase_unary_operation_t op, Lisp_Object l);
74
75 \f
76 extern_inline void
77 ent_unop_register(ase_unary_operation_t op,
78                   ase_object_type_t t, ase_unary_operation_f opf)
79 {
80         ase_unary_optable[op][t] = opf;
81         return;
82 }
83 extern_inline void
84 ent_unop_unregister(ase_unary_operation_t op, ase_object_type_t t)
85 {
86         ase_unary_optable[op][t] = ase_unary_operation_undefined;
87         return;
88 }
89
90 extern void ase_unary_optable_init(void);
91
92 extern_inline Lisp_Object
93 _ent_unop(ase_unary_operation_t op, ase_object_type_t lt, Lisp_Object l)
94 {
95         ase_unary_operation_f opf =
96                 ase_unary_optable[op][lt];
97
98         return opf(l);
99 }
100 extern_inline Lisp_Object
101 ent_unop(ase_unary_operation_t op, Lisp_Object l)
102 {
103         ase_object_type_t lt = ase_optable_index(l);
104
105         return _ent_unop(op, lt, l);
106 }
107
108 #define _ent_unop_neg(_t, _o)   _ent_unop(ASE_UNARY_OP_NEG, _t, _o)
109 #define ent_unop_neg(_o)        ent_unop(ASE_UNARY_OP_NEG, _o)
110 #define _ent_unop_inv(_t, _o)   _ent_unop(ASE_UNARY_OP_INV, _t, _o)
111 #define ent_unop_inv(_o)        ent_unop(ASE_UNARY_OP_INV, _o)
112
113
114 EXFUN(Fent_unop_neg, MANY);
115 EXFUN(Fent_unop_inv, MANY);
116
117 extern void syms_of_ent_unary_op(void);
118 extern void vars_of_ent_unary_op(void);
119
120 #endif  /* INCLUDED_ent_unary_op_h_ */