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:
parent
8693cddf0a
commit
1ce63c508c
3 changed files with 18 additions and 4 deletions
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
16
lib/v8/conversion/reference.rb
Normal file
16
lib/v8/conversion/reference.rb
Normal 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
|
Loading…
Reference in a new issue