mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
d1e9088cf0
You can now create a JS object from Ruby-land without segfaulting
45 lines
865 B
C++
45 lines
865 B
C++
#include "rr.h"
|
|
|
|
namespace rr {
|
|
|
|
void Isolate::Init() {
|
|
ClassBuilder("Isolate").
|
|
defineSingletonMethod("New", &New).
|
|
defineSingletonMethod("GetCurrent", &GetCurrent).
|
|
|
|
defineMethod("Enter", &Enter).
|
|
defineMethod("Exit", &Exit).
|
|
|
|
store(&Class);
|
|
}
|
|
|
|
VALUE Isolate::New(VALUE self) {
|
|
return Isolate(v8::Isolate::New());
|
|
}
|
|
|
|
VALUE Isolate::Enter(VALUE self) {
|
|
Isolate(self)->Enter();
|
|
return Qtrue;
|
|
}
|
|
|
|
VALUE Isolate::Exit(VALUE self) {
|
|
Isolate(self)->Exit();
|
|
return Qtrue;
|
|
}
|
|
|
|
VALUE Isolate::GetCurrent(VALUE self) {
|
|
v8::Isolate* currentIsolate = v8::Isolate::GetCurrent();
|
|
|
|
if (!currentIsolate) {
|
|
return Qnil;
|
|
}
|
|
|
|
return Isolate(currentIsolate);
|
|
}
|
|
|
|
template <>
|
|
void Pointer<v8::Isolate>::unwrap(VALUE value) {
|
|
Data_Get_Struct(value, class v8::Isolate, pointer);
|
|
}
|
|
|
|
}
|