From 883c45b931a7f1ed44fa3c629520f5481fe4fad3 Mon Sep 17 00:00:00 2001 From: Jun Hiroe Date: Fri, 12 Jul 2013 01:00:50 +0900 Subject: Replace mrb_intern() func with mrb_intern2() func or mrb_intern_cstr() func. --- src/variable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/variable.c') diff --git a/src/variable.c b/src/variable.c index 2610c5d7a..36ad24d09 100644 --- a/src/variable.c +++ b/src/variable.c @@ -916,7 +916,7 @@ mrb_const_remove(mrb_state *mrb, mrb_value mod, mrb_sym sym) void mrb_define_const(mrb_state *mrb, struct RClass *mod, const char *name, mrb_value v) { - mrb_obj_iv_set(mrb, (struct RObject*)mod, mrb_intern(mrb, name), v); + mrb_obj_iv_set(mrb, (struct RObject*)mod, mrb_intern_cstr(mrb, name), v); } void -- cgit v1.2.3 From 6bab0c65f097babf98098b249332664165881550 Mon Sep 17 00:00:00 2001 From: Jun Hiroe Date: Sun, 14 Jul 2013 04:03:57 +0900 Subject: Add comments in variable.c --- src/variable.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'src/variable.c') diff --git a/src/variable.c b/src/variable.c index 36ad24d09..52ffb42e7 100644 --- a/src/variable.c +++ b/src/variable.c @@ -27,12 +27,21 @@ typedef struct segment { struct segment *next; } segment; +/* Instance variable table structure */ typedef struct iv_tbl { segment *rootseg; size_t size; size_t last_len; } iv_tbl; +/* + * Creates instance variable table. + * + * Parameters + * mrb + * Returns + * the instance variable table. + */ static iv_tbl* iv_new(mrb_state *mrb) { @@ -47,6 +56,15 @@ iv_new(mrb_state *mrb) return t; } +/* + * Set the value for the symbol in the instance variable table. + * + * Parameters + * mrb + * t the instance variable table to be set in. + * sym the symbol to be used as the key. + * val the value to be set. + */ static void iv_put(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value val) { @@ -59,7 +77,7 @@ iv_put(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value val) while (seg) { for (i=0; ikey[i]; - /* found room in last segment after last_len */ + /* Found room in last segment after last_len */ if (!seg->next && i >= t->last_len) { seg->key[i] = sym; seg->val[i] = val; @@ -80,7 +98,7 @@ iv_put(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value val) seg = seg->next; } - /* not found */ + /* Not found */ t->size++; if (matched_seg) { matched_seg->key[matched_idx] = sym; @@ -103,6 +121,18 @@ iv_put(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value val) return; } +/* + * Get a value for a symbol from the instance the variable table. + * + * Parameters + * mrb + * t the variable table to be searched. + * sym the symbol to be used as the key. + * vp the value pointer. Recieves the value if if the specified symbol contains + * in the instance variable table. + * Returns + * true if the specfiyed symbol contains in the instance variable table. + */ static mrb_bool iv_get(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value *vp) { @@ -127,6 +157,17 @@ iv_get(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value *vp) return FALSE; } +/* + * Deletes the value for the symbol from the instance variable table. + * + * Parameters + * t the variable table to be searched. + * sym the symbol to be used as the key. + * vp the value pointer. Recieve the deleted value if the symbol contans + * in the instance varible table. + * Returns + * true if the specfied symbol contains in the instance variable table. + */ static mrb_bool iv_del(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value *vp) { -- cgit v1.2.3 From a202446c79b1f723a4717ec9a121a3657a6b6b38 Mon Sep 17 00:00:00 2001 From: Jun Hiroe Date: Wed, 24 Jul 2013 22:22:54 +0900 Subject: I fix typos in variable.c. --- src/variable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/variable.c') diff --git a/src/variable.c b/src/variable.c index 52ffb42e7..048b63bca 100644 --- a/src/variable.c +++ b/src/variable.c @@ -35,7 +35,7 @@ typedef struct iv_tbl { } iv_tbl; /* - * Creates instance variable table. + * Creates the instance variable table. * * Parameters * mrb @@ -128,7 +128,7 @@ iv_put(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value val) * mrb * t the variable table to be searched. * sym the symbol to be used as the key. - * vp the value pointer. Recieves the value if if the specified symbol contains + * vp the value pointer. Recieves the value if the specified symbol contains * in the instance variable table. * Returns * true if the specfiyed symbol contains in the instance variable table. -- cgit v1.2.3