KHtml

kjs_arraybuffer.h
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 2013 Bernd Buschinski <[email protected]>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef KJS_ARRAYBUFFER_H
21 #define KJS_ARRAYBUFFER_H
22 
23 #include "ecma/kjs_dom.h"
24 
25 #include <kjs/object.h>
26 
27 namespace KJS
28 {
29 
30 class ArrayBufferConstructorImp : public JSObject
31 {
32 public:
33  ArrayBufferConstructorImp(ExecState *exec, DOM::DocumentImpl *d);
34  bool implementsConstruct() const override;
35  using KJS::JSObject::construct;
36  JSObject *construct(ExecState *exec, const List &args) override;
37 private:
38  SharedPtr<DOM::DocumentImpl> doc;
39 };
40 
41 class ArrayBuffer : public JSObject
42 {
43 public:
44  explicit ArrayBuffer(size_t size);
45  //copy the buffer
46  explicit ArrayBuffer(uint8_t *buffer, size_t size);
47  virtual ~ArrayBuffer();
48 
49  enum {
50  ByteLength, Splice
51  };
52 
53  using KJS::JSObject::getOwnPropertySlot;
54  bool getOwnPropertySlot(ExecState *exec, const Identifier &propertyName, PropertySlot &slot) override;
55  JSValue *getValueProperty(ExecState *exec, int token) const;
56 
57  const ClassInfo *classInfo() const override
58  {
59  return &info;
60  }
61  static const ClassInfo info;
62 
63  size_t byteLength() const
64  {
65  return m_size;
66  }
67  uint8_t *buffer() const
68  {
69  return m_buffer;
70  }
71 
72 private:
73  size_t m_size;
74  uint8_t *m_buffer;
75 };
76 
77 } // namespace KJS
78 
79 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:04 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.