diff options
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript/v8')
24 files changed, 2089 insertions, 0 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.cpp new file mode 100644 index 0000000..d4146fe --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.cpp @@ -0,0 +1,57 @@ +#include "V8ArrayBuffer.h" + +namespace Arabica { +namespace DOM { + +v8::Persistent<v8::FunctionTemplate> V8ArrayBuffer::Tmpl; + + +v8::Handle<v8::Value> V8ArrayBuffer::byteLengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8ArrayBufferPrivate* privData = V8DOM::toClassPtr<V8ArrayBufferPrivate >(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getByteLength()); +} +v8::Handle<v8::Value> V8ArrayBuffer::sliceCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in slice"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8ArrayBufferPrivate* privData = V8DOM::toClassPtr<V8ArrayBufferPrivate >(self->GetInternalField(0)); + long localBegin = args[0]->ToNumber()->Int32Value(); + long localEnd = args[1]->ToNumber()->Int32Value(); + + uscxml::ArrayBuffer* retVal = new uscxml::ArrayBuffer(privData->nativeObj->slice(localBegin, localEnd)); + v8::Handle<v8::Function> retCtor = V8ArrayBuffer::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + struct V8ArrayBuffer::V8ArrayBufferPrivate* retPrivData = new V8ArrayBuffer::V8ArrayBufferPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8ArrayBuffer::jsDestructor); + return retObj; + +} + +v8::Handle<v8::Value> V8ArrayBuffer::isViewCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in isView"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8ArrayBufferPrivate* privData = V8DOM::toClassPtr<V8ArrayBufferPrivate >(self->GetInternalField(0)); + void* localValue = v8::External::Unwrap(args[0]->ToObject()->GetInternalField(0)); + + bool retVal = privData->nativeObj->isView(localValue); + + return v8::Boolean::New(retVal); +} + +bool V8ArrayBuffer::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.h new file mode 100644 index 0000000..3399575 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.h @@ -0,0 +1,82 @@ +/* + This file is part of the Wrapper open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef V8ArrayBuffer_h +#define V8ArrayBuffer_h + +#include <string> +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include <v8.h> + +namespace Arabica { +namespace DOM { + +class V8ArrayBuffer { +public: + struct V8ArrayBufferPrivate { + V8DOM* dom; + uscxml::ArrayBuffer* nativeObj; + }; + + V8_DESTRUCTOR(V8ArrayBufferPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> sliceCallback(const v8::Arguments&); + static v8::Handle<v8::Value> isViewCallback(const v8::Arguments&); + + static v8::Handle<v8::Value> byteLengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + static v8::Persistent<v8::FunctionTemplate> Tmpl; + static v8::Handle<v8::FunctionTemplate> getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("ArrayBuffer")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("byteLength"), V8ArrayBuffer::byteLengthAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + prototype->Set(v8::String::NewSymbol("slice"), + v8::FunctionTemplate::New(V8ArrayBuffer::sliceCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("isView"), + v8::FunctionTemplate::New(V8ArrayBuffer::isViewCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + + + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // V8ArrayBuffer_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBufferView.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBufferView.cpp new file mode 100644 index 0000000..ff0b744 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBufferView.cpp @@ -0,0 +1,48 @@ +#include "V8ArrayBuffer.h" +#include "V8ArrayBufferView.h" + +namespace Arabica { +namespace DOM { + +v8::Persistent<v8::FunctionTemplate> V8ArrayBufferView::Tmpl; + + +v8::Handle<v8::Value> V8ArrayBufferView::bufferAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8ArrayBufferViewPrivate* privData = V8DOM::toClassPtr<V8ArrayBufferViewPrivate >(self->GetInternalField(0)); + + if (!privData->nativeObj->getBuffer()) return v8::Undefined(); + uscxml::ArrayBuffer* arbaicaRet = new uscxml::ArrayBuffer(privData->nativeObj->getBuffer()); + + v8::Handle<v8::Function> arbaicaRetCtor = V8ArrayBuffer::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + + struct V8ArrayBuffer::V8ArrayBufferPrivate* retPrivData = new V8ArrayBuffer::V8ArrayBufferPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8ArrayBuffer::jsDestructor); + return arbaicaRetObj; + +} + +v8::Handle<v8::Value> V8ArrayBufferView::byteOffsetAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8ArrayBufferViewPrivate* privData = V8DOM::toClassPtr<V8ArrayBufferViewPrivate >(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getByteOffset()); +} + +v8::Handle<v8::Value> V8ArrayBufferView::byteLengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8ArrayBufferViewPrivate* privData = V8DOM::toClassPtr<V8ArrayBufferViewPrivate >(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getByteLength()); +} +bool V8ArrayBufferView::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBufferView.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBufferView.h new file mode 100644 index 0000000..1f4a75c --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBufferView.h @@ -0,0 +1,82 @@ +/* + This file is part of the Wrapper open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef V8ArrayBufferView_h +#define V8ArrayBufferView_h + +#include <string> +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include <v8.h> + +namespace Arabica { +namespace DOM { + +class V8ArrayBufferView { +public: + struct V8ArrayBufferViewPrivate { + V8DOM* dom; + uscxml::ArrayBufferView* nativeObj; + }; + + V8_DESTRUCTOR(V8ArrayBufferViewPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + + static v8::Handle<v8::Value> bufferAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> byteOffsetAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + static v8::Handle<v8::Value> byteLengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + static v8::Persistent<v8::FunctionTemplate> Tmpl; + static v8::Handle<v8::FunctionTemplate> getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("ArrayBufferView")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("buffer"), V8ArrayBufferView::bufferAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("byteOffset"), V8ArrayBufferView::byteOffsetAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("byteLength"), V8ArrayBufferView::byteLengthAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + + + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // V8ArrayBufferView_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DataView.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DataView.cpp new file mode 100644 index 0000000..4a756ee --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DataView.cpp @@ -0,0 +1,241 @@ +#include "V8DataView.h" + +namespace Arabica { +namespace DOM { + +v8::Persistent<v8::FunctionTemplate> V8DataView::Tmpl; + +v8::Handle<v8::Value> V8DataView::getInt8Callback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in getInt8"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr<V8DataViewPrivate >(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + + char retVal = privData->nativeObj->getInt8(localByteOffset); + + return v8::Number::New(retVal); +} + +v8::Handle<v8::Value> V8DataView::getUint8Callback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in getUint8"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr<V8DataViewPrivate >(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + + char retVal = privData->nativeObj->getUint8(localByteOffset); + + return v8::Number::New(retVal); +} + +v8::Handle<v8::Value> V8DataView::getInt16Callback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getInt16"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr<V8DataViewPrivate >(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + bool localLittleEndian = args[1]->ToBoolean()->BooleanValue(); + + short retVal = privData->nativeObj->getInt16(localByteOffset, localLittleEndian); + + return v8::Number::New(retVal); +} + +v8::Handle<v8::Value> V8DataView::getUint16Callback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getUint16"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr<V8DataViewPrivate >(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + bool localLittleEndian = args[1]->ToBoolean()->BooleanValue(); + + unsigned short retVal = privData->nativeObj->getUint16(localByteOffset, localLittleEndian); + + return v8::Number::New(retVal); +} + +v8::Handle<v8::Value> V8DataView::getInt32Callback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getInt32"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr<V8DataViewPrivate >(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + bool localLittleEndian = args[1]->ToBoolean()->BooleanValue(); + + long retVal = privData->nativeObj->getInt32(localByteOffset, localLittleEndian); + + return v8::Number::New(retVal); +} + +v8::Handle<v8::Value> V8DataView::getUint32Callback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getUint32"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr<V8DataViewPrivate >(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + bool localLittleEndian = args[1]->ToBoolean()->BooleanValue(); + + unsigned long retVal = privData->nativeObj->getUint32(localByteOffset, localLittleEndian); + + return v8::Number::New(retVal); +} + +v8::Handle<v8::Value> V8DataView::getFloat32Callback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getFloat32"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr<V8DataViewPrivate >(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + bool localLittleEndian = args[1]->ToBoolean()->BooleanValue(); + + float retVal = privData->nativeObj->getFloat32(localByteOffset, localLittleEndian); + + return v8::Number::New(retVal); +} + +v8::Handle<v8::Value> V8DataView::getFloat64Callback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getFloat64"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr<V8DataViewPrivate >(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + bool localLittleEndian = args[1]->ToBoolean()->BooleanValue(); + + double retVal = privData->nativeObj->getFloat64(localByteOffset, localLittleEndian); + + return v8::Number::New(retVal); +} + +v8::Handle<v8::Value> V8DataView::setInt8Callback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in setInt8"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr<V8DataViewPrivate >(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + char localValue = args[1]->ToNumber()->Int32Value(); + + privData->nativeObj->setInt8(localByteOffset, localValue); + + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8DataView::setUint8Callback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in setUint8"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr<V8DataViewPrivate >(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + unsigned char localValue = args[1]->ToNumber()->Uint32Value(); + + privData->nativeObj->setUint8(localByteOffset, localValue); + + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8DataView::setInt16Callback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in setInt16"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr<V8DataViewPrivate >(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + short localValue = args[1]->ToNumber()->Int32Value(); + bool localLittleEndian = args[2]->ToBoolean()->BooleanValue(); + + privData->nativeObj->setInt16(localByteOffset, localValue, localLittleEndian); + + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8DataView::setUint16Callback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in setUint16"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr<V8DataViewPrivate >(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + unsigned short localValue = args[1]->ToNumber()->Uint32Value(); + bool localLittleEndian = args[2]->ToBoolean()->BooleanValue(); + + privData->nativeObj->setUint16(localByteOffset, localValue, localLittleEndian); + + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8DataView::setInt32Callback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in setInt32"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr<V8DataViewPrivate >(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + long localValue = args[1]->ToNumber()->Int32Value(); + bool localLittleEndian = args[2]->ToBoolean()->BooleanValue(); + + privData->nativeObj->setInt32(localByteOffset, localValue, localLittleEndian); + + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8DataView::setUint32Callback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in setUint32"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr<V8DataViewPrivate >(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + unsigned long localValue = args[1]->ToNumber()->Uint32Value(); + bool localLittleEndian = args[2]->ToBoolean()->BooleanValue(); + + privData->nativeObj->setUint32(localByteOffset, localValue, localLittleEndian); + + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8DataView::setFloat32Callback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in setFloat32"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr<V8DataViewPrivate >(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + float localValue = args[1]->ToNumber()->Value(); + bool localLittleEndian = args[2]->ToBoolean()->BooleanValue(); + + privData->nativeObj->setFloat32(localByteOffset, localValue, localLittleEndian); + + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8DataView::setFloat64Callback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in setFloat64"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr<V8DataViewPrivate >(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + double localValue = args[1]->ToNumber()->Value(); + bool localLittleEndian = args[2]->ToBoolean()->BooleanValue(); + + privData->nativeObj->setFloat64(localByteOffset, localValue, localLittleEndian); + + return v8::Undefined(); +} + +bool V8DataView::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DataView.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DataView.h new file mode 100644 index 0000000..476ff87 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DataView.h @@ -0,0 +1,121 @@ +/* + This file is part of the Wrapper open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef V8DataView_h +#define V8DataView_h + +#include <string> +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include <v8.h> + +namespace Arabica { +namespace DOM { + +class V8DataView { +public: + struct V8DataViewPrivate { + V8DOM* dom; + uscxml::DataView* nativeObj; + }; + + V8_DESTRUCTOR(V8DataViewPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> getInt8Callback(const v8::Arguments&); + static v8::Handle<v8::Value> getUint8Callback(const v8::Arguments&); + static v8::Handle<v8::Value> getInt16Callback(const v8::Arguments&); + static v8::Handle<v8::Value> getUint16Callback(const v8::Arguments&); + static v8::Handle<v8::Value> getInt32Callback(const v8::Arguments&); + static v8::Handle<v8::Value> getUint32Callback(const v8::Arguments&); + static v8::Handle<v8::Value> getFloat32Callback(const v8::Arguments&); + static v8::Handle<v8::Value> getFloat64Callback(const v8::Arguments&); + static v8::Handle<v8::Value> setInt8Callback(const v8::Arguments&); + static v8::Handle<v8::Value> setUint8Callback(const v8::Arguments&); + static v8::Handle<v8::Value> setInt16Callback(const v8::Arguments&); + static v8::Handle<v8::Value> setUint16Callback(const v8::Arguments&); + static v8::Handle<v8::Value> setInt32Callback(const v8::Arguments&); + static v8::Handle<v8::Value> setUint32Callback(const v8::Arguments&); + static v8::Handle<v8::Value> setFloat32Callback(const v8::Arguments&); + static v8::Handle<v8::Value> setFloat64Callback(const v8::Arguments&); + + + static v8::Persistent<v8::FunctionTemplate> Tmpl; + static v8::Handle<v8::FunctionTemplate> getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("DataView")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + + prototype->Set(v8::String::NewSymbol("getInt8"), + v8::FunctionTemplate::New(V8DataView::getInt8Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getUint8"), + v8::FunctionTemplate::New(V8DataView::getUint8Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getInt16"), + v8::FunctionTemplate::New(V8DataView::getInt16Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getUint16"), + v8::FunctionTemplate::New(V8DataView::getUint16Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getInt32"), + v8::FunctionTemplate::New(V8DataView::getInt32Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getUint32"), + v8::FunctionTemplate::New(V8DataView::getUint32Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getFloat32"), + v8::FunctionTemplate::New(V8DataView::getFloat32Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getFloat64"), + v8::FunctionTemplate::New(V8DataView::getFloat64Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setInt8"), + v8::FunctionTemplate::New(V8DataView::setInt8Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setUint8"), + v8::FunctionTemplate::New(V8DataView::setUint8Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setInt16"), + v8::FunctionTemplate::New(V8DataView::setInt16Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setUint16"), + v8::FunctionTemplate::New(V8DataView::setUint16Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setInt32"), + v8::FunctionTemplate::New(V8DataView::setInt32Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setUint32"), + v8::FunctionTemplate::New(V8DataView::setUint32Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setFloat32"), + v8::FunctionTemplate::New(V8DataView::setFloat32Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setFloat64"), + v8::FunctionTemplate::New(V8DataView::setFloat64Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + + + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // V8DataView_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Float32Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Float32Array.cpp new file mode 100644 index 0000000..6d3fa47 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Float32Array.cpp @@ -0,0 +1,71 @@ +#include "V8Float32Array.h" + +namespace Arabica { +namespace DOM { + +v8::Persistent<v8::FunctionTemplate> V8Float32Array::Tmpl; + + +v8::Handle<v8::Value> V8Float32Array::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8Float32ArrayPrivate* privData = V8DOM::toClassPtr<V8Float32ArrayPrivate >(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle<v8::Value> V8Float32Array::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Float32ArrayPrivate* privData = V8DOM::toClassPtr<V8Float32ArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + float retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle<v8::Value> V8Float32Array::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Float32ArrayPrivate* privData = V8DOM::toClassPtr<V8Float32ArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + float localValue = args[1]->ToNumber()->Value(); + + privData->nativeObj->set(localIndex, localValue); + + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8Float32Array::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Float32ArrayPrivate* privData = V8DOM::toClassPtr<V8Float32ArrayPrivate >(self->GetInternalField(0)); + long localStart = args[0]->ToNumber()->Int32Value(); + long localEnd = args[1]->ToNumber()->Int32Value(); + + uscxml::Float32Array* retVal = new uscxml::Float32Array(privData->nativeObj->subarray(localStart, localEnd)); + v8::Handle<v8::Function> retCtor = V8Float32Array::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + struct V8Float32Array::V8Float32ArrayPrivate* retPrivData = new V8Float32Array::V8Float32ArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8Float32Array::jsDestructor); + return retObj; + +} + +bool V8Float32Array::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Float32Array.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Float32Array.h new file mode 100644 index 0000000..ffb5fa7 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Float32Array.h @@ -0,0 +1,91 @@ +/* + This file is part of the Wrapper open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef V8Float32Array_h +#define V8Float32Array_h + +#include <string> +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include <v8.h> + +namespace Arabica { +namespace DOM { + +class V8Float32Array { +public: + struct V8Float32ArrayPrivate { + V8DOM* dom; + uscxml::Float32Array* nativeObj; + }; + + V8_DESTRUCTOR(V8Float32ArrayPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> getCallback(const v8::Arguments&); + static v8::Handle<v8::Value> setCallback(const v8::Arguments&); + static v8::Handle<v8::Value> subarrayCallback(const v8::Arguments&); + + static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + static v8::Persistent<v8::FunctionTemplate> Tmpl; + static v8::Handle<v8::FunctionTemplate> getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Float32Array")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("length"), V8Float32Array::lengthAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Float32Array::getCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Float32Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Float32Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Float32Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Float32Array::subarrayCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(4), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(4), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // V8Float32Array_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Float64Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Float64Array.cpp new file mode 100644 index 0000000..3dc69d0 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Float64Array.cpp @@ -0,0 +1,71 @@ +#include "V8Float64Array.h" + +namespace Arabica { +namespace DOM { + +v8::Persistent<v8::FunctionTemplate> V8Float64Array::Tmpl; + + +v8::Handle<v8::Value> V8Float64Array::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8Float64ArrayPrivate* privData = V8DOM::toClassPtr<V8Float64ArrayPrivate >(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle<v8::Value> V8Float64Array::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Float64ArrayPrivate* privData = V8DOM::toClassPtr<V8Float64ArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + double retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle<v8::Value> V8Float64Array::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Float64ArrayPrivate* privData = V8DOM::toClassPtr<V8Float64ArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + double localValue = args[1]->ToNumber()->Value(); + + privData->nativeObj->set(localIndex, localValue); + + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8Float64Array::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Float64ArrayPrivate* privData = V8DOM::toClassPtr<V8Float64ArrayPrivate >(self->GetInternalField(0)); + long localStart = args[0]->ToNumber()->Int32Value(); + long localEnd = args[1]->ToNumber()->Int32Value(); + + uscxml::Float64Array* retVal = new uscxml::Float64Array(privData->nativeObj->subarray(localStart, localEnd)); + v8::Handle<v8::Function> retCtor = V8Float64Array::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + struct V8Float64Array::V8Float64ArrayPrivate* retPrivData = new V8Float64Array::V8Float64ArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8Float64Array::jsDestructor); + return retObj; + +} + +bool V8Float64Array::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Float64Array.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Float64Array.h new file mode 100644 index 0000000..8537a09 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Float64Array.h @@ -0,0 +1,91 @@ +/* + This file is part of the Wrapper open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef V8Float64Array_h +#define V8Float64Array_h + +#include <string> +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include <v8.h> + +namespace Arabica { +namespace DOM { + +class V8Float64Array { +public: + struct V8Float64ArrayPrivate { + V8DOM* dom; + uscxml::Float64Array* nativeObj; + }; + + V8_DESTRUCTOR(V8Float64ArrayPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> getCallback(const v8::Arguments&); + static v8::Handle<v8::Value> setCallback(const v8::Arguments&); + static v8::Handle<v8::Value> subarrayCallback(const v8::Arguments&); + + static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + static v8::Persistent<v8::FunctionTemplate> Tmpl; + static v8::Handle<v8::FunctionTemplate> getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Float64Array")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("length"), V8Float64Array::lengthAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Float64Array::getCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Float64Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Float64Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Float64Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Float64Array::subarrayCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(8), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(8), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // V8Float64Array_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int16Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int16Array.cpp new file mode 100644 index 0000000..ba268da --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int16Array.cpp @@ -0,0 +1,71 @@ +#include "V8Int16Array.h" + +namespace Arabica { +namespace DOM { + +v8::Persistent<v8::FunctionTemplate> V8Int16Array::Tmpl; + + +v8::Handle<v8::Value> V8Int16Array::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8Int16ArrayPrivate* privData = V8DOM::toClassPtr<V8Int16ArrayPrivate >(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle<v8::Value> V8Int16Array::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Int16ArrayPrivate* privData = V8DOM::toClassPtr<V8Int16ArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + short retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle<v8::Value> V8Int16Array::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Int16ArrayPrivate* privData = V8DOM::toClassPtr<V8Int16ArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + short localValue = args[1]->ToNumber()->Int32Value(); + + privData->nativeObj->set(localIndex, localValue); + + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8Int16Array::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Int16ArrayPrivate* privData = V8DOM::toClassPtr<V8Int16ArrayPrivate >(self->GetInternalField(0)); + long localStart = args[0]->ToNumber()->Int32Value(); + long localEnd = args[1]->ToNumber()->Int32Value(); + + uscxml::Int16Array* retVal = new uscxml::Int16Array(privData->nativeObj->subarray(localStart, localEnd)); + v8::Handle<v8::Function> retCtor = V8Int16Array::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + struct V8Int16Array::V8Int16ArrayPrivate* retPrivData = new V8Int16Array::V8Int16ArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8Int16Array::jsDestructor); + return retObj; + +} + +bool V8Int16Array::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int16Array.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int16Array.h new file mode 100644 index 0000000..e221cdd --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int16Array.h @@ -0,0 +1,91 @@ +/* + This file is part of the Wrapper open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef V8Int16Array_h +#define V8Int16Array_h + +#include <string> +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include <v8.h> + +namespace Arabica { +namespace DOM { + +class V8Int16Array { +public: + struct V8Int16ArrayPrivate { + V8DOM* dom; + uscxml::Int16Array* nativeObj; + }; + + V8_DESTRUCTOR(V8Int16ArrayPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> getCallback(const v8::Arguments&); + static v8::Handle<v8::Value> setCallback(const v8::Arguments&); + static v8::Handle<v8::Value> subarrayCallback(const v8::Arguments&); + + static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + static v8::Persistent<v8::FunctionTemplate> Tmpl; + static v8::Handle<v8::FunctionTemplate> getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Int16Array")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("length"), V8Int16Array::lengthAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Int16Array::getCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int16Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int16Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int16Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Int16Array::subarrayCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(2), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(2), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // V8Int16Array_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int32Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int32Array.cpp new file mode 100644 index 0000000..5d00d46 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int32Array.cpp @@ -0,0 +1,71 @@ +#include "V8Int32Array.h" + +namespace Arabica { +namespace DOM { + +v8::Persistent<v8::FunctionTemplate> V8Int32Array::Tmpl; + + +v8::Handle<v8::Value> V8Int32Array::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8Int32ArrayPrivate* privData = V8DOM::toClassPtr<V8Int32ArrayPrivate >(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle<v8::Value> V8Int32Array::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Int32ArrayPrivate* privData = V8DOM::toClassPtr<V8Int32ArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + long retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle<v8::Value> V8Int32Array::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Int32ArrayPrivate* privData = V8DOM::toClassPtr<V8Int32ArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + long localValue = args[1]->ToNumber()->Int32Value(); + + privData->nativeObj->set(localIndex, localValue); + + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8Int32Array::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Int32ArrayPrivate* privData = V8DOM::toClassPtr<V8Int32ArrayPrivate >(self->GetInternalField(0)); + long localStart = args[0]->ToNumber()->Int32Value(); + long localEnd = args[1]->ToNumber()->Int32Value(); + + uscxml::Int32Array* retVal = new uscxml::Int32Array(privData->nativeObj->subarray(localStart, localEnd)); + v8::Handle<v8::Function> retCtor = V8Int32Array::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + struct V8Int32Array::V8Int32ArrayPrivate* retPrivData = new V8Int32Array::V8Int32ArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8Int32Array::jsDestructor); + return retObj; + +} + +bool V8Int32Array::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int32Array.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int32Array.h new file mode 100644 index 0000000..892b666 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int32Array.h @@ -0,0 +1,91 @@ +/* + This file is part of the Wrapper open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef V8Int32Array_h +#define V8Int32Array_h + +#include <string> +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include <v8.h> + +namespace Arabica { +namespace DOM { + +class V8Int32Array { +public: + struct V8Int32ArrayPrivate { + V8DOM* dom; + uscxml::Int32Array* nativeObj; + }; + + V8_DESTRUCTOR(V8Int32ArrayPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> getCallback(const v8::Arguments&); + static v8::Handle<v8::Value> setCallback(const v8::Arguments&); + static v8::Handle<v8::Value> subarrayCallback(const v8::Arguments&); + + static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + static v8::Persistent<v8::FunctionTemplate> Tmpl; + static v8::Handle<v8::FunctionTemplate> getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Int32Array")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("length"), V8Int32Array::lengthAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Int32Array::getCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int32Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int32Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int32Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Int32Array::subarrayCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(4), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(4), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // V8Int32Array_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int8Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int8Array.cpp new file mode 100644 index 0000000..fd64a8c --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int8Array.cpp @@ -0,0 +1,71 @@ +#include "V8Int8Array.h" + +namespace Arabica { +namespace DOM { + +v8::Persistent<v8::FunctionTemplate> V8Int8Array::Tmpl; + + +v8::Handle<v8::Value> V8Int8Array::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8Int8ArrayPrivate* privData = V8DOM::toClassPtr<V8Int8ArrayPrivate >(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle<v8::Value> V8Int8Array::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Int8ArrayPrivate* privData = V8DOM::toClassPtr<V8Int8ArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + char retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle<v8::Value> V8Int8Array::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Int8ArrayPrivate* privData = V8DOM::toClassPtr<V8Int8ArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + char localValue = args[1]->ToNumber()->Int32Value(); + + privData->nativeObj->set(localIndex, localValue); + + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8Int8Array::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Int8ArrayPrivate* privData = V8DOM::toClassPtr<V8Int8ArrayPrivate >(self->GetInternalField(0)); + long localStart = args[0]->ToNumber()->Int32Value(); + long localEnd = args[1]->ToNumber()->Int32Value(); + + uscxml::Int8Array* retVal = new uscxml::Int8Array(privData->nativeObj->subarray(localStart, localEnd)); + v8::Handle<v8::Function> retCtor = V8Int8Array::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + struct V8Int8Array::V8Int8ArrayPrivate* retPrivData = new V8Int8Array::V8Int8ArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8Int8Array::jsDestructor); + return retObj; + +} + +bool V8Int8Array::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int8Array.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int8Array.h new file mode 100644 index 0000000..bcfcc3c --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int8Array.h @@ -0,0 +1,91 @@ +/* + This file is part of the Wrapper open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef V8Int8Array_h +#define V8Int8Array_h + +#include <string> +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include <v8.h> + +namespace Arabica { +namespace DOM { + +class V8Int8Array { +public: + struct V8Int8ArrayPrivate { + V8DOM* dom; + uscxml::Int8Array* nativeObj; + }; + + V8_DESTRUCTOR(V8Int8ArrayPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> getCallback(const v8::Arguments&); + static v8::Handle<v8::Value> setCallback(const v8::Arguments&); + static v8::Handle<v8::Value> subarrayCallback(const v8::Arguments&); + + static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + static v8::Persistent<v8::FunctionTemplate> Tmpl; + static v8::Handle<v8::FunctionTemplate> getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Int8Array")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("length"), V8Int8Array::lengthAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Int8Array::getCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int8Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int8Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int8Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Int8Array::subarrayCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(1), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(1), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // V8Int8Array_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint16Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint16Array.cpp new file mode 100644 index 0000000..c1d94d7 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint16Array.cpp @@ -0,0 +1,71 @@ +#include "V8Uint16Array.h" + +namespace Arabica { +namespace DOM { + +v8::Persistent<v8::FunctionTemplate> V8Uint16Array::Tmpl; + + +v8::Handle<v8::Value> V8Uint16Array::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8Uint16ArrayPrivate* privData = V8DOM::toClassPtr<V8Uint16ArrayPrivate >(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle<v8::Value> V8Uint16Array::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Uint16ArrayPrivate* privData = V8DOM::toClassPtr<V8Uint16ArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + unsigned short retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle<v8::Value> V8Uint16Array::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Uint16ArrayPrivate* privData = V8DOM::toClassPtr<V8Uint16ArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + unsigned short localValue = args[1]->ToNumber()->Uint32Value(); + + privData->nativeObj->set(localIndex, localValue); + + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8Uint16Array::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Uint16ArrayPrivate* privData = V8DOM::toClassPtr<V8Uint16ArrayPrivate >(self->GetInternalField(0)); + long localStart = args[0]->ToNumber()->Int32Value(); + long localEnd = args[1]->ToNumber()->Int32Value(); + + uscxml::Uint16Array* retVal = new uscxml::Uint16Array(privData->nativeObj->subarray(localStart, localEnd)); + v8::Handle<v8::Function> retCtor = V8Uint16Array::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + struct V8Uint16Array::V8Uint16ArrayPrivate* retPrivData = new V8Uint16Array::V8Uint16ArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8Uint16Array::jsDestructor); + return retObj; + +} + +bool V8Uint16Array::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint16Array.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint16Array.h new file mode 100644 index 0000000..e4d237d --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint16Array.h @@ -0,0 +1,91 @@ +/* + This file is part of the Wrapper open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef V8Uint16Array_h +#define V8Uint16Array_h + +#include <string> +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include <v8.h> + +namespace Arabica { +namespace DOM { + +class V8Uint16Array { +public: + struct V8Uint16ArrayPrivate { + V8DOM* dom; + uscxml::Uint16Array* nativeObj; + }; + + V8_DESTRUCTOR(V8Uint16ArrayPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> getCallback(const v8::Arguments&); + static v8::Handle<v8::Value> setCallback(const v8::Arguments&); + static v8::Handle<v8::Value> subarrayCallback(const v8::Arguments&); + + static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + static v8::Persistent<v8::FunctionTemplate> Tmpl; + static v8::Handle<v8::FunctionTemplate> getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Uint16Array")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("length"), V8Uint16Array::lengthAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Uint16Array::getCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint16Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint16Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint16Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Uint16Array::subarrayCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(2), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(2), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // V8Uint16Array_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint32Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint32Array.cpp new file mode 100644 index 0000000..54b05aa --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint32Array.cpp @@ -0,0 +1,71 @@ +#include "V8Uint32Array.h" + +namespace Arabica { +namespace DOM { + +v8::Persistent<v8::FunctionTemplate> V8Uint32Array::Tmpl; + + +v8::Handle<v8::Value> V8Uint32Array::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8Uint32ArrayPrivate* privData = V8DOM::toClassPtr<V8Uint32ArrayPrivate >(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle<v8::Value> V8Uint32Array::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Uint32ArrayPrivate* privData = V8DOM::toClassPtr<V8Uint32ArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + unsigned long retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle<v8::Value> V8Uint32Array::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Uint32ArrayPrivate* privData = V8DOM::toClassPtr<V8Uint32ArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + unsigned long localValue = args[1]->ToNumber()->Uint32Value(); + + privData->nativeObj->set(localIndex, localValue); + + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8Uint32Array::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Uint32ArrayPrivate* privData = V8DOM::toClassPtr<V8Uint32ArrayPrivate >(self->GetInternalField(0)); + long localStart = args[0]->ToNumber()->Int32Value(); + long localEnd = args[1]->ToNumber()->Int32Value(); + + uscxml::Uint32Array* retVal = new uscxml::Uint32Array(privData->nativeObj->subarray(localStart, localEnd)); + v8::Handle<v8::Function> retCtor = V8Uint32Array::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + struct V8Uint32Array::V8Uint32ArrayPrivate* retPrivData = new V8Uint32Array::V8Uint32ArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8Uint32Array::jsDestructor); + return retObj; + +} + +bool V8Uint32Array::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint32Array.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint32Array.h new file mode 100644 index 0000000..09098aa --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint32Array.h @@ -0,0 +1,91 @@ +/* + This file is part of the Wrapper open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef V8Uint32Array_h +#define V8Uint32Array_h + +#include <string> +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include <v8.h> + +namespace Arabica { +namespace DOM { + +class V8Uint32Array { +public: + struct V8Uint32ArrayPrivate { + V8DOM* dom; + uscxml::Uint32Array* nativeObj; + }; + + V8_DESTRUCTOR(V8Uint32ArrayPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> getCallback(const v8::Arguments&); + static v8::Handle<v8::Value> setCallback(const v8::Arguments&); + static v8::Handle<v8::Value> subarrayCallback(const v8::Arguments&); + + static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + static v8::Persistent<v8::FunctionTemplate> Tmpl; + static v8::Handle<v8::FunctionTemplate> getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Uint32Array")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("length"), V8Uint32Array::lengthAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Uint32Array::getCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint32Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint32Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint32Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Uint32Array::subarrayCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(4), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(4), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // V8Uint32Array_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint8Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint8Array.cpp new file mode 100644 index 0000000..cc13bf0 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint8Array.cpp @@ -0,0 +1,71 @@ +#include "V8Uint8Array.h" + +namespace Arabica { +namespace DOM { + +v8::Persistent<v8::FunctionTemplate> V8Uint8Array::Tmpl; + + +v8::Handle<v8::Value> V8Uint8Array::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8Uint8ArrayPrivate* privData = V8DOM::toClassPtr<V8Uint8ArrayPrivate >(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle<v8::Value> V8Uint8Array::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Uint8ArrayPrivate* privData = V8DOM::toClassPtr<V8Uint8ArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + char retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle<v8::Value> V8Uint8Array::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Uint8ArrayPrivate* privData = V8DOM::toClassPtr<V8Uint8ArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + unsigned char localValue = args[1]->ToNumber()->Uint32Value(); + + privData->nativeObj->set(localIndex, localValue); + + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8Uint8Array::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Uint8ArrayPrivate* privData = V8DOM::toClassPtr<V8Uint8ArrayPrivate >(self->GetInternalField(0)); + long localStart = args[0]->ToNumber()->Int32Value(); + long localEnd = args[1]->ToNumber()->Int32Value(); + + uscxml::Uint8Array* retVal = new uscxml::Uint8Array(privData->nativeObj->subarray(localStart, localEnd)); + v8::Handle<v8::Function> retCtor = V8Uint8Array::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + struct V8Uint8Array::V8Uint8ArrayPrivate* retPrivData = new V8Uint8Array::V8Uint8ArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8Uint8Array::jsDestructor); + return retObj; + +} + +bool V8Uint8Array::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint8Array.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint8Array.h new file mode 100644 index 0000000..e59d8a6 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint8Array.h @@ -0,0 +1,91 @@ +/* + This file is part of the Wrapper open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef V8Uint8Array_h +#define V8Uint8Array_h + +#include <string> +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include <v8.h> + +namespace Arabica { +namespace DOM { + +class V8Uint8Array { +public: + struct V8Uint8ArrayPrivate { + V8DOM* dom; + uscxml::Uint8Array* nativeObj; + }; + + V8_DESTRUCTOR(V8Uint8ArrayPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> getCallback(const v8::Arguments&); + static v8::Handle<v8::Value> setCallback(const v8::Arguments&); + static v8::Handle<v8::Value> subarrayCallback(const v8::Arguments&); + + static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + static v8::Persistent<v8::FunctionTemplate> Tmpl; + static v8::Handle<v8::FunctionTemplate> getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Uint8Array")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("length"), V8Uint8Array::lengthAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Uint8Array::getCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint8Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint8Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint8Array::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Uint8Array::subarrayCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(1), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(1), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // V8Uint8Array_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint8ClampedArray.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint8ClampedArray.cpp new file mode 100644 index 0000000..64c8d95 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint8ClampedArray.cpp @@ -0,0 +1,71 @@ +#include "V8Uint8ClampedArray.h" + +namespace Arabica { +namespace DOM { + +v8::Persistent<v8::FunctionTemplate> V8Uint8ClampedArray::Tmpl; + + +v8::Handle<v8::Value> V8Uint8ClampedArray::lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) { + v8::Local<v8::Object> self = info.Holder(); + struct V8Uint8ClampedArrayPrivate* privData = V8DOM::toClassPtr<V8Uint8ClampedArrayPrivate >(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle<v8::Value> V8Uint8ClampedArray::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Uint8ClampedArrayPrivate* privData = V8DOM::toClassPtr<V8Uint8ClampedArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + char retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle<v8::Value> V8Uint8ClampedArray::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Uint8ClampedArrayPrivate* privData = V8DOM::toClassPtr<V8Uint8ClampedArrayPrivate >(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + unsigned char localValue = args[1]->ToNumber()->Uint32Value(); + + privData->nativeObj->set(localIndex, localValue); + + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8Uint8ClampedArray::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local<v8::Object> self = args.Holder(); + struct V8Uint8ClampedArrayPrivate* privData = V8DOM::toClassPtr<V8Uint8ClampedArrayPrivate >(self->GetInternalField(0)); + long localStart = args[0]->ToNumber()->Int32Value(); + long localEnd = args[1]->ToNumber()->Int32Value(); + + uscxml::Uint8ClampedArray* retVal = new uscxml::Uint8ClampedArray(privData->nativeObj->subarray(localStart, localEnd)); + v8::Handle<v8::Function> retCtor = V8Uint8ClampedArray::getTmpl()->GetFunction(); + v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); + + struct V8Uint8ClampedArray::V8Uint8ClampedArrayPrivate* retPrivData = new V8Uint8ClampedArray::V8Uint8ClampedArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, V8Uint8ClampedArray::jsDestructor); + return retObj; + +} + +bool V8Uint8ClampedArray::hasInstance(v8::Handle<v8::Value> value) { + return getTmpl()->HasInstance(value); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint8ClampedArray.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint8ClampedArray.h new file mode 100644 index 0000000..37f9482 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint8ClampedArray.h @@ -0,0 +1,91 @@ +/* + This file is part of the Wrapper open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef V8Uint8ClampedArray_h +#define V8Uint8ClampedArray_h + +#include <string> +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include <v8.h> + +namespace Arabica { +namespace DOM { + +class V8Uint8ClampedArray { +public: + struct V8Uint8ClampedArrayPrivate { + V8DOM* dom; + uscxml::Uint8ClampedArray* nativeObj; + }; + + V8_DESTRUCTOR(V8Uint8ClampedArrayPrivate); + static bool hasInstance(v8::Handle<v8::Value>); + + static v8::Handle<v8::Value> getCallback(const v8::Arguments&); + static v8::Handle<v8::Value> setCallback(const v8::Arguments&); + static v8::Handle<v8::Value> subarrayCallback(const v8::Arguments&); + + static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info); + + static v8::Persistent<v8::FunctionTemplate> Tmpl; + static v8::Handle<v8::FunctionTemplate> getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Uint8ClampedArray")); + tmpl->ReadOnlyPrototype(); + + v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("length"), V8Uint8ClampedArray::lengthAttrGetter, 0, + v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Uint8ClampedArray::getCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint8ClampedArray::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint8ClampedArray::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint8ClampedArray::setCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Uint8ClampedArray::subarrayCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(1), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(1), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // V8Uint8ClampedArray_h |