diff --git a/lib/v8/conversion/object.rb b/lib/v8/conversion/object.rb index 47c1b38..f18b792 100644 --- a/lib/v8/conversion/object.rb +++ b/lib/v8/conversion/object.rb @@ -2,7 +2,7 @@ class V8::Conversion module Object def to_v8 template = V8::C::ObjectTemplate::New() - template.SetNamedPropertyHandler(Get, nil, nil, nil, nil, V8::C::External::New(self)) + template.SetNamedPropertyHandler(Get, Set, nil, nil, nil, V8::C::External::New(self)) instance = template.NewInstance() V8::Context.link self, instance return instance @@ -19,13 +19,28 @@ class V8::Conversion object = info.Data().Value() name = property.Utf8Value() dontintercept = proc do - return V8::C::Empty + return V8::C::Value::Empty end context.to_v8 access.get(object, name, &dontintercept) rescue Exception => e warn "uncaught exception: #{e.class}: #{e.message} while accessing object property: #{e.backtrace.join('\n')}" end end + + class Set + def self.call(property, value, info) + context = V8::Context.current + access = context.access + object = info.Data().Value() + name = property.Utf8Value() + dontintercept = proc do + return V8::C::Value::Empty + end + access.set(object, name, context.to_ruby(value), &dontintercept) + rescue Exception => e + warn "uncaught exception: #{e.class}: #{e.message} while accessing object property: #{e.backtrace.join('\n')}" + end + end end module NativeObject