1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00
therubyracer/ext/v8/v8.cc
Georgy Angelov 2fca33f9d0 Remove old ext files and spec & link to the new V8
The functionality will be added (that is, if I don't get bored) one thing at a time with the spec.
If you want to test, point the libv8 gem (in Gemfile) to its trunk branch & my changes at stormbreakerbg/libv8 @ trunk.

What works currently is getting V8 to initialize, say its version and create a new Isolate.
2015-03-18 21:57:39 +00:00

49 lines
1.8 KiB
C++

#include "rr.h"
namespace rr {
v8::Platform* V8::v8_platform = NULL;
void V8::Init() {
// Initialize V8.
v8::V8::InitializeICU();
v8_platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(v8_platform);
v8::V8::Initialize();
ClassBuilder("V8").
// defineSingletonMethod("IdleNotification", &IdleNotification).
// defineSingletonMethod("SetFlagsFromString", &SetFlagsFromString).
// defineSingletonMethod("SetFlagsFromCommandLine", &SetFlagsFromCommandLine).
// defineSingletonMethod("PauseProfiler", &PauseProfiler).
// defineSingletonMethod("ResumeProfiler", &ResumeProfiler).
// defineSingletonMethod("IsProfilerPaused", &IsProfilerPaused).
// defineSingletonMethod("GetCurrentThreadId", &GetCurrentThreadId).
// defineSingletonMethod("TerminateExecution", &TerminateExecution).
// defineSingletonMethod("IsExecutionTerminating", &IsExecutionTerminating).
defineSingletonMethod("Dispose", &Dispose).
// defineSingletonMethod("LowMemoryNotification", &LowMemoryNotification).
// defineSingletonMethod("AdjustAmountOfExternalAllocatedMemory", &AdjustAmountOfExternalAllocatedMemory).
// defineSingletonMethod("ContextDisposedNotification", &ContextDisposedNotification).
// defineSingletonMethod("SetCaptureStackTraceForUncaughtExceptions", &SetCaptureStackTraceForUncaughtExceptions).
// defineSingletonMethod("GetHeapStatistics", &GetHeapStatistics).
defineSingletonMethod("GetVersion", &GetVersion);
}
VALUE V8::Dispose(VALUE self) {
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
if (v8_platform) {
delete v8_platform;
v8_platform = NULL;
}
return Qnil;
}
VALUE V8::GetVersion(VALUE self) {
return rb_str_new2(v8::V8::GetVersion());
}
}