Class: FOMA::FSM
- Inherits:
-
Object
- Object
- FOMA::FSM
- Defined in:
- ext/foma.c
Instance Method Summary collapse
Constructor Details
#initialize(filename) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'ext/foma.c', line 34
static VALUE foma_fsm_init(VALUE obj, VALUE filename)
{
FILE *file;
struct foma_fsm *t;
t = malloc(sizeof(struct foma_fsm));
if (!t) {
rb_raise(rb_eRuntimeError, "Error allocating memory");
}
file = fopen(RSTRING(filename)->ptr, "rb");
if (!file) {
free(t);
rb_raise(rb_eRuntimeError, "Unable to open file %s", RSTRING(filename)->ptr);
}
fclose(file);
t->net = fsm_read_binary_file(RSTRING(filename)->ptr);
if (!t->net) {
free(t);
rb_raise(rb_eRuntimeError, "Unable to read file %s", RSTRING(filename)->ptr);
}
t->ah = apply_init(t->net);
DATA_PTR(obj) = t;
return Qnil;
}
|
Instance Method Details
#apply_down(string) ⇒ Object
92 93 94 95 |
# File 'ext/foma.c', line 92
static VALUE foma_fsm_apply_down(VALUE self, VALUE string)
{
return foma_fsm_apply(self, string, &apply_down);
}
|
#apply_up(string) ⇒ Object
97 98 99 100 |
# File 'ext/foma.c', line 97
static VALUE foma_fsm_apply_up(VALUE self, VALUE string)
{
return foma_fsm_apply(self, string, &apply_up);
}
|