1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00

extract default object conversion

This commit is contained in:
Charles Lowell 2012-06-19 04:42:04 -05:00
parent 8693cddf0a
commit 1ce63c508c
3 changed files with 18 additions and 4 deletions

View file

@ -7,6 +7,7 @@ require 'v8/error/protect'
require 'v8/error/try'
require 'v8/conversion/fundamental'
require 'v8/conversion/indentity'
require 'v8/conversion/reference'
require 'v8/conversion/primitive'
require 'v8/conversion/code'
require 'v8/conversion/class'

View file

@ -1,10 +1,7 @@
class V8::Conversion
module Object
def to_v8
context = V8::Context.current
constructor = context.to_v8(self.class)
object = constructor.NewInstance([V8::C::External::New(self)])
return object
Reference.construct! self
end
def to_ruby

View file

@ -0,0 +1,16 @@
class V8::Conversion
module Reference
def self.construct!(object)
context = V8::Context.current
constructor = context.to_v8(object.class)
reference = constructor.NewInstance([V8::C::External::New(object)])
return reference
end
def to_v8
Reference.construct! self
end
end
end