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_ObjectImpl_inl_h michael@0: #define vm_ObjectImpl_inl_h michael@0: michael@0: #include "vm/ObjectImpl.h" michael@0: michael@0: #include "jscntxt.h" michael@0: #include "jsproxy.h" michael@0: michael@0: #include "vm/ProxyObject.h" michael@0: #include "vm/TypedArrayObject.h" michael@0: michael@0: namespace js { michael@0: michael@0: /* static */ inline bool michael@0: ObjectImpl::isExtensible(ExclusiveContext *cx, Handle obj, bool *extensible) michael@0: { michael@0: if (obj->asObjectPtr()->is()) { michael@0: if (!cx->shouldBeJSContext()) michael@0: return false; michael@0: HandleObject h = michael@0: HandleObject::fromMarkedLocation(reinterpret_cast(obj.address())); michael@0: return Proxy::isExtensible(cx->asJSContext(), h, extensible); michael@0: } michael@0: michael@0: *extensible = obj->nonProxyIsExtensible(); michael@0: return true; michael@0: } michael@0: michael@0: inline bool michael@0: ClassCanHaveFixedData(const Class *clasp) michael@0: { michael@0: // Normally, the number of fixed slots given an object is the maximum michael@0: // permitted for its size class. For array buffers and typed arrays we only michael@0: // use enough to cover the class reserved slots, so that the remaining michael@0: // space in the object's allocation is available for the buffer's data. michael@0: return clasp == &ArrayBufferObject::class_ || IsTypedArrayClass(clasp); michael@0: } michael@0: michael@0: inline void * michael@0: ObjectImpl::fixedData(size_t nslots) const michael@0: { michael@0: JS_ASSERT(ClassCanHaveFixedData(getClass())); michael@0: JS_ASSERT(nslots == numFixedSlots() + (hasPrivate() ? 1 : 0)); michael@0: return &fixedSlots()[nslots]; michael@0: } michael@0: michael@0: } // namespace js michael@0: michael@0: #endif /* vm_ObjectImpl_inl_h */