1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/vm/ObjectImpl-inl.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99: 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef vm_ObjectImpl_inl_h 1.11 +#define vm_ObjectImpl_inl_h 1.12 + 1.13 +#include "vm/ObjectImpl.h" 1.14 + 1.15 +#include "jscntxt.h" 1.16 +#include "jsproxy.h" 1.17 + 1.18 +#include "vm/ProxyObject.h" 1.19 +#include "vm/TypedArrayObject.h" 1.20 + 1.21 +namespace js { 1.22 + 1.23 +/* static */ inline bool 1.24 +ObjectImpl::isExtensible(ExclusiveContext *cx, Handle<ObjectImpl*> obj, bool *extensible) 1.25 +{ 1.26 + if (obj->asObjectPtr()->is<ProxyObject>()) { 1.27 + if (!cx->shouldBeJSContext()) 1.28 + return false; 1.29 + HandleObject h = 1.30 + HandleObject::fromMarkedLocation(reinterpret_cast<JSObject* const*>(obj.address())); 1.31 + return Proxy::isExtensible(cx->asJSContext(), h, extensible); 1.32 + } 1.33 + 1.34 + *extensible = obj->nonProxyIsExtensible(); 1.35 + return true; 1.36 +} 1.37 + 1.38 +inline bool 1.39 +ClassCanHaveFixedData(const Class *clasp) 1.40 +{ 1.41 + // Normally, the number of fixed slots given an object is the maximum 1.42 + // permitted for its size class. For array buffers and typed arrays we only 1.43 + // use enough to cover the class reserved slots, so that the remaining 1.44 + // space in the object's allocation is available for the buffer's data. 1.45 + return clasp == &ArrayBufferObject::class_ || IsTypedArrayClass(clasp); 1.46 +} 1.47 + 1.48 +inline void * 1.49 +ObjectImpl::fixedData(size_t nslots) const 1.50 +{ 1.51 + JS_ASSERT(ClassCanHaveFixedData(getClass())); 1.52 + JS_ASSERT(nslots == numFixedSlots() + (hasPrivate() ? 1 : 0)); 1.53 + return &fixedSlots()[nslots]; 1.54 +} 1.55 + 1.56 +} // namespace js 1.57 + 1.58 +#endif /* vm_ObjectImpl_inl_h */