2012-01-31 16:52:08 -05:00
|
|
|
#include "rr.h"
|
|
|
|
|
|
|
|
namespace rr {
|
2012-05-01 14:53:01 -04:00
|
|
|
|
2012-05-03 18:21:25 -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).
|
2012-05-03 18:21:25 -04:00
|
|
|
defineMethod("Enter", &Enter).
|
2012-05-08 17:04:47 -04:00
|
|
|
defineMethod("Exit", &Exit).
|
|
|
|
store(&Class);
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::Global(VALUE self) {
|
2012-05-15 17:49:01 -04:00
|
|
|
return Object(Context(self)->Global());
|
2012-05-08 17:04:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::DetachGlobal(VALUE self) {
|
2012-05-16 23:25:31 -04:00
|
|
|
Void(Context(self)->DetachGlobal());
|
2012-05-08 17:04:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::ReattachGlobal(VALUE self, VALUE global) {
|
2012-05-16 23:25:31 -04:00
|
|
|
Void(Context(self)->ReattachGlobal(Object(global)));
|
2012-05-08 17:04:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::GetEntered(VALUE self) {
|
2012-05-15 13:23:06 -04:00
|
|
|
return Context(v8::Context::GetEntered());
|
2012-05-08 17:04:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::GetCurrent(VALUE self) {
|
2012-05-15 13:23:06 -04:00
|
|
|
return Context(v8::Context::GetCurrent());
|
2012-05-08 17:04:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::GetCalling(VALUE self) {
|
2012-05-15 13:23:06 -04:00
|
|
|
return Context(v8::Context::GetCalling());
|
2012-05-08 17:04:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::SetSecurityToken(VALUE self, VALUE token) {
|
2012-05-16 23:25:31 -04:00
|
|
|
Void(Context(self)->SetSecurityToken(Value(token)));
|
2012-05-08 17:04:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::UseDefaultSecurityToken(VALUE self) {
|
2012-05-16 23:25:31 -04:00
|
|
|
Void(Context(self)->UseDefaultSecurityToken());
|
2012-05-08 17:04:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::GetSecurityToken(VALUE self) {
|
2012-05-15 17:49:01 -04:00
|
|
|
return Value(Context(self)->GetSecurityToken());
|
2012-05-08 17:04:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::HasOutOfMemoryException(VALUE self) {
|
2012-05-15 17:49:01 -04:00
|
|
|
return Bool(Context(self)->HasOutOfMemoryException());
|
2012-05-08 17:04:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::InContext(VALUE self) {
|
2012-05-15 17:49:01 -04:00
|
|
|
return Bool(v8::Context::InContext());
|
2012-05-08 17:04:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::SetData(VALUE self, VALUE data) {
|
2012-05-16 23:25:31 -04:00
|
|
|
Void(Context(self)->SetData(String(data)));
|
2012-05-08 17:04:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::GetData(VALUE self) {
|
2012-05-15 17:49:01 -04:00
|
|
|
return Value(Context(self)->GetData());
|
2012-05-08 17:04:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::AllowCodeGenerationFromStrings(VALUE self, VALUE allow) {
|
2012-05-16 23:25:31 -04:00
|
|
|
Void(Context(self)->AllowCodeGenerationFromStrings(RTEST(allow)));
|
2012-05-08 17:04:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::IsCodeGenerationFromStringsAllowed(VALUE self) {
|
2012-05-15 17:49:01 -04:00
|
|
|
return Bool(Context(self)->IsCodeGenerationFromStringsAllowed());
|
2012-05-03 18:21:25 -04:00
|
|
|
}
|
2012-05-01 14:53:01 -04:00
|
|
|
|
2012-05-03 18:21:25 -04:00
|
|
|
VALUE Context::New(VALUE ContextClass) {
|
|
|
|
v8::Persistent<v8::Context> context = v8::Context::New();
|
2012-05-15 13:23:06 -04:00
|
|
|
Context reference(context);
|
2012-05-03 18:21:25 -04:00
|
|
|
context.Dispose();
|
2012-05-15 13:23:06 -04:00
|
|
|
return reference;
|
2012-05-03 18:21:25 -04:00
|
|
|
}
|
2012-05-01 14:53:01 -04:00
|
|
|
|
2012-05-03 18:21:25 -04:00
|
|
|
VALUE Context::Enter(VALUE self) {
|
2012-05-16 23:25:31 -04:00
|
|
|
Void(Context(self)->Enter());
|
2012-05-03 18:21:25 -04:00
|
|
|
}
|
2012-05-01 14:53:01 -04:00
|
|
|
|
2012-05-03 18:21:25 -04:00
|
|
|
VALUE Context::Exit(VALUE self) {
|
2012-05-16 23:25:31 -04:00
|
|
|
Void(Context(self)->Exit());
|
2012-05-03 18:21:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|