2015-03-20 20:47:57 +00:00
|
|
|
#include "rr.h"
|
|
|
|
|
|
|
|
namespace rr {
|
|
|
|
|
|
|
|
void Context::Init() {
|
|
|
|
ClassBuilder("Context").
|
|
|
|
defineSingletonMethod("New", &New).
|
|
|
|
|
|
|
|
defineMethod("Dispose", &Dispose).
|
|
|
|
defineMethod("Enter", &Enter).
|
|
|
|
defineMethod("Exit", &Exit).
|
|
|
|
|
2015-04-04 18:23:23 +00:00
|
|
|
defineMethod("Global", &Global).
|
|
|
|
|
2015-03-20 20:47:57 +00:00
|
|
|
store(&Class);
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
// ClassBuilder("ExtensionConfiguration").
|
|
|
|
// defineSingletonMethod("new", &ExtensionConfiguration::initialize).
|
|
|
|
// store(&ExtensionConfiguration::Class);
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::New(int argc, VALUE argv[], VALUE self) {
|
2015-04-04 14:16:15 +00:00
|
|
|
VALUE rb_isolate, extension_configuration, global_template, global_object;
|
|
|
|
rb_scan_args(argc, argv, "13", &rb_isolate, &extension_configuration, &global_template, &global_object);
|
|
|
|
|
|
|
|
Isolate isolate(rb_isolate);
|
|
|
|
Locker lock(isolate);
|
2015-03-20 20:47:57 +00:00
|
|
|
|
2015-03-21 09:51:17 +00:00
|
|
|
return Context(v8::Context::New(
|
2015-04-04 14:16:15 +00:00
|
|
|
isolate
|
2015-03-21 09:51:17 +00:00
|
|
|
// TODO
|
|
|
|
// ,
|
|
|
|
// ExtensionConfiguration(extension_configuration),
|
|
|
|
// *ObjectTemplate(global_template),
|
|
|
|
// *Object(global_object)
|
|
|
|
));
|
2015-03-20 20:47:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::Dispose(VALUE self) {
|
|
|
|
Context(self).dispose();
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::Enter(VALUE self) {
|
2015-04-04 14:03:06 +00:00
|
|
|
Context context(self);
|
|
|
|
Locker lock(context.getIsolate());
|
|
|
|
|
|
|
|
context->Enter();
|
|
|
|
|
2015-03-20 20:47:57 +00:00
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE Context::Exit(VALUE self) {
|
2015-04-04 14:03:06 +00:00
|
|
|
Context context(self);
|
|
|
|
Locker lock(context.getIsolate());
|
|
|
|
|
|
|
|
context->Exit();
|
|
|
|
|
2015-03-20 20:47:57 +00:00
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2015-04-04 18:23:23 +00:00
|
|
|
VALUE Context::Global(VALUE self) {
|
|
|
|
Context context(self);
|
|
|
|
Locker lock(context.getIsolate());
|
|
|
|
|
|
|
|
return Object(context->GetIsolate(), context->Global());
|
|
|
|
}
|
|
|
|
|
2015-03-20 20:47:57 +00:00
|
|
|
// TODO
|
|
|
|
// template <> void Pointer<v8::ExtensionConfiguration>::unwrap(VALUE value) {
|
|
|
|
// Data_Get_Struct(value, class v8::ExtensionConfiguration, pointer);
|
|
|
|
// }
|
|
|
|
|
|
|
|
}
|