From a20ade811ccf143c213260bd378fc31212ee1aab Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Thu, 14 Jun 2012 03:52:32 -0500 Subject: [PATCH] expose V8 version string. --- ext/v8/rr.h | 1 + ext/v8/v8.cc | 6 +++++- spec/c/constants_spec.rb | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ext/v8/rr.h b/ext/v8/rr.h index 008fa87..849080e 100644 --- a/ext/v8/rr.h +++ b/ext/v8/rr.h @@ -790,6 +790,7 @@ public: static VALUE IdleNotification(int argc, VALUE argv[], VALUE self); static VALUE SetCaptureStackTraceForUncaughtExceptions(int argc, VALUE argv[], VALUE self); static VALUE GetHeapStatistics(VALUE self, VALUE statistics_ptr); + static VALUE GetVersion(VALUE self); }; class ClassBuilder { diff --git a/ext/v8/v8.cc b/ext/v8/v8.cc index 43bfc1c..f6e9a80 100644 --- a/ext/v8/v8.cc +++ b/ext/v8/v8.cc @@ -6,7 +6,8 @@ void V8::Init() { ClassBuilder("V8"). defineSingletonMethod("IdleNotification", &IdleNotification). defineSingletonMethod("SetCaptureStackTraceForUncaughtExceptions", &SetCaptureStackTraceForUncaughtExceptions). - defineSingletonMethod("GetHeapStatistics", &GetHeapStatistics); + defineSingletonMethod("GetHeapStatistics", &GetHeapStatistics). + defineSingletonMethod("GetVersion", &GetVersion); } VALUE V8::IdleNotification(int argc, VALUE argv[], VALUE self) { @@ -30,4 +31,7 @@ VALUE V8::GetHeapStatistics(VALUE self, VALUE statistics_ptr) { Void(v8::V8::GetHeapStatistics(HeapStatistics(statistics_ptr))); } +VALUE V8::GetVersion(VALUE self) { + return rb_str_new2(v8::V8::GetVersion()); +} } \ No newline at end of file diff --git a/spec/c/constants_spec.rb b/spec/c/constants_spec.rb index 52c9391..538ed19 100644 --- a/spec/c/constants_spec.rb +++ b/spec/c/constants_spec.rb @@ -13,4 +13,8 @@ describe V8::C do V8::C::Value::Empty.should_not be_nil V8::C::Value::Empty.should be V8::C::Value::Empty end + + it "can access the V8 version" do + V8::C::V8::GetVersion().should match /^3\.10/ + end end \ No newline at end of file