summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-09-01 20:51:59 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-09-01 20:51:59 (GMT)
commitddd9db10907ee4cee6c44b24b96d81b062521752 (patch)
treedad93a6003344852c61d5916c8fbc11ab88ad9ed /src/uscxml/plugins
parentfd0778237785840ec754f98e847a524590cbf61c (diff)
downloaduscxml-ddd9db10907ee4cee6c44b24b96d81b062521752.zip
uscxml-ddd9db10907ee4cee6c44b24b96d81b062521752.tar.gz
uscxml-ddd9db10907ee4cee6c44b24b96d81b062521752.tar.bz2
Added Data::BINARY and compile fixes for non MacOSX platforms
Diffstat (limited to 'src/uscxml/plugins')
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp32
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/Storage.cpp2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp4
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/TypedArray.h5
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp26
5 files changed, 57 insertions, 12 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
index 173a0ed..f8e0479 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
@@ -292,14 +292,32 @@ JSValueRef JSCDataModel::getDataAsValue(const Data& data) {
handleException(exception);
return value;
}
- if (data.type == Data::VERBATIM) {
- JSStringRef stringRef = JSStringCreateWithUTF8CString(data.atom.c_str());
- JSValueRef value = JSValueMakeString(_ctx, stringRef);
- JSStringRelease(stringRef);
- return value;
- } else {
- return evalAsValue(data.atom);
+
+ switch (data.type) {
+ case Data::VERBATIM: {
+ JSStringRef stringRef = JSStringCreateWithUTF8CString(data.atom.c_str());
+ JSValueRef value = JSValueMakeString(_ctx, stringRef);
+ JSStringRelease(stringRef);
+ return value;
+ break;
+ }
+ case Data::INTERPRETED: {
+ return evalAsValue(data.atom);
+ break;
+ }
+ case Data::BINARY: {
+ uscxml::ArrayBuffer* localInstance = new uscxml::ArrayBuffer((void*)data.atom.c_str(), data.atom.size());
+
+ JSClassRef retClass = JSCArrayBuffer::getTmpl();
+ struct JSCArrayBuffer::JSCArrayBufferPrivate* retPrivData = new JSCArrayBuffer::JSCArrayBufferPrivate();
+ retPrivData->nativeObj = localInstance;
+
+ JSObjectRef retObj = JSObjectMake(_ctx, retClass, retPrivData);
+ return retObj;
+ break;
+ }
}
+
}
Data JSCDataModel::getValueAsData(const JSValueRef value) {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/Storage.cpp b/src/uscxml/plugins/datamodel/ecmascript/Storage.cpp
index b5bb474..b3071ee 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/Storage.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/Storage.cpp
@@ -45,7 +45,7 @@ std::string Storage::key(unsigned long index) {
return "";
std::map<std::string, std::string>::iterator dataIter = _data.begin();
- for (int i = 0; i < index; i++) {
+ for (unsigned int i = 0; i < index; i++) {
dataIter++;
}
return dataIter->first;
diff --git a/src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp
index 98859da..16ee766 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp
@@ -34,6 +34,10 @@ ArrayBuffer::ArrayBuffer(unsigned long length) {
ArrayBuffer::ArrayBuffer(boost::shared_ptr<ArrayBuffer::Buffer> buffer) : _buffer(buffer) {
}
+ArrayBuffer::ArrayBuffer(void* data, unsigned int size) {
+ _buffer = boost::shared_ptr<Buffer>(new Buffer(data, size));
+}
+
unsigned long ArrayBuffer::getByteLength() {
return _buffer->_size;
}
diff --git a/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h
index 82da629..229ae70 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h
@@ -4,6 +4,9 @@
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
+#include <string.h>
+#include <inttypes.h>
+
namespace uscxml {
@@ -18,6 +21,7 @@ public:
size_t _size;
};
+ ArrayBuffer(void* data, unsigned int size);
ArrayBuffer(unsigned long length);
ArrayBuffer(boost::shared_ptr<ArrayBuffer::Buffer>);
unsigned long getByteLength();
@@ -48,6 +52,7 @@ public:
class ArrayBufferView {
public:
+ virtual ~ArrayBufferView() {}
ArrayBuffer getBuffer();
virtual unsigned long getByteOffset() = 0;
virtual unsigned long getByteLength() = 0;
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
index aef41ca..919f4a1 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
@@ -350,11 +350,29 @@ v8::Handle<v8::Value> V8DataModel::getDataAsValue(const Data& data) {
}
return value;
}
- if (data.type == Data::VERBATIM) {
- return v8::String::New(data.atom.c_str());
- } else {
- return evalAsValue(data.atom);
+ switch (data.type) {
+ case Data::VERBATIM:
+ return v8::String::New(data.atom.c_str());
+ break;
+ case Data::INTERPRETED:
+ return evalAsValue(data.atom);
+ break;
+ case Data::BINARY: {
+ uscxml::ArrayBuffer* arrBuffer = new uscxml::ArrayBuffer((void*)data.atom.c_str(), data.atom.size());
+ v8::Handle<v8::Function> retCtor = V8ArrayBuffer::getTmpl()->GetFunction();
+ v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance());
+
+ struct V8ArrayBuffer::V8ArrayBufferPrivate* retPrivData = new V8ArrayBuffer::V8ArrayBufferPrivate();
+ retPrivData->nativeObj = arrBuffer;
+ retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+
+ retObj.MakeWeak(0, V8ArrayBuffer::jsDestructor);
+ return retObj;
+ break;
+ }
}
+ // this will never be reached
+ return v8::Undefined();
}
v8::Handle<v8::Value> V8DataModel::jsPrint(const v8::Arguments& args) {