Initial git import
[sxemacs] / src / ent / ent-unary-rel.c
1 /*
2   ent-unary-rel.c -- Global Unary Relations
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 #include <config.h>
40 #include "lisp.h"
41 #include "ent-unary-rel.h"
42
43 ase_unary_relation_f ase_unary_reltable
44 [N_ASE_UNARY_RELS][ASE_OPTABLE_SIZE];
45
46 \f
47 int
48 ase_unary_relation_undefined(Lisp_Object l)
49 {
50         Fsignal(Qrelation_error, list1(l));
51         return 0;
52 }
53
54 static inline void
55 _ase_unary_reltable_init(ase_unary_relation_t rel)
56 {
57         ase_object_type_t i;
58         for (i = 0; i < ASE_OPTABLE_SIZE; i++) {
59                 ent_unrel_unregister(rel, i);
60         }
61 }
62
63 void
64 ase_unary_reltable_init(void)
65 {
66         ase_unary_relation_t rel;
67         for (rel = ASE_UNARY_FIRST_REL; rel < N_ASE_UNARY_RELS; rel++) {
68                 _ase_unary_reltable_init(rel);
69         }
70 }
71
72 \f
73 DEFUN("zerop", Fzerop, 1, 1, 0, /*
74 Return t if NUMBER is a zero.
75 */
76       (number))
77 {
78         if (!ent_unrel(ASE_UNARY_REL_ZEROP, number))
79                 return Qnil;
80         else
81                 return Qt;
82 }
83
84 DEFUN("onep", Fonep, 1, 1, 0,   /*
85 Return t if NUMBER is a one.
86 */
87       (number))
88 {
89         if (!ent_unrel(ASE_UNARY_REL_ONEP, number))
90                 return Qnil;
91         else
92                 return Qt;
93 }
94
95 DEFUN("unitp", Funitp, 1, 1, 0, /*
96 Return t if NUMBER is a unit, nil otherwise.
97 That is, if there exists another number B, such that
98   NUMBER * B = 1
99 */
100       (number))
101 {
102         if (!ent_unrel(ASE_UNARY_REL_UNITP, number))
103                 return Qnil;
104         else
105                 return Qt;
106 }
107
108 \f
109 void
110 syms_of_ent_unary_rel(void)
111 {
112         DEFSUBR(Fzerop);
113         DEFSUBR(Fonep);
114         DEFSUBR(Funitp);
115 }
116
117 void
118 vars_of_ent_unary_rel(void)
119 {
120 }
121
122 /* ent-unary-rel.c ends here */