summaryrefslogtreecommitdiffhomepage
path: root/src/state.c
diff options
context:
space:
mode:
authortake_cheeze <[email protected]>2014-06-16 15:28:04 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-06-23 20:06:17 +0900
commit6bb56ed9201c10738404aef3f5a375145cba1153 (patch)
tree25e511363f9fd67f6ceed8e0452ea15699a06a40 /src/state.c
parentad23483f32d251eb06abb9df7bd14749c45fe030 (diff)
downloadmruby-6bb56ed9201c10738404aef3f5a375145cba1153.tar.gz
mruby-6bb56ed9201c10738404aef3f5a375145cba1153.zip
add mrb_open_without_mrbgems API
Diffstat (limited to 'src/state.c')
-rw-r--r--src/state.c25
1 files changed, 23 insertions, 2 deletions
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);