Support setting read-only property value
This commit is contained in:
parent
912307386c
commit
c78a6fa7d4
1 changed files with 13 additions and 0 deletions
|
@ -93,6 +93,19 @@ class Dictionary {
|
|||
return !result.IsNothing() && result.FromJust();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool SetReadOnly(const base::StringPiece& key, T val) {
|
||||
v8::Local<v8::Value> v8_value;
|
||||
if (!TryConvertToV8(isolate_, val, &v8_value))
|
||||
return false;
|
||||
v8::Maybe<bool> result =
|
||||
GetHandle()->DefineOwnProperty(isolate_->GetCurrentContext(),
|
||||
StringToV8(isolate_, key),
|
||||
v8_value,
|
||||
v8::ReadOnly);
|
||||
return !result.IsNothing() && result.FromJust();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool SetMethod(const base::StringPiece& key, const T& callback) {
|
||||
return GetHandle()->Set(
|
||||
|
|
Loading…
Reference in a new issue