michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef vm_BooleanObject_h michael@0: #define vm_BooleanObject_h michael@0: michael@0: #include "jsbool.h" michael@0: #include "jsobj.h" michael@0: michael@0: namespace js { michael@0: michael@0: class BooleanObject : public JSObject michael@0: { michael@0: /* Stores this Boolean object's [[PrimitiveValue]]. */ michael@0: static const unsigned PRIMITIVE_VALUE_SLOT = 0; michael@0: michael@0: public: michael@0: static const unsigned RESERVED_SLOTS = 1; michael@0: michael@0: static const Class class_; michael@0: michael@0: /* michael@0: * Creates a new Boolean object boxing the given primitive bool. The michael@0: * object's [[Prototype]] is determined from context. michael@0: */ michael@0: static inline BooleanObject *create(JSContext *cx, bool b); michael@0: michael@0: bool unbox() const { michael@0: return getFixedSlot(PRIMITIVE_VALUE_SLOT).toBoolean(); michael@0: } michael@0: michael@0: private: michael@0: inline void setPrimitiveValue(bool b) { michael@0: setFixedSlot(PRIMITIVE_VALUE_SLOT, BooleanValue(b)); michael@0: } michael@0: michael@0: /* For access to init, as Boolean.prototype is special. */ michael@0: friend JSObject * michael@0: ::js_InitBooleanClass(JSContext *cx, js::HandleObject global); michael@0: }; michael@0: michael@0: } // namespace js michael@0: michael@0: #endif /* vm_BooleanObject_h */