Class: FOMA::FSM
- Inherits:
-
Object
- Object
- FOMA::FSM
- Defined in:
- ext/foma.c
Instance Method Summary collapse
Constructor Details
#initialize(filename) ⇒ Object
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 66 67 68 |
# File 'ext/foma.c', line 38
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_PTR(filename), "rb");
if (!file) {
free(t);
rb_raise(rb_eRuntimeError, "unable to open file");
}
fclose(file);
t->net = fsm_read_binary_file(RSTRING_PTR(filename));
if (!t->net) {
free(t);
rb_raise(rb_eRuntimeError, "unable to read file");
}
t->ah = apply_init(t->net);
DATA_PTR(obj) = t;
return Qnil;
}
|
Instance Method Details
#apply_down(string) ⇒ Object
105 106 107 108 |
# File 'ext/foma.c', line 105
static VALUE foma_fsm_apply_down(VALUE self, VALUE string)
{
return foma_fsm_apply(self, string, &apply_down);
}
|
#apply_up(string) ⇒ Object
110 111 112 113 |
# File 'ext/foma.c', line 110
static VALUE foma_fsm_apply_up(VALUE self, VALUE string)
{
return foma_fsm_apply(self, string, &apply_up);
}
|