From 6bb56ed9201c10738404aef3f5a375145cba1153 Mon Sep 17 00:00:00 2001 From: take_cheeze Date: Mon, 16 Jun 2014 15:28:04 +0900 Subject: add mrb_open_without_mrbgems API --- src/state.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/state.c') diff --git a/src/state.c b/src/state.c index 3e82a159d..f264a8eba 100644 --- a/src/state.c +++ b/src/state.c @@ -14,6 +14,7 @@ void mrb_init_heap(mrb_state*); void mrb_init_core(mrb_state*); +void mrb_init_mrbgems(mrb_state*); static mrb_value inspect_main(mrb_state *mrb, mrb_value mod) @@ -21,8 +22,8 @@ inspect_main(mrb_state *mrb, mrb_value mod) return mrb_str_new_lit(mrb, "main"); } -mrb_state* -mrb_open_allocf(mrb_allocf f, void *ud) +static mrb_state* +mrb_open_common(mrb_allocf f, void *ud, mrb_bool with_gems) { static const mrb_state mrb_state_zero = { 0 }; static const struct mrb_context mrb_context_zero = { 0 }; @@ -50,8 +51,16 @@ mrb_open_allocf(mrb_allocf f, void *ud) mrb->c = (struct mrb_context*)mrb_malloc(mrb, sizeof(struct mrb_context)); *mrb->c = mrb_context_zero; mrb->root_c = mrb->c; + mrb_init_core(mrb); +#ifndef DISABLE_GEMS + if (with_gems) { + mrb_init_mrbgems(mrb); + mrb_gc_arena_restore(mrb, 0); + } +#endif + return mrb; } @@ -107,6 +116,18 @@ mrb_open(void) return mrb; } +mrb_state* +mrb_open_allocf(mrb_allocf f, void *ud) +{ + return mrb_open_common(f, ud, TRUE); +} + +mrb_state* +mrb_open_without_mrbgems(mrb_allocf f, void *ud) +{ + return mrb_open_common(f, ud, FALSE); +} + void mrb_free_symtbl(mrb_state *mrb); void mrb_free_heap(mrb_state *mrb); -- cgit v1.2.3