Sha256: b0004585bbc66d81e59f0b9145bed1c2650ae0a837604a396ba6a78daf549855
Contents?: true
Size: 1.06 KB
Versions: 12
Compression:
Stored size: 1.06 KB
Contents
#include "v8.h" #include "v8_ref.h" #include "v8_script.h" using namespace v8; namespace { VALUE New(VALUE self, VALUE source, VALUE source_name) { HandleScope scope; Local<String> src(rr_rb2v8(source)->ToString()); Local<String> src_name(rr_rb2v8(source_name)->ToString()); return rr_v8_ref_create(self, Script::Compile(src, src_name)); } VALUE Compile(VALUE self, VALUE source, VALUE source_name) { HandleScope scope; Local<String> src(rr_rb2v8(source)->ToString()); Local<String> src_name(rr_rb2v8(source_name)->ToString()); return rr_v8_ref_create(self, Script::Compile(src, src_name)); } VALUE Run(VALUE self) { HandleScope scope; Local<Script> script(V8_Ref_Get<Script>(self)); Local<Value> result(script->Run()); return result.IsEmpty() ? Qnil : rr_v82rb(result); } } void rr_init_script() { VALUE ScriptClass = rr_define_class("Script"); rr_define_singleton_method(ScriptClass, "New", New, 2); rr_define_singleton_method(ScriptClass, "Compile", Compile, 2); rr_define_method(ScriptClass, "Run", Run, 0); }
Version data entries
12 entries across 12 versions & 2 rubygems