47#include "ling_class/EST_Utterance.h"
48#include "ling_class/EST_Item.h"
51#include "EST_wave_aux.h"
53#include "EST_track_aux.h"
55Declare_TStringHash_Base(
LISP,(
LISP)0,NIL)
57#if defined(INSTANTIATE_TEMPLATES)
58#include "../base_class/EST_THash.cc"
60Instantiate_TStringHash(
LISP)
87static int tc_utt = -1;
88static int tc_val = -1;
95 err(
"wrong type of argument to get_c_utt",
x);
100int utterance_p(
LISP x)
114 void_to_addrname(u,
saddr);
120 utt = siod_make_typed_cell(tc_utt,(
void *)u);
133 void_to_addrname(u,
saddr);
142 USERVAL(
lutt) = NULL;
156 return *((
class EST_Val *)
x->storage_as.val.
v);
159 err(
"wrong type of argument to get_c_val",
x);
168 if (val(a) == val(b))
184 return siod_make_typed_cell(tc_val,
new EST_Val(v));
187static void val_free(
LISP val)
194static void val_prin1(
LISP v,
FILE *fd)
198 fput_st(fd,val(v).
type());
199 sprintf(b,
" %p",val(v).internal_ptr());
204static void val_print_string(
LISP v,
char *tkbuffer)
206 sprintf(tkbuffer,
"#<%s %p>",val(v).
type(),val(v).internal_ptr());
223struct obj_val {
LISP l;};
226 if (v.
type() == val_type_scheme)
227 return ((obj_val *)v.internal_ptr())->l;
229 EST_error(
"val not of type val_type_scheme");
232static void val_delete_scheme(
void *v)
234 struct obj_val *
ov = (
struct obj_val *)v;
235 gc_unprotect(&
ov->l);
241 struct obj_val *
ov = walloc(
struct obj_val,1);
244 return EST_Val(val_type_scheme,
251 if (
pv.type() == val_unset)
253 cerr <<
"EST_Val unset, can't build lisp value" <<
endl;
257 else if (
pv.type() == val_int)
258 return flocons(
pv.Int());
259 else if (
pv.type() == val_float)
260 return flocons(
pv.Float());
261 else if (
pv.type() == val_string)
262 return strintern(
pv.string_only());
263 else if (
pv.type() == val_type_scheme)
266 return features_to_lisp(*
feats(
pv));
271static int feature_like(
LISP v)
274 if ((v == NIL) || (!consp(v)))
279 for (p=v; p != NIL; p=cdr(p))
281 if (!consp(p) || (!consp(car(p))) || (consp(car(car(p)))))
293 lisp_to_features(v,*f);
297 return EST_Val(get_c_float(v));
298 else if (TYPEP(v,tc_val))
300 else if (TYPEP(v,tc_symbol) || (TYPEP(v,tc_string)))
312 for(p.begin(
kvl); p; ++p)
314 l=cons(cons(rintern(p->
k),
315 cons(lisp_val(p->
v),NIL)),
326 for (p=l; p; p = cdr(p))
327 kvl.add_item(get_c_string(car(car(p))),
328 get_c_string(car(cdr(car(p)))));
337 for(p.
begin(f); p; ++p)
339 lf=cons(cons(rintern(p->
k),
340 cons(lisp_val(p->
v),NIL)),
351 for (p=
lf; p; p = cdr(p))
352 f.set_val(get_c_string(car(car(p))),
353 val_lisp(car(cdr(car(p)))));
371 return lisp_val(
feats(f)->val_path(get_c_string(
fname)));
374static LISP feats_make()
382 return features_to_lisp(*
feats(
lf));
388 f->remove(get_c_string(
fname));
395 if (f->present(get_c_string(
fname)))
423 tc_utt = siod_register_user_type(
"Utterance");
424 set_gc_hooks(tc_utt, 0, NULL,utt_mark,NULL,utt_free,NULL,&
kind);
426 tc_val = siod_register_user_type(
"Val");
427 set_gc_hooks(tc_val, 0, NULL,NULL,NULL,val_free,NULL,&
kind);
428 set_print_hooks(tc_val,val_prin1,val_print_string);
429 set_type_hooks(tc_val,NULL,val_equal);
431 init_subr_2(
"feats.get",feats_get,
432 "(feats.get FEATS FEATNAME)\n\
433 Return value of FEATNAME (which may be a simple feature name or a\n\
434 pathname) in FEATS. If FEATS is nil a new feature set is created");
435 init_subr_3(
"feats.set",feats_set,
436 "(feats.set FEATS FEATNAME VALUE)\n\
437 Set FEATNAME to VALUE in FEATS.");
438 init_subr_2(
"feats.remove",feats_remove,
439 "(feats.remove FEATS FEATNAME)\n\
440 Remove feature names FEATNAME from FEATS.");
441 init_subr_2(
"feats.present",feats_present,
442 "(feats.present FEATS FEATNAME)\n\
443 Return t is FEATNAME is present in FEATS, nil otherwise.");
444 init_subr_0(
"feats.make",feats_make,
446 Return an new empty features object.");
447 init_subr_1(
"feats.tolisp",feats_tolisp,
448 "(feats.tolisp FEATS)\n\
449 Gives a lisp representation of the features, this is a debug function\n\
450 and may or may not exist tomorrow.");
void begin(const Container &over)
Set the iterator ready to run over this container.
const val_type type(void) const