2012-06-11 07:14:00 -05:00
|
|
|
class V8::Conversion
|
|
|
|
module Method
|
2012-06-16 04:54:31 -05:00
|
|
|
include V8::Conversion::Code
|
2012-06-11 07:14:00 -05:00
|
|
|
|
|
|
|
def to_v8
|
2012-06-16 04:54:31 -05:00
|
|
|
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)
|
2012-06-20 04:35:40 -05:00
|
|
|
@map[method.to_s]
|
2012-06-11 07:14:00 -05:00
|
|
|
end
|
2012-06-19 08:33:48 -05:00
|
|
|
|
2012-06-11 07:14:00 -05:00
|
|
|
def []=(method, template)
|
2012-06-20 04:35:40 -05:00
|
|
|
@map[method.to_s] = template
|
2012-06-11 07:14:00 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@@method_cache = MethodCache.new
|
|
|
|
end
|
|
|
|
end
|