From 99d2c52f1068b2dd4bd16b8c1c8231beeb94a649 Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Fri, 30 Aug 2013 12:33:43 +0200 Subject: Started work on ECMAScript TypedArrays --- CMakeLists.txt | 7 +- contrib/cmake/FindFFMPEG.cmake | 14 + contrib/dom/idl/TypedArray.idl | 284 ++++++++++++ contrib/dom/scripts/CodeGeneratorArabicaJSC.pm | 58 ++- contrib/dom/scripts/CodeGeneratorArabicaV8.pm | 55 ++- contrib/dom/scripts/generate-bindings.pl | 2 + contrib/dom/scripts/preprocessor.pm | 2 +- .../JavaScriptCore/dom/JSCArrayBuffer.cpp | 76 ++++ .../ecmascript/JavaScriptCore/dom/JSCArrayBuffer.h | 71 +++ .../JavaScriptCore/dom/JSCArrayBufferView.cpp | 53 +++ .../JavaScriptCore/dom/JSCArrayBufferView.h | 71 +++ .../ecmascript/JavaScriptCore/dom/JSCDataView.cpp | 374 ++++++++++++++++ .../ecmascript/JavaScriptCore/dom/JSCDataView.h | 84 ++++ .../JavaScriptCore/dom/JSCFloat32Array.cpp | 105 +++++ .../JavaScriptCore/dom/JSCFloat32Array.h | 73 +++ .../JavaScriptCore/dom/JSCFloat64Array.cpp | 105 +++++ .../JavaScriptCore/dom/JSCFloat64Array.h | 73 +++ .../JavaScriptCore/dom/JSCInt16Array.cpp | 105 +++++ .../ecmascript/JavaScriptCore/dom/JSCInt16Array.h | 73 +++ .../JavaScriptCore/dom/JSCInt32Array.cpp | 105 +++++ .../ecmascript/JavaScriptCore/dom/JSCInt32Array.h | 73 +++ .../ecmascript/JavaScriptCore/dom/JSCInt8Array.cpp | 105 +++++ .../ecmascript/JavaScriptCore/dom/JSCInt8Array.h | 73 +++ .../JavaScriptCore/dom/JSCUint16Array.cpp | 105 +++++ .../ecmascript/JavaScriptCore/dom/JSCUint16Array.h | 73 +++ .../JavaScriptCore/dom/JSCUint32Array.cpp | 105 +++++ .../ecmascript/JavaScriptCore/dom/JSCUint32Array.h | 73 +++ .../JavaScriptCore/dom/JSCUint8Array.cpp | 105 +++++ .../ecmascript/JavaScriptCore/dom/JSCUint8Array.h | 73 +++ .../JavaScriptCore/dom/JSCUint8ClampedArray.cpp | 105 +++++ .../JavaScriptCore/dom/JSCUint8ClampedArray.h | 73 +++ .../plugins/datamodel/ecmascript/TypedArray.cpp | 89 ++++ .../plugins/datamodel/ecmascript/TypedArray.h | 149 ++++++ .../datamodel/ecmascript/v8/dom/V8ArrayBuffer.cpp | 57 +++ .../datamodel/ecmascript/v8/dom/V8ArrayBuffer.h | 82 ++++ .../ecmascript/v8/dom/V8ArrayBufferView.cpp | 48 ++ .../ecmascript/v8/dom/V8ArrayBufferView.h | 82 ++++ .../datamodel/ecmascript/v8/dom/V8DataView.cpp | 241 ++++++++++ .../datamodel/ecmascript/v8/dom/V8DataView.h | 121 +++++ .../datamodel/ecmascript/v8/dom/V8Float32Array.cpp | 71 +++ .../datamodel/ecmascript/v8/dom/V8Float32Array.h | 91 ++++ .../datamodel/ecmascript/v8/dom/V8Float64Array.cpp | 71 +++ .../datamodel/ecmascript/v8/dom/V8Float64Array.h | 91 ++++ .../datamodel/ecmascript/v8/dom/V8Int16Array.cpp | 71 +++ .../datamodel/ecmascript/v8/dom/V8Int16Array.h | 91 ++++ .../datamodel/ecmascript/v8/dom/V8Int32Array.cpp | 71 +++ .../datamodel/ecmascript/v8/dom/V8Int32Array.h | 91 ++++ .../datamodel/ecmascript/v8/dom/V8Int8Array.cpp | 71 +++ .../datamodel/ecmascript/v8/dom/V8Int8Array.h | 91 ++++ .../datamodel/ecmascript/v8/dom/V8Uint16Array.cpp | 71 +++ .../datamodel/ecmascript/v8/dom/V8Uint16Array.h | 91 ++++ .../datamodel/ecmascript/v8/dom/V8Uint32Array.cpp | 71 +++ .../datamodel/ecmascript/v8/dom/V8Uint32Array.h | 91 ++++ .../datamodel/ecmascript/v8/dom/V8Uint8Array.cpp | 71 +++ .../datamodel/ecmascript/v8/dom/V8Uint8Array.h | 91 ++++ .../ecmascript/v8/dom/V8Uint8ClampedArray.cpp | 71 +++ .../ecmascript/v8/dom/V8Uint8ClampedArray.h | 91 ++++ src/uscxml/plugins/invoker/CMakeLists.txt | 1 + src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp | 12 +- .../plugins/invoker/ffmpeg/FFMPEGInvoker.cpp | 497 ++++++++++++++++++++- src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.h | 18 + test/samples/uscxml/test-ffmpeg.scxml | 5 + 62 files changed, 5598 insertions(+), 15 deletions(-) create mode 100644 contrib/dom/idl/TypedArray.idl create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBufferView.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBufferView.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDataView.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDataView.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat32Array.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat32Array.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat64Array.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat64Array.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt16Array.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt16Array.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt32Array.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt32Array.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt8Array.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt8Array.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint16Array.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint16Array.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint32Array.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint32Array.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8Array.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8Array.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8ClampedArray.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8ClampedArray.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/TypedArray.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBufferView.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBufferView.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DataView.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DataView.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Float32Array.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Float32Array.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Float64Array.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Float64Array.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int16Array.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int16Array.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int32Array.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int32Array.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int8Array.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Int8Array.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint16Array.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint16Array.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint32Array.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint32Array.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint8Array.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint8Array.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint8ClampedArray.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Uint8ClampedArray.h create mode 100644 test/samples/uscxml/test-ffmpeg.scxml diff --git a/CMakeLists.txt b/CMakeLists.txt index 82a8b4f..db61c10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -500,7 +500,7 @@ if (APPLE OR IOS) endif() -if (APPLE OR IOS) +if (OFF AND APPLE OR IOS) find_library(JSC_LIBRARY JavaScriptCore) list (APPEND USCXML_OPT_LIBS ${JSC_LIBRARY}) set(JSC_FOUND ON) @@ -536,10 +536,13 @@ find_package(Sqlite3) if (SQLITE3_FOUND) endif() +set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SHARED}) find_package(FFMPEG) if (FFMPEG_FOUND) - include_directories (${FFMPEG_INCLUDE_DIR}) + include_directories (${FFMPEG_INCLUDE_DIR}) + list (APPEND USCXML_OPT_LIBS ${FFMPEG_LIBRARIES}) endif() +set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_STATIC}) set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SHARED}) find_package(LIBICAL) diff --git a/contrib/cmake/FindFFMPEG.cmake b/contrib/cmake/FindFFMPEG.cmake index 6be21cd..e01e1f9 100644 --- a/contrib/cmake/FindFFMPEG.cmake +++ b/contrib/cmake/FindFFMPEG.cmake @@ -27,6 +27,8 @@ else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) pkg_check_modules(_FFMPEG_AVCODEC libavcodec) pkg_check_modules(_FFMPEG_AVFORMAT libavformat) pkg_check_modules(_FFMPEG_AVUTIL libavutil) + pkg_check_modules(_FFMPEG_SWSCALE libswscale) + pkg_check_modules(_FFMPEG_SWRESAMPLE libswresample) endif (PKG_CONFIG_FOUND) find_path(FFMPEG_AVCODEC_INCLUDE_DIR @@ -50,6 +52,16 @@ else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib ) + find_library(FFMPEG_LIBSWSCALE + NAMES swscale + PATHS ${_FFMPEG_SWSCALE_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib + ) + + find_library(FFMPEG_SWRESAMPLE + NAMES swresample + PATHS ${_FFMPEG_SWRESAMPLE_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib + ) + if (FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVFORMAT) set(FFMPEG_FOUND TRUE) endif() @@ -61,6 +73,8 @@ else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) ${FFMPEG_LIBAVCODEC} ${FFMPEG_LIBAVFORMAT} ${FFMPEG_LIBAVUTIL} + ${FFMPEG_LIBSWSCALE} + ${FFMPEG_SWRESAMPLE} ) endif (FFMPEG_FOUND) diff --git a/contrib/dom/idl/TypedArray.idl b/contrib/dom/idl/TypedArray.idl new file mode 100644 index 0000000..17df5c3 --- /dev/null +++ b/contrib/dom/idl/TypedArray.idl @@ -0,0 +1,284 @@ +/* + * typedarray.idl + * + * TypedArray IDL definitions scraped from the Khronos specification. + * + * Original Khronos Working Draft: + * + * https://www.khronos.org/registry/typedarray/specs/latest/ + */ + +[ Constructor(unsigned long length) ] +interface ArrayBuffer { + readonly attribute unsigned long byteLength; + ArrayBuffer slice(long begin, optional long end); + static boolean isView(any value); +}; + +[NoInterfaceObject] +interface ArrayBufferView { + readonly attribute ArrayBuffer buffer; + readonly attribute unsigned long byteOffset; + readonly attribute unsigned long byteLength; +}; + + +// The 'byte' type does not currently exist in Web IDL. +// In this IDL, it should be a signed 8 bit type. +[ + Constructor(unsigned long length), + Constructor(Int8Array array), + Constructor(byte[] array), + Constructor(ArrayBuffer buffer, + optional unsigned long byteOffset, optional unsigned long length) +] +interface Int8Array { + const long BYTES_PER_ELEMENT = 1; + + readonly attribute unsigned long length; + + getter byte get(unsigned long index); + setter void set(unsigned long index, byte value); + void set(Int8Array array, optional unsigned long offset); + void set(byte[] array, optional unsigned long offset); + Int8Array subarray(long start, long end); +}; +Int8Array implements ArrayBufferView; + + +// The 'unsigned byte' type does not currently exist in Web IDL, though +// 'octet' is equivalent. +[ + Constructor(unsigned long length), + Constructor(Uint8Array array), + Constructor(octet[] array), + Constructor(ArrayBuffer buffer, + optional unsigned long byteOffset, optional unsigned long length) +] +interface Uint8Array { + const long BYTES_PER_ELEMENT = 1; + + readonly attribute unsigned long length; + + getter octet get(unsigned long index); + setter void set(unsigned long index, octet value); + void set(Uint8Array array, optional unsigned long offset); + void set(octet[] array, optional unsigned long offset); + Uint8Array subarray(long start, long end); +}; +Uint8Array implements ArrayBufferView; + + +[ + Constructor(unsigned long length), + Constructor(Uint8ClampedArray array), + Constructor(octet[] array), + Constructor(ArrayBuffer buffer, + optional unsigned long byteOffset, optional unsigned long length) +] +interface Uint8ClampedArray { + const long BYTES_PER_ELEMENT = 1; + + readonly attribute unsigned long length; + + getter octet get(unsigned long index); + setter void set(unsigned long index, [Clamp] octet value); + void set(Uint8ClampedArray array, optional unsigned long offset); + void set(octet[] array, optional unsigned long offset); + Uint8ClampedArray subarray(long start, long end); +}; +Uint8ClampedArray implements ArrayBufferView; + + +[ + Constructor(unsigned long length), + Constructor(Int16Array array), + Constructor(short[] array), + Constructor(ArrayBuffer buffer, + optional unsigned long byteOffset, optional unsigned long length) +] +interface Int16Array { + const long BYTES_PER_ELEMENT = 2; + + readonly attribute unsigned long length; + + getter short get(unsigned long index); + setter void set(unsigned long index, short value); + void set(Int16Array array, optional unsigned long offset); + void set(short[] array, optional unsigned long offset); + Int16Array subarray(long start, long end); +}; +Int16Array implements ArrayBufferView; + + +[ + Constructor(unsigned long length), + Constructor(Uint16Array array), + Constructor(unsigned short[] array), + Constructor(ArrayBuffer buffer, + optional unsigned long byteOffset, optional unsigned long length) +] +interface Uint16Array { + const long BYTES_PER_ELEMENT = 2; + + readonly attribute unsigned long length; + + getter unsigned short get(unsigned long index); + setter void set(unsigned long index, unsigned short value); + void set(Uint16Array array, optional unsigned long offset); + void set(unsigned short[] array, optional unsigned long offset); + Uint16Array subarray(long start, long end); +}; +Uint16Array implements ArrayBufferView; + + +[ + Constructor(unsigned long length), + Constructor(Int32Array array), + Constructor(long[] array), + Constructor(ArrayBuffer buffer, + optional unsigned long byteOffset, optional unsigned long length) +] +interface Int32Array { + const long BYTES_PER_ELEMENT = 4; + + readonly attribute unsigned long length; + + getter long get(unsigned long index); + setter void set(unsigned long index, long value); + void set(Int32Array array, optional unsigned long offset); + void set(long[] array, optional unsigned long offset); + Int32Array subarray(long start, long end); +}; +Int32Array implements ArrayBufferView; + + +[ + Constructor(unsigned long length), + Constructor(Uint32Array array), + Constructor(unsigned long[] array), + Constructor(ArrayBuffer buffer, + optional unsigned long byteOffset, optional unsigned long length) +] +interface Uint32Array { + const long BYTES_PER_ELEMENT = 4; + + readonly attribute unsigned long length; + + getter unsigned long get(unsigned long index); + setter void set(unsigned long index, unsigned long value); + void set(Uint32Array array, optional unsigned long offset); + void set(unsigned long[] array, optional unsigned long offset); + Uint32Array subarray(long start, long end); +}; +Uint32Array implements ArrayBufferView; + + +[ + Constructor(unsigned long length), + Constructor(Float32Array array), + Constructor(float[] array), + Constructor(ArrayBuffer buffer, + optional unsigned long byteOffset, optional unsigned long length) +] +interface Float32Array { + const long BYTES_PER_ELEMENT = 4; + + readonly attribute unsigned long length; + + getter float get(unsigned long index); + setter void set(unsigned long index, float value); + void set(Float32Array array, optional unsigned long offset); + void set(float[] array, optional unsigned long offset); + Float32Array subarray(long start, long end); +}; +Float32Array implements ArrayBufferView; + + +[ + Constructor(unsigned long length), + Constructor(Float64Array array), + Constructor(double[] array), + Constructor(ArrayBuffer buffer, + optional unsigned long byteOffset, optional unsigned long length) +] +interface Float64Array { + const long BYTES_PER_ELEMENT = 8; + + readonly attribute unsigned long length; + + getter double get(unsigned long index); + setter void set(unsigned long index, double value); + void set(Float64Array array, optional unsigned long offset); + void set(double[] array, optional unsigned long offset); + Float64Array subarray(long start, long end); +}; +Float64Array implements ArrayBufferView; + + +[ + Constructor(ArrayBuffer buffer, + optional unsigned long byteOffset, + optional unsigned long byteLength) +] +interface DataView { + // Gets the value of the given type at the specified byte offset + // from the start of the view. There is no alignment constraint; + // multi-byte values may be fetched from any offset. + // + // For multi-byte values, the optional littleEndian argument + // indicates whether a big-endian or little-endian value should be + // read. If false or undefined, a big-endian value is read. + // + // These methods raise an INDEX_SIZE_ERR exception if they would read + // beyond the end of the view. + byte getInt8(unsigned long byteOffset); + octet getUint8(unsigned long byteOffset); + short getInt16(unsigned long byteOffset, + optional boolean littleEndian); + unsigned short getUint16(unsigned long byteOffset, + optional boolean littleEndian); + long getInt32(unsigned long byteOffset, + optional boolean littleEndian); + unsigned long getUint32(unsigned long byteOffset, + optional boolean littleEndian); + float getFloat32(unsigned long byteOffset, + optional boolean littleEndian); + double getFloat64(unsigned long byteOffset, + optional boolean littleEndian); + + // Stores a value of the given type at the specified byte offset + // from the start of the view. There is no alignment constraint; + // multi-byte values may be stored at any offset. + // + // For multi-byte values, the optional littleEndian argument + // indicates whether the value should be stored in big-endian or + // little-endian byte order. If false or undefined, the value is + // stored in big-endian byte order. + // + // These methods throw exceptions if they would write beyond the end + // of the view. + void setInt8(unsigned long byteOffset, + byte value); + void setUint8(unsigned long byteOffset, + octet value); + void setInt16(unsigned long byteOffset, + short value, + optional boolean littleEndian); + void setUint16(unsigned long byteOffset, + unsigned short value, + optional boolean littleEndian); + void setInt32(unsigned long byteOffset, + long value, + optional boolean littleEndian); + void setUint32(unsigned long byteOffset, + unsigned long value, + optional boolean littleEndian); + void setFloat32(unsigned long byteOffset, + float value, + optional boolean littleEndian); + void setFloat64(unsigned long byteOffset, + double value, + optional boolean littleEndian); +}; +DataView implements ArrayBufferView; \ No newline at end of file diff --git a/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm b/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm index 1546ea6..8fc67ce 100644 --- a/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm +++ b/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm @@ -127,7 +127,7 @@ sub GenerateHeader my $interface = shift; my $interfaceName = $interface->name; my $extensions = $interface->extendedAttributes; -# print Dumper($extensions); + #print Dumper($interface); # Copy contents of parent interfaces except the first parent. my @parents; @@ -141,6 +141,10 @@ sub GenerateHeader $headerIncludes{"DOM/Node.hpp"} = 1; $headerIncludes{"JavaScriptCore/JavaScriptCore.h"} = 1; + if ($interfaceName =~ /.*Array$/ or $interfaceName =~ /^ArrayBuffer.*/) { + $headerIncludes{"../../TypedArray.h"} = 1; + } + foreach (@{$interface->parents}) { my $parent = $_; $headerIncludes{"JSC${parent}.h"} = 1; @@ -180,11 +184,15 @@ END # callbacks for actual functions + my %generated; foreach my $function (@{$interface->functions}) { my $name = $function->signature->name; my $attrExt = $function->signature->extendedAttributes; my $custom = ($attrExt->{'Custom'} ? "Custom" : ""); + next if (exists $generated{"${name}${custom}Callback"}); + push(@headerContent, "\n static JSValueRef ${name}${custom}Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception);"); + $generated{"${name}${custom}Callback"} = 1; } push(@headerContent, "\n"); @@ -440,6 +448,7 @@ sub GenerateImplementationFunctionCallbacks my $wrapperType = IdlToWrapperType($interfaceName); # Generate methods for functions. + my %generated; foreach my $function (@{$interface->functions}) { my $name = $function->signature->name; my $attrExt = $function->signature->extendedAttributes; @@ -447,6 +456,8 @@ sub GenerateImplementationFunctionCallbacks my $wrapperRetType = IdlToWrapperType($retType); next if ($attrExt->{'Custom'}); + next if (exists $generated{"${name}Callback"}); + $generated{"${name}Callback"} = 1; # signature push(@implContent, <" if ($idlType eq "Element"); return "uscxml::Event" if ($idlType eq "SCXMLEvent"); return "uscxml::Storage" if ($idlType eq "Storage"); + return "uscxml::ArrayBuffer" if ($idlType eq "ArrayBuffer"); + return "uscxml::ArrayBufferView" if ($idlType eq "ArrayBufferView"); + return "uscxml::Int8Array" if ($idlType eq "Int8Array"); + return "uscxml::Uint8Array" if ($idlType eq "Uint8Array"); + return "uscxml::Uint8ClampedArray" if ($idlType eq "Uint8ClampedArray"); + return "uscxml::Int16Array" if ($idlType eq "Int16Array"); + return "uscxml::Uint16Array" if ($idlType eq "Uint16Array"); + return "uscxml::Int32Array" if ($idlType eq "Int32Array"); + return "uscxml::Uint32Array" if ($idlType eq "Uint32Array"); + return "uscxml::Float32Array" if ($idlType eq "Float32Array"); + return "uscxml::Float64Array" if ($idlType eq "Float64Array"); + return "uscxml::DataView" if ($idlType eq "DataView"); return "Arabica::DOM::${idlType}"; } @@ -689,8 +725,18 @@ sub IdlToArgHandle "${localName}") ; } return ("unsigned long ${localName} = (unsigned long)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "unsigned long"); + return ("long ${localName} = (long)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "long"); return ("unsigned short ${localName} = (unsigned short)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "unsigned short"); + return ("float ${localName} = (float)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "float"); + return ("double ${localName} = (double)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "double"); + return ("short ${localName} = (short)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "short"); + return ("char ${localName} = (char)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "byte"); + return ("unsigned char ${localName} = (char)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "octet"); return ("bool ${localName} = JSValueToBoolean(ctx, ${paramName});", ${localName}) if ($type eq "boolean"); + return ("float[] ${localName} = JSObjectGetPrivate(JSValueToObject(ctx, ${paramName}, exception))->getFloatArray();", ${localName}) if ($type eq "float[]"); + return ("double[] ${localName} = JSObjectGetPrivate(JSValueToObject(ctx, ${paramName}, exception))->getDoubleArray();", ${localName}) if ($type eq "double[]"); + return ("long[] ${localName} = JSObjectGetPrivate(JSValueToObject(ctx, ${paramName}, exception))->getLongArray();", ${localName}) if ($type eq "long[]"); + return ("void* ${localName} = JSObjectGetPrivate(JSValueToObject(ctx, ${paramName}, exception));", ${localName}) if ($type eq "any"); if (IsWrapperType($type)) { my $wrapperType = IdlToWrapperType($type); @@ -847,8 +893,16 @@ my %non_wrapper_types = ( 'int' => 1, 'long long' => 1, 'long' => 1, + 'long[]' => 1, 'short' => 1, 'void' => 1, + 'byte' => 1, + 'octet' => 1, + 'char' => 1, + 'float[]' => 1, + 'float' => 1, + 'double[]' => 1, + 'double' => 1, 'unsigned int' => 1, 'unsigned long long' => 1, 'unsigned long' => 1, diff --git a/contrib/dom/scripts/CodeGeneratorArabicaV8.pm b/contrib/dom/scripts/CodeGeneratorArabicaV8.pm index 7befef9..8623694 100644 --- a/contrib/dom/scripts/CodeGeneratorArabicaV8.pm +++ b/contrib/dom/scripts/CodeGeneratorArabicaV8.pm @@ -142,6 +142,10 @@ sub GenerateHeader $headerIncludes{"DOM/Node.hpp"} = 1; $headerIncludes{"v8.h"} = 1; + if ($interfaceName =~ /.*Array$/ or $interfaceName =~ /^ArrayBuffer.*/) { + $headerIncludes{"../../TypedArray.h"} = 1; + } + foreach (@{$interface->parents}) { my $parent = $_; $headerIncludes{"V8${parent}.h"} = 1; @@ -182,11 +186,14 @@ END # callbacks for actual functions + my %generated; foreach my $function (@{$interface->functions}) { my $name = $function->signature->name; my $attrExt = $function->signature->extendedAttributes; my $custom = ($attrExt->{'Custom'} ? "Custom" : ""); + next if (exists $generated{"${name}${custom}Callback"}); push(@headerContent, "\n static v8::Handle ${name}${custom}Callback(const v8::Arguments&);"); + $generated{"${name}${custom}Callback"} = 1; } push(@headerContent, "\n"); @@ -401,6 +408,7 @@ sub GenerateImplementationFunctionCallbacks my $wrapperType = IdlToWrapperType($interfaceName); # Generate methods for functions. + my %generated; foreach my $function (@{$interface->functions}) { my $name = $function->signature->name; my $attrExt = $function->signature->extendedAttributes; @@ -408,6 +416,8 @@ sub GenerateImplementationFunctionCallbacks my $wrapperRetType = IdlToWrapperType($retType); next if ($attrExt->{'Custom'}); + next if (exists $generated{"${name}Callback"}); + $generated{"${name}Callback"} = 1; # signature push(@implContent, <" if ($idlType eq "Element"); return "uscxml::Event" if ($idlType eq "SCXMLEvent"); return "uscxml::Storage" if ($idlType eq "Storage"); + return "uscxml::ArrayBuffer" if ($idlType eq "ArrayBuffer"); + return "uscxml::ArrayBufferView" if ($idlType eq "ArrayBufferView"); + return "uscxml::Int8Array" if ($idlType eq "Int8Array"); + return "uscxml::Uint8Array" if ($idlType eq "Uint8Array"); + return "uscxml::Uint8ClampedArray" if ($idlType eq "Uint8ClampedArray"); + return "uscxml::Int16Array" if ($idlType eq "Int16Array"); + return "uscxml::Uint16Array" if ($idlType eq "Uint16Array"); + return "uscxml::Int32Array" if ($idlType eq "Int32Array"); + return "uscxml::Uint32Array" if ($idlType eq "Uint32Array"); + return "uscxml::Float32Array" if ($idlType eq "Float32Array"); + return "uscxml::Float64Array" if ($idlType eq "Float64Array"); + return "uscxml::DataView" if ($idlType eq "DataView"); return "Arabica::DOM::${idlType}"; } @@ -646,8 +682,18 @@ sub IdlToArgHandle return ("v8::String::AsciiValue ${localName}(${paramName});", "*${localName}") if ($type eq "DOMString"); return ("unsigned long ${localName} = ${paramName}->ToNumber()->Uint32Value();", ${localName}) if ($type eq "unsigned long"); + return ("long ${localName} = ${paramName}->ToNumber()->Int32Value();", ${localName}) if ($type eq "long"); + return ("double ${localName} = ${paramName}->ToNumber()->Value();", ${localName}) if ($type eq "double"); + return ("float ${localName} = ${paramName}->ToNumber()->Value();", ${localName}) if ($type eq "float"); return ("unsigned short ${localName} = ${paramName}->ToNumber()->Uint32Value();", ${localName}) if ($type eq "unsigned short"); return ("bool ${localName} = ${paramName}->ToBoolean()->BooleanValue();", ${localName}) if ($type eq "boolean"); + return ("char ${localName} = ${paramName}->ToNumber()->Int32Value();", ${localName}) if ($type eq "byte"); + return ("short ${localName} = ${paramName}->ToNumber()->Int32Value();", ${localName}) if ($type eq "short"); + return ("unsigned char ${localName} = ${paramName}->ToNumber()->Uint32Value();", ${localName}) if ($type eq "octet"); + return ("void* ${localName} = v8::External::Unwrap(${paramName}->ToObject()->GetInternalField(0));", ${localName}) if ($type eq "any"); + return ("long[] ${localName} = V8DOM::toClassPtr(${paramName}->ToObject()->GetInternalField(0))->nativeObj->getLongArray();", "${localName}") if ($type eq "long[]"); + return ("float[] ${localName} = V8DOM::toClassPtr(${paramName}->ToObject()->GetInternalField(0))->nativeObj->getFloatArray();", "${localName}") if ($type eq "float[]"); + return ("double[] ${localName} = V8DOM::toClassPtr(${paramName}->ToObject()->GetInternalField(0))->nativeObj->getDoubleArray();", "${localName}") if ($type eq "double[]"); if (IsWrapperType($type)) { my $wrapperType = IdlToWrapperType($type); @@ -789,7 +835,6 @@ my %non_wrapper_types = ( 'JSObject' => 1, 'MediaQueryListListener' => 1, 'NodeFilter' => 1, - 'SerializedScriptValue' => 1, 'any' => 1, 'boolean' => 1, 'double' => 1, @@ -797,8 +842,16 @@ my %non_wrapper_types = ( 'int' => 1, 'long long' => 1, 'long' => 1, + 'long[]' => 1, 'short' => 1, 'void' => 1, + 'byte' => 1, + 'octet' => 1, + 'char' => 1, + 'float[]' => 1, + 'float' => 1, + 'double[]' => 1, + 'double' => 1, 'unsigned int' => 1, 'unsigned long long' => 1, 'unsigned long' => 1, diff --git a/contrib/dom/scripts/generate-bindings.pl b/contrib/dom/scripts/generate-bindings.pl index a31a862..ecf0218 100755 --- a/contrib/dom/scripts/generate-bindings.pl +++ b/contrib/dom/scripts/generate-bindings.pl @@ -68,6 +68,8 @@ GetOptions('include=s@' => \@idlDirectories, my $targetIdlFile = $ARGV[0]; +print "$targetIdlFile\n"; + die('Must specify input file.') unless defined($targetIdlFile); die('Must specify generator') unless defined($generator); die('Must specify output directory.') unless defined($outputDirectory); diff --git a/contrib/dom/scripts/preprocessor.pm b/contrib/dom/scripts/preprocessor.pm index 95995f0..5f67539 100644 --- a/contrib/dom/scripts/preprocessor.pm +++ b/contrib/dom/scripts/preprocessor.pm @@ -39,7 +39,7 @@ BEGIN { sub applyPreprocessor { my $fileName = shift; - my $defines = shift; + my $defines = shift || ""; my $preprocessor = shift; my @args = (); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.cpp new file mode 100644 index 0000000..39c8dab --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.cpp @@ -0,0 +1,76 @@ +#include "JSCArrayBuffer.h" + +namespace Arabica { +namespace DOM { + +JSClassRef JSCArrayBuffer::Tmpl; + +JSStaticValue JSCArrayBuffer::staticValues[] = { + { "byteLength", byteLengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCArrayBuffer::staticFunctions[] = { + { "slice", sliceCallback, kJSPropertyAttributeDontDelete }, + { "isView", isViewCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCArrayBuffer::byteLengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { + struct JSCArrayBufferPrivate* privData = (struct JSCArrayBufferPrivate*)JSObjectGetPrivate(object); + + return JSValueMakeNumber(ctx, privData->nativeObj->getByteLength()); +} + +JSValueRef JSCArrayBuffer::sliceCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in slice"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCArrayBufferPrivate* privData = (struct JSCArrayBufferPrivate*)JSObjectGetPrivate(thisObj); + + long localBegin = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + + uscxml::ArrayBuffer* retVal = new uscxml::ArrayBuffer(privData->nativeObj->slice(localBegin, localEnd)); + JSClassRef retClass = JSCArrayBuffer::getTmpl(); + + struct JSCArrayBuffer::JSCArrayBufferPrivate* retPrivData = new JSCArrayBuffer::JSCArrayBufferPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + + return retObj; + +} + +JSValueRef JSCArrayBuffer::isViewCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 1) { + std::string errorMsg = "Wrong number of arguments in isView"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCArrayBufferPrivate* privData = (struct JSCArrayBufferPrivate*)JSObjectGetPrivate(thisObj); + + void* localValue = JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)); + + bool retVal = privData->nativeObj->isView(localValue); + + JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); + return jscRetVal; +} + + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.h new file mode 100644 index 0000000..e3e7a14 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.h @@ -0,0 +1,71 @@ +/* + 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 JSCArrayBuffer_h +#define JSCArrayBuffer_h + +#include +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCArrayBuffer { +public: + struct JSCArrayBufferPrivate { + JSCDOM* dom; + uscxml::ArrayBuffer* nativeObj; + }; + + JSC_DESTRUCTOR(JSCArrayBufferPrivate); + + static JSValueRef sliceCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef isViewCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + static JSValueRef byteLengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + + + static JSStaticValue staticValues[]; + static JSStaticFunction staticFunctions[]; + + static JSClassRef Tmpl; + static JSClassRef getTmpl() { + if (Tmpl == NULL) { + JSClassDefinition classDef = kJSClassDefinitionEmpty; + classDef.staticValues = staticValues; + classDef.staticFunctions = staticFunctions; + classDef.finalize = jsDestructor; + + Tmpl = JSClassCreate(&classDef); + JSClassRetain(Tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // JSCArrayBuffer_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBufferView.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBufferView.cpp new file mode 100644 index 0000000..f599aff --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBufferView.cpp @@ -0,0 +1,53 @@ +#include "JSCArrayBuffer.h" +#include "JSCArrayBufferView.h" + +namespace Arabica { +namespace DOM { + +JSClassRef JSCArrayBufferView::Tmpl; + +JSStaticValue JSCArrayBufferView::staticValues[] = { + { "buffer", bufferAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "byteOffset", byteOffsetAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "byteLength", byteLengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCArrayBufferView::staticFunctions[] = { + { 0, 0, 0 } +}; + +JSValueRef JSCArrayBufferView::bufferAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { + struct JSCArrayBufferViewPrivate* privData = (struct JSCArrayBufferViewPrivate*)JSObjectGetPrivate(object); + + if (!privData->nativeObj->getBuffer()) return JSValueMakeUndefined(ctx); + uscxml::ArrayBuffer* arabicaRet = new uscxml::ArrayBuffer(privData->nativeObj->getBuffer()); + + JSClassRef arbaicaRetClass = JSCArrayBuffer::getTmpl(); + + struct JSCArrayBuffer::JSCArrayBufferPrivate* retPrivData = new JSCArrayBuffer::JSCArrayBufferPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arabicaRet; + + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, arabicaRet); + return arbaicaRetObj; +} + + +JSValueRef JSCArrayBufferView::byteOffsetAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { + struct JSCArrayBufferViewPrivate* privData = (struct JSCArrayBufferViewPrivate*)JSObjectGetPrivate(object); + + return JSValueMakeNumber(ctx, privData->nativeObj->getByteOffset()); +} + + +JSValueRef JSCArrayBufferView::byteLengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { + struct JSCArrayBufferViewPrivate* privData = (struct JSCArrayBufferViewPrivate*)JSObjectGetPrivate(object); + + return JSValueMakeNumber(ctx, privData->nativeObj->getByteLength()); +} + + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBufferView.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBufferView.h new file mode 100644 index 0000000..ab683c2 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBufferView.h @@ -0,0 +1,71 @@ +/* + 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 JSCArrayBufferView_h +#define JSCArrayBufferView_h + +#include +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCArrayBufferView { +public: + struct JSCArrayBufferViewPrivate { + JSCDOM* dom; + uscxml::ArrayBufferView* nativeObj; + }; + + JSC_DESTRUCTOR(JSCArrayBufferViewPrivate); + + + static JSValueRef bufferAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef byteOffsetAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef byteLengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + + + static JSStaticValue staticValues[]; + static JSStaticFunction staticFunctions[]; + + static JSClassRef Tmpl; + static JSClassRef getTmpl() { + if (Tmpl == NULL) { + JSClassDefinition classDef = kJSClassDefinitionEmpty; + classDef.staticValues = staticValues; + classDef.staticFunctions = staticFunctions; + classDef.finalize = jsDestructor; + + Tmpl = JSClassCreate(&classDef); + JSClassRetain(Tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // JSCArrayBufferView_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDataView.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDataView.cpp new file mode 100644 index 0000000..5e6ee80 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDataView.cpp @@ -0,0 +1,374 @@ +#include "JSCDataView.h" + +namespace Arabica { +namespace DOM { + +JSClassRef JSCDataView::Tmpl; + +JSStaticValue JSCDataView::staticValues[] = { + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCDataView::staticFunctions[] = { + { "getInt8", getInt8Callback, kJSPropertyAttributeDontDelete }, + { "getUint8", getUint8Callback, kJSPropertyAttributeDontDelete }, + { "getInt16", getInt16Callback, kJSPropertyAttributeDontDelete }, + { "getUint16", getUint16Callback, kJSPropertyAttributeDontDelete }, + { "getInt32", getInt32Callback, kJSPropertyAttributeDontDelete }, + { "getUint32", getUint32Callback, kJSPropertyAttributeDontDelete }, + { "getFloat32", getFloat32Callback, kJSPropertyAttributeDontDelete }, + { "getFloat64", getFloat64Callback, kJSPropertyAttributeDontDelete }, + { "setInt8", setInt8Callback, kJSPropertyAttributeDontDelete }, + { "setUint8", setUint8Callback, kJSPropertyAttributeDontDelete }, + { "setInt16", setInt16Callback, kJSPropertyAttributeDontDelete }, + { "setUint16", setUint16Callback, kJSPropertyAttributeDontDelete }, + { "setInt32", setInt32Callback, kJSPropertyAttributeDontDelete }, + { "setUint32", setUint32Callback, kJSPropertyAttributeDontDelete }, + { "setFloat32", setFloat32Callback, kJSPropertyAttributeDontDelete }, + { "setFloat64", setFloat64Callback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; +JSValueRef JSCDataView::getInt8Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 1) { + std::string errorMsg = "Wrong number of arguments in getInt8"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + + char retVal = privData->nativeObj->getInt8(localByteOffset); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCDataView::getUint8Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 1) { + std::string errorMsg = "Wrong number of arguments in getUint8"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + + char retVal = privData->nativeObj->getUint8(localByteOffset); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCDataView::getInt16Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in getInt16"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + + short retVal = privData->nativeObj->getInt16(localByteOffset, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCDataView::getUint16Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in getUint16"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + + unsigned short retVal = privData->nativeObj->getUint16(localByteOffset, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCDataView::getInt32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in getInt32"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + + long retVal = privData->nativeObj->getInt32(localByteOffset, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCDataView::getUint32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in getUint32"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + + unsigned long retVal = privData->nativeObj->getUint32(localByteOffset, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCDataView::getFloat32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in getFloat32"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + + float retVal = privData->nativeObj->getFloat32(localByteOffset, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCDataView::getFloat64Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in getFloat64"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + + double retVal = privData->nativeObj->getFloat64(localByteOffset, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCDataView::setInt8Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in setInt8"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + char localValue = (char)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->setInt8(localByteOffset, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCDataView::setUint8Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in setUint8"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned char localValue = (char)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->setUint8(localByteOffset, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCDataView::setInt16Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 3) { + std::string errorMsg = "Wrong number of arguments in setInt16"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + short localValue = (short)JSValueToNumber(ctx, arguments[1], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); + + privData->nativeObj->setInt16(localByteOffset, localValue, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCDataView::setUint16Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 3) { + std::string errorMsg = "Wrong number of arguments in setUint16"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned short localValue = (unsigned short)JSValueToNumber(ctx, arguments[1], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); + + privData->nativeObj->setUint16(localByteOffset, localValue, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCDataView::setInt32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 3) { + std::string errorMsg = "Wrong number of arguments in setInt32"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + long localValue = (long)JSValueToNumber(ctx, arguments[1], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); + + privData->nativeObj->setInt32(localByteOffset, localValue, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCDataView::setUint32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 3) { + std::string errorMsg = "Wrong number of arguments in setUint32"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned long localValue = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); + + privData->nativeObj->setUint32(localByteOffset, localValue, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCDataView::setFloat32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 3) { + std::string errorMsg = "Wrong number of arguments in setFloat32"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + float localValue = (float)JSValueToNumber(ctx, arguments[1], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); + + privData->nativeObj->setFloat32(localByteOffset, localValue, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCDataView::setFloat64Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 3) { + std::string errorMsg = "Wrong number of arguments in setFloat64"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + double localValue = (double)JSValueToNumber(ctx, arguments[1], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); + + privData->nativeObj->setFloat64(localByteOffset, localValue, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDataView.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDataView.h new file mode 100644 index 0000000..4d37120 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDataView.h @@ -0,0 +1,84 @@ +/* + 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 JSCDataView_h +#define JSCDataView_h + +#include +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCDataView { +public: + struct JSCDataViewPrivate { + JSCDOM* dom; + uscxml::DataView* nativeObj; + }; + + JSC_DESTRUCTOR(JSCDataViewPrivate); + + static JSValueRef getInt8Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef getUint8Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef getInt16Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef getUint16Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef getInt32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef getUint32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef getFloat32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef getFloat64Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setInt8Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setUint8Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setInt16Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setUint16Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setInt32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setUint32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setFloat32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setFloat64Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + + + static JSStaticValue staticValues[]; + static JSStaticFunction staticFunctions[]; + + static JSClassRef Tmpl; + static JSClassRef getTmpl() { + if (Tmpl == NULL) { + JSClassDefinition classDef = kJSClassDefinitionEmpty; + classDef.staticValues = staticValues; + classDef.staticFunctions = staticFunctions; + classDef.finalize = jsDestructor; + + Tmpl = JSClassCreate(&classDef); + JSClassRetain(Tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // JSCDataView_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat32Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat32Array.cpp new file mode 100644 index 0000000..f22ba32 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat32Array.cpp @@ -0,0 +1,105 @@ +#include "JSCFloat32Array.h" + +namespace Arabica { +namespace DOM { + +JSClassRef JSCFloat32Array::Tmpl; + +JSStaticValue JSCFloat32Array::staticValues[] = { + { "length", lengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { "BYTES_PER_ELEMENT", BYTES_PER_ELEMENTConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCFloat32Array::staticFunctions[] = { + { "get", getCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCFloat32Array::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { + struct JSCFloat32ArrayPrivate* privData = (struct JSCFloat32ArrayPrivate*)JSObjectGetPrivate(object); + + return JSValueMakeNumber(ctx, privData->nativeObj->getLength()); +} + +JSValueRef JSCFloat32Array::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef *exception) { + return JSValueMakeNumber(ctx, 4); +} + +JSValueRef JSCFloat32Array::getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 1) { + std::string errorMsg = "Wrong number of arguments in get"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCFloat32ArrayPrivate* privData = (struct JSCFloat32ArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + + float retVal = privData->nativeObj->get(localIndex); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCFloat32Array::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in set"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCFloat32ArrayPrivate* privData = (struct JSCFloat32ArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + float localValue = (float)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCFloat32Array::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in subarray"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCFloat32ArrayPrivate* privData = (struct JSCFloat32ArrayPrivate*)JSObjectGetPrivate(thisObj); + + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + + uscxml::Float32Array* retVal = new uscxml::Float32Array(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCFloat32Array::getTmpl(); + + struct JSCFloat32Array::JSCFloat32ArrayPrivate* retPrivData = new JSCFloat32Array::JSCFloat32ArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + + return retObj; + +} + + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat32Array.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat32Array.h new file mode 100644 index 0000000..21d4c59 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat32Array.h @@ -0,0 +1,73 @@ +/* + 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 JSCFloat32Array_h +#define JSCFloat32Array_h + +#include +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCFloat32Array { +public: + struct JSCFloat32ArrayPrivate { + JSCDOM* dom; + uscxml::Float32Array* nativeObj; + }; + + JSC_DESTRUCTOR(JSCFloat32ArrayPrivate); + + static JSValueRef getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + + + static JSStaticValue staticValues[]; + static JSStaticFunction staticFunctions[]; + + static JSClassRef Tmpl; + static JSClassRef getTmpl() { + if (Tmpl == NULL) { + JSClassDefinition classDef = kJSClassDefinitionEmpty; + classDef.staticValues = staticValues; + classDef.staticFunctions = staticFunctions; + classDef.finalize = jsDestructor; + + Tmpl = JSClassCreate(&classDef); + JSClassRetain(Tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // JSCFloat32Array_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat64Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat64Array.cpp new file mode 100644 index 0000000..06ca510 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat64Array.cpp @@ -0,0 +1,105 @@ +#include "JSCFloat64Array.h" + +namespace Arabica { +namespace DOM { + +JSClassRef JSCFloat64Array::Tmpl; + +JSStaticValue JSCFloat64Array::staticValues[] = { + { "length", lengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { "BYTES_PER_ELEMENT", BYTES_PER_ELEMENTConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCFloat64Array::staticFunctions[] = { + { "get", getCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCFloat64Array::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { + struct JSCFloat64ArrayPrivate* privData = (struct JSCFloat64ArrayPrivate*)JSObjectGetPrivate(object); + + return JSValueMakeNumber(ctx, privData->nativeObj->getLength()); +} + +JSValueRef JSCFloat64Array::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef *exception) { + return JSValueMakeNumber(ctx, 8); +} + +JSValueRef JSCFloat64Array::getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 1) { + std::string errorMsg = "Wrong number of arguments in get"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCFloat64ArrayPrivate* privData = (struct JSCFloat64ArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + + double retVal = privData->nativeObj->get(localIndex); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCFloat64Array::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in set"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCFloat64ArrayPrivate* privData = (struct JSCFloat64ArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + double localValue = (double)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCFloat64Array::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in subarray"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCFloat64ArrayPrivate* privData = (struct JSCFloat64ArrayPrivate*)JSObjectGetPrivate(thisObj); + + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + + uscxml::Float64Array* retVal = new uscxml::Float64Array(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCFloat64Array::getTmpl(); + + struct JSCFloat64Array::JSCFloat64ArrayPrivate* retPrivData = new JSCFloat64Array::JSCFloat64ArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + + return retObj; + +} + + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat64Array.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat64Array.h new file mode 100644 index 0000000..f21962d --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat64Array.h @@ -0,0 +1,73 @@ +/* + 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 JSCFloat64Array_h +#define JSCFloat64Array_h + +#include +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCFloat64Array { +public: + struct JSCFloat64ArrayPrivate { + JSCDOM* dom; + uscxml::Float64Array* nativeObj; + }; + + JSC_DESTRUCTOR(JSCFloat64ArrayPrivate); + + static JSValueRef getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + + + static JSStaticValue staticValues[]; + static JSStaticFunction staticFunctions[]; + + static JSClassRef Tmpl; + static JSClassRef getTmpl() { + if (Tmpl == NULL) { + JSClassDefinition classDef = kJSClassDefinitionEmpty; + classDef.staticValues = staticValues; + classDef.staticFunctions = staticFunctions; + classDef.finalize = jsDestructor; + + Tmpl = JSClassCreate(&classDef); + JSClassRetain(Tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // JSCFloat64Array_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt16Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt16Array.cpp new file mode 100644 index 0000000..2844b75 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt16Array.cpp @@ -0,0 +1,105 @@ +#include "JSCInt16Array.h" + +namespace Arabica { +namespace DOM { + +JSClassRef JSCInt16Array::Tmpl; + +JSStaticValue JSCInt16Array::staticValues[] = { + { "length", lengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { "BYTES_PER_ELEMENT", BYTES_PER_ELEMENTConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCInt16Array::staticFunctions[] = { + { "get", getCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCInt16Array::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { + struct JSCInt16ArrayPrivate* privData = (struct JSCInt16ArrayPrivate*)JSObjectGetPrivate(object); + + return JSValueMakeNumber(ctx, privData->nativeObj->getLength()); +} + +JSValueRef JSCInt16Array::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef *exception) { + return JSValueMakeNumber(ctx, 2); +} + +JSValueRef JSCInt16Array::getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 1) { + std::string errorMsg = "Wrong number of arguments in get"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCInt16ArrayPrivate* privData = (struct JSCInt16ArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + + short retVal = privData->nativeObj->get(localIndex); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCInt16Array::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in set"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCInt16ArrayPrivate* privData = (struct JSCInt16ArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + short localValue = (short)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCInt16Array::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in subarray"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCInt16ArrayPrivate* privData = (struct JSCInt16ArrayPrivate*)JSObjectGetPrivate(thisObj); + + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + + uscxml::Int16Array* retVal = new uscxml::Int16Array(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCInt16Array::getTmpl(); + + struct JSCInt16Array::JSCInt16ArrayPrivate* retPrivData = new JSCInt16Array::JSCInt16ArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + + return retObj; + +} + + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt16Array.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt16Array.h new file mode 100644 index 0000000..7510336 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt16Array.h @@ -0,0 +1,73 @@ +/* + 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 JSCInt16Array_h +#define JSCInt16Array_h + +#include +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCInt16Array { +public: + struct JSCInt16ArrayPrivate { + JSCDOM* dom; + uscxml::Int16Array* nativeObj; + }; + + JSC_DESTRUCTOR(JSCInt16ArrayPrivate); + + static JSValueRef getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + + + static JSStaticValue staticValues[]; + static JSStaticFunction staticFunctions[]; + + static JSClassRef Tmpl; + static JSClassRef getTmpl() { + if (Tmpl == NULL) { + JSClassDefinition classDef = kJSClassDefinitionEmpty; + classDef.staticValues = staticValues; + classDef.staticFunctions = staticFunctions; + classDef.finalize = jsDestructor; + + Tmpl = JSClassCreate(&classDef); + JSClassRetain(Tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // JSCInt16Array_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt32Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt32Array.cpp new file mode 100644 index 0000000..09d8f76 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt32Array.cpp @@ -0,0 +1,105 @@ +#include "JSCInt32Array.h" + +namespace Arabica { +namespace DOM { + +JSClassRef JSCInt32Array::Tmpl; + +JSStaticValue JSCInt32Array::staticValues[] = { + { "length", lengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { "BYTES_PER_ELEMENT", BYTES_PER_ELEMENTConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCInt32Array::staticFunctions[] = { + { "get", getCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCInt32Array::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { + struct JSCInt32ArrayPrivate* privData = (struct JSCInt32ArrayPrivate*)JSObjectGetPrivate(object); + + return JSValueMakeNumber(ctx, privData->nativeObj->getLength()); +} + +JSValueRef JSCInt32Array::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef *exception) { + return JSValueMakeNumber(ctx, 4); +} + +JSValueRef JSCInt32Array::getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 1) { + std::string errorMsg = "Wrong number of arguments in get"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCInt32ArrayPrivate* privData = (struct JSCInt32ArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + + long retVal = privData->nativeObj->get(localIndex); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCInt32Array::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in set"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCInt32ArrayPrivate* privData = (struct JSCInt32ArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + long localValue = (long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCInt32Array::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in subarray"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCInt32ArrayPrivate* privData = (struct JSCInt32ArrayPrivate*)JSObjectGetPrivate(thisObj); + + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + + uscxml::Int32Array* retVal = new uscxml::Int32Array(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCInt32Array::getTmpl(); + + struct JSCInt32Array::JSCInt32ArrayPrivate* retPrivData = new JSCInt32Array::JSCInt32ArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + + return retObj; + +} + + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt32Array.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt32Array.h new file mode 100644 index 0000000..901eb3c --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt32Array.h @@ -0,0 +1,73 @@ +/* + 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 JSCInt32Array_h +#define JSCInt32Array_h + +#include +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCInt32Array { +public: + struct JSCInt32ArrayPrivate { + JSCDOM* dom; + uscxml::Int32Array* nativeObj; + }; + + JSC_DESTRUCTOR(JSCInt32ArrayPrivate); + + static JSValueRef getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + + + static JSStaticValue staticValues[]; + static JSStaticFunction staticFunctions[]; + + static JSClassRef Tmpl; + static JSClassRef getTmpl() { + if (Tmpl == NULL) { + JSClassDefinition classDef = kJSClassDefinitionEmpty; + classDef.staticValues = staticValues; + classDef.staticFunctions = staticFunctions; + classDef.finalize = jsDestructor; + + Tmpl = JSClassCreate(&classDef); + JSClassRetain(Tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // JSCInt32Array_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt8Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt8Array.cpp new file mode 100644 index 0000000..509481e --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt8Array.cpp @@ -0,0 +1,105 @@ +#include "JSCInt8Array.h" + +namespace Arabica { +namespace DOM { + +JSClassRef JSCInt8Array::Tmpl; + +JSStaticValue JSCInt8Array::staticValues[] = { + { "length", lengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { "BYTES_PER_ELEMENT", BYTES_PER_ELEMENTConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCInt8Array::staticFunctions[] = { + { "get", getCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCInt8Array::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { + struct JSCInt8ArrayPrivate* privData = (struct JSCInt8ArrayPrivate*)JSObjectGetPrivate(object); + + return JSValueMakeNumber(ctx, privData->nativeObj->getLength()); +} + +JSValueRef JSCInt8Array::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef *exception) { + return JSValueMakeNumber(ctx, 1); +} + +JSValueRef JSCInt8Array::getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 1) { + std::string errorMsg = "Wrong number of arguments in get"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCInt8ArrayPrivate* privData = (struct JSCInt8ArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + + char retVal = privData->nativeObj->get(localIndex); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCInt8Array::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in set"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCInt8ArrayPrivate* privData = (struct JSCInt8ArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + char localValue = (char)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCInt8Array::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in subarray"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCInt8ArrayPrivate* privData = (struct JSCInt8ArrayPrivate*)JSObjectGetPrivate(thisObj); + + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + + uscxml::Int8Array* retVal = new uscxml::Int8Array(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCInt8Array::getTmpl(); + + struct JSCInt8Array::JSCInt8ArrayPrivate* retPrivData = new JSCInt8Array::JSCInt8ArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + + return retObj; + +} + + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt8Array.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt8Array.h new file mode 100644 index 0000000..a693f2a --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt8Array.h @@ -0,0 +1,73 @@ +/* + 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 JSCInt8Array_h +#define JSCInt8Array_h + +#include +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCInt8Array { +public: + struct JSCInt8ArrayPrivate { + JSCDOM* dom; + uscxml::Int8Array* nativeObj; + }; + + JSC_DESTRUCTOR(JSCInt8ArrayPrivate); + + static JSValueRef getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + + + static JSStaticValue staticValues[]; + static JSStaticFunction staticFunctions[]; + + static JSClassRef Tmpl; + static JSClassRef getTmpl() { + if (Tmpl == NULL) { + JSClassDefinition classDef = kJSClassDefinitionEmpty; + classDef.staticValues = staticValues; + classDef.staticFunctions = staticFunctions; + classDef.finalize = jsDestructor; + + Tmpl = JSClassCreate(&classDef); + JSClassRetain(Tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // JSCInt8Array_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint16Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint16Array.cpp new file mode 100644 index 0000000..88e71d6 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint16Array.cpp @@ -0,0 +1,105 @@ +#include "JSCUint16Array.h" + +namespace Arabica { +namespace DOM { + +JSClassRef JSCUint16Array::Tmpl; + +JSStaticValue JSCUint16Array::staticValues[] = { + { "length", lengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { "BYTES_PER_ELEMENT", BYTES_PER_ELEMENTConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCUint16Array::staticFunctions[] = { + { "get", getCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCUint16Array::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { + struct JSCUint16ArrayPrivate* privData = (struct JSCUint16ArrayPrivate*)JSObjectGetPrivate(object); + + return JSValueMakeNumber(ctx, privData->nativeObj->getLength()); +} + +JSValueRef JSCUint16Array::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef *exception) { + return JSValueMakeNumber(ctx, 2); +} + +JSValueRef JSCUint16Array::getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 1) { + std::string errorMsg = "Wrong number of arguments in get"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCUint16ArrayPrivate* privData = (struct JSCUint16ArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + + unsigned short retVal = privData->nativeObj->get(localIndex); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCUint16Array::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in set"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCUint16ArrayPrivate* privData = (struct JSCUint16ArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned short localValue = (unsigned short)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCUint16Array::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in subarray"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCUint16ArrayPrivate* privData = (struct JSCUint16ArrayPrivate*)JSObjectGetPrivate(thisObj); + + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + + uscxml::Uint16Array* retVal = new uscxml::Uint16Array(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCUint16Array::getTmpl(); + + struct JSCUint16Array::JSCUint16ArrayPrivate* retPrivData = new JSCUint16Array::JSCUint16ArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + + return retObj; + +} + + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint16Array.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint16Array.h new file mode 100644 index 0000000..dfc6cc8 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint16Array.h @@ -0,0 +1,73 @@ +/* + 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 JSCUint16Array_h +#define JSCUint16Array_h + +#include +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCUint16Array { +public: + struct JSCUint16ArrayPrivate { + JSCDOM* dom; + uscxml::Uint16Array* nativeObj; + }; + + JSC_DESTRUCTOR(JSCUint16ArrayPrivate); + + static JSValueRef getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + + + static JSStaticValue staticValues[]; + static JSStaticFunction staticFunctions[]; + + static JSClassRef Tmpl; + static JSClassRef getTmpl() { + if (Tmpl == NULL) { + JSClassDefinition classDef = kJSClassDefinitionEmpty; + classDef.staticValues = staticValues; + classDef.staticFunctions = staticFunctions; + classDef.finalize = jsDestructor; + + Tmpl = JSClassCreate(&classDef); + JSClassRetain(Tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // JSCUint16Array_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint32Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint32Array.cpp new file mode 100644 index 0000000..9887423 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint32Array.cpp @@ -0,0 +1,105 @@ +#include "JSCUint32Array.h" + +namespace Arabica { +namespace DOM { + +JSClassRef JSCUint32Array::Tmpl; + +JSStaticValue JSCUint32Array::staticValues[] = { + { "length", lengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { "BYTES_PER_ELEMENT", BYTES_PER_ELEMENTConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCUint32Array::staticFunctions[] = { + { "get", getCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCUint32Array::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { + struct JSCUint32ArrayPrivate* privData = (struct JSCUint32ArrayPrivate*)JSObjectGetPrivate(object); + + return JSValueMakeNumber(ctx, privData->nativeObj->getLength()); +} + +JSValueRef JSCUint32Array::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef *exception) { + return JSValueMakeNumber(ctx, 4); +} + +JSValueRef JSCUint32Array::getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 1) { + std::string errorMsg = "Wrong number of arguments in get"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCUint32ArrayPrivate* privData = (struct JSCUint32ArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + + unsigned long retVal = privData->nativeObj->get(localIndex); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCUint32Array::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in set"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCUint32ArrayPrivate* privData = (struct JSCUint32ArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned long localValue = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCUint32Array::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in subarray"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCUint32ArrayPrivate* privData = (struct JSCUint32ArrayPrivate*)JSObjectGetPrivate(thisObj); + + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + + uscxml::Uint32Array* retVal = new uscxml::Uint32Array(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCUint32Array::getTmpl(); + + struct JSCUint32Array::JSCUint32ArrayPrivate* retPrivData = new JSCUint32Array::JSCUint32ArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + + return retObj; + +} + + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint32Array.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint32Array.h new file mode 100644 index 0000000..0fac7fc --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint32Array.h @@ -0,0 +1,73 @@ +/* + 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 JSCUint32Array_h +#define JSCUint32Array_h + +#include +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCUint32Array { +public: + struct JSCUint32ArrayPrivate { + JSCDOM* dom; + uscxml::Uint32Array* nativeObj; + }; + + JSC_DESTRUCTOR(JSCUint32ArrayPrivate); + + static JSValueRef getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + + + static JSStaticValue staticValues[]; + static JSStaticFunction staticFunctions[]; + + static JSClassRef Tmpl; + static JSClassRef getTmpl() { + if (Tmpl == NULL) { + JSClassDefinition classDef = kJSClassDefinitionEmpty; + classDef.staticValues = staticValues; + classDef.staticFunctions = staticFunctions; + classDef.finalize = jsDestructor; + + Tmpl = JSClassCreate(&classDef); + JSClassRetain(Tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // JSCUint32Array_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8Array.cpp new file mode 100644 index 0000000..62c49af --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8Array.cpp @@ -0,0 +1,105 @@ +#include "JSCUint8Array.h" + +namespace Arabica { +namespace DOM { + +JSClassRef JSCUint8Array::Tmpl; + +JSStaticValue JSCUint8Array::staticValues[] = { + { "length", lengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { "BYTES_PER_ELEMENT", BYTES_PER_ELEMENTConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCUint8Array::staticFunctions[] = { + { "get", getCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCUint8Array::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { + struct JSCUint8ArrayPrivate* privData = (struct JSCUint8ArrayPrivate*)JSObjectGetPrivate(object); + + return JSValueMakeNumber(ctx, privData->nativeObj->getLength()); +} + +JSValueRef JSCUint8Array::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef *exception) { + return JSValueMakeNumber(ctx, 1); +} + +JSValueRef JSCUint8Array::getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 1) { + std::string errorMsg = "Wrong number of arguments in get"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCUint8ArrayPrivate* privData = (struct JSCUint8ArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + + char retVal = privData->nativeObj->get(localIndex); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCUint8Array::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in set"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCUint8ArrayPrivate* privData = (struct JSCUint8ArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned char localValue = (char)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCUint8Array::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in subarray"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCUint8ArrayPrivate* privData = (struct JSCUint8ArrayPrivate*)JSObjectGetPrivate(thisObj); + + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + + uscxml::Uint8Array* retVal = new uscxml::Uint8Array(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCUint8Array::getTmpl(); + + struct JSCUint8Array::JSCUint8ArrayPrivate* retPrivData = new JSCUint8Array::JSCUint8ArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + + return retObj; + +} + + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8Array.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8Array.h new file mode 100644 index 0000000..d45cee3 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8Array.h @@ -0,0 +1,73 @@ +/* + 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 JSCUint8Array_h +#define JSCUint8Array_h + +#include +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCUint8Array { +public: + struct JSCUint8ArrayPrivate { + JSCDOM* dom; + uscxml::Uint8Array* nativeObj; + }; + + JSC_DESTRUCTOR(JSCUint8ArrayPrivate); + + static JSValueRef getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + + + static JSStaticValue staticValues[]; + static JSStaticFunction staticFunctions[]; + + static JSClassRef Tmpl; + static JSClassRef getTmpl() { + if (Tmpl == NULL) { + JSClassDefinition classDef = kJSClassDefinitionEmpty; + classDef.staticValues = staticValues; + classDef.staticFunctions = staticFunctions; + classDef.finalize = jsDestructor; + + Tmpl = JSClassCreate(&classDef); + JSClassRetain(Tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // JSCUint8Array_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8ClampedArray.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8ClampedArray.cpp new file mode 100644 index 0000000..85222dc --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8ClampedArray.cpp @@ -0,0 +1,105 @@ +#include "JSCUint8ClampedArray.h" + +namespace Arabica { +namespace DOM { + +JSClassRef JSCUint8ClampedArray::Tmpl; + +JSStaticValue JSCUint8ClampedArray::staticValues[] = { + { "length", lengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { "BYTES_PER_ELEMENT", BYTES_PER_ELEMENTConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCUint8ClampedArray::staticFunctions[] = { + { "get", getCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "set", setCallback, kJSPropertyAttributeDontDelete }, + { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCUint8ClampedArray::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { + struct JSCUint8ClampedArrayPrivate* privData = (struct JSCUint8ClampedArrayPrivate*)JSObjectGetPrivate(object); + + return JSValueMakeNumber(ctx, privData->nativeObj->getLength()); +} + +JSValueRef JSCUint8ClampedArray::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef *exception) { + return JSValueMakeNumber(ctx, 1); +} + +JSValueRef JSCUint8ClampedArray::getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 1) { + std::string errorMsg = "Wrong number of arguments in get"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCUint8ClampedArrayPrivate* privData = (struct JSCUint8ClampedArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + + char retVal = privData->nativeObj->get(localIndex); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCUint8ClampedArray::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in set"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCUint8ClampedArrayPrivate* privData = (struct JSCUint8ClampedArrayPrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned char localValue = (char)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCUint8ClampedArray::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in subarray"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCUint8ClampedArrayPrivate* privData = (struct JSCUint8ClampedArrayPrivate*)JSObjectGetPrivate(thisObj); + + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + + uscxml::Uint8ClampedArray* retVal = new uscxml::Uint8ClampedArray(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCUint8ClampedArray::getTmpl(); + + struct JSCUint8ClampedArray::JSCUint8ClampedArrayPrivate* retPrivData = new JSCUint8ClampedArray::JSCUint8ClampedArrayPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + + return retObj; + +} + + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8ClampedArray.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8ClampedArray.h new file mode 100644 index 0000000..76cd77b --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8ClampedArray.h @@ -0,0 +1,73 @@ +/* + 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 JSCUint8ClampedArray_h +#define JSCUint8ClampedArray_h + +#include +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCUint8ClampedArray { +public: + struct JSCUint8ClampedArrayPrivate { + JSCDOM* dom; + uscxml::Uint8ClampedArray* nativeObj; + }; + + JSC_DESTRUCTOR(JSCUint8ClampedArrayPrivate); + + static JSValueRef getCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + + + static JSStaticValue staticValues[]; + static JSStaticFunction staticFunctions[]; + + static JSClassRef Tmpl; + static JSClassRef getTmpl() { + if (Tmpl == NULL) { + JSClassDefinition classDef = kJSClassDefinitionEmpty; + classDef.staticValues = staticValues; + classDef.staticFunctions = staticFunctions; + classDef.finalize = jsDestructor; + + Tmpl = JSClassCreate(&classDef); + JSClassRetain(Tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // JSCUint8ClampedArray_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp new file mode 100644 index 0000000..d6e2ada --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp @@ -0,0 +1,89 @@ +#include "TypedArray.h" +#include + +namespace uscxml { + +unsigned long ArrayBuffer::getByteLength() {} +ArrayBuffer ArrayBuffer::slice(long begin, long end) {} +bool ArrayBuffer::isView(void*) {} +ArrayBuffer::operator bool() {} + +ArrayBuffer ArrayBufferView::getBuffer() {} +unsigned long ArrayBufferView::getByteOffset() {} +unsigned long ArrayBufferView::getByteLength() {} + +ArrayBuffer DataView::getBuffer() {} +unsigned long DataView::getByteOffset() {} +unsigned long DataView::getByteLength() {} +char DataView::getInt8(unsigned long) {} +unsigned char DataView::getUint8(unsigned long) {} +short DataView::getInt16(unsigned long, bool) {} +unsigned short DataView::getUint16(unsigned long, bool) {} +long DataView::getInt32(unsigned long, bool) {} +unsigned long DataView::getUint32(unsigned long, bool) {} +float DataView::getFloat32(unsigned long, bool) {} +double DataView::getFloat64(unsigned long, bool) {} +void DataView::setInt8(long, char) {} +void DataView::setUint8(long, unsigned char) {} +void DataView::setInt16(long, short, bool) {} +void DataView::setUint16(long, unsigned short, bool) {} +void DataView::setInt32(long, long, bool) {} +void DataView::setUint32(long, unsigned long, bool) {} +void DataView::setFloat32(long, float, bool) {} +void DataView::setFloat64(long, double, bool) {} + +Uint8Array::Uint8Array(Uint8Array* other) {} +unsigned char Uint8Array::get(unsigned long) {} +void Uint8Array::set(unsigned long, char) {} +Uint8Array* Uint8Array::subarray(long, long) {} +unsigned long Uint8Array::getLength() {} + +Uint8ClampedArray::Uint8ClampedArray(Uint8ClampedArray* other) {} +unsigned char Uint8ClampedArray::get(unsigned long) {} +void Uint8ClampedArray::set(unsigned long, char) {} +Uint8ClampedArray* Uint8ClampedArray::subarray(long, long) {} +unsigned long Uint8ClampedArray::getLength() {} + +Int8Array::Int8Array(Int8Array* other) {} +char Int8Array::get(unsigned long) {} +void Int8Array::set(unsigned long, char) {} +Int8Array* Int8Array::subarray(long, long) {} +unsigned long Int8Array::getLength() {} + +Int16Array::Int16Array(Int16Array* other) {} +short Int16Array::get(unsigned long) {} +void Int16Array::set(unsigned long, short) {} +Int16Array* Int16Array::subarray(long, long) {} +unsigned long Int16Array::getLength() {} + +Uint16Array::Uint16Array(Uint16Array* other) {} +unsigned short Uint16Array::get(unsigned long) {} +void Uint16Array::set(unsigned long, unsigned short) {} +Uint16Array* Uint16Array::subarray(long, long) {} +unsigned long Uint16Array::getLength() {} + +Int32Array::Int32Array(Int32Array* other) {} +long Int32Array::get(unsigned long) {} +void Int32Array::set(unsigned long, long) {} +Int32Array* Int32Array::subarray(long, long) {} +unsigned long Int32Array::getLength() {} + +Uint32Array::Uint32Array(Uint32Array* other) {} +unsigned long Uint32Array::get(unsigned long) {} +void Uint32Array::set(unsigned long, unsigned long) {} +Uint32Array* Uint32Array::subarray(long, long) {} +unsigned long Uint32Array::getLength() {} + +Float32Array::Float32Array(Float32Array* other) {} +float Float32Array::get(unsigned long) {} +void Float32Array::set(unsigned long, float) {} +Float32Array* Float32Array::subarray(long, long) {} +unsigned long Float32Array::getLength() {} + +Float64Array::Float64Array(Float64Array* other) {} +double Float64Array::get(unsigned long) {} +void Float64Array::set(unsigned long, double) {} +Float64Array* Float64Array::subarray(long, long) {} +unsigned long Float64Array::getLength() {} + +} \ No newline at end of file diff --git a/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h new file mode 100644 index 0000000..0d3b786 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h @@ -0,0 +1,149 @@ +#ifndef TYPEDARRAY_H_99815BLY +#define TYPEDARRAY_H_99815BLY + +#include +#include + +namespace uscxml { + +class ArrayBuffer { +public: + unsigned long getByteLength(); + ArrayBuffer slice(long begin, long end); + static bool isView(void*); + operator bool(); +}; + +class ArrayBufferView { +public: + ArrayBuffer getBuffer(); + unsigned long getByteOffset(); + unsigned long getByteLength(); + +}; + +class DataView { +public: + ArrayBuffer getBuffer(); + unsigned long getByteOffset(); + unsigned long getByteLength(); + + char getInt8(unsigned long); + unsigned char getUint8(unsigned long); + short getInt16(unsigned long, bool); + unsigned short getUint16(unsigned long, bool); + long getInt32(unsigned long, bool); + unsigned long getUint32(unsigned long, bool); + float getFloat32(unsigned long, bool); + double getFloat64(unsigned long, bool); + + void setInt8(long, char); + void setUint8(long, unsigned char); + void setInt16(long, short, bool); + void setUint16(long, unsigned short, bool); + void setInt32(long, long, bool); + void setUint32(long, unsigned long, bool); + void setFloat32(long, float, bool); + void setFloat64(long, double, bool); + +}; + +class JSArray { +public: + virtual unsigned long getLength() = 0; +protected: + std::string _data; +}; + +class Uint8Array : public JSArray { +public: + virtual ~Uint8Array() {} + Uint8Array(Uint8Array* other); + unsigned char get(unsigned long); + void set(unsigned long, char); + Uint8Array* subarray(long, long); + unsigned long getLength(); +}; + +class Uint8ClampedArray : public JSArray { +public: + virtual ~Uint8ClampedArray() {} + Uint8ClampedArray(Uint8ClampedArray* other); + unsigned char get(unsigned long); + void set(unsigned long, char); + Uint8ClampedArray* subarray(long, long); + unsigned long getLength(); +}; + +class Int8Array : public JSArray { +public: + virtual ~Int8Array() {} + Int8Array(Int8Array* other); + char get(unsigned long); + void set(unsigned long, char); + Int8Array* subarray(long, long); + unsigned long getLength(); +}; + +class Int16Array : public JSArray { +public: + virtual ~Int16Array() {} + Int16Array(Int16Array* other); + short get(unsigned long); + void set(unsigned long, short); + Int16Array* subarray(long, long); + unsigned long getLength(); +}; + +class Uint16Array : public JSArray { +public: + virtual ~Uint16Array() {} + Uint16Array(Uint16Array* other); + unsigned short get(unsigned long); + void set(unsigned long, unsigned short); + Uint16Array* subarray(long, long); + unsigned long getLength(); +}; + +class Int32Array : public JSArray { +public: + virtual ~Int32Array() {} + Int32Array(Int32Array* other); + long get(unsigned long); + void set(unsigned long, long); + Int32Array* subarray(long, long); + unsigned long getLength(); +}; + +class Uint32Array : public JSArray { +public: + virtual ~Uint32Array() {} + Uint32Array(Uint32Array* other); + unsigned long get(unsigned long); + void set(unsigned long, unsigned long); + Uint32Array* subarray(long, long); + unsigned long getLength(); +}; + +class Float32Array : public JSArray { +public: + virtual ~Float32Array() {} + Float32Array(Float32Array* other); + float get(unsigned long); + void set(unsigned long, float); + Float32Array* subarray(long, long); + unsigned long getLength(); +}; + +class Float64Array : public JSArray { +public: + virtual ~Float64Array() {} + Float64Array(Float64Array* other); + double get(unsigned long); + void set(unsigned long, double); + Float64Array* subarray(long, long); + unsigned long getLength(); +}; +} + +#endif /* end of include guard: TYPEDARRAY_H_99815BLY */ 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 V8ArrayBuffer::Tmpl; + + +v8::Handle V8ArrayBuffer::byteLengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8ArrayBufferPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getByteLength()); +} +v8::Handle V8ArrayBuffer::sliceCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in slice"); + + v8::Local self = args.Holder(); + struct V8ArrayBufferPrivate* privData = V8DOM::toClassPtr(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 retCtor = V8ArrayBuffer::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::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 V8ArrayBuffer::isViewCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in isView"); + + v8::Local self = args.Holder(); + struct V8ArrayBufferPrivate* privData = V8DOM::toClassPtr(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 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 +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include + +namespace Arabica { +namespace DOM { + +class V8ArrayBuffer { +public: + struct V8ArrayBufferPrivate { + V8DOM* dom; + uscxml::ArrayBuffer* nativeObj; + }; + + V8_DESTRUCTOR(V8ArrayBufferPrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle sliceCallback(const v8::Arguments&); + static v8::Handle isViewCallback(const v8::Arguments&); + + static v8::Handle byteLengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("ArrayBuffer")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local 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::DEFAULT), static_cast(v8::None)); + + prototype->Set(v8::String::NewSymbol("slice"), + v8::FunctionTemplate::New(V8ArrayBuffer::sliceCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("isView"), + v8::FunctionTemplate::New(V8ArrayBuffer::isViewCallback, v8::Undefined()), static_cast(v8::DontDelete)); + + + Tmpl = v8::Persistent::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 V8ArrayBufferView::Tmpl; + + +v8::Handle V8ArrayBufferView::bufferAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8ArrayBufferViewPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + if (!privData->nativeObj->getBuffer()) return v8::Undefined(); + uscxml::ArrayBuffer* arbaicaRet = new uscxml::ArrayBuffer(privData->nativeObj->getBuffer()); + + v8::Handle arbaicaRetCtor = V8ArrayBuffer::getTmpl()->GetFunction(); + v8::Persistent arbaicaRetObj = v8::Persistent::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 V8ArrayBufferView::byteOffsetAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8ArrayBufferViewPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getByteOffset()); +} + +v8::Handle V8ArrayBufferView::byteLengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8ArrayBufferViewPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getByteLength()); +} +bool V8ArrayBufferView::hasInstance(v8::Handle 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 +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include + +namespace Arabica { +namespace DOM { + +class V8ArrayBufferView { +public: + struct V8ArrayBufferViewPrivate { + V8DOM* dom; + uscxml::ArrayBufferView* nativeObj; + }; + + V8_DESTRUCTOR(V8ArrayBufferViewPrivate); + static bool hasInstance(v8::Handle); + + + static v8::Handle bufferAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle byteOffsetAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle byteLengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("ArrayBufferView")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local 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::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("byteOffset"), V8ArrayBufferView::byteOffsetAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("byteLength"), V8ArrayBufferView::byteLengthAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + + + + Tmpl = v8::Persistent::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 V8DataView::Tmpl; + +v8::Handle V8DataView::getInt8Callback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in getInt8"); + + v8::Local self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + + char retVal = privData->nativeObj->getInt8(localByteOffset); + + return v8::Number::New(retVal); +} + +v8::Handle V8DataView::getUint8Callback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in getUint8"); + + v8::Local self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localByteOffset = args[0]->ToNumber()->Uint32Value(); + + char retVal = privData->nativeObj->getUint8(localByteOffset); + + return v8::Number::New(retVal); +} + +v8::Handle V8DataView::getInt16Callback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getInt16"); + + v8::Local self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr(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 V8DataView::getUint16Callback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getUint16"); + + v8::Local self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr(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 V8DataView::getInt32Callback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getInt32"); + + v8::Local self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr(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 V8DataView::getUint32Callback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getUint32"); + + v8::Local self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr(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 V8DataView::getFloat32Callback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getFloat32"); + + v8::Local self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr(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 V8DataView::getFloat64Callback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getFloat64"); + + v8::Local self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr(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 V8DataView::setInt8Callback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in setInt8"); + + v8::Local self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr(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 V8DataView::setUint8Callback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in setUint8"); + + v8::Local self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr(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 V8DataView::setInt16Callback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in setInt16"); + + v8::Local self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr(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 V8DataView::setUint16Callback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in setUint16"); + + v8::Local self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr(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 V8DataView::setInt32Callback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in setInt32"); + + v8::Local self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr(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 V8DataView::setUint32Callback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in setUint32"); + + v8::Local self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr(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 V8DataView::setFloat32Callback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in setFloat32"); + + v8::Local self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr(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 V8DataView::setFloat64Callback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in setFloat64"); + + v8::Local self = args.Holder(); + struct V8DataViewPrivate* privData = V8DOM::toClassPtr(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 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 +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include + +namespace Arabica { +namespace DOM { + +class V8DataView { +public: + struct V8DataViewPrivate { + V8DOM* dom; + uscxml::DataView* nativeObj; + }; + + V8_DESTRUCTOR(V8DataViewPrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle getInt8Callback(const v8::Arguments&); + static v8::Handle getUint8Callback(const v8::Arguments&); + static v8::Handle getInt16Callback(const v8::Arguments&); + static v8::Handle getUint16Callback(const v8::Arguments&); + static v8::Handle getInt32Callback(const v8::Arguments&); + static v8::Handle getUint32Callback(const v8::Arguments&); + static v8::Handle getFloat32Callback(const v8::Arguments&); + static v8::Handle getFloat64Callback(const v8::Arguments&); + static v8::Handle setInt8Callback(const v8::Arguments&); + static v8::Handle setUint8Callback(const v8::Arguments&); + static v8::Handle setInt16Callback(const v8::Arguments&); + static v8::Handle setUint16Callback(const v8::Arguments&); + static v8::Handle setInt32Callback(const v8::Arguments&); + static v8::Handle setUint32Callback(const v8::Arguments&); + static v8::Handle setFloat32Callback(const v8::Arguments&); + static v8::Handle setFloat64Callback(const v8::Arguments&); + + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("DataView")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local 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::DontDelete)); + prototype->Set(v8::String::NewSymbol("getUint8"), + v8::FunctionTemplate::New(V8DataView::getUint8Callback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getInt16"), + v8::FunctionTemplate::New(V8DataView::getInt16Callback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getUint16"), + v8::FunctionTemplate::New(V8DataView::getUint16Callback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getInt32"), + v8::FunctionTemplate::New(V8DataView::getInt32Callback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getUint32"), + v8::FunctionTemplate::New(V8DataView::getUint32Callback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getFloat32"), + v8::FunctionTemplate::New(V8DataView::getFloat32Callback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getFloat64"), + v8::FunctionTemplate::New(V8DataView::getFloat64Callback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setInt8"), + v8::FunctionTemplate::New(V8DataView::setInt8Callback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setUint8"), + v8::FunctionTemplate::New(V8DataView::setUint8Callback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setInt16"), + v8::FunctionTemplate::New(V8DataView::setInt16Callback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setUint16"), + v8::FunctionTemplate::New(V8DataView::setUint16Callback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setInt32"), + v8::FunctionTemplate::New(V8DataView::setInt32Callback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setUint32"), + v8::FunctionTemplate::New(V8DataView::setUint32Callback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setFloat32"), + v8::FunctionTemplate::New(V8DataView::setFloat32Callback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setFloat64"), + v8::FunctionTemplate::New(V8DataView::setFloat64Callback, v8::Undefined()), static_cast(v8::DontDelete)); + + + Tmpl = v8::Persistent::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 V8Float32Array::Tmpl; + + +v8::Handle V8Float32Array::lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8Float32ArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle V8Float32Array::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local self = args.Holder(); + struct V8Float32ArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + float retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle V8Float32Array::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local self = args.Holder(); + struct V8Float32ArrayPrivate* privData = V8DOM::toClassPtr(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 V8Float32Array::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local self = args.Holder(); + struct V8Float32ArrayPrivate* privData = V8DOM::toClassPtr(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 retCtor = V8Float32Array::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::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 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 +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include + +namespace Arabica { +namespace DOM { + +class V8Float32Array { +public: + struct V8Float32ArrayPrivate { + V8DOM* dom; + uscxml::Float32Array* nativeObj; + }; + + V8_DESTRUCTOR(V8Float32ArrayPrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle getCallback(const v8::Arguments&); + static v8::Handle setCallback(const v8::Arguments&); + static v8::Handle subarrayCallback(const v8::Arguments&); + + static v8::Handle lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Float32Array")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local 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::DEFAULT), static_cast(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Float32Array::getCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Float32Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Float32Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Float32Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Float32Array::subarrayCallback, v8::Undefined()), static_cast(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(4), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(4), static_cast(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent::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 V8Float64Array::Tmpl; + + +v8::Handle V8Float64Array::lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8Float64ArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle V8Float64Array::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local self = args.Holder(); + struct V8Float64ArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + double retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle V8Float64Array::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local self = args.Holder(); + struct V8Float64ArrayPrivate* privData = V8DOM::toClassPtr(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 V8Float64Array::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local self = args.Holder(); + struct V8Float64ArrayPrivate* privData = V8DOM::toClassPtr(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 retCtor = V8Float64Array::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::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 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 +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include + +namespace Arabica { +namespace DOM { + +class V8Float64Array { +public: + struct V8Float64ArrayPrivate { + V8DOM* dom; + uscxml::Float64Array* nativeObj; + }; + + V8_DESTRUCTOR(V8Float64ArrayPrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle getCallback(const v8::Arguments&); + static v8::Handle setCallback(const v8::Arguments&); + static v8::Handle subarrayCallback(const v8::Arguments&); + + static v8::Handle lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Float64Array")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local 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::DEFAULT), static_cast(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Float64Array::getCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Float64Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Float64Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Float64Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Float64Array::subarrayCallback, v8::Undefined()), static_cast(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(8), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(8), static_cast(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent::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 V8Int16Array::Tmpl; + + +v8::Handle V8Int16Array::lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8Int16ArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle V8Int16Array::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local self = args.Holder(); + struct V8Int16ArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + short retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle V8Int16Array::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local self = args.Holder(); + struct V8Int16ArrayPrivate* privData = V8DOM::toClassPtr(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 V8Int16Array::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local self = args.Holder(); + struct V8Int16ArrayPrivate* privData = V8DOM::toClassPtr(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 retCtor = V8Int16Array::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::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 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 +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include + +namespace Arabica { +namespace DOM { + +class V8Int16Array { +public: + struct V8Int16ArrayPrivate { + V8DOM* dom; + uscxml::Int16Array* nativeObj; + }; + + V8_DESTRUCTOR(V8Int16ArrayPrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle getCallback(const v8::Arguments&); + static v8::Handle setCallback(const v8::Arguments&); + static v8::Handle subarrayCallback(const v8::Arguments&); + + static v8::Handle lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Int16Array")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local 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::DEFAULT), static_cast(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Int16Array::getCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int16Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int16Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int16Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Int16Array::subarrayCallback, v8::Undefined()), static_cast(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(2), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(2), static_cast(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent::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 V8Int32Array::Tmpl; + + +v8::Handle V8Int32Array::lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8Int32ArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle V8Int32Array::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local self = args.Holder(); + struct V8Int32ArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + long retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle V8Int32Array::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local self = args.Holder(); + struct V8Int32ArrayPrivate* privData = V8DOM::toClassPtr(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 V8Int32Array::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local self = args.Holder(); + struct V8Int32ArrayPrivate* privData = V8DOM::toClassPtr(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 retCtor = V8Int32Array::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::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 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 +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include + +namespace Arabica { +namespace DOM { + +class V8Int32Array { +public: + struct V8Int32ArrayPrivate { + V8DOM* dom; + uscxml::Int32Array* nativeObj; + }; + + V8_DESTRUCTOR(V8Int32ArrayPrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle getCallback(const v8::Arguments&); + static v8::Handle setCallback(const v8::Arguments&); + static v8::Handle subarrayCallback(const v8::Arguments&); + + static v8::Handle lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Int32Array")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local 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::DEFAULT), static_cast(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Int32Array::getCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int32Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int32Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int32Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Int32Array::subarrayCallback, v8::Undefined()), static_cast(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(4), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(4), static_cast(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent::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 V8Int8Array::Tmpl; + + +v8::Handle V8Int8Array::lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8Int8ArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle V8Int8Array::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local self = args.Holder(); + struct V8Int8ArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + char retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle V8Int8Array::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local self = args.Holder(); + struct V8Int8ArrayPrivate* privData = V8DOM::toClassPtr(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 V8Int8Array::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local self = args.Holder(); + struct V8Int8ArrayPrivate* privData = V8DOM::toClassPtr(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 retCtor = V8Int8Array::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::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 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 +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include + +namespace Arabica { +namespace DOM { + +class V8Int8Array { +public: + struct V8Int8ArrayPrivate { + V8DOM* dom; + uscxml::Int8Array* nativeObj; + }; + + V8_DESTRUCTOR(V8Int8ArrayPrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle getCallback(const v8::Arguments&); + static v8::Handle setCallback(const v8::Arguments&); + static v8::Handle subarrayCallback(const v8::Arguments&); + + static v8::Handle lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Int8Array")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local 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::DEFAULT), static_cast(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Int8Array::getCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int8Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int8Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Int8Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Int8Array::subarrayCallback, v8::Undefined()), static_cast(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent::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 V8Uint16Array::Tmpl; + + +v8::Handle V8Uint16Array::lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8Uint16ArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle V8Uint16Array::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local self = args.Holder(); + struct V8Uint16ArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + unsigned short retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle V8Uint16Array::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local self = args.Holder(); + struct V8Uint16ArrayPrivate* privData = V8DOM::toClassPtr(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 V8Uint16Array::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local self = args.Holder(); + struct V8Uint16ArrayPrivate* privData = V8DOM::toClassPtr(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 retCtor = V8Uint16Array::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::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 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 +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include + +namespace Arabica { +namespace DOM { + +class V8Uint16Array { +public: + struct V8Uint16ArrayPrivate { + V8DOM* dom; + uscxml::Uint16Array* nativeObj; + }; + + V8_DESTRUCTOR(V8Uint16ArrayPrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle getCallback(const v8::Arguments&); + static v8::Handle setCallback(const v8::Arguments&); + static v8::Handle subarrayCallback(const v8::Arguments&); + + static v8::Handle lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Uint16Array")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local 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::DEFAULT), static_cast(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Uint16Array::getCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint16Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint16Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint16Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Uint16Array::subarrayCallback, v8::Undefined()), static_cast(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(2), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(2), static_cast(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent::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 V8Uint32Array::Tmpl; + + +v8::Handle V8Uint32Array::lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8Uint32ArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle V8Uint32Array::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local self = args.Holder(); + struct V8Uint32ArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + unsigned long retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle V8Uint32Array::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local self = args.Holder(); + struct V8Uint32ArrayPrivate* privData = V8DOM::toClassPtr(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 V8Uint32Array::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local self = args.Holder(); + struct V8Uint32ArrayPrivate* privData = V8DOM::toClassPtr(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 retCtor = V8Uint32Array::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::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 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 +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include + +namespace Arabica { +namespace DOM { + +class V8Uint32Array { +public: + struct V8Uint32ArrayPrivate { + V8DOM* dom; + uscxml::Uint32Array* nativeObj; + }; + + V8_DESTRUCTOR(V8Uint32ArrayPrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle getCallback(const v8::Arguments&); + static v8::Handle setCallback(const v8::Arguments&); + static v8::Handle subarrayCallback(const v8::Arguments&); + + static v8::Handle lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Uint32Array")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local 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::DEFAULT), static_cast(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Uint32Array::getCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint32Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint32Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint32Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Uint32Array::subarrayCallback, v8::Undefined()), static_cast(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(4), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(4), static_cast(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent::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 V8Uint8Array::Tmpl; + + +v8::Handle V8Uint8Array::lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8Uint8ArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle V8Uint8Array::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local self = args.Holder(); + struct V8Uint8ArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + char retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle V8Uint8Array::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local self = args.Holder(); + struct V8Uint8ArrayPrivate* privData = V8DOM::toClassPtr(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 V8Uint8Array::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local self = args.Holder(); + struct V8Uint8ArrayPrivate* privData = V8DOM::toClassPtr(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 retCtor = V8Uint8Array::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::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 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 +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include + +namespace Arabica { +namespace DOM { + +class V8Uint8Array { +public: + struct V8Uint8ArrayPrivate { + V8DOM* dom; + uscxml::Uint8Array* nativeObj; + }; + + V8_DESTRUCTOR(V8Uint8ArrayPrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle getCallback(const v8::Arguments&); + static v8::Handle setCallback(const v8::Arguments&); + static v8::Handle subarrayCallback(const v8::Arguments&); + + static v8::Handle lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Uint8Array")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local 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::DEFAULT), static_cast(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Uint8Array::getCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint8Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint8Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint8Array::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Uint8Array::subarrayCallback, v8::Undefined()), static_cast(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent::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 V8Uint8ClampedArray::Tmpl; + + +v8::Handle V8Uint8ClampedArray::lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8Uint8ClampedArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->getLength()); +} +v8::Handle V8Uint8ClampedArray::getCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in get"); + + v8::Local self = args.Holder(); + struct V8Uint8ClampedArrayPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + + char retVal = privData->nativeObj->get(localIndex); + + return v8::Number::New(retVal); +} + +v8::Handle V8Uint8ClampedArray::setCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in set"); + + v8::Local self = args.Holder(); + struct V8Uint8ClampedArrayPrivate* privData = V8DOM::toClassPtr(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 V8Uint8ClampedArray::subarrayCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in subarray"); + + v8::Local self = args.Holder(); + struct V8Uint8ClampedArrayPrivate* privData = V8DOM::toClassPtr(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 retCtor = V8Uint8ClampedArray::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::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 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 +#include "../../TypedArray.h" +#include "DOM/Node.hpp" +#include "string" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h" +#include + +namespace Arabica { +namespace DOM { + +class V8Uint8ClampedArray { +public: + struct V8Uint8ClampedArrayPrivate { + V8DOM* dom; + uscxml::Uint8ClampedArray* nativeObj; + }; + + V8_DESTRUCTOR(V8Uint8ClampedArrayPrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle getCallback(const v8::Arguments&); + static v8::Handle setCallback(const v8::Arguments&); + static v8::Handle subarrayCallback(const v8::Arguments&); + + static v8::Handle lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Uint8ClampedArray")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local 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::DEFAULT), static_cast(v8::None)); + + prototype->Set(v8::String::NewSymbol("get"), + v8::FunctionTemplate::New(V8Uint8ClampedArray::getCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint8ClampedArray::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint8ClampedArray::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("set"), + v8::FunctionTemplate::New(V8Uint8ClampedArray::setCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("subarray"), + v8::FunctionTemplate::New(V8Uint8ClampedArray::subarrayCallback, v8::Undefined()), static_cast(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("BYTES_PER_ELEMENT"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // V8Uint8ClampedArray_h diff --git a/src/uscxml/plugins/invoker/CMakeLists.txt b/src/uscxml/plugins/invoker/CMakeLists.txt index def840a..db0d61f 100644 --- a/src/uscxml/plugins/invoker/CMakeLists.txt +++ b/src/uscxml/plugins/invoker/CMakeLists.txt @@ -113,6 +113,7 @@ endif() # ffmpeg invoker if (FFMPEG_FOUND) + set(USCXML_INVOKERS "ffmpeg ${USCXML_INVOKERS}") file(GLOB_RECURSE FFMPEG_INVOKER ffmpeg/*.cpp ffmpeg/*.h diff --git a/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp b/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp index d038573..be6ffc7 100644 --- a/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp +++ b/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp @@ -29,12 +29,12 @@ OpenALInvoker::OpenALInvoker() { _alContext = NULL; _alDevice = NULL; _thread = NULL; - _listenerPos[0] = _listenerPos[1] = _listenerPos[2] = 0; - _listenerVel[0] = _listenerVel[1] = _listenerVel[2] = 0; - _maxPos[0] = _maxPos[1] = _maxPos[2] = 1; + _listenerPos[0] = _listenerPos[1] = _listenerPos[2] = 0; + _listenerVel[0] = _listenerVel[1] = _listenerVel[2] = 0; + _maxPos[0] = _maxPos[1] = _maxPos[2] = 1; - _listenerOrient[0] = _listenerOrient[1] = _listenerOrient[3] = _listenerOrient[5] = 0; - _listenerOrient[2] = _listenerOrient[4] = 1.0; + _listenerOrient[0] = _listenerOrient[1] = _listenerOrient[3] = _listenerOrient[5] = 0; + _listenerOrient[2] = _listenerOrient[4] = 1.0; } OpenALInvoker::~OpenALInvoker() { @@ -144,7 +144,7 @@ void OpenALInvoker::send(const SendRequest& req) { if (boost::iequals(req.name, "move.listener")) { getPosFromParams(req.params, _listenerPos); - + try { alcMakeContextCurrent(_alContext); alListenerfv(AL_POSITION, _listenerPos); diff --git a/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp b/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp index c04c90d..ccf65ce 100644 --- a/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp +++ b/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp @@ -1,13 +1,16 @@ #include "FFMPEGInvoker.h" #include -#include -#include #ifdef BUILD_AS_PLUGINS #include #endif +#define STREAM_DURATION 200.0 +#define STREAM_FRAME_RATE 25 /* 25 images/s */ +#define STREAM_NB_FRAMES ((int)(STREAM_DURATION * STREAM_FRAME_RATE)) +#define STREAM_PIX_FMT AV_PIX_FMT_YUV420P /* default pix_fmt */ + namespace uscxml { #ifdef BUILD_AS_PLUGINS @@ -36,13 +39,501 @@ Data FFMPEGInvoker::getDataModelVariables() { } void FFMPEGInvoker::send(const SendRequest& req) { + if (boost::iequals(req.name, "add")) { + + } else if(boost::iequals(req.name, "render")) { + + } } void FFMPEGInvoker::cancel(const std::string sendId) { } +static AVFrame *frame; +static AVPicture src_picture, dst_picture; +static int frame_count; +static int sws_flags = SWS_BICUBIC; + +static AVStream *add_stream(AVFormatContext *oc, AVCodec **codec, + enum AVCodecID codec_id) { + AVCodecContext *c; + AVStream *st; + + /* find the encoder */ + *codec = avcodec_find_encoder(codec_id); + if (!(*codec)) { + fprintf(stderr, "Could not find encoder for '%s'\n", + avcodec_get_name(codec_id)); + exit(1); + } + + st = avformat_new_stream(oc, *codec); + if (!st) { + fprintf(stderr, "Could not allocate stream\n"); + exit(1); + } + st->id = oc->nb_streams-1; + c = st->codec; + + switch ((*codec)->type) { + case AVMEDIA_TYPE_AUDIO: + c->sample_fmt = AV_SAMPLE_FMT_FLTP; + c->bit_rate = 64000; + c->sample_rate = 44100; + c->channels = 2; + break; + + case AVMEDIA_TYPE_VIDEO: + c->codec_id = codec_id; + + c->bit_rate = 400000; + /* Resolution must be a multiple of two. */ + c->width = 352; + c->height = 288; + /* timebase: This is the fundamental unit of time (in seconds) in terms + * of which frame timestamps are represented. For fixed-fps content, + * timebase should be 1/framerate and timestamp increments should be + * identical to 1. */ + c->time_base.den = STREAM_FRAME_RATE; + c->time_base.num = 1; + c->gop_size = 12; /* emit one intra frame every twelve frames at most */ + c->pix_fmt = STREAM_PIX_FMT; + if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) { + /* just for testing, we also add B frames */ + c->max_b_frames = 2; + } + if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) { + /* Needed to avoid using macroblocks in which some coeffs overflow. + * This does not happen with normal video, it just happens here as + * the motion of the chroma plane does not match the luma plane. */ + c->mb_decision = 2; + } + break; + + default: + break; + } + + /* Some formats want stream headers to be separate. */ + if (oc->oformat->flags & AVFMT_GLOBALHEADER) + c->flags |= CODEC_FLAG_GLOBAL_HEADER; + + return st; +} + +static void open_video(AVFormatContext *oc, AVCodec *codec, AVStream *st) { + int ret; + AVCodecContext *c = st->codec; + + /* open the codec */ + ret = avcodec_open2(c, codec, NULL); + if (ret < 0) { + fprintf(stderr, "Could not open video codec: %s\n", av_err2str(ret)); + exit(1); + } + + /* allocate and init a re-usable frame */ + frame = avcodec_alloc_frame(); + if (!frame) { + fprintf(stderr, "Could not allocate video frame\n"); + exit(1); + } + + /* Allocate the encoded raw picture. */ + ret = avpicture_alloc(&dst_picture, c->pix_fmt, c->width, c->height); + if (ret < 0) { + fprintf(stderr, "Could not allocate picture: %s\n", av_err2str(ret)); + exit(1); + } + + /* If the output format is not YUV420P, then a temporary YUV420P + * picture is needed too. It is then converted to the required + * output format. */ + if (c->pix_fmt != AV_PIX_FMT_YUV420P) { + ret = avpicture_alloc(&src_picture, AV_PIX_FMT_YUV420P, c->width, c->height); + if (ret < 0) { + fprintf(stderr, "Could not allocate temporary picture: %s\n", + av_err2str(ret)); + exit(1); + } + } + + /* copy data and linesize picture pointers to frame */ + *((AVPicture *)frame) = dst_picture; +} + +/* Prepare a dummy image. */ +static void fill_yuv_image(AVPicture *pict, int frame_index, + int width, int height) { + int x, y, i; + + i = frame_index; + + /* Y */ + for (y = 0; y < height; y++) + for (x = 0; x < width; x++) + pict->data[0][y * pict->linesize[0] + x] = x + y + i * 3; + + /* Cb and Cr */ + for (y = 0; y < height / 2; y++) { + for (x = 0; x < width / 2; x++) { + pict->data[1][y * pict->linesize[1] + x] = 128 + y + i * 2; + pict->data[2][y * pict->linesize[2] + x] = 64 + x + i * 5; + } + } +} + +static void write_video_frame(AVFormatContext *oc, AVStream *st) { + int ret; + static struct SwsContext *sws_ctx; + AVCodecContext *c = st->codec; + + if (frame_count >= STREAM_NB_FRAMES) { + /* No more frames to compress. The codec has a latency of a few + * frames if using B-frames, so we get the last frames by + * passing the same picture again. */ + } else { + if (c->pix_fmt != AV_PIX_FMT_YUV420P) { + /* as we only generate a YUV420P picture, we must convert it + * to the codec pixel format if needed */ + if (!sws_ctx) { + sws_ctx = sws_getContext(c->width, c->height, AV_PIX_FMT_YUV420P, + c->width, c->height, c->pix_fmt, + sws_flags, NULL, NULL, NULL); + if (!sws_ctx) { + fprintf(stderr, + "Could not initialize the conversion context\n"); + exit(1); + } + } + fill_yuv_image(&src_picture, frame_count, c->width, c->height); + sws_scale(sws_ctx, + (const uint8_t * const *)src_picture.data, src_picture.linesize, + 0, c->height, dst_picture.data, dst_picture.linesize); + } else { + fill_yuv_image(&dst_picture, frame_count, c->width, c->height); + } + } + + if (oc->oformat->flags & AVFMT_RAWPICTURE) { + /* Raw video case - directly store the picture in the packet */ + AVPacket pkt; + av_init_packet(&pkt); + + pkt.flags |= AV_PKT_FLAG_KEY; + pkt.stream_index = st->index; + pkt.data = dst_picture.data[0]; + pkt.size = sizeof(AVPicture); + + ret = av_interleaved_write_frame(oc, &pkt); + } else { + AVPacket pkt = { 0 }; + int got_packet; + av_init_packet(&pkt); + + /* encode the image */ + ret = avcodec_encode_video2(c, &pkt, frame, &got_packet); + if (ret < 0) { + fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret)); + exit(1); + } + /* If size is zero, it means the image was buffered. */ + + if (!ret && got_packet && pkt.size) { + pkt.stream_index = st->index; + + /* Write the compressed frame to the media file. */ + ret = av_interleaved_write_frame(oc, &pkt); + } else { + ret = 0; + } + } + if (ret != 0) { + fprintf(stderr, "Error while writing video frame: %s\n", av_err2str(ret)); + exit(1); + } + frame_count++; +} + +static void close_video(AVFormatContext *oc, AVStream *st) { + avcodec_close(st->codec); + av_free(src_picture.data[0]); + av_free(dst_picture.data[0]); + av_free(frame); +} + +static float t, tincr, tincr2; + +static uint8_t **src_samples_data; +static int src_samples_linesize; +static int src_nb_samples; + +static int max_dst_nb_samples; +uint8_t **dst_samples_data; +int dst_samples_linesize; +int dst_samples_size; + +struct SwrContext *swr_ctx = NULL; + +static void open_audio(AVFormatContext *oc, AVCodec *codec, AVStream *st) { + AVCodecContext *c; + int ret; + + c = st->codec; + + /* open it */ + ret = avcodec_open2(c, codec, NULL); + if (ret < 0) { + fprintf(stderr, "Could not open audio codec: %s\n", av_err2str(ret)); + exit(1); + } + + /* init signal generator */ + t = 0; + tincr = 2 * M_PI * 110.0 / c->sample_rate; + /* increment frequency by 110 Hz per second */ + tincr2 = 2 * M_PI * 110.0 / c->sample_rate / c->sample_rate; + + src_nb_samples = c->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE ? + 10000 : c->frame_size; + + ret = av_samples_alloc_array_and_samples(&src_samples_data, &src_samples_linesize, c->channels, + src_nb_samples, c->sample_fmt, 0); + if (ret < 0) { + fprintf(stderr, "Could not allocate source samples\n"); + exit(1); + } + + /* create resampler context */ + if (c->sample_fmt != AV_SAMPLE_FMT_S16) { + swr_ctx = swr_alloc(); + if (!swr_ctx) { + fprintf(stderr, "Could not allocate resampler context\n"); + exit(1); + } + + /* set options */ + av_opt_set_int (swr_ctx, "in_channel_count", c->channels, 0); + av_opt_set_int (swr_ctx, "in_sample_rate", c->sample_rate, 0); + av_opt_set_sample_fmt(swr_ctx, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0); + av_opt_set_int (swr_ctx, "out_channel_count", c->channels, 0); + av_opt_set_int (swr_ctx, "out_sample_rate", c->sample_rate, 0); + av_opt_set_sample_fmt(swr_ctx, "out_sample_fmt", c->sample_fmt, 0); + + /* initialize the resampling context */ + if ((ret = swr_init(swr_ctx)) < 0) { + fprintf(stderr, "Failed to initialize the resampling context\n"); + exit(1); + } + } + + /* compute the number of converted samples: buffering is avoided + * ensuring that the output buffer will contain at least all the + * converted input samples */ + max_dst_nb_samples = src_nb_samples; + ret = av_samples_alloc_array_and_samples(&dst_samples_data, &dst_samples_linesize, c->channels, + max_dst_nb_samples, c->sample_fmt, 0); + if (ret < 0) { + fprintf(stderr, "Could not allocate destination samples\n"); + exit(1); + } + dst_samples_size = av_samples_get_buffer_size(NULL, c->channels, max_dst_nb_samples, + c->sample_fmt, 0); +} + +/* Prepare a 16 bit dummy audio frame of 'frame_size' samples and + * 'nb_channels' channels. */ +static void get_audio_frame(int16_t *samples, int frame_size, int nb_channels) { + int j, i, v; + int16_t *q; + + q = samples; + for (j = 0; j < frame_size; j++) { + v = (int)(sin(t) * 10000); + for (i = 0; i < nb_channels; i++) + *q++ = v; + t += tincr; + tincr += tincr2; + } +} + +static void write_audio_frame(AVFormatContext *oc, AVStream *st) { + AVCodecContext *c; + AVPacket pkt = { 0 }; // data and size must be 0; + AVFrame *frame = avcodec_alloc_frame(); + int got_packet, ret, dst_nb_samples; + + av_init_packet(&pkt); + c = st->codec; + + get_audio_frame((int16_t *)src_samples_data[0], src_nb_samples, c->channels); + + /* convert samples from native format to destination codec format, using the resampler */ + if (swr_ctx) { + /* compute destination number of samples */ + dst_nb_samples = av_rescale_rnd(swr_get_delay(swr_ctx, c->sample_rate) + src_nb_samples, + c->sample_rate, c->sample_rate, AV_ROUND_UP); + if (dst_nb_samples > max_dst_nb_samples) { + av_free(dst_samples_data[0]); + ret = av_samples_alloc(dst_samples_data, &dst_samples_linesize, c->channels, + dst_nb_samples, c->sample_fmt, 0); + if (ret < 0) + exit(1); + max_dst_nb_samples = dst_nb_samples; + dst_samples_size = av_samples_get_buffer_size(NULL, c->channels, dst_nb_samples, + c->sample_fmt, 0); + } + + /* convert to destination format */ + ret = swr_convert(swr_ctx, + dst_samples_data, dst_nb_samples, + (const uint8_t **)src_samples_data, src_nb_samples); + if (ret < 0) { + fprintf(stderr, "Error while converting\n"); + exit(1); + } + } else { + dst_samples_data[0] = src_samples_data[0]; + dst_nb_samples = src_nb_samples; + } + + frame->nb_samples = dst_nb_samples; + avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt, + dst_samples_data[0], dst_samples_size, 0); + + ret = avcodec_encode_audio2(c, &pkt, frame, &got_packet); + if (ret < 0) { + fprintf(stderr, "Error encoding audio frame: %s\n", av_err2str(ret)); + exit(1); + } + + if (!got_packet) + return; + + pkt.stream_index = st->index; + + /* Write the compressed frame to the media file. */ + ret = av_interleaved_write_frame(oc, &pkt); + if (ret != 0) { + fprintf(stderr, "Error while writing audio frame: %s\n", + av_err2str(ret)); + exit(1); + } + avcodec_free_frame(&frame); +} + +static void close_audio(AVFormatContext *oc, AVStream *st) { + avcodec_close(st->codec); + av_free(src_samples_data[0]); + av_free(dst_samples_data[0]); +} + void FFMPEGInvoker::invoke(const InvokeRequest& req) { -// AVIOContext* avCtx = avio_alloc_context(); + +#if 0 + const char *filename; + AVOutputFormat *fmt; + AVFormatContext *oc; + AVStream *audio_st, *video_st; + AVCodec *audio_codec, *video_codec; + double audio_time, video_time; + int ret; + + filename = "foo.avi"; + // Register all formats and codecs + av_register_all(); + + /* allocate the output media context */ + avformat_alloc_output_context2(&oc, NULL, NULL, filename); + if (!oc) { + printf("Could not deduce output format from file extension: using MPEG.\n"); + avformat_alloc_output_context2(&oc, NULL, "mpeg", filename); + } + if (!oc) { + return 1; + } + fmt = oc->oformat; + + /* Add the audio and video streams using the default format codecs + * and initialize the codecs. */ + video_st = NULL; + audio_st = NULL; + + if (fmt->video_codec != AV_CODEC_ID_NONE) { + video_st = add_stream(oc, &video_codec, fmt->video_codec); + } + if (fmt->audio_codec != AV_CODEC_ID_NONE) { + audio_st = add_stream(oc, &audio_codec, fmt->audio_codec); + } + + /* Now that all the parameters are set, we can open the audio and + * video codecs and allocate the necessary encode buffers. */ + if (video_st) + open_video(oc, video_codec, video_st); + if (audio_st) + open_audio(oc, audio_codec, audio_st); + + av_dump_format(oc, 0, filename, 1); + + /* open the output file, if needed */ + if (!(fmt->flags & AVFMT_NOFILE)) { + ret = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE); + if (ret < 0) { + fprintf(stderr, "Could not open '%s': %s\n", filename, + av_err2str(ret)); + return 1; + } + } + + /* Write the stream header, if any. */ + ret = avformat_write_header(oc, NULL); + if (ret < 0) { + fprintf(stderr, "Error occurred when opening output file: %s\n", + av_err2str(ret)); + return 1; + } + + if (frame) + frame->pts = 0; + for (;;) { + /* Compute current audio and video time. */ + audio_time = audio_st ? audio_st->pts.val * av_q2d(audio_st->time_base) : 0.0; + video_time = video_st ? video_st->pts.val * av_q2d(video_st->time_base) : 0.0; + + if ((!audio_st || audio_time >= STREAM_DURATION) && + (!video_st || video_time >= STREAM_DURATION)) + break; + + /* write interleaved audio and video frames */ + if (!video_st || (video_st && audio_st && audio_time < video_time)) { + write_audio_frame(oc, audio_st); + } else { + write_video_frame(oc, video_st); + frame->pts += av_rescale_q(1, video_st->codec->time_base, video_st->time_base); + } + } + + /* Write the trailer, if any. The trailer must be written before you + * close the CodecContexts open when you wrote the header; otherwise + * av_write_trailer() may try to use memory that was freed on + * av_codec_close(). */ + av_write_trailer(oc); + + /* Close each codec. */ + if (video_st) + close_video(oc, video_st); + if (audio_st) + close_audio(oc, audio_st); + + if (!(fmt->flags & AVFMT_NOFILE)) + /* Close the output file. */ + avio_close(oc->pb); + + /* free the stream */ + avformat_free_context(oc); + + return 0; +#endif } } \ No newline at end of file diff --git a/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.h b/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.h index c29a173..0337f25 100644 --- a/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.h +++ b/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.h @@ -3,6 +3,14 @@ #include +extern "C" { +#include +#include +#include +#include +#include +} + #ifdef BUILD_AS_PLUGINS #include "uscxml/plugins/Plugins.h" #endif @@ -28,6 +36,16 @@ public: virtual void invoke(const InvokeRequest& req); protected: + class EncodingContext { + std::string filename; + AVOutputFormat* format; + AVFormatContext* formatCtx; + AVStream *audio_st, *video_st; + AVCodec *audio_codec, *video_codec; + double audio_time, video_time; + }; + + std::map _encoders; }; #ifdef BUILD_AS_PLUGINS diff --git a/test/samples/uscxml/test-ffmpeg.scxml b/test/samples/uscxml/test-ffmpeg.scxml new file mode 100644 index 0000000..7897a27 --- /dev/null +++ b/test/samples/uscxml/test-ffmpeg.scxml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file -- cgit v0.12