History

Base implementation of ArrayBuffer

Atlante45 committed 12 years ago

Commit c2462051 parent 12eeb504 files · +222 −0Browse files

Showing the changes to libraries/script-engine/src/ArrayBufferPrototype.cpp (1 of 4 files). Show all

Unified · Split

libraries/script-engine/src/ArrayBufferPrototype.cpp+29−0
@@ -0,0 +1,29 @@
1+//
2+// ArrayBufferPrototype.cpp
3+//
4+//
5+// Created by Clement on 7/3/14.
6+// Copyright 2014 High Fidelity, Inc.
7+//
8+// Distributed under the Apache License, Version 2.0.
9+// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10+//
11+
12+#include <QScriptEngine>
13+
14+#include "ArrayBufferPrototype.h"
15+
16+ArrayBufferPrototype::ArrayBufferPrototype(QObject* parent) : QObject(parent) {
17+}
18+
19+QByteArray ArrayBufferPrototype::slice(long begin, long end) const {
20+ if (end == -1) {
21+ return thisArrayBuffer().mid(begin);
22+ } else {
23+ return thisArrayBuffer().mid(begin, end);
24+ }
25+}
26+
27+QByteArray ArrayBufferPrototype::thisArrayBuffer() const {
28+ return qscriptvalue_cast<QByteArray>(thisObject().data());
29+}