mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
add third param context(NULL) to mrb_parse_string()
+12
-3
@@ -6,8 +6,7 @@
|
||||
#include <mruby.h>
|
||||
#include <mruby/proc.h>
|
||||
#include <mruby/data.h>
|
||||
// to be replaced by #include <mruby/compile.h>
|
||||
#include <compile.h>
|
||||
#include <mruby/compile.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
@@ -16,7 +15,7 @@ int main(void)
|
||||
char code[] = "p 'hello world!'";
|
||||
printf("Executing Ruby code from C!\n");
|
||||
|
||||
p = mrb_parse_string(mrb, code);
|
||||
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));
|
||||
@@ -26,5 +25,15 @@ int main(void)
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
compile & link
|
||||
```
|
||||
$ gcc -Iinclude hello.c lib/libmruby.a -lm -o hello.out
|
||||
```
|
||||
execute
|
||||
```
|
||||
$ ./hello.out
|
||||
Executing Ruby code from C!
|
||||
"hello world!"
|
||||
```
|
||||
|
||||
For more information on [getting started](http://matt.aimonetti.net/posts/2012/04/25/getting-started-with-mruby/), you can read this [introduction blog post](http://matt.aimonetti.net/posts/2012/04/25/getting-started-with-mruby/).
|
||||
Reference in New Issue
Block a user