1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef vm_StencilObject_h
8 #define vm_StencilObject_h
10 #include "mozilla/RefPtr.h" // RefPtr
12 #include <stddef.h> // size_t
13 #include <stdint.h> // uint8_t
15 #include "js/Class.h" // JSClassOps, JSClass
16 #include "js/experimental/JSStencil.h" // JS::Stencil
17 #include "js/TypeDecls.h"
18 #include "vm/NativeObject.h" // NativeObject
24 // Object that holds JS::Stencil.
26 // This is a testing-only feature which can only be produced by testing
28 class StencilObject
: public NativeObject
{
29 static constexpr size_t StencilSlot
= 0;
30 static constexpr size_t ReservedSlots
= 1;
33 static const JSClassOps classOps_
;
34 static const JSClass class_
;
36 bool hasStencil() const;
37 JS::Stencil
* stencil() const;
39 static StencilObject
* create(JSContext
* cx
, RefPtr
<JS::Stencil
> stencil
);
40 static void finalize(JS::GCContext
* gcx
, JSObject
* obj
);
43 // Object that holds Stencil XDR buffer.
45 // This is a testing-only feature which can only be produced by testing
47 class StencilXDRBufferObject
: public NativeObject
{
48 static constexpr size_t BufferSlot
= 0;
49 static constexpr size_t LengthSlot
= 1;
50 static constexpr size_t ReservedSlots
= 2;
53 static const JSClassOps classOps_
;
54 static const JSClass class_
;
56 bool hasBuffer() const;
57 const uint8_t* buffer() const;
58 size_t bufferLength() const;
61 uint8_t* writableBuffer();
64 static StencilXDRBufferObject
* create(JSContext
* cx
, uint8_t* buffer
,
66 static void finalize(JS::GCContext
* gcx
, JSObject
* obj
);
71 #endif /* vm_StencilObject_h */