mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
add mrb_open_without_mrbgems API
This commit is contained in:
committed by
Yukihiro "Matz" Matsumoto
parent
ad23483f32
commit
6bb56ed920
@@ -296,6 +296,7 @@ mrb_value mrb_str_new_static(mrb_state *mrb, const char *p, size_t len);
|
||||
|
||||
mrb_state* mrb_open(void);
|
||||
mrb_state* mrb_open_allocf(mrb_allocf, void *ud);
|
||||
mrb_state* mrb_open_without_mrbgems(mrb_allocf, void *ud);
|
||||
void mrb_close(mrb_state*);
|
||||
|
||||
mrb_value mrb_top_self(mrb_state *);
|
||||
|
||||
@@ -24,8 +24,6 @@ void mrb_init_gc(mrb_state*);
|
||||
void mrb_init_math(mrb_state*);
|
||||
void mrb_init_version(mrb_state*);
|
||||
void mrb_init_mrblib(mrb_state*);
|
||||
void mrb_init_mrbgems(mrb_state*);
|
||||
void mrb_final_mrbgems(mrb_state*);
|
||||
|
||||
#define DONE mrb_gc_arena_restore(mrb, 0);
|
||||
void
|
||||
@@ -50,7 +48,4 @@ mrb_init_core(mrb_state *mrb)
|
||||
mrb_init_gc(mrb); DONE;
|
||||
mrb_init_version(mrb); DONE;
|
||||
mrb_init_mrblib(mrb); DONE;
|
||||
#ifndef DISABLE_GEMS
|
||||
mrb_init_mrbgems(mrb); DONE;
|
||||
#endif
|
||||
}
|
||||
|
||||
+23
-2
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user