Struct js::jsapi::ObjectOpResult [] [src]

#[repr(C)]
pub struct ObjectOpResult { pub code_: usize, }

Per ES6, the [[DefineOwnProperty]] internal method has three different possible outcomes:

It's not just [[DefineOwnProperty]]: all the mutating internal methods have the same three outcomes. (The other affected internal methods are [[Set]], [[Delete]], [[SetPrototypeOf]], and [[PreventExtensions]].)

If you think this design is awful, you're not alone. But as it's the standard, we must represent these boolean "success" values somehow. ObjectOpSuccess is the class for this. It's like a bool, but when it's false it also stores an error code.

Typical usage:

ObjectOpResult result;
if (!DefineProperty(cx, obj, id, ..., result))
    return false;
if (!result)
    return result.reportError(cx, obj, id);

Users don't have to call result.report(); another possible ending is:

argv.rval().setBoolean(bool(result));
return true;

Fields

code_ is either one of the special codes OkCode or Uninitialized, or an error code. For now the error codes are private to the JS engine; they're defined in js/src/js.msg.

code_ is uintptr_t (rather than uint32_t) for the convenience of the JITs, which would otherwise have to deal with either padding or stack alignment on 64-bit platforms.

Methods

impl ObjectOpResult
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl ObjectOpResult
[src]

[src]

Set this ObjectOpResult to true and return true.

Trait Implementations

impl Debug for ObjectOpResult
[src]

[src]

Formats the value using the given formatter.

impl Copy for ObjectOpResult
[src]

impl Clone for ObjectOpResult
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more