Debian Codegraph @

3rdparty/flite_hts_engine/flite/include/cst_val.h

raw symbols SCIP
1 /*************************************************************************/
2 /* */
3 /* Language Technologies Institute */
4 /* Carnegie Mellon University */
5 /* Copyright (c) 1999 */
6 /* All Rights Reserved. */
7 /* */
8 /* Permission is hereby granted, free of charge, to use and distribute */
9 /* this software and its documentation without restriction, including */
10 /* without limitation the rights to use, copy, modify, merge, publish, */
11 /* distribute, sublicense, and/or sell copies of this work, and to */
12 /* permit persons to whom this work is furnished to do so, subject to */
13 /* the following conditions: */
14 /* 1. The code must retain the above copyright notice, this list of */
15 /* conditions and the following disclaimer. */
16 /* 2. Any modifications must be clearly marked as such. */
17 /* 3. Original authors' names are not deleted. */
18 /* 4. The authors' names are not used to endorse or promote products */
19 /* derived from this software without specific prior written */
20 /* permission. */
21 /* */
22 /* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
23 /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24 /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25 /* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
26 /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27 /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28 /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29 /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30 /* THIS SOFTWARE. */
31 /* */
32 /*************************************************************************/
33 /* Author: Alan W Black ([email protected]) */
34 /* Date: December 1999 */
35 /*************************************************************************/
36 /* */
37 /* Vals, typed objects */
38 /* */
39 /*************************************************************************/
40
41 /* ----------------------------------------------------------------- */
42 /* The English TTS System "Flite+hts_engine" */
43 /* developed by HTS Working Group */
44 /* http://hts-engine.sourceforge.net/ */
45 /* ----------------------------------------------------------------- */
46 /* */
47 /* Copyright (c) 2005-2013 Nagoya Institute of Technology */
48 /* Department of Computer Science */
49 /* */
50 /* 2005-2008 Tokyo Institute of Technology */
51 /* Interdisciplinary Graduate School of */
52 /* Science and Engineering */
53 /* */
54 /* All rights reserved. */
55 /* */
56 /* Redistribution and use in source and binary forms, with or */
57 /* without modification, are permitted provided that the following */
58 /* conditions are met: */
59 /* */
60 /* - Redistributions of source code must retain the above copyright */
61 /* notice, this list of conditions and the following disclaimer. */
62 /* - Redistributions in binary form must reproduce the above */
63 /* copyright notice, this list of conditions and the following */
64 /* disclaimer in the documentation and/or other materials provided */
65 /* with the distribution. */
66 /* - Neither the name of the HTS working group nor the names of its */
67 /* contributors may be used to endorse or promote products derived */
68 /* from this software without specific prior written permission. */
69 /* */
70 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */
71 /* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */
72 /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
73 /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
74 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */
75 /* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */
76 /* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
77 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */
78 /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
79 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
80 /* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY */
81 /* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
82 /* POSSIBILITY OF SUCH DAMAGE. */
83 /* ----------------------------------------------------------------- */
84
85 #ifndef _CST_VAL_H__
86 #define _CST_VAL_H__
87
88 #include "cst_file.h"
89 #include "cst_string.h"
90 #include "cst_error.h"
91 #include "cst_alloc.h"
92 #include "cst_val_defs.h"
93
94 /* Only CONS can be an even number */
95 #define CST_VAL_TYPE_CONS 0
96 #define CST_VAL_TYPE_INT 1
97 #define CST_VAL_TYPE_FLOAT 3
98 #define CST_VAL_TYPE_STRING 5
99 #define CST_VAL_TYPE_FIRST_FREE 7
100 #define CST_VAL_TYPE_MAX 54
101
102 typedef struct cst_val_cons_struct {
103 struct cst_val_struct *car;
104 struct cst_val_struct *cdr;
105 } cst_val_cons;
106
107 typedef struct cst_val_atom_struct {
108 #ifdef WORDS_BIGENDIAN
109 #if defined(SIZEOF_VOID_P) && SIZEOF_VOID_P == 8
110 int ref_count;
111 int type;
112 #else
113 short ref_count;
114 short type; /* order is here important */
115 #endif
116 #else
117 #if defined(SIZEOF_VOID_P) && SIZEOF_VOID_P == 8
118 int type;
119 int ref_count;
120 #else
121 short type; /* order is here important */
122 short ref_count;
123 #endif
124 #endif
125 union
126 {
127 float fval;
128 int ival;
129 void *vval;
130 } v;
131 } cst_val_atom;
132
133 typedef struct cst_val_struct {
134 union
135 {
136 cst_val_cons cc;
137 cst_val_atom a;
138 } c;
139 } cst_val;
140
141 typedef struct cst_val_def_struct {
142 const char *name;
143 void (*delete_function)(void *);
144 } cst_val_def;
145
146 /* Constructor functions */
147 cst_val *int_val(int i);
148 cst_val *float_val(float f);
149 cst_val *string_val(const char *s);
150 cst_val *val_new_typed(int type, void *vv);
151 cst_val *cons_val(const cst_val *a, const cst_val *b);
152
153 /* Derefence and delete val if no other references */
154 void delete_val(cst_val *val);
155 void delete_val_list(cst_val *val);
156
157 /* Accessor functions */
158 int val_int(const cst_val *v);
159 float val_float(const cst_val *v);
160 const char *val_string(const cst_val *v);
161 void *val_void(const cst_val *v);
162 void *val_generic(const cst_val *v, int type, const char *stype);
163 const cst_val *val_car(const cst_val *v);
164 const cst_val *val_cdr(const cst_val *v);
165
166 const cst_val *set_cdr(cst_val *v1, const cst_val *v2);
167 const cst_val *set_car(cst_val *v1, const cst_val *v2);
168
169 int cst_val_consp(const cst_val *v);
170
171 /* Unsafe accessor function -- for the brave and foolish */
172 #define CST_VAL_STRING_LVAL(X) ((X)->c.a.v.vval)
173 #define CST_VAL_TYPE(X) ((X)->c.a.type)
174 #define CST_VAL_INT(X) ((X)->c.a.v.ival)
175 #define CST_VAL_FLOAT(X) ((X)->c.a.v.fval)
176 #define CST_VAL_STRING(X) ((const char *)(CST_VAL_STRING_LVAL(X)))
177 #define CST_VAL_VOID(X) ((X)->c.a.v.vval)
178 #define CST_VAL_CAR(X) ((X)->c.cc.car)
179 #define CST_VAL_CDR(X) ((X)->c.cc.cdr)
180
181 #define CST_VAL_REFCOUNT(X) ((X)->c.a.ref_count)
182
183 /* Some standard function */
184 int val_equal(const cst_val *a, const cst_val *b);
185 int val_less(const cst_val *a, const cst_val *b);
186 int val_greater(const cst_val *a, const cst_val *b);
187 int val_member(const cst_val *a, const cst_val *b);
188 int val_member_string (const char *a, const cst_val *b);
189 int val_stringp(const cst_val *a);
190 const cst_val *val_assoc_string(const char *v1,const cst_val *al);
191
192 void val_print(cst_file fd,const cst_val *v);
193 cst_val *val_reverse(cst_val *v);
194 cst_val *val_append(cst_val *a,cst_val *b);
195 int val_length(const cst_val *l);
196 cst_val *cst_utf8_explode(const cst_string *utf8string);
197 cst_string *cst_implode(const cst_val *string_list);
198
199 /* make sure you know what you are doing before you call these */
200 int val_dec_refcount(const cst_val *b);
201 cst_val *val_inc_refcount(const cst_val *b);
202
203 #include "cst_val_const.h"
204 extern const cst_val_def cst_val_defs[];
205
206 /* Generic pointer vals */
207 typedef void cst_userdata;
208 CST_VAL_USER_TYPE_DCLS(userdata,cst_userdata)
209
210 #endif