2 ase.h -- Fancifying ENT a little
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_ase_h_
40 #define INCLUDED_ase_h_ 1
42 #include "semaphore.h"
45 #ifdef ALL_DEBUG_FLAGS
46 #undef EMOD_ASE_DEBUG_FLAG
47 #define EMOD_ASE_DEBUG_FLAG
50 #define __EMOD_ASE_DEBUG__(args...) fprintf(stderr, "emodule(ASE) " args)
51 #ifndef EMOD_ASE_DEBUG_FLAG
52 #define EMOD_ASE_DEBUG(args...)
53 #define EMOD_ASE_DEBUG_DMP(args...)
55 #define EMOD_ASE_DEBUG(args...) __EMOD_ASE_DEBUG__(args)
56 #define EMOD_ASE_DEBUG_DMP(args...) fprintf(stderr, args)
58 #define EMOD_ASE_DEBUG_GC(args...) EMOD_ASE_DEBUG("[GC]: " args)
59 #define EMOD_ASE_CRITICAL(args...) __EMOD_ASE_DEBUG__("CRITICAL: " args)
62 #elif defined(__GNUC__)
63 # define SXE_UNUSED(x) UNUSED_ ## x __attribute__((unused))
64 #elif defined(__LCLINT__)
65 # define SXE_UNUSED(x) /*@unused@*/ x
67 # define SXE_UNUSED(x) x
71 typedef long unsigned int ase_hash_t;
73 #ifdef EMOD_ASE_MONOMOD
74 extern void ase_mono_LTX_init(void);
76 extern void ase_LTX_init(void);
77 extern void ase_LTX_reinit(void);
78 extern void ase_LTX_deinit(void);
81 typedef int(*ase_relation_f)(Lisp_Object, Lisp_Object);
82 typedef int(*ase_c_relation_f)(Lisp_Object, Lisp_Object); /* compatible */
83 typedef int(*ase_r_relation_f)(Lisp_Object, Lisp_Object); /* reflexive */
84 typedef int(*ase_s_relation_f)(Lisp_Object, Lisp_Object); /* symmetric */
85 typedef int(*ase_t_relation_f)(Lisp_Object, Lisp_Object); /* transitive */
86 typedef int(*ase_cr_relation_f)(Lisp_Object, Lisp_Object);
87 typedef int(*ase_cs_relation_f)(Lisp_Object, Lisp_Object);
88 typedef int(*ase_ct_relation_f)(Lisp_Object, Lisp_Object);
89 typedef int(*ase_rs_relation_f)(Lisp_Object, Lisp_Object);
90 typedef int(*ase_rt_relation_f)(Lisp_Object, Lisp_Object);
91 typedef int(*ase_st_relation_f)(Lisp_Object, Lisp_Object);
92 typedef int(*ase_crs_relation_f)(Lisp_Object, Lisp_Object);
93 typedef int(*ase_crt_relation_f)(Lisp_Object, Lisp_Object);
94 typedef int(*ase_cst_relation_f)(Lisp_Object, Lisp_Object);
95 typedef int(*ase_equivalence_relation_f)(Lisp_Object, Lisp_Object); /* r+s+t */
96 typedef int(*ase_congruence_relation_f)(Lisp_Object, Lisp_Object); /* c+r+s+t */
97 typedef Lisp_Object(*ase_element_relation_f)(Lisp_Object, Lisp_Object);
99 typedef ase_t_relation_f ase_order_relation_f; /* special context! */
101 /* generic ase objects */
102 typedef struct ase_object_impl_s *ase_object_impl_t;
103 typedef void *ase_object_options_t;
104 typedef struct ase_object_s *ase_object_t;
106 typedef ase_object_t(*ase_object_constr_f)(ase_object_options_t opts, ...);
107 typedef void(*ase_object_destr_f)(ase_object_t);
108 typedef ase_hash_t(*ase_object_hash_f)(ase_object_t);
109 typedef struct ase_category_s *ase_category_t;
110 typedef long unsigned int ase_description_t;
111 typedef ase_description_t ase_object_d;
113 struct ase_object_impl_s {
114 ase_object_constr_f constrf;
115 ase_object_destr_f destrf;
116 ase_object_hash_f hashf;
119 struct ase_object_s {
120 /* the `capabilities' of the particular object */
121 ase_object_impl_t impl;
122 ase_object_options_t options;
123 /* the category of the object's world, i.e. where the object lives in */
124 ase_category_t category;
125 /* properties of this particular object
126 * these depend upon the world of the object */
127 ase_object_d properties;
132 struct ase_category_s {
143 _ase_less_p(Lisp_Object, Lisp_Object);
145 _ase_greater_p(Lisp_Object, Lisp_Object);
147 _ase_equal_p(Lisp_Object, Lisp_Object);
149 _ase_lessequal_p(Lisp_Object, Lisp_Object);
151 _ase_greaterequal_p(Lisp_Object, Lisp_Object);
153 _ase_swap(Lisp_Object *args, int idx1, int idx2);
157 _ase_less_p(Lisp_Object a, Lisp_Object b)
159 return ent_binrel(ASE_BINARY_REL_LESSP, a, b);
162 _ase_greater_p(Lisp_Object a, Lisp_Object b)
164 return ent_binrel(ASE_BINARY_REL_GREATERP, a, b);
167 _ase_equal_p(Lisp_Object a, Lisp_Object b)
169 return ent_binrel(ASE_BINARY_REL_EQUALP, a, b);
172 _ase_lessequal_p(Lisp_Object a, Lisp_Object b)
174 return ent_binrel2(ASE_BINARY_REL_LESSP,
175 ASE_BINARY_REL_EQUALP, a, b);
178 _ase_greaterequal_p(Lisp_Object a, Lisp_Object b)
180 return ent_binrel2(ASE_BINARY_REL_GREATERP,
181 ASE_BINARY_REL_EQUALP, a, b);
185 _ase_swap(Lisp_Object *args, int idx1, int idx2)
187 Lisp_Object foo = args[idx1];
188 args[idx1] = args[idx2];
193 #define DEFASETYPE_WITH_OPS(_tsym, _tstr) \
195 defsymbol(&_tsym, _tstr); \
196 ase_optable_add(_tsym); \
199 #endif /* INCLUDED_ase_h_ */