2 ent-unary-op.h -- Global Unary 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_unary_op_h_
40 #define INCLUDED_ent_unary_op_h_
42 #define ENT_DEBUG_UNOP(args...) ENT_DEBUG("[UNOP]: " args)
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);
51 enum ase_unary_operation_e {
53 ASE_UNARY_FIRST_OP = ASE_UNARY_OP_NEG,
55 ASE_UNARY_LAST_OP = ASE_UNARY_OP_INV,
59 extern ase_unary_operation_f ase_unary_optable
60 [N_ASE_UNARY_OPS][ASE_OPTABLE_SIZE];
62 extern Lisp_Object ase_unary_operation_undefined(Lisp_Object l);
65 ase_unary_operation_t op,
67 ase_unary_operation_f opf);
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);
77 ent_unop_register(ase_unary_operation_t op,
78 ase_object_type_t t, ase_unary_operation_f opf)
80 ase_unary_optable[op][t] = opf;
84 ent_unop_unregister(ase_unary_operation_t op, ase_object_type_t t)
86 ase_unary_optable[op][t] = ase_unary_operation_undefined;
90 extern void ase_unary_optable_init(void);
92 extern_inline Lisp_Object
93 _ent_unop(ase_unary_operation_t op, ase_object_type_t lt, Lisp_Object l)
95 ase_unary_operation_f opf =
96 ase_unary_optable[op][lt];
100 extern_inline Lisp_Object
101 ent_unop(ase_unary_operation_t op, Lisp_Object l)
103 ase_object_type_t lt = ase_optable_index(l);
105 return _ent_unop(op, lt, l);
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)
114 EXFUN(Fent_unop_neg, MANY);
115 EXFUN(Fent_unop_inv, MANY);
117 extern void syms_of_ent_unary_op(void);
118 extern void vars_of_ent_unary_op(void);
120 #endif /* INCLUDED_ent_unary_op_h_ */