2009-12-07 02:20:16 -05:00
|
|
|
|
|
|
|
#include "v8_cxt.h"
|
|
|
|
#include "ruby.h"
|
|
|
|
|
|
|
|
using namespace v8;
|
|
|
|
|
|
|
|
VALUE v8_cxt_allocate(VALUE clazz) {
|
2009-12-09 09:30:48 -05:00
|
|
|
return V8_Ref_Create(clazz, Context::New());
|
2009-12-07 09:06:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE v8_cxt_Global(VALUE self) {
|
2009-12-09 09:30:48 -05:00
|
|
|
V8_Ref_Get(Context, cxt, self);
|
2009-12-07 09:06:06 -05:00
|
|
|
cxt->Global();
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE v8_cxt_open(VALUE self) {
|
|
|
|
HandleScope handles;
|
2009-12-09 09:30:48 -05:00
|
|
|
V8_Ref_Get(Context, cxt, self);
|
2009-12-07 09:06:06 -05:00
|
|
|
Context::Scope enter(cxt);
|
|
|
|
if (rb_block_given_p()) {
|
|
|
|
return rb_yield(self);
|
|
|
|
} else {
|
|
|
|
return Qnil;
|
|
|
|
}
|
2009-12-07 02:20:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|