| 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/. */ |
| 6 |
|
| 7 |
#ifndef vm_StencilObject_h |
| 8 |
#define vm_StencilObject_h |
| 9 |
|
| 10 |
#include "mozilla/RefPtr.h" // RefPtr |
| 11 |
|
| 12 |
#include <stddef.h> // size_t |
| 13 |
#include <stdint.h> // uint8_t |
| 14 |
|
| 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 |
| 19 |
|
| 20 |
class JSObject; |
| 21 |
|
| 22 |
namespace js { |
| 23 |
|
| 24 |
// Object that holds JS::Stencil. |
| 25 |
// |
| 26 |
// This is a testing-only feature which can only be produced by testing |
| 27 |
// functions. |
| 28 |
class StencilObject : public NativeObject { |
| 29 |
static constexpr size_t StencilSlot = 0; |
| 30 |
static constexpr size_t ReservedSlots = 1; |
| 31 |
|
| 32 |
public: |
| 33 |
static const JSClassOps classOps_; |
| 34 |
static const JSClass class_; |
| 35 |
|
| 36 |
bool hasStencil() const; |
| 37 |
JS::Stencil* stencil() const; |
| 38 |
|
| 39 |
static StencilObject* create(JSContext* cx, RefPtr<JS::Stencil> stencil); |
| 40 |
static void finalize(JS::GCContext* gcx, JSObject* obj); |
| 41 |
}; |
| 42 |
|
| 43 |
// Object that holds Stencil XDR buffer. |
| 44 |
// |
| 45 |
// This is a testing-only feature which can only be produced by testing |
| 46 |
// functions. |
| 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; |
| 51 |
|
| 52 |
public: |
| 53 |
static const JSClassOps classOps_; |
| 54 |
static const JSClass class_; |
| 55 |
|
| 56 |
bool hasBuffer() const; |
| 57 |
const uint8_t* buffer() const; |
| 58 |
size_t bufferLength() const; |
| 59 |
|
| 60 |
private: |
| 61 |
uint8_t* writableBuffer(); |
| 62 |
|
| 63 |
public: |
| 64 |
static StencilXDRBufferObject* create(JSContext* cx, uint8_t* buffer, |
| 65 |
size_t length); |
| 66 |
static void finalize(JS::GCContext* gcx, JSObject* obj); |
| 67 |
}; |
| 68 |
|
| 69 |
} /* namespace js */ |
| 70 |
|
| 71 |
#endif /* vm_StencilObject_h */ |