summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bindings/swig/php/CMakeLists.txt2
-rw-r--r--src/bindings/swig/php/uscxmlNativePHP.php2
-rw-r--r--src/uscxml/Convenience.h10
-rw-r--r--src/uscxml/Message.h1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp7
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp5
-rw-r--r--src/uscxml/plugins/element/respond/RespondElement.cpp8
7 files changed, 32 insertions, 3 deletions
diff --git a/src/bindings/swig/php/CMakeLists.txt b/src/bindings/swig/php/CMakeLists.txt
index 8f6103d..3884a7f 100644
--- a/src/bindings/swig/php/CMakeLists.txt
+++ b/src/bindings/swig/php/CMakeLists.txt
@@ -11,7 +11,7 @@ endif()
# copied from cmake's FindPHP4.cmake and adapted
if(APPLE)
# this is a hack for now
- set(PHP_MODULE_CXX_FLAGS "${CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS} -Wl,-flat_namespace -Wno-unused-label")
+ set(PHP_MODULE_CXX_FLAGS "${CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS} -Wno-unused-label -Wl,-flat_namespace")
foreach(symbol
__efree
__emalloc
diff --git a/src/bindings/swig/php/uscxmlNativePHP.php b/src/bindings/swig/php/uscxmlNativePHP.php
index 769ed4c..d7bb3d0 100644
--- a/src/bindings/swig/php/uscxmlNativePHP.php
+++ b/src/bindings/swig/php/uscxmlNativePHP.php
@@ -2,7 +2,7 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.7
+ * Version 2.0.9
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
diff --git a/src/uscxml/Convenience.h b/src/uscxml/Convenience.h
index b2b437c..1ecc8b0 100644
--- a/src/uscxml/Convenience.h
+++ b/src/uscxml/Convenience.h
@@ -46,6 +46,16 @@ inline bool isNumeric( const char* pszInput, int nNumberBase) {
return (input.find_first_not_of(base.substr(0, nNumberBase + 2)) == std::string::npos);
}
+inline bool iequals(const std::string& a, const std::string& b) {
+ unsigned int size = a.size();
+ if (b.size() != size)
+ return false;
+ for (unsigned int i = 0; i < size; ++i)
+ if (tolower(a[i]) != tolower(b[i]))
+ return false;
+ return true;
+}
+
}
diff --git a/src/uscxml/Message.h b/src/uscxml/Message.h
index 547c6c9..6b84923 100644
--- a/src/uscxml/Message.h
+++ b/src/uscxml/Message.h
@@ -166,6 +166,7 @@ public:
protected:
#endif
+ Arabica::DOM::Node<std::string> node;
std::map<std::string, Data> compound;
std::list<Data> array;
std::string atom;
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
index 4a4a6e7..c737d16 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
@@ -376,10 +376,15 @@ Data JSCDataModel::getValueAsData(const JSValueRef value) {
if (exception)
handleException(exception);
if (JSValueIsObjectOfClass(_ctx, value, JSCArrayBuffer::getTmpl())) {
- // binary data!
+ // binary data
JSCArrayBuffer::JSCArrayBufferPrivate* privObj = (JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(objValue);
data.binary = privObj->nativeObj->_buffer;
return data;
+ } else if (JSValueIsObjectOfClass(_ctx, value, JSCNode::getTmpl())) {
+ // dom node
+ JSCNode::JSCNodePrivate* privObj = (JSCNode::JSCNodePrivate*)JSObjectGetPrivate(objValue);
+ data.node = *privObj->nativeObj;
+ return data;
}
std::set<std::string> propertySet;
JSPropertyNameArrayRef properties = JSObjectCopyPropertyNames(_ctx, objValue);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
index b0ffcea..a0de760 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
@@ -324,6 +324,11 @@ Data V8DataModel::getValueAsData(const v8::Handle<v8::Value>& value, std::set<v8
data.binary = privObj->nativeObj->_buffer;
return data;
}
+ if (V8Node::hasInstance(value)) {
+ uscxml::V8Node::V8NodePrivate* privObj = V8DOM::toClassPtr<V8Node::V8NodePrivate >(value->ToObject()->GetInternalField(0));
+ data.node = *privObj->nativeObj;
+ return data;
+ }
v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value);
v8::Local<v8::Array> properties = object->GetPropertyNames();
for (int i = 0; i < properties->Length(); i++) {
diff --git a/src/uscxml/plugins/element/respond/RespondElement.cpp b/src/uscxml/plugins/element/respond/RespondElement.cpp
index 21d5907..2b8d02d 100644
--- a/src/uscxml/plugins/element/respond/RespondElement.cpp
+++ b/src/uscxml/plugins/element/respond/RespondElement.cpp
@@ -85,10 +85,18 @@ void RespondElement::enterElement(const Arabica::DOM::Node<std::string>& node) {
Data contentData = _interpreter->getDataModel().getStringAsData(ATTR(contents[0], "expr"));
if (contentData.atom.length() > 0) {
httpReply.content = contentData.atom;
+ httpReply.headers["Content-Type"] = "text/plain";
} else if (contentData.binary) {
httpReply.content = std::string(contentData.binary->data, contentData.binary->size);
+ httpReply.headers["Content-Type"] = contentData.binary->mimeType;
+ } else if (contentData.node) {
+ std::stringstream ss;
+ ss << contentData.node;
+ httpReply.content = ss.str();;
+ httpReply.headers["Content-Type"] = "application/xml";
} else {
httpReply.content = Data::toJSON(contentData);
+ httpReply.headers["Content-Type"] = "application/json";
}
} catch (Event e) {
LOG(ERROR) << "Syntax error with expr in content child of Respond element:" << std::endl << e << std::endl;