From a9c4ecb7187521411322f2724d6c80dbf08f7108 Mon Sep 17 00:00:00 2001 From: magewhopper Date: Thu, 5 Jul 2012 06:15:29 -0700 Subject: [PATCH] changes to mrb_load_string() version --- Hello-World.md | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/Hello-World.md b/Hello-World.md index e17b072..0c9a8c5 100644 --- a/Hello-World.md +++ b/Hello-World.md @@ -4,24 +4,15 @@ /* Include the mruby header */ #include -#include -#include #include int main(void) { - struct mrb_parser_state *p; mrb_state *mrb = mrb_open(); char code[] = "p 'hello world!'"; printf("Executing Ruby code from C!\n"); - p = mrb_parse_string(mrb, code, NULL); - int n; - n = mrb_generate_code(mrb, p->tree); - mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb)); - if (mrb->exc) { - mrb_p(mrb, mrb_obj_value(mrb->exc)); - } + mrb_load_string(mrb, code); return 0; } ``` @@ -29,7 +20,7 @@ compile & link ``` $ gcc -Iinclude hello.c lib/libmruby.a -lm -o hello.out ``` -execute +execution ``` $ ./hello.out Executing Ruby code from C!