1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00
therubyracer/ext/v8/context.cc
2012-05-09 14:46:04 -05:00

28 lines
No EOL
654 B
C++

#include "rr.h"
namespace rr {
VALUE New(VALUE ContextClass) {
v8::Persistent<v8::Context> context = v8::Context::New();
Ref<v8::Context> ref = Ref<v8::Context>::create(context, ContextClass);
context.Dispose();
return ref;
}
VALUE Enter(VALUE self) {
Context(self)->Enter();
return Qnil;
}
VALUE Exit(VALUE self) {
Context(self)->Exit();
return Qnil;
}
void Context::Init() {
VALUE ContextClass = defineClass("Context");
RR_DEFINE_SINGLETON_METHOD(ContextClass, "New", &New, 0);
RR_DEFINE_METHOD(ContextClass, "Enter", &Enter, 0);
RR_DEFINE_METHOD(ContextClass, "Exit", &Exit, 0);
}
}