#include "ruby_data.h" #include "v8_data.h" #include "generic_data.h" #include "v8_context.h" #include using namespace v8; v8_context::v8_context() : handle(Context::New()) {} v8_context::~v8_context() { handle.Dispose(); } VALUE v8_context_allocate(VALUE clazz) { v8_context *cxt = new v8_context; return Data_Wrap_Struct(clazz, v8_context_mark, v8_context_free, cxt); } void v8_context_free(v8_context *context) { delete context; } void v8_context_mark(v8_context *context) { //don't mark anything. } //methods VALUE v8_context_eval(VALUE self, VALUE javascript) { v8_context* cxt = 0; Data_Get_Struct(self, struct v8_context, cxt); Context::Scope enter(cxt->handle); HandleScope handles; RubyValueSource tostring; const std::string source(tostring.push(javascript)); Local