mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
use weakcell to manage template reference.
This commit is contained in:
parent
d8579acf28
commit
476367a133
3 changed files with 8 additions and 8 deletions
|
@ -1,6 +1,7 @@
|
|||
require "v8/version"
|
||||
|
||||
require 'v8/init'
|
||||
require 'v8/util/weakcell'
|
||||
require 'v8/conversion/fundamental'
|
||||
require 'v8/conversion/indentity'
|
||||
require 'v8/conversion/primitive'
|
||||
|
@ -20,4 +21,3 @@ require 'v8/access'
|
|||
require 'v8/context'
|
||||
require 'v8/object'
|
||||
require 'v8/array'
|
||||
require 'v8/util/weakcell'
|
|
@ -3,7 +3,7 @@ class V8::Conversion
|
|||
include V8::Conversion::Proc
|
||||
|
||||
def to_v8
|
||||
(@@method_cache[self] ||= v8_template).GetFunction()
|
||||
(@@method_cache[self] ||= to_v8_template).GetFunction()
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
class V8::Conversion
|
||||
module Proc
|
||||
include V8::Util::Weakcell
|
||||
|
||||
def to_v8
|
||||
return v8_template.GetFunction()
|
||||
return to_v8_template.GetFunction()
|
||||
end
|
||||
|
||||
def v8_template
|
||||
unless @v8_template && @v8_template.weakref_alive?
|
||||
def to_v8_template
|
||||
weakcell(:v8_template) do
|
||||
template = V8::C::FunctionTemplate::New()
|
||||
template.SetCallHandler(InvocationHandler.new, V8::C::External::New(self))
|
||||
@v8_template = WeakRef.new(template)
|
||||
template
|
||||
end
|
||||
return @v8_template.__getobj__
|
||||
end
|
||||
|
||||
class InvocationHandler
|
||||
|
|
Loading…
Add table
Reference in a new issue