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

28 lines
654 B
C++
Raw Normal View History

#include "rr.h"
namespace rr {
2012-05-01 11:53:01 -07:00
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() {
2012-05-02 16:15:11 -07:00
VALUE ContextClass = defineClass("Context");
2012-05-01 11:53:01 -07:00
RR_DEFINE_SINGLETON_METHOD(ContextClass, "New", &New, 0);
RR_DEFINE_METHOD(ContextClass, "Enter", &Enter, 0);
RR_DEFINE_METHOD(ContextClass, "Exit", &Exit, 0);
}
}