Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Unified Diff: include/v8.h

Issue 971693002: convert object::* to return maybe values (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index a38dc0a68fbf2686f67ee72db85ce41bd2d36d98..e6d73d72cf16912af94913441449c00a8a10c199 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -438,7 +438,7 @@ class MaybeLocal {
template <class S>
V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local<S>* out) const {
- if (val_ == NULL) {
+ if (val_ == nullptr) {
out->val_ = nullptr;
return false;
} else {
@@ -452,6 +452,12 @@ class MaybeLocal {
return Local<T>(val_);
}
+ template <class S>
+ V8_INLINE Local<S> FromMaybe(Local<S> default_value) const {
+ if (val_ == nullptr) return default_value;
Sven Panne 2015/03/02 12:37:12 Ternary aversion? :-)
+ return Local<S>(val_);
+ }
+
private:
T* val_;
};
@@ -2490,9 +2496,13 @@ enum AccessControl {
*/
class V8_EXPORT Object : public Value {
public:
+ // TODO(dcarney): deprecate
bool Set(Handle<Value> key, Handle<Value> value);
+ Maybe<bool> Set(Local<Context> context, Local<Value> key, Local<Value> value);
+ // TODO(dcarney): deprecate
bool Set(uint32_t index, Handle<Value> value);
+ Maybe<bool> Set(Local<Context> context, uint32_t index, Local<Value> value);
// Sets an own property on this object bypassing interceptors and
// overriding accessors or read-only properties.
@@ -2502,46 +2512,74 @@ class V8_EXPORT Object : public Value {
// will only be returned if the interceptor doesn't return a value.
//
// Note also that this only works for named properties.
+ // TODO(dcarney): deprecate
bool ForceSet(Handle<Value> key,
Handle<Value> value,
PropertyAttribute attribs = None);
+ Maybe<bool> ForceSet(Local<Context> context, Local<Value> key,
+ Local<Value> value, PropertyAttribute attribs = None);
+ // TODO(dcarney): deprecate
Local<Value> Get(Handle<Value> key);
+ MaybeLocal<Value> Get(Local<Context> context, Local<Value> key);
+ // TODO(dcarney): deprecate
Local<Value> Get(uint32_t index);
+ MaybeLocal<Value> Get(Local<Context> context, uint32_t index);
/**
* Gets the property attributes of a property which can be None or
* any combination of ReadOnly, DontEnum and DontDelete. Returns
* None when the property doesn't exist.
*/
+ // TODO(dcarney): deprecate
PropertyAttribute GetPropertyAttributes(Handle<Value> key);
+ Maybe<PropertyAttribute> GetPropertyAttributes(Local<Context> context,
+ Local<Value> key);
/**
* Returns Object.getOwnPropertyDescriptor as per ES5 section 15.2.3.3.
*/
+ // TODO(dcarney): deprecate
Local<Value> GetOwnPropertyDescriptor(Local<String> key);
+ MaybeLocal<Value> GetOwnPropertyDescriptor(Local<Context> context,
+ Local<String> key);
+ // TODO(dcarney): deprecate
bool Has(Handle<Value> key);
+ Maybe<bool> Has(Local<Context> context, Local<Value> key);
+ // TODO(dcarney): deprecate
bool Delete(Handle<Value> key);
+ Maybe<bool> Delete(Local<Context> context, Local<Value> key);
+ // TODO(dcarney): deprecate
bool Has(uint32_t index);
+ Maybe<bool> Has(Local<Context> context, uint32_t index);
+ // TODO(dcarney): deprecate
bool Delete(uint32_t index);
+ Maybe<bool> Delete(Local<Context> context, uint32_t index);
+ // TODO(dcarney): deprecate
bool SetAccessor(Handle<String> name,
AccessorGetterCallback getter,
AccessorSetterCallback setter = 0,
Handle<Value> data = Handle<Value>(),
AccessControl settings = DEFAULT,
PropertyAttribute attribute = None);
- bool SetAccessor(Handle<Name> name,
- AccessorNameGetterCallback getter,
+ // TODO(dcarney): deprecate
+ bool SetAccessor(Handle<Name> name, AccessorNameGetterCallback getter,
AccessorNameSetterCallback setter = 0,
Handle<Value> data = Handle<Value>(),
AccessControl settings = DEFAULT,
PropertyAttribute attribute = None);
+ Maybe<bool> SetAccessor(Local<Context> context, Local<Name> name,
+ AccessorNameGetterCallback getter,
+ AccessorNameSetterCallback setter = 0,
+ MaybeLocal<Value> data = MaybeLocal<Value>(),
+ AccessControl settings = DEFAULT,
+ PropertyAttribute attribute = None);
void SetAccessorProperty(Local<Name> name,
Local<Function> getter,
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698