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

112 lines
2.9 KiB
C++
Raw Normal View History

#include "rr.h"
namespace rr {
2012-05-01 14:53:01 -04:00
void Context::Init() {
ClassBuilder("Context").
defineSingletonMethod("New", &New).
2012-05-08 17:04:47 -04:00
defineSingletonMethod("GetCurrent", &GetCurrent).
defineSingletonMethod("GetEntered", &GetEntered).
defineSingletonMethod("GetCalling", &GetCalling).
defineSingletonMethod("InContext", &InContext).
defineMethod("Global", &Global).
defineMethod("DetachGlobal", &Global).
defineMethod("ReattachGlobal", &ReattachGlobal).
defineMethod("SetSecurityToken", &SetSecurityToken).
defineMethod("UseDefaultSecurityToken", &UseDefaultSecurityToken).
defineMethod("GetSecurityToken", &GetSecurityToken).
defineMethod("HasOutOfMemoryException", &HasOutOfMemoryException).
defineMethod("SetData", &SetData).
defineMethod("GetData", &GetData).
defineMethod("AllowCodeGenerationFromStrings", &AllowCodeGenerationFromStrings).
defineMethod("IsCodeGenerationFromStringsAllowed", &IsCodeGenerationFromStringsAllowed).
defineMethod("Enter", &Enter).
2012-05-08 17:04:47 -04:00
defineMethod("Exit", &Exit).
store(&Class);
}
VALUE Context::Global(VALUE self) {
return Object(Context(self)->Global());
2012-05-08 17:04:47 -04:00
}
VALUE Context::DetachGlobal(VALUE self) {
Context(self)->DetachGlobal();
return Qnil;
}
VALUE Context::ReattachGlobal(VALUE self, VALUE global) {
Context(self)->ReattachGlobal(Object(global));
return Qnil;
}
VALUE Context::GetEntered(VALUE self) {
return Context(v8::Context::GetEntered());
2012-05-08 17:04:47 -04:00
}
VALUE Context::GetCurrent(VALUE self) {
return Context(v8::Context::GetCurrent());
2012-05-08 17:04:47 -04:00
}
VALUE Context::GetCalling(VALUE self) {
return Context(v8::Context::GetCalling());
2012-05-08 17:04:47 -04:00
}
VALUE Context::SetSecurityToken(VALUE self, VALUE token) {
Context(self)->SetSecurityToken(Value(token));
return Qnil;
}
VALUE Context::UseDefaultSecurityToken(VALUE self) {
Context(self)->UseDefaultSecurityToken();
return Qnil;
}
VALUE Context::GetSecurityToken(VALUE self) {
return Value(Context(self)->GetSecurityToken());
2012-05-08 17:04:47 -04:00
}
VALUE Context::HasOutOfMemoryException(VALUE self) {
return Bool(Context(self)->HasOutOfMemoryException());
2012-05-08 17:04:47 -04:00
}
VALUE Context::InContext(VALUE self) {
return Bool(v8::Context::InContext());
2012-05-08 17:04:47 -04:00
}
VALUE Context::SetData(VALUE self, VALUE data) {
Context(self)->SetData(String(data));
return Qnil;
}
VALUE Context::GetData(VALUE self) {
return Value(Context(self)->GetData());
2012-05-08 17:04:47 -04:00
}
VALUE Context::AllowCodeGenerationFromStrings(VALUE self, VALUE allow) {
Context(self)->AllowCodeGenerationFromStrings(RTEST(allow));
return Qnil;
}
VALUE Context::IsCodeGenerationFromStringsAllowed(VALUE self) {
return Bool(Context(self)->IsCodeGenerationFromStringsAllowed());
}
2012-05-01 14:53:01 -04:00
VALUE Context::New(VALUE ContextClass) {
v8::Persistent<v8::Context> context = v8::Context::New();
Context reference(context);
context.Dispose();
return reference;
}
2012-05-01 14:53:01 -04:00
VALUE Context::Enter(VALUE self) {
Context(self)->Enter();
return Qnil;
}
2012-05-01 14:53:01 -04:00
VALUE Context::Exit(VALUE self) {
Context(self)->Exit();
return Qnil;
}
}