/
phuby.c
41 lines (31 loc) · 815 Bytes
/
phuby.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <phuby.h>
VALUE mPhuby;
VALUE cPhubyRuntime;
static VALUE start(VALUE self)
{
/* FIXME:
* I got these from the book. I don't know wtf they're for yet. */
int argc = 1;
char *argv[2] = { "embed4", NULL };
php_embed_init(argc, argv);
return Qnil;
}
static VALUE native_eval(VALUE self, VALUE string, VALUE filename)
{
zend_first_try {
zend_eval_string(
StringValuePtr(string),
NULL,
StringValuePtr(filename)
);
} zend_end_try();
return Qnil;
}
void Init_phuby()
{
mPhuby = rb_define_module("Phuby");
/* FIXME: This belongs in it's own .c file */
cPhubyRuntime = rb_define_class_under(mPhuby, "Runtime", rb_cObject);
rb_define_method(cPhubyRuntime, "start", start, 0);
rb_define_private_method(cPhubyRuntime, "native_eval", native_eval, 2);
}