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

26 lines
465 B
Ruby
Raw Normal View History

2012-06-11 07:14:00 -05:00
class V8::Conversion
module Method
include V8::Conversion::Code
2012-06-11 07:14:00 -05:00
def to_v8
template = @@method_cache[self] ||= to_template
template.GetFunction()
2012-06-11 07:14:00 -05:00
end
class MethodCache
def initialize
2012-08-11 12:26:14 -05:00
@map = V8::Weak::WeakValueMap.new
2012-06-11 07:14:00 -05:00
end
def [](method)
@map[method.to_s]
2012-06-11 07:14:00 -05:00
end
2012-06-11 07:14:00 -05:00
def []=(method, template)
@map[method.to_s] = template
2012-06-11 07:14:00 -05:00
end
end
@@method_cache = MethodCache.new
end
end