summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-08-13 10:07:32 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-08-13 10:07:32 (GMT)
commit459f406eb2a36d393bd3a2b6aa3d63d86eb99c07 (patch)
tree35593bb978fee75bb7547f3d2c84a9039413fe1f /src/uscxml/plugins
parentbeac3e74f703148085947d75da6fdaa9fd7472b4 (diff)
downloaduscxml-459f406eb2a36d393bd3a2b6aa3d63d86eb99c07.zip
uscxml-459f406eb2a36d393bd3a2b6aa3d63d86eb99c07.tar.gz
uscxml-459f406eb2a36d393bd3a2b6aa3d63d86eb99c07.tar.bz2
Started Java datamodel and fixed memory leaks
Diffstat (limited to 'src/uscxml/plugins')
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp8
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp5
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp20
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h12
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.cpp37
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp82
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp67
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.cpp106
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.cpp34
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp32
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h4
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeListCustom.cpp71
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h4
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSetCustom.cpp89
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.cpp5
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp15
-rw-r--r--src/uscxml/plugins/invoker/audio/AudioToolbox.h4
-rw-r--r--src/uscxml/plugins/invoker/audio/LibSoundFile.cpp40
-rw-r--r--src/uscxml/plugins/invoker/audio/LibSoundFile.h4
-rw-r--r--src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp77
-rw-r--r--src/uscxml/plugins/invoker/audio/OpenALInvoker.h12
-rw-r--r--src/uscxml/plugins/invoker/audio/OpenALPlayer.cpp16
-rw-r--r--src/uscxml/plugins/invoker/audio/PCMConverter.h2
-rw-r--r--src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp18
-rw-r--r--src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.h20
-rw-r--r--src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp16
-rw-r--r--src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp56
-rw-r--r--src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp3
41 files changed, 608 insertions, 264 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
index 33746a5..2c877b2 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp
@@ -370,6 +370,14 @@ void JSCDataModel::setForeach(const std::string& item,
}
bool JSCDataModel::isDeclared(const std::string& expr) {
+ JSStringRef scriptJS = JSStringCreateWithUTF8CString(expr.c_str());
+ JSValueRef exception = NULL;
+ JSValueRef result = JSEvaluateScript(_ctx, scriptJS, NULL, NULL, 0, &exception);
+ JSStringRelease(scriptJS);
+
+ if (exception || JSValueIsNull(_ctx, result)) {
+ return false;
+ }
return true;
}
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp
index 6ceb642..3f967dd 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp
@@ -53,8 +53,9 @@ bool JSCAttr::valueAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef
JSStringRef stringReflocalValue = JSValueToStringCopy(ctx, value, exception);
size_t localValueMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalValue);
char* localValueBuffer = new char[localValueMaxSize];
- JSStringGetUTF8CString(stringReflocalValue, localValueBuffer, sizeof(localValueBuffer));
- std::string localValue(localValueBuffer, localValueMaxSize);
+ JSStringGetUTF8CString(stringReflocalValue, localValueBuffer, localValueMaxSize);
+ std::string localValue(localValueBuffer);
+ JSStringRelease(stringReflocalValue);
free(localValueBuffer);
privData->nativeObj->setValue(localValue);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h
index 5efc53a..01628a6 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h
@@ -57,6 +57,7 @@ public:
classDef.staticValues = staticValues;
classDef.staticFunctions = staticFunctions;
classDef.finalize = jsDestructor;
+ classDef.parentClass = JSCNode::getTmpl();
Tmpl = JSClassCreate(&classDef);
JSClassRetain(Tmpl);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h
index a4d86f2..9fe225b 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h
@@ -52,6 +52,7 @@ public:
classDef.staticValues = staticValues;
classDef.staticFunctions = staticFunctions;
classDef.finalize = jsDestructor;
+ classDef.parentClass = JSCText::getTmpl();
Tmpl = JSClassCreate(&classDef);
JSClassRetain(Tmpl);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp
index c7ce20a..f64b4c9 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp
@@ -38,8 +38,9 @@ bool JSCCharacterData::dataAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSS
JSStringRef stringReflocalData = JSValueToStringCopy(ctx, value, exception);
size_t localDataMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalData);
char* localDataBuffer = new char[localDataMaxSize];
- JSStringGetUTF8CString(stringReflocalData, localDataBuffer, sizeof(localDataBuffer));
- std::string localData(localDataBuffer, localDataMaxSize);
+ JSStringGetUTF8CString(stringReflocalData, localDataBuffer, localDataMaxSize);
+ std::string localData(localDataBuffer);
+ JSStringRelease(stringReflocalData);
free(localDataBuffer);
privData->nativeObj->setData(localData);
@@ -90,8 +91,9 @@ JSValueRef JSCCharacterData::appendDataCallback(JSContextRef ctx, JSObjectRef fu
JSStringRef stringReflocalArg = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localArgMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalArg);
char* localArgBuffer = new char[localArgMaxSize];
- JSStringGetUTF8CString(stringReflocalArg, localArgBuffer, sizeof(localArgBuffer));
- std::string localArg(localArgBuffer, localArgMaxSize);
+ JSStringGetUTF8CString(stringReflocalArg, localArgBuffer, localArgMaxSize);
+ std::string localArg(localArgBuffer);
+ JSStringRelease(stringReflocalArg);
free(localArgBuffer);
@@ -117,8 +119,9 @@ JSValueRef JSCCharacterData::insertDataCallback(JSContextRef ctx, JSObjectRef fu
JSStringRef stringReflocalArg = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localArgMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalArg);
char* localArgBuffer = new char[localArgMaxSize];
- JSStringGetUTF8CString(stringReflocalArg, localArgBuffer, sizeof(localArgBuffer));
- std::string localArg(localArgBuffer, localArgMaxSize);
+ JSStringGetUTF8CString(stringReflocalArg, localArgBuffer, localArgMaxSize);
+ std::string localArg(localArgBuffer);
+ JSStringRelease(stringReflocalArg);
free(localArgBuffer);
@@ -166,8 +169,9 @@ JSValueRef JSCCharacterData::replaceDataCallback(JSContextRef ctx, JSObjectRef f
JSStringRef stringReflocalArg = JSValueToStringCopy(ctx, arguments[2], exception);
size_t localArgMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalArg);
char* localArgBuffer = new char[localArgMaxSize];
- JSStringGetUTF8CString(stringReflocalArg, localArgBuffer, sizeof(localArgBuffer));
- std::string localArg(localArgBuffer, localArgMaxSize);
+ JSStringGetUTF8CString(stringReflocalArg, localArgBuffer, localArgMaxSize);
+ std::string localArg(localArgBuffer);
+ JSStringRelease(stringReflocalArg);
free(localArgBuffer);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h
index 2620468..0bdca74 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h
@@ -60,6 +60,7 @@ public:
classDef.staticValues = staticValues;
classDef.staticFunctions = staticFunctions;
classDef.finalize = jsDestructor;
+ classDef.parentClass = JSCNode::getTmpl();
Tmpl = JSClassCreate(&classDef);
JSClassRetain(Tmpl);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h
index c1678ea..7c4e96f 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h
@@ -52,6 +52,7 @@ public:
classDef.staticValues = staticValues;
classDef.staticFunctions = staticFunctions;
classDef.finalize = jsDestructor;
+ classDef.parentClass = JSCCharacterData::getTmpl();
Tmpl = JSClassCreate(&classDef);
JSClassRetain(Tmpl);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h
index e2b8a4d..bffeab8 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h
@@ -3,11 +3,21 @@
#include "uscxml/Interpreter.h"
#include <JavaScriptCore/JavaScriptCore.h>
+#include <XPath/XPath.hpp>
#define JSC_DESTRUCTOR(type) \
static void jsDestructor(JSObjectRef object) { \
+ type* thing = static_cast<type*>(JSObjectGetPrivate(object)); \
+ if (thing) {\
+ delete thing->nativeObj; \
+ delete thing; \
+ JSObjectSetPrivate(object, NULL);\
+ }\
+}
+
+#define JSC_DESTRUCTOR_KEEP_WRAPPED(type) \
+static void jsDestructor(JSObjectRef object) { \
type* thing = static_cast<type*>(JSObjectGetPrivate(object)); \
-delete thing->nativeObj; \
delete thing; \
}
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.cpp
index 66c9666..72d4beb 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.cpp
@@ -33,15 +33,17 @@ JSValueRef JSCDOMImplementation::hasFeatureCallback(JSContextRef ctx, JSObjectRe
JSStringRef stringReflocalFeature = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localFeatureMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalFeature);
char* localFeatureBuffer = new char[localFeatureMaxSize];
- JSStringGetUTF8CString(stringReflocalFeature, localFeatureBuffer, sizeof(localFeatureBuffer));
- std::string localFeature(localFeatureBuffer, localFeatureMaxSize);
+ JSStringGetUTF8CString(stringReflocalFeature, localFeatureBuffer, localFeatureMaxSize);
+ std::string localFeature(localFeatureBuffer);
+ JSStringRelease(stringReflocalFeature);
free(localFeatureBuffer);
JSStringRef stringReflocalVersion = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localVersionMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalVersion);
char* localVersionBuffer = new char[localVersionMaxSize];
- JSStringGetUTF8CString(stringReflocalVersion, localVersionBuffer, sizeof(localVersionBuffer));
- std::string localVersion(localVersionBuffer, localVersionMaxSize);
+ JSStringGetUTF8CString(stringReflocalVersion, localVersionBuffer, localVersionMaxSize);
+ std::string localVersion(localVersionBuffer);
+ JSStringRelease(stringReflocalVersion);
free(localVersionBuffer);
@@ -66,22 +68,25 @@ JSValueRef JSCDOMImplementation::createDocumentTypeCallback(JSContextRef ctx, JS
JSStringRef stringReflocalQualifiedName = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localQualifiedNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalQualifiedName);
char* localQualifiedNameBuffer = new char[localQualifiedNameMaxSize];
- JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, sizeof(localQualifiedNameBuffer));
- std::string localQualifiedName(localQualifiedNameBuffer, localQualifiedNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, localQualifiedNameMaxSize);
+ std::string localQualifiedName(localQualifiedNameBuffer);
+ JSStringRelease(stringReflocalQualifiedName);
free(localQualifiedNameBuffer);
JSStringRef stringReflocalPublicId = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localPublicIdMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalPublicId);
char* localPublicIdBuffer = new char[localPublicIdMaxSize];
- JSStringGetUTF8CString(stringReflocalPublicId, localPublicIdBuffer, sizeof(localPublicIdBuffer));
- std::string localPublicId(localPublicIdBuffer, localPublicIdMaxSize);
+ JSStringGetUTF8CString(stringReflocalPublicId, localPublicIdBuffer, localPublicIdMaxSize);
+ std::string localPublicId(localPublicIdBuffer);
+ JSStringRelease(stringReflocalPublicId);
free(localPublicIdBuffer);
JSStringRef stringReflocalSystemId = JSValueToStringCopy(ctx, arguments[2], exception);
size_t localSystemIdMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalSystemId);
char* localSystemIdBuffer = new char[localSystemIdMaxSize];
- JSStringGetUTF8CString(stringReflocalSystemId, localSystemIdBuffer, sizeof(localSystemIdBuffer));
- std::string localSystemId(localSystemIdBuffer, localSystemIdMaxSize);
+ JSStringGetUTF8CString(stringReflocalSystemId, localSystemIdBuffer, localSystemIdMaxSize);
+ std::string localSystemId(localSystemIdBuffer);
+ JSStringRelease(stringReflocalSystemId);
free(localSystemIdBuffer);
@@ -113,18 +118,20 @@ JSValueRef JSCDOMImplementation::createDocumentCallback(JSContextRef ctx, JSObje
JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI);
char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize];
- JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, sizeof(localNamespaceURIBuffer));
- std::string localNamespaceURI(localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ std::string localNamespaceURI(localNamespaceURIBuffer);
+ JSStringRelease(stringReflocalNamespaceURI);
free(localNamespaceURIBuffer);
JSStringRef stringReflocalQualifiedName = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localQualifiedNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalQualifiedName);
char* localQualifiedNameBuffer = new char[localQualifiedNameMaxSize];
- JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, sizeof(localQualifiedNameBuffer));
- std::string localQualifiedName(localQualifiedNameBuffer, localQualifiedNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, localQualifiedNameMaxSize);
+ std::string localQualifiedName(localQualifiedNameBuffer);
+ JSStringRelease(stringReflocalQualifiedName);
free(localQualifiedNameBuffer);
- Arabica::DOM::DocumentType<std::string>* localDoctype = ((struct JSCDocumentType::JSCDocumentTypePrivate*)JSObjectGetPrivate(thisObj))->nativeObj;
+ Arabica::DOM::DocumentType<std::string>* localDoctype = ((struct JSCDocumentType::JSCDocumentTypePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[2], exception)))->nativeObj;
Arabica::DOM::Document<std::string>* retVal = new Arabica::DOM::Document<std::string>(privData->nativeObj->createDocument(localNamespaceURI, localQualifiedName, *localDoctype));
JSClassRef retClass = JSCDocument::getTmpl();
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp
index ed12bb0..4fae6c9 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp
@@ -109,8 +109,9 @@ JSValueRef JSCDocument::createElementCallback(JSContextRef ctx, JSObjectRef func
JSStringRef stringReflocalTagName = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localTagNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalTagName);
char* localTagNameBuffer = new char[localTagNameMaxSize];
- JSStringGetUTF8CString(stringReflocalTagName, localTagNameBuffer, sizeof(localTagNameBuffer));
- std::string localTagName(localTagNameBuffer, localTagNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalTagName, localTagNameBuffer, localTagNameMaxSize);
+ std::string localTagName(localTagNameBuffer);
+ JSStringRelease(stringReflocalTagName);
free(localTagNameBuffer);
@@ -160,8 +161,9 @@ JSValueRef JSCDocument::createTextNodeCallback(JSContextRef ctx, JSObjectRef fun
JSStringRef stringReflocalData = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localDataMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalData);
char* localDataBuffer = new char[localDataMaxSize];
- JSStringGetUTF8CString(stringReflocalData, localDataBuffer, sizeof(localDataBuffer));
- std::string localData(localDataBuffer, localDataMaxSize);
+ JSStringGetUTF8CString(stringReflocalData, localDataBuffer, localDataMaxSize);
+ std::string localData(localDataBuffer);
+ JSStringRelease(stringReflocalData);
free(localDataBuffer);
@@ -193,8 +195,9 @@ JSValueRef JSCDocument::createCommentCallback(JSContextRef ctx, JSObjectRef func
JSStringRef stringReflocalData = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localDataMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalData);
char* localDataBuffer = new char[localDataMaxSize];
- JSStringGetUTF8CString(stringReflocalData, localDataBuffer, sizeof(localDataBuffer));
- std::string localData(localDataBuffer, localDataMaxSize);
+ JSStringGetUTF8CString(stringReflocalData, localDataBuffer, localDataMaxSize);
+ std::string localData(localDataBuffer);
+ JSStringRelease(stringReflocalData);
free(localDataBuffer);
@@ -226,8 +229,9 @@ JSValueRef JSCDocument::createCDATASectionCallback(JSContextRef ctx, JSObjectRef
JSStringRef stringReflocalData = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localDataMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalData);
char* localDataBuffer = new char[localDataMaxSize];
- JSStringGetUTF8CString(stringReflocalData, localDataBuffer, sizeof(localDataBuffer));
- std::string localData(localDataBuffer, localDataMaxSize);
+ JSStringGetUTF8CString(stringReflocalData, localDataBuffer, localDataMaxSize);
+ std::string localData(localDataBuffer);
+ JSStringRelease(stringReflocalData);
free(localDataBuffer);
@@ -259,15 +263,17 @@ JSValueRef JSCDocument::createProcessingInstructionCallback(JSContextRef ctx, JS
JSStringRef stringReflocalTarget = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localTargetMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalTarget);
char* localTargetBuffer = new char[localTargetMaxSize];
- JSStringGetUTF8CString(stringReflocalTarget, localTargetBuffer, sizeof(localTargetBuffer));
- std::string localTarget(localTargetBuffer, localTargetMaxSize);
+ JSStringGetUTF8CString(stringReflocalTarget, localTargetBuffer, localTargetMaxSize);
+ std::string localTarget(localTargetBuffer);
+ JSStringRelease(stringReflocalTarget);
free(localTargetBuffer);
JSStringRef stringReflocalData = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localDataMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalData);
char* localDataBuffer = new char[localDataMaxSize];
- JSStringGetUTF8CString(stringReflocalData, localDataBuffer, sizeof(localDataBuffer));
- std::string localData(localDataBuffer, localDataMaxSize);
+ JSStringGetUTF8CString(stringReflocalData, localDataBuffer, localDataMaxSize);
+ std::string localData(localDataBuffer);
+ JSStringRelease(stringReflocalData);
free(localDataBuffer);
@@ -299,8 +305,9 @@ JSValueRef JSCDocument::createAttributeCallback(JSContextRef ctx, JSObjectRef fu
JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName);
char* localNameBuffer = new char[localNameMaxSize];
- JSStringGetUTF8CString(stringReflocalName, localNameBuffer, sizeof(localNameBuffer));
- std::string localName(localNameBuffer, localNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize);
+ std::string localName(localNameBuffer);
+ JSStringRelease(stringReflocalName);
free(localNameBuffer);
@@ -332,8 +339,9 @@ JSValueRef JSCDocument::createEntityReferenceCallback(JSContextRef ctx, JSObject
JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName);
char* localNameBuffer = new char[localNameMaxSize];
- JSStringGetUTF8CString(stringReflocalName, localNameBuffer, sizeof(localNameBuffer));
- std::string localName(localNameBuffer, localNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize);
+ std::string localName(localNameBuffer);
+ JSStringRelease(stringReflocalName);
free(localNameBuffer);
@@ -365,8 +373,9 @@ JSValueRef JSCDocument::getElementsByTagNameCallback(JSContextRef ctx, JSObjectR
JSStringRef stringReflocalTagname = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localTagnameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalTagname);
char* localTagnameBuffer = new char[localTagnameMaxSize];
- JSStringGetUTF8CString(stringReflocalTagname, localTagnameBuffer, sizeof(localTagnameBuffer));
- std::string localTagname(localTagnameBuffer, localTagnameMaxSize);
+ JSStringGetUTF8CString(stringReflocalTagname, localTagnameBuffer, localTagnameMaxSize);
+ std::string localTagname(localTagnameBuffer);
+ JSStringRelease(stringReflocalTagname);
free(localTagnameBuffer);
@@ -395,7 +404,7 @@ JSValueRef JSCDocument::importNodeCallback(JSContextRef ctx, JSObjectRef functio
struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(thisObj);
- Arabica::DOM::Node<std::string>* localImportedNode = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(thisObj))->nativeObj;
+ Arabica::DOM::Node<std::string>* localImportedNode = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj;
bool localDeep = JSValueToBoolean(ctx, arguments[1]);
Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->importNode(*localImportedNode, localDeep));
@@ -426,15 +435,17 @@ JSValueRef JSCDocument::createElementNSCallback(JSContextRef ctx, JSObjectRef fu
JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI);
char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize];
- JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, sizeof(localNamespaceURIBuffer));
- std::string localNamespaceURI(localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ std::string localNamespaceURI(localNamespaceURIBuffer);
+ JSStringRelease(stringReflocalNamespaceURI);
free(localNamespaceURIBuffer);
JSStringRef stringReflocalQualifiedName = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localQualifiedNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalQualifiedName);
char* localQualifiedNameBuffer = new char[localQualifiedNameMaxSize];
- JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, sizeof(localQualifiedNameBuffer));
- std::string localQualifiedName(localQualifiedNameBuffer, localQualifiedNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, localQualifiedNameMaxSize);
+ std::string localQualifiedName(localQualifiedNameBuffer);
+ JSStringRelease(stringReflocalQualifiedName);
free(localQualifiedNameBuffer);
@@ -466,15 +477,17 @@ JSValueRef JSCDocument::createAttributeNSCallback(JSContextRef ctx, JSObjectRef
JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI);
char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize];
- JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, sizeof(localNamespaceURIBuffer));
- std::string localNamespaceURI(localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ std::string localNamespaceURI(localNamespaceURIBuffer);
+ JSStringRelease(stringReflocalNamespaceURI);
free(localNamespaceURIBuffer);
JSStringRef stringReflocalQualifiedName = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localQualifiedNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalQualifiedName);
char* localQualifiedNameBuffer = new char[localQualifiedNameMaxSize];
- JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, sizeof(localQualifiedNameBuffer));
- std::string localQualifiedName(localQualifiedNameBuffer, localQualifiedNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, localQualifiedNameMaxSize);
+ std::string localQualifiedName(localQualifiedNameBuffer);
+ JSStringRelease(stringReflocalQualifiedName);
free(localQualifiedNameBuffer);
@@ -506,15 +519,17 @@ JSValueRef JSCDocument::getElementsByTagNameNSCallback(JSContextRef ctx, JSObjec
JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI);
char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize];
- JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, sizeof(localNamespaceURIBuffer));
- std::string localNamespaceURI(localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ std::string localNamespaceURI(localNamespaceURIBuffer);
+ JSStringRelease(stringReflocalNamespaceURI);
free(localNamespaceURIBuffer);
JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName);
char* localLocalNameBuffer = new char[localLocalNameMaxSize];
- JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, sizeof(localLocalNameBuffer));
- std::string localLocalName(localLocalNameBuffer, localLocalNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize);
+ std::string localLocalName(localLocalNameBuffer);
+ JSStringRelease(stringReflocalLocalName);
free(localLocalNameBuffer);
@@ -546,8 +561,9 @@ JSValueRef JSCDocument::getElementByIdCallback(JSContextRef ctx, JSObjectRef fun
JSStringRef stringReflocalElementId = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localElementIdMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalElementId);
char* localElementIdBuffer = new char[localElementIdMaxSize];
- JSStringGetUTF8CString(stringReflocalElementId, localElementIdBuffer, sizeof(localElementIdBuffer));
- std::string localElementId(localElementIdBuffer, localElementIdMaxSize);
+ JSStringGetUTF8CString(stringReflocalElementId, localElementIdBuffer, localElementIdMaxSize);
+ std::string localElementId(localElementIdBuffer);
+ JSStringRelease(stringReflocalElementId);
free(localElementIdBuffer);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h
index 3446cc2..6657f3b 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h
@@ -70,6 +70,7 @@ public:
classDef.staticValues = staticValues;
classDef.staticFunctions = staticFunctions;
classDef.finalize = jsDestructor;
+ classDef.parentClass = JSCNode::getTmpl();
Tmpl = JSClassCreate(&classDef);
JSClassRetain(Tmpl);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp
index 23cc0f9..c6fdce1 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp
@@ -1,11 +1,76 @@
#include "JSCDocument.h"
#include "JSCXPathResult.h"
+#include "JSCNode.h"
+#include <XPath/XPath.hpp>
namespace Arabica {
namespace DOM {
-JSValueRef JSCDocument::evaluateCustomCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
+JSValueRef JSCDocument::evaluateCustomCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef object, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
+ struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(object);
+
+ if (!privData->dom || !privData->dom->xpath) return JSValueMakeUndefined(ctx);
+ if (argumentCount < 1) {
+ std::string errorMsg = "Wrong number of arguments in evaluate";
+ JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str());
+ JSValueRef exceptionString = JSValueMakeString(ctx, string);
+ JSStringRelease(string);
+ *exception = JSValueToObject(ctx, exceptionString, NULL);
+ return JSValueMakeUndefined(ctx);
+ }
+
+ // make sure first argument is a string
+ if (!JSValueIsString(ctx, arguments[0])) {
+ std::string errorMsg = "Expected xpath expression as first argument";
+ JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str());
+ JSValueRef exceptionString = JSValueMakeString(ctx, string);
+ JSStringRelease(string);
+ *exception = JSValueToObject(ctx, exceptionString, NULL);
+ return JSValueMakeUndefined(ctx);
+ }
+
+ JSStringRef stringReflocalXPath = JSValueToStringCopy(ctx, arguments[0], NULL);
+ size_t localXPathMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalXPath);
+ char* localXPathBuffer = new char[localXPathMaxSize];
+ JSStringGetUTF8CString(stringReflocalXPath, localXPathBuffer, localXPathMaxSize);
+ std::string localXPath(localXPathBuffer);
+ JSStringRelease(stringReflocalXPath);
+ free(localXPathBuffer);
+
+ JSClassRef arbaicaRetClass = JSCXPathResult::getTmpl();
+
+ XPath::XPathValue<std::string>* retVal;
+
+ try {
+ if (argumentCount > 1) {
+ // make sure second argument is a node
+ if (!JSValueIsObject(ctx, arguments[1])) {
+ std::string errorMsg = "Second argument is not of type node";
+ JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str());
+ JSValueRef exceptionString = JSValueMakeString(ctx, string);
+ JSStringRelease(string);
+ *exception = JSValueToObject(ctx, exceptionString, NULL);
+ return JSValueMakeUndefined(ctx);
+ }
+
+ Arabica::DOM::Node<std::string>* localContextNode = (Arabica::DOM::Node<std::string>*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[1], NULL));
+ retVal = new XPath::XPathValue<std::string>(privData->dom->xpath->evaluate(localXPath, *localContextNode));
+ } else {
+ retVal = new XPath::XPathValue<std::string>(privData->dom->xpath->evaluate(localXPath, *privData->nativeObj));
+ }
+ } catch (std::runtime_error e) {
+ std::cout << e.what() << std::endl;
+ return JSValueMakeUndefined(ctx);
+ }
+
+ struct JSCXPathResult::JSCXPathResultPrivate* retPrivData = new JSCXPathResult::JSCXPathResultPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
+
+ JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData);
+ return arbaicaRetObj;
+
#if 0
if (args.Length() < 1)
throw V8Exception("Wrong number of arguments in evaluate");
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h
index 1d8a9c9..3a9d8d6 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h
@@ -52,6 +52,7 @@ public:
classDef.staticValues = staticValues;
classDef.staticFunctions = staticFunctions;
classDef.finalize = jsDestructor;
+ classDef.parentClass = JSCNode::getTmpl();
Tmpl = JSClassCreate(&classDef);
JSClassRetain(Tmpl);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h
index 6f839a2..3dc46f4 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h
@@ -58,6 +58,7 @@ public:
classDef.staticValues = staticValues;
classDef.staticFunctions = staticFunctions;
classDef.finalize = jsDestructor;
+ classDef.parentClass = JSCNode::getTmpl();
Tmpl = JSClassCreate(&classDef);
JSClassRetain(Tmpl);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.cpp
index ce77091..e0b403f 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.cpp
@@ -57,8 +57,9 @@ JSValueRef JSCElement::getAttributeCallback(JSContextRef ctx, JSObjectRef functi
JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName);
char* localNameBuffer = new char[localNameMaxSize];
- JSStringGetUTF8CString(stringReflocalName, localNameBuffer, sizeof(localNameBuffer));
- std::string localName(localNameBuffer, localNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize);
+ std::string localName(localNameBuffer);
+ JSStringRelease(stringReflocalName);
free(localNameBuffer);
@@ -85,15 +86,17 @@ JSValueRef JSCElement::setAttributeCallback(JSContextRef ctx, JSObjectRef functi
JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName);
char* localNameBuffer = new char[localNameMaxSize];
- JSStringGetUTF8CString(stringReflocalName, localNameBuffer, sizeof(localNameBuffer));
- std::string localName(localNameBuffer, localNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize);
+ std::string localName(localNameBuffer);
+ JSStringRelease(stringReflocalName);
free(localNameBuffer);
JSStringRef stringReflocalValue = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localValueMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalValue);
char* localValueBuffer = new char[localValueMaxSize];
- JSStringGetUTF8CString(stringReflocalValue, localValueBuffer, sizeof(localValueBuffer));
- std::string localValue(localValueBuffer, localValueMaxSize);
+ JSStringGetUTF8CString(stringReflocalValue, localValueBuffer, localValueMaxSize);
+ std::string localValue(localValueBuffer);
+ JSStringRelease(stringReflocalValue);
free(localValueBuffer);
@@ -118,8 +121,9 @@ JSValueRef JSCElement::removeAttributeCallback(JSContextRef ctx, JSObjectRef fun
JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName);
char* localNameBuffer = new char[localNameMaxSize];
- JSStringGetUTF8CString(stringReflocalName, localNameBuffer, sizeof(localNameBuffer));
- std::string localName(localNameBuffer, localNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize);
+ std::string localName(localNameBuffer);
+ JSStringRelease(stringReflocalName);
free(localNameBuffer);
@@ -144,8 +148,9 @@ JSValueRef JSCElement::getAttributeNodeCallback(JSContextRef ctx, JSObjectRef fu
JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName);
char* localNameBuffer = new char[localNameMaxSize];
- JSStringGetUTF8CString(stringReflocalName, localNameBuffer, sizeof(localNameBuffer));
- std::string localName(localNameBuffer, localNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize);
+ std::string localName(localNameBuffer);
+ JSStringRelease(stringReflocalName);
free(localNameBuffer);
@@ -174,7 +179,7 @@ JSValueRef JSCElement::setAttributeNodeCallback(JSContextRef ctx, JSObjectRef fu
struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj);
- Arabica::DOM::Attr<std::string>* localNewAttr = ((struct JSCAttr::JSCAttrPrivate*)JSObjectGetPrivate(thisObj))->nativeObj;
+ Arabica::DOM::Attr<std::string>* localNewAttr = ((struct JSCAttr::JSCAttrPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj;
Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->setAttributeNode(*localNewAttr));
JSClassRef retClass = JSCAttr::getTmpl();
@@ -201,7 +206,7 @@ JSValueRef JSCElement::removeAttributeNodeCallback(JSContextRef ctx, JSObjectRef
struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj);
- Arabica::DOM::Attr<std::string>* localOldAttr = ((struct JSCAttr::JSCAttrPrivate*)JSObjectGetPrivate(thisObj))->nativeObj;
+ Arabica::DOM::Attr<std::string>* localOldAttr = ((struct JSCAttr::JSCAttrPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj;
Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->removeAttributeNode(*localOldAttr));
JSClassRef retClass = JSCAttr::getTmpl();
@@ -231,8 +236,9 @@ JSValueRef JSCElement::getElementsByTagNameCallback(JSContextRef ctx, JSObjectRe
JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName);
char* localNameBuffer = new char[localNameMaxSize];
- JSStringGetUTF8CString(stringReflocalName, localNameBuffer, sizeof(localNameBuffer));
- std::string localName(localNameBuffer, localNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize);
+ std::string localName(localNameBuffer);
+ JSStringRelease(stringReflocalName);
free(localNameBuffer);
@@ -264,15 +270,17 @@ JSValueRef JSCElement::getAttributeNSCallback(JSContextRef ctx, JSObjectRef func
JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI);
char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize];
- JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, sizeof(localNamespaceURIBuffer));
- std::string localNamespaceURI(localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ std::string localNamespaceURI(localNamespaceURIBuffer);
+ JSStringRelease(stringReflocalNamespaceURI);
free(localNamespaceURIBuffer);
JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName);
char* localLocalNameBuffer = new char[localLocalNameMaxSize];
- JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, sizeof(localLocalNameBuffer));
- std::string localLocalName(localLocalNameBuffer, localLocalNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize);
+ std::string localLocalName(localLocalNameBuffer);
+ JSStringRelease(stringReflocalLocalName);
free(localLocalNameBuffer);
@@ -299,22 +307,25 @@ JSValueRef JSCElement::setAttributeNSCallback(JSContextRef ctx, JSObjectRef func
JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI);
char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize];
- JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, sizeof(localNamespaceURIBuffer));
- std::string localNamespaceURI(localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ std::string localNamespaceURI(localNamespaceURIBuffer);
+ JSStringRelease(stringReflocalNamespaceURI);
free(localNamespaceURIBuffer);
JSStringRef stringReflocalQualifiedName = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localQualifiedNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalQualifiedName);
char* localQualifiedNameBuffer = new char[localQualifiedNameMaxSize];
- JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, sizeof(localQualifiedNameBuffer));
- std::string localQualifiedName(localQualifiedNameBuffer, localQualifiedNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, localQualifiedNameMaxSize);
+ std::string localQualifiedName(localQualifiedNameBuffer);
+ JSStringRelease(stringReflocalQualifiedName);
free(localQualifiedNameBuffer);
JSStringRef stringReflocalValue = JSValueToStringCopy(ctx, arguments[2], exception);
size_t localValueMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalValue);
char* localValueBuffer = new char[localValueMaxSize];
- JSStringGetUTF8CString(stringReflocalValue, localValueBuffer, sizeof(localValueBuffer));
- std::string localValue(localValueBuffer, localValueMaxSize);
+ JSStringGetUTF8CString(stringReflocalValue, localValueBuffer, localValueMaxSize);
+ std::string localValue(localValueBuffer);
+ JSStringRelease(stringReflocalValue);
free(localValueBuffer);
@@ -339,15 +350,17 @@ JSValueRef JSCElement::removeAttributeNSCallback(JSContextRef ctx, JSObjectRef f
JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI);
char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize];
- JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, sizeof(localNamespaceURIBuffer));
- std::string localNamespaceURI(localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ std::string localNamespaceURI(localNamespaceURIBuffer);
+ JSStringRelease(stringReflocalNamespaceURI);
free(localNamespaceURIBuffer);
JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName);
char* localLocalNameBuffer = new char[localLocalNameMaxSize];
- JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, sizeof(localLocalNameBuffer));
- std::string localLocalName(localLocalNameBuffer, localLocalNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize);
+ std::string localLocalName(localLocalNameBuffer);
+ JSStringRelease(stringReflocalLocalName);
free(localLocalNameBuffer);
@@ -372,15 +385,17 @@ JSValueRef JSCElement::getAttributeNodeNSCallback(JSContextRef ctx, JSObjectRef
JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI);
char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize];
- JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, sizeof(localNamespaceURIBuffer));
- std::string localNamespaceURI(localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ std::string localNamespaceURI(localNamespaceURIBuffer);
+ JSStringRelease(stringReflocalNamespaceURI);
free(localNamespaceURIBuffer);
JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName);
char* localLocalNameBuffer = new char[localLocalNameMaxSize];
- JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, sizeof(localLocalNameBuffer));
- std::string localLocalName(localLocalNameBuffer, localLocalNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize);
+ std::string localLocalName(localLocalNameBuffer);
+ JSStringRelease(stringReflocalLocalName);
free(localLocalNameBuffer);
@@ -409,7 +424,7 @@ JSValueRef JSCElement::setAttributeNodeNSCallback(JSContextRef ctx, JSObjectRef
struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj);
- Arabica::DOM::Attr<std::string>* localNewAttr = ((struct JSCAttr::JSCAttrPrivate*)JSObjectGetPrivate(thisObj))->nativeObj;
+ Arabica::DOM::Attr<std::string>* localNewAttr = ((struct JSCAttr::JSCAttrPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj;
Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->setAttributeNodeNS(*localNewAttr));
JSClassRef retClass = JSCAttr::getTmpl();
@@ -439,15 +454,17 @@ JSValueRef JSCElement::getElementsByTagNameNSCallback(JSContextRef ctx, JSObject
JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI);
char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize];
- JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, sizeof(localNamespaceURIBuffer));
- std::string localNamespaceURI(localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ std::string localNamespaceURI(localNamespaceURIBuffer);
+ JSStringRelease(stringReflocalNamespaceURI);
free(localNamespaceURIBuffer);
JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName);
char* localLocalNameBuffer = new char[localLocalNameMaxSize];
- JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, sizeof(localLocalNameBuffer));
- std::string localLocalName(localLocalNameBuffer, localLocalNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize);
+ std::string localLocalName(localLocalNameBuffer);
+ JSStringRelease(stringReflocalLocalName);
free(localLocalNameBuffer);
@@ -479,8 +496,9 @@ JSValueRef JSCElement::hasAttributeCallback(JSContextRef ctx, JSObjectRef functi
JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName);
char* localNameBuffer = new char[localNameMaxSize];
- JSStringGetUTF8CString(stringReflocalName, localNameBuffer, sizeof(localNameBuffer));
- std::string localName(localNameBuffer, localNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize);
+ std::string localName(localNameBuffer);
+ JSStringRelease(stringReflocalName);
free(localNameBuffer);
@@ -505,15 +523,17 @@ JSValueRef JSCElement::hasAttributeNSCallback(JSContextRef ctx, JSObjectRef func
JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI);
char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize];
- JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, sizeof(localNamespaceURIBuffer));
- std::string localNamespaceURI(localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ std::string localNamespaceURI(localNamespaceURIBuffer);
+ JSStringRelease(stringReflocalNamespaceURI);
free(localNamespaceURIBuffer);
JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName);
char* localLocalNameBuffer = new char[localLocalNameMaxSize];
- JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, sizeof(localLocalNameBuffer));
- std::string localLocalName(localLocalNameBuffer, localLocalNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize);
+ std::string localLocalName(localLocalNameBuffer);
+ JSStringRelease(stringReflocalLocalName);
free(localLocalNameBuffer);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h
index 42dc2ac..9520a8b 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h
@@ -68,6 +68,7 @@ public:
classDef.staticValues = staticValues;
classDef.staticFunctions = staticFunctions;
classDef.finalize = jsDestructor;
+ classDef.parentClass = JSCNode::getTmpl();
Tmpl = JSClassCreate(&classDef);
JSClassRetain(Tmpl);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h
index e16cc1f..69f54a3 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h
@@ -55,6 +55,7 @@ public:
classDef.staticValues = staticValues;
classDef.staticFunctions = staticFunctions;
classDef.finalize = jsDestructor;
+ classDef.parentClass = JSCNode::getTmpl();
Tmpl = JSClassCreate(&classDef);
JSClassRetain(Tmpl);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h
index d8e4803..428274f 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h
@@ -52,6 +52,7 @@ public:
classDef.staticValues = staticValues;
classDef.staticFunctions = staticFunctions;
classDef.finalize = jsDestructor;
+ classDef.parentClass = JSCNode::getTmpl();
Tmpl = JSClassCreate(&classDef);
JSClassRetain(Tmpl);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.cpp
index aeb0913..c72b27b 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.cpp
@@ -44,8 +44,9 @@ JSValueRef JSCNamedNodeMap::getNamedItemCallback(JSContextRef ctx, JSObjectRef f
JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName);
char* localNameBuffer = new char[localNameMaxSize];
- JSStringGetUTF8CString(stringReflocalName, localNameBuffer, sizeof(localNameBuffer));
- std::string localName(localNameBuffer, localNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize);
+ std::string localName(localNameBuffer);
+ JSStringRelease(stringReflocalName);
free(localNameBuffer);
@@ -74,7 +75,7 @@ JSValueRef JSCNamedNodeMap::setNamedItemCallback(JSContextRef ctx, JSObjectRef f
struct JSCNamedNodeMapPrivate* privData = (struct JSCNamedNodeMapPrivate*)JSObjectGetPrivate(thisObj);
- Arabica::DOM::Node<std::string>* localArg = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(thisObj))->nativeObj;
+ Arabica::DOM::Node<std::string>* localArg = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj;
Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->setNamedItem(*localArg));
JSClassRef retClass = JSCNode::getTmpl();
@@ -104,8 +105,9 @@ JSValueRef JSCNamedNodeMap::removeNamedItemCallback(JSContextRef ctx, JSObjectRe
JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName);
char* localNameBuffer = new char[localNameMaxSize];
- JSStringGetUTF8CString(stringReflocalName, localNameBuffer, sizeof(localNameBuffer));
- std::string localName(localNameBuffer, localNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize);
+ std::string localName(localNameBuffer);
+ JSStringRelease(stringReflocalName);
free(localNameBuffer);
@@ -164,15 +166,17 @@ JSValueRef JSCNamedNodeMap::getNamedItemNSCallback(JSContextRef ctx, JSObjectRef
JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI);
char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize];
- JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, sizeof(localNamespaceURIBuffer));
- std::string localNamespaceURI(localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ std::string localNamespaceURI(localNamespaceURIBuffer);
+ JSStringRelease(stringReflocalNamespaceURI);
free(localNamespaceURIBuffer);
JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName);
char* localLocalNameBuffer = new char[localLocalNameMaxSize];
- JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, sizeof(localLocalNameBuffer));
- std::string localLocalName(localLocalNameBuffer, localLocalNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize);
+ std::string localLocalName(localLocalNameBuffer);
+ JSStringRelease(stringReflocalLocalName);
free(localLocalNameBuffer);
@@ -201,7 +205,7 @@ JSValueRef JSCNamedNodeMap::setNamedItemNSCallback(JSContextRef ctx, JSObjectRef
struct JSCNamedNodeMapPrivate* privData = (struct JSCNamedNodeMapPrivate*)JSObjectGetPrivate(thisObj);
- Arabica::DOM::Node<std::string>* localArg = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(thisObj))->nativeObj;
+ Arabica::DOM::Node<std::string>* localArg = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj;
Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->setNamedItemNS(*localArg));
JSClassRef retClass = JSCNode::getTmpl();
@@ -231,15 +235,17 @@ JSValueRef JSCNamedNodeMap::removeNamedItemNSCallback(JSContextRef ctx, JSObject
JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI);
char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize];
- JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, sizeof(localNamespaceURIBuffer));
- std::string localNamespaceURI(localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize);
+ std::string localNamespaceURI(localNamespaceURIBuffer);
+ JSStringRelease(stringReflocalNamespaceURI);
free(localNamespaceURIBuffer);
JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName);
char* localLocalNameBuffer = new char[localLocalNameMaxSize];
- JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, sizeof(localLocalNameBuffer));
- std::string localLocalName(localLocalNameBuffer, localLocalNameMaxSize);
+ JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize);
+ std::string localLocalName(localLocalNameBuffer);
+ JSStringRelease(stringReflocalLocalName);
free(localLocalNameBuffer);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp
index 0e84442..22d048c 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp
@@ -77,8 +77,9 @@ bool JSCNode::nodeValueAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStrin
JSStringRef stringReflocalNodeValue = JSValueToStringCopy(ctx, value, exception);
size_t localNodeValueMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNodeValue);
char* localNodeValueBuffer = new char[localNodeValueMaxSize];
- JSStringGetUTF8CString(stringReflocalNodeValue, localNodeValueBuffer, sizeof(localNodeValueBuffer));
- std::string localNodeValue(localNodeValueBuffer, localNodeValueMaxSize);
+ JSStringGetUTF8CString(stringReflocalNodeValue, localNodeValueBuffer, localNodeValueMaxSize);
+ std::string localNodeValue(localNodeValueBuffer);
+ JSStringRelease(stringReflocalNodeValue);
free(localNodeValueBuffer);
privData->nativeObj->setNodeValue(localNodeValue);
@@ -237,8 +238,9 @@ bool JSCNode::prefixAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRe
JSStringRef stringReflocalPrefix = JSValueToStringCopy(ctx, value, exception);
size_t localPrefixMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalPrefix);
char* localPrefixBuffer = new char[localPrefixMaxSize];
- JSStringGetUTF8CString(stringReflocalPrefix, localPrefixBuffer, sizeof(localPrefixBuffer));
- std::string localPrefix(localPrefixBuffer, localPrefixMaxSize);
+ JSStringGetUTF8CString(stringReflocalPrefix, localPrefixBuffer, localPrefixMaxSize);
+ std::string localPrefix(localPrefixBuffer);
+ JSStringRelease(stringReflocalPrefix);
free(localPrefixBuffer);
privData->nativeObj->setPrefix(localPrefix);
@@ -314,8 +316,8 @@ JSValueRef JSCNode::insertBeforeCallback(JSContextRef ctx, JSObjectRef function,
struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(thisObj);
- Arabica::DOM::Node<std::string>* localNewChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(thisObj))->nativeObj;
- Arabica::DOM::Node<std::string>* localRefChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(thisObj))->nativeObj;
+ Arabica::DOM::Node<std::string>* localNewChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj;
+ Arabica::DOM::Node<std::string>* localRefChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[1], exception)))->nativeObj;
Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->insertBefore(*localNewChild, *localRefChild));
JSClassRef retClass = JSCNode::getTmpl();
@@ -342,8 +344,8 @@ JSValueRef JSCNode::replaceChildCallback(JSContextRef ctx, JSObjectRef function,
struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(thisObj);
- Arabica::DOM::Node<std::string>* localNewChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(thisObj))->nativeObj;
- Arabica::DOM::Node<std::string>* localOldChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(thisObj))->nativeObj;
+ Arabica::DOM::Node<std::string>* localNewChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj;
+ Arabica::DOM::Node<std::string>* localOldChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[1], exception)))->nativeObj;
Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->replaceChild(*localNewChild, *localOldChild));
JSClassRef retClass = JSCNode::getTmpl();
@@ -370,7 +372,7 @@ JSValueRef JSCNode::removeChildCallback(JSContextRef ctx, JSObjectRef function,
struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(thisObj);
- Arabica::DOM::Node<std::string>* localOldChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(thisObj))->nativeObj;
+ Arabica::DOM::Node<std::string>* localOldChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj;
Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->removeChild(*localOldChild));
JSClassRef retClass = JSCNode::getTmpl();
@@ -397,7 +399,7 @@ JSValueRef JSCNode::appendChildCallback(JSContextRef ctx, JSObjectRef function,
struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(thisObj);
- Arabica::DOM::Node<std::string>* localNewChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(thisObj))->nativeObj;
+ Arabica::DOM::Node<std::string>* localNewChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj;
Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->appendChild(*localNewChild));
JSClassRef retClass = JSCNode::getTmpl();
@@ -476,15 +478,17 @@ JSValueRef JSCNode::isSupportedCallback(JSContextRef ctx, JSObjectRef function,
JSStringRef stringReflocalFeature = JSValueToStringCopy(ctx, arguments[0], exception);
size_t localFeatureMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalFeature);
char* localFeatureBuffer = new char[localFeatureMaxSize];
- JSStringGetUTF8CString(stringReflocalFeature, localFeatureBuffer, sizeof(localFeatureBuffer));
- std::string localFeature(localFeatureBuffer, localFeatureMaxSize);
+ JSStringGetUTF8CString(stringReflocalFeature, localFeatureBuffer, localFeatureMaxSize);
+ std::string localFeature(localFeatureBuffer);
+ JSStringRelease(stringReflocalFeature);
free(localFeatureBuffer);
JSStringRef stringReflocalVersion = JSValueToStringCopy(ctx, arguments[1], exception);
size_t localVersionMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalVersion);
char* localVersionBuffer = new char[localVersionMaxSize];
- JSStringGetUTF8CString(stringReflocalVersion, localVersionBuffer, sizeof(localVersionBuffer));
- std::string localVersion(localVersionBuffer, localVersionMaxSize);
+ JSStringGetUTF8CString(stringReflocalVersion, localVersionBuffer, localVersionMaxSize);
+ std::string localVersion(localVersionBuffer);
+ JSStringRelease(stringReflocalVersion);
free(localVersionBuffer);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h
index 4a1ba11..fca81b8 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h
@@ -41,6 +41,8 @@ public:
static JSValueRef itemCallback(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 bool hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
+ static JSValueRef getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
static JSStaticValue staticValues[];
@@ -53,6 +55,8 @@ public:
classDef.staticValues = staticValues;
classDef.staticFunctions = staticFunctions;
classDef.finalize = jsDestructor;
+ classDef.hasProperty = hasPropertyCustomCallback;
+ classDef.getProperty = getPropertyCustomCallback;
Tmpl = JSClassCreate(&classDef);
JSClassRetain(Tmpl);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeListCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeListCustom.cpp
index 788c8ec..adb366e 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeListCustom.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeListCustom.cpp
@@ -5,6 +5,77 @@
namespace Arabica {
namespace DOM {
+bool JSCNodeList::hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) {
+ size_t propMaxSize = JSStringGetMaximumUTF8CStringSize(propertyName);
+ char* propBuffer = new char[propMaxSize];
+ JSStringGetUTF8CString(propertyName, propBuffer, propMaxSize);
+ std::string propName(propBuffer);
+ free(propBuffer);
+
+ std::string base = "0123456789";
+ if (propName.find_first_not_of(base) != std::string::npos) {
+ return false;
+ }
+
+ int index = boost::lexical_cast<int>(propName);
+ struct JSCNodeListPrivate* privData = (struct JSCNodeListPrivate*)JSObjectGetPrivate(object);
+
+ if (privData->nativeObj->getLength() < index) {
+ return false;
+ }
+
+ return true;
+}
+
+JSValueRef JSCNodeList::getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
+ size_t propMaxSize = JSStringGetMaximumUTF8CStringSize(propertyName);
+ char* propBuffer = new char[propMaxSize];
+ JSStringGetUTF8CString(propertyName, propBuffer, propMaxSize);
+ std::string propName(propBuffer);
+ free(propBuffer);
+
+ std::string base = "0123456789";
+ if (propName.find_first_not_of(base) != std::string::npos) {
+ return JSValueMakeUndefined(ctx);
+ }
+
+ int index = boost::lexical_cast<int>(propName);
+ struct JSCNodeListPrivate* privData = (struct JSCNodeListPrivate*)JSObjectGetPrivate(object);
+ if (privData->nativeObj->getLength() < index) {
+ return JSValueMakeUndefined(ctx);
+ }
+
+ switch(privData->nativeObj->item(index).getNodeType()) {
+ case Node_base::ELEMENT_NODE: {
+ Arabica::DOM::Element<std::string>* retVal = new Arabica::DOM::Element<std::string>(privData->nativeObj->item(index));
+ JSClassRef retClass = JSCElement::getTmpl();
+
+ struct JSCElement::JSCElementPrivate* retPrivData = new JSCElement::JSCElementPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
+
+ JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData);
+
+ return retObj;
+ break;
+ }
+ default: {
+ Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->item(index));
+ JSClassRef retClass = JSCNode::getTmpl();
+
+ struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
+
+ JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData);
+
+ return retObj;
+ }
+ }
+
+ return JSValueMakeUndefined(ctx);
+}
+
#if 0
v8::Handle<v8::Value> V8NodeList::indexedPropertyCustomGetter(uint32_t index, const v8::AccessorInfo &info) {
v8::Local<v8::Object> self = info.Holder();
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h
index 42b4f29..b38d04e 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h
@@ -42,6 +42,8 @@ public:
static JSValueRef sizeAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception);
static JSValueRef emptyAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception);
+ static bool hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
+ static JSValueRef getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
static JSStaticValue staticValues[];
@@ -54,6 +56,8 @@ public:
classDef.staticValues = staticValues;
classDef.staticFunctions = staticFunctions;
classDef.finalize = jsDestructor;
+ classDef.hasProperty = hasPropertyCustomCallback;
+ classDef.getProperty = getPropertyCustomCallback;
Tmpl = JSClassCreate(&classDef);
JSClassRetain(Tmpl);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSetCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSetCustom.cpp
index 1591310..98f563e 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSetCustom.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSetCustom.cpp
@@ -5,50 +5,77 @@
namespace Arabica {
namespace DOM {
-#if 0
-v8::Handle<v8::Value> V8NodeSet::indexedPropertyCustomGetter(uint32_t index, const v8::AccessorInfo &info) {
- v8::Local<v8::Object> self = info.Holder();
- V8NodeSetPrivate* privData = V8DOM::toClassPtr<V8NodeSetPrivate >(self->GetInternalField(0));
- if (privData->nativeObj->size() >= index) {
- switch((*privData->nativeObj)[index].getNodeType()) {
- case Node_base::ELEMENT_NODE: {
- Arabica::DOM::Element<std::string>* retVal = new Arabica::DOM::Element<std::string>((*privData->nativeObj)[index]);
+bool JSCNodeSet::hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) {
+ size_t propMaxSize = JSStringGetMaximumUTF8CStringSize(propertyName);
+ char* propBuffer = new char[propMaxSize];
+ JSStringGetUTF8CString(propertyName, propBuffer, propMaxSize);
+ std::string propName(propBuffer);
+ free(propBuffer);
- v8::Handle<v8::Function> retCtor = V8Element::getTmpl()->GetFunction();
- v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance());
+ std::string base = "0123456789";
+ if (propName.find_first_not_of(base) != std::string::npos) {
+ return false;
+ }
+
+ int index = boost::lexical_cast<int>(propName);
+ struct JSCNodeSetPrivate* privData = (struct JSCNodeSetPrivate*)JSObjectGetPrivate(object);
+
+ if (privData->nativeObj->size() < index) {
+ return false;
+ }
+
+ return true;
+}
- struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
+JSValueRef JSCNodeSet::getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
+ size_t propMaxSize = JSStringGetMaximumUTF8CStringSize(propertyName);
+ char* propBuffer = new char[propMaxSize];
+ JSStringGetUTF8CString(propertyName, propBuffer, propMaxSize);
+ std::string propName(propBuffer);
+ free(propBuffer);
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ std::string base = "0123456789";
+ if (propName.find_first_not_of(base) != std::string::npos) {
+ return JSValueMakeUndefined(ctx);
+ }
- retObj.MakeWeak(0, V8Element::jsDestructor);
- return retObj;
- }
- default: {
- Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>((*privData->nativeObj)[index]);
+ int index = boost::lexical_cast<int>(propName);
+ struct JSCNodeSetPrivate* privData = (struct JSCNodeSetPrivate*)JSObjectGetPrivate(object);
+ if (privData->nativeObj->size() < index) {
+ return JSValueMakeUndefined(ctx);
+ }
- v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction();
- v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance());
+ switch((*privData->nativeObj)[index].getNodeType()) {
+ case Node_base::ELEMENT_NODE: {
+ Arabica::DOM::Element<std::string>* retVal = new Arabica::DOM::Element<std::string>((*privData->nativeObj)[index]);
+ JSClassRef retClass = JSCElement::getTmpl();
- struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
+ struct JSCElement::JSCElementPrivate* retPrivData = new JSCElement::JSCElementPrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
+ JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData);
- retObj.MakeWeak(0, V8Node::jsDestructor);
- return retObj;
- }
- }
+ return retObj;
+ break;
}
+ default: {
+ Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>((*privData->nativeObj)[index]);
+ JSClassRef retClass = JSCNode::getTmpl();
+
+ struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- return v8::Undefined();
+ JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData);
+
+ return retObj;
+ }
+ }
+ return JSValueMakeUndefined(ctx);
}
-#endif
}
} \ No newline at end of file
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h
index ed793ed..bb84c50 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h
@@ -54,6 +54,7 @@ public:
classDef.staticValues = staticValues;
classDef.staticFunctions = staticFunctions;
classDef.finalize = jsDestructor;
+ classDef.parentClass = JSCNode::getTmpl();
Tmpl = JSClassCreate(&classDef);
JSClassRetain(Tmpl);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.cpp
index d60c39b..9ea0220 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.cpp
@@ -43,8 +43,9 @@ bool JSCProcessingInstruction::dataAttrSetter(JSContextRef ctx, JSObjectRef this
JSStringRef stringReflocalData = JSValueToStringCopy(ctx, value, exception);
size_t localDataMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalData);
char* localDataBuffer = new char[localDataMaxSize];
- JSStringGetUTF8CString(stringReflocalData, localDataBuffer, sizeof(localDataBuffer));
- std::string localData(localDataBuffer, localDataMaxSize);
+ JSStringGetUTF8CString(stringReflocalData, localDataBuffer, localDataMaxSize);
+ std::string localData(localDataBuffer);
+ JSStringRelease(stringReflocalData);
free(localDataBuffer);
privData->nativeObj->setData(localData);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h
index fdf7bc5..fc8c44b 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h
@@ -55,6 +55,7 @@ public:
classDef.staticValues = staticValues;
classDef.staticFunctions = staticFunctions;
classDef.finalize = jsDestructor;
+ classDef.parentClass = JSCNode::getTmpl();
Tmpl = JSClassCreate(&classDef);
JSClassRetain(Tmpl);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h
index a6fdbbd..786df27 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h
@@ -53,6 +53,7 @@ public:
classDef.staticValues = staticValues;
classDef.staticFunctions = staticFunctions;
classDef.finalize = jsDestructor;
+ classDef.parentClass = JSCCharacterData::getTmpl();
Tmpl = JSClassCreate(&classDef);
JSClassRetain(Tmpl);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp
index be9b05c..1e0b700 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp
@@ -17,11 +17,16 @@ v8::Handle<v8::Value> V8Document::evaluateCustomCallback(const v8::Arguments& ar
v8::String::AsciiValue localExpression(args[0]);
XPath::XPathValue<std::string>* retVal;
- if (args.Length() > 1) {
- Arabica::DOM::Node<std::string>* localContextNode = V8DOM::toClassPtr<Arabica::DOM::Node<std::string> >(args[1]->ToObject()->GetInternalField(0));
- retVal = new XPath::XPathValue<std::string>(privData->dom->xpath->evaluate(*localExpression, *localContextNode));
- } else {
- retVal = new XPath::XPathValue<std::string>(privData->dom->xpath->evaluate(*localExpression, *privData->nativeObj));
+ try {
+ if (args.Length() > 1) {
+ Arabica::DOM::Node<std::string>* localContextNode = V8DOM::toClassPtr<Arabica::DOM::Node<std::string> >(args[1]->ToObject()->GetInternalField(0));
+ retVal = new XPath::XPathValue<std::string>(privData->dom->xpath->evaluate(*localExpression, *localContextNode));
+ } else {
+ retVal = new XPath::XPathValue<std::string>(privData->dom->xpath->evaluate(*localExpression, *privData->nativeObj));
+ }
+ } catch (std::runtime_error e) {
+ std::cout << e.what() << std::endl;
+ return v8::Undefined();
}
v8::Handle<v8::Function> retCtor = V8XPathResult::getTmpl()->GetFunction();
diff --git a/src/uscxml/plugins/invoker/audio/AudioToolbox.h b/src/uscxml/plugins/invoker/audio/AudioToolbox.h
index 3e04d8f..6ad7390 100644
--- a/src/uscxml/plugins/invoker/audio/AudioToolbox.h
+++ b/src/uscxml/plugins/invoker/audio/AudioToolbox.h
@@ -5,7 +5,7 @@
#include <AudioToolbox/AudioToolbox.h>
namespace uscxml {
-
+
class AudioToolbox : public PCMConverter {
public:
AudioToolbox(const std::string filename);
@@ -20,7 +20,7 @@ protected:
ExtAudioFileRef _afId;
AudioStreamBasicDescription _outputFormat;
AudioStreamBasicDescription _inputFormat;
-
+
ALenum formatToALEnum(AudioStreamBasicDescription);
bool alEnumToFormat(AudioStreamBasicDescription&, ALenum);
};
diff --git a/src/uscxml/plugins/invoker/audio/LibSoundFile.cpp b/src/uscxml/plugins/invoker/audio/LibSoundFile.cpp
index 1340140..26d3328 100644
--- a/src/uscxml/plugins/invoker/audio/LibSoundFile.cpp
+++ b/src/uscxml/plugins/invoker/audio/LibSoundFile.cpp
@@ -7,39 +7,39 @@ LibSoundFile::LibSoundFile(const std::string filename) : PCMConverter() {
_handle = SndfileHandle(_filename, SFM_READ, SF_FORMAT_PCM_16, 1, 44100);
_format.sampleRate = _handle.samplerate();
_format.alFormat = AL_FORMAT_MONO16;
-
+
}
LibSoundFile::~LibSoundFile() {
-
+
}
void LibSoundFile::seek(unsigned int pos) {
- _handle.seek(pos, 0);
+ _handle.seek(pos, 0);
}
int LibSoundFile::read(char* buffer, unsigned int size) {
- return _handle.readRaw(buffer, size);
+ return _handle.readRaw(buffer, size);
}
-
+
void LibSoundFile::setOutFormat(const PCMFormat& format) {
_format = format;
switch (_format.alFormat) {
- case AL_FORMAT_MONO8:
- _handle = SndfileHandle(_filename, SFM_READ, SF_FORMAT_PCM_S8, 1, _format.sampleRate);
- break;
- case AL_FORMAT_MONO16:
- _handle = SndfileHandle(_filename, SFM_READ, SF_FORMAT_PCM_16, 1, _format.sampleRate);
- break;
- case AL_FORMAT_STEREO8:
- _handle = SndfileHandle(_filename, SFM_READ, SF_FORMAT_PCM_S8, 2, _format.sampleRate);
- break;
- case AL_FORMAT_STEREO16:
- _handle = SndfileHandle(_filename, SFM_READ, SF_FORMAT_PCM_16, 2, _format.sampleRate);
- break;
-
- default:
- break;
+ case AL_FORMAT_MONO8:
+ _handle = SndfileHandle(_filename, SFM_READ, SF_FORMAT_PCM_S8, 1, _format.sampleRate);
+ break;
+ case AL_FORMAT_MONO16:
+ _handle = SndfileHandle(_filename, SFM_READ, SF_FORMAT_PCM_16, 1, _format.sampleRate);
+ break;
+ case AL_FORMAT_STEREO8:
+ _handle = SndfileHandle(_filename, SFM_READ, SF_FORMAT_PCM_S8, 2, _format.sampleRate);
+ break;
+ case AL_FORMAT_STEREO16:
+ _handle = SndfileHandle(_filename, SFM_READ, SF_FORMAT_PCM_16, 2, _format.sampleRate);
+ break;
+
+ default:
+ break;
}
}
diff --git a/src/uscxml/plugins/invoker/audio/LibSoundFile.h b/src/uscxml/plugins/invoker/audio/LibSoundFile.h
index 5491609..0d740f6 100644
--- a/src/uscxml/plugins/invoker/audio/LibSoundFile.h
+++ b/src/uscxml/plugins/invoker/audio/LibSoundFile.h
@@ -5,14 +5,14 @@
#include <sndfile.hh>
namespace uscxml {
-
+
class LibSoundFile : public PCMConverter {
public:
LibSoundFile(const std::string filename);
virtual ~LibSoundFile();
void seek(unsigned int pos);
int read(char* buffer, unsigned int size);
-
+
virtual void setOutFormat(const PCMFormat& format);
virtual PCMFormat getInFormat();
diff --git a/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp b/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp
index cf9d15a..6b52c8c 100644
--- a/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp
+++ b/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp
@@ -1,6 +1,6 @@
-// see http://stackoverflow.com/questions/6563810/m-pi-works-with-math-h-but-not-with-cmath-in-visual-studio
-#define _USE_MATH_DEFINES
-#include <cmath>
+// see http://stackoverflow.com/questions/6563810/m-pi-works-with-math-h-but-not-with-cmath-in-visual-studio
+#define _USE_MATH_DEFINES
+#include <cmath>
#include "OpenALInvoker.h"
#include <uscxml/config.h>
@@ -20,13 +20,12 @@ bool connect(pluma::Host& host) {
return true;
}
#endif
-
-// see http://stackoverflow.com/questions/1904635/warning-c4003-and-errors-c2589-and-c2059-on-x-stdnumeric-limitsintmax
+
+// see http://stackoverflow.com/questions/1904635/warning-c4003-and-errors-c2589-and-c2059-on-x-stdnumeric-limitsintmax
#undef max
OpenALInvoker::OpenALInvoker() {
_isStarted = false;
- _isRunning = false;
_alContext = NULL;
_alDevice = NULL;
_thread = NULL;
@@ -34,13 +33,14 @@ OpenALInvoker::OpenALInvoker() {
OpenALInvoker::~OpenALInvoker() {
if (_thread) {
- _isRunning = false;
+ _isStarted = false;
+ _sourcesAvailable.notify_all();
_thread->join();
delete(_thread);
}
if (_alContext) {
- alcCloseDevice(alcGetContextsDevice(_alContext));
- alcDestroyContext(_alContext);
+// alcCloseDevice(alcGetContextsDevice(_alContext));
+// alcDestroyContext(_alContext);
}
};
@@ -57,15 +57,15 @@ Data OpenALInvoker::getDataModelVariables() {
void OpenALInvoker::send(const SendRequest& req) {
tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
-
+
if (!_isStarted)
start();
-
+
if (boost::iequals(req.name, "play")) {
if (req.params.find("src") == req.params.end()) {
LOG(ERROR) << "Sent event play with no src URL";
}
-
+
URL srcURL = req.params.find("src")->second;
if (!srcURL.toAbsolute(_interpreter->getBaseURI())) {
LOG(ERROR) << "src URL " << req.params.find("src")->second << " is relative with no base URI set for interpreter";
@@ -87,12 +87,12 @@ void OpenALInvoker::send(const SendRequest& req) {
_sources.erase(req.sendid);
return;
}
-
+
// force mono format to ensure actual spatial audio
PCMFormat format = _sources[req.sendid]->transform->getInFormat();
format.alFormat = AL_FORMAT_MONO16;
_sources[req.sendid]->transform->setOutFormat(format);
-
+
try {
_sources[req.sendid]->player = new OpenALPlayer(_alContext, NULL, format.alFormat, format.sampleRate);
} catch (std::exception ex) {
@@ -108,10 +108,9 @@ void OpenALInvoker::send(const SendRequest& req) {
returnErrorExecution(ex.what());
}
-
_sourcesAvailable.notify_all();
}
-
+
if (boost::iequals(req.name, "move.source")) {
std::string sourceId;
if (req.params.find("source") == req.params.end()) {
@@ -119,12 +118,12 @@ void OpenALInvoker::send(const SendRequest& req) {
return;
}
sourceId = req.params.find("source")->second;
-
+
if (_sources.find(sourceId) == _sources.end()) {
LOG(WARNING) << "Given source '" << sourceId << "' not active or not existing";
return;
}
-
+
getPosFromParams(req.params, _sources[sourceId]->pos);
try {
_sources[sourceId]->player->setPosition(_sources[sourceId]->pos);
@@ -145,12 +144,16 @@ void OpenALInvoker::fillBuffers(void* userdata) {
// do nothing until we have at least one source
int waitMs = std::numeric_limits<int>::max();
INST->_mutex.lock();
- while (INST->_sources.size() == 0) {
+ while (INST->_sources.size() == 0 && INST->_isStarted) {
INST->_sourcesAvailable.wait(INST->_mutex);
}
+
+ if (!INST->_isStarted)
+ return;
+
// here we are with at least one source and a locked mutex
assert(INST->_sources.size() > 0);
-
+
std::map<std::string, OpenALSource*>::iterator srcIter = INST->_sources.begin();
while(srcIter != INST->_sources.end()) {
OpenALSource* src = srcIter->second;
@@ -195,7 +198,7 @@ void OpenALInvoker::fillBuffers(void* userdata) {
}
}
}
-
+
// there are unwritten samples in the buffer
if (src->read != src->written) {
try {
@@ -211,15 +214,16 @@ void OpenALInvoker::fillBuffers(void* userdata) {
assert(src->finished);
}
}
-
+
waitMs = (wait < waitMs ? wait : waitMs);
srcIter++;
}
-
+
// std::cout << "W" << waitMs << ".";
-
+
INST->_mutex.unlock();
- tthread::this_thread::sleep_for(tthread::chrono::milliseconds(waitMs));
+ if (waitMs < std::numeric_limits<int>::max())
+ tthread::this_thread::sleep_for(tthread::chrono::milliseconds(waitMs));
}
}
@@ -233,14 +237,17 @@ void OpenALInvoker::invoke(const InvokeRequest& req) {
if (_alDevice == NULL) {
throw std::string("__FILE__ __LINE__ openal error opening device");
}
-
+
// create new context with device
_alContext = alcCreateContext (_alDevice, NULL);
if (_alContext == NULL) {
alcCloseDevice (_alDevice);
throw std::string("openal error create context");
}
-
+
+ std::cout << boost::lexical_cast<std::string>(_alContext);
+ std::cout << boost::lexical_cast<std::string>(_alDevice);
+
// alcMakeContextCurrent(_alContext);
// float listener[3] = {0,0,0};
// alListenerfv(AL_POSITION, listener);
@@ -257,7 +264,7 @@ void OpenALInvoker::invoke(const InvokeRequest& req) {
start();
}
-
+
void OpenALInvoker::notifyOfEnd(OpenALSource* src) {
Event ev;
ev.name = "audio.end";
@@ -284,7 +291,7 @@ void OpenALInvoker::getPosFromParams(const std::multimap<std::string, std::strin
} catch (boost::bad_lexical_cast& e) {
LOG(ERROR) << "Cannot interpret x, y or z as float value in params: " << e.what();
}
-
+
try {
// right is an alias for x
if (params.find("right") != params.end())
@@ -298,7 +305,7 @@ void OpenALInvoker::getPosFromParams(const std::multimap<std::string, std::strin
} catch (boost::bad_lexical_cast& e) {
LOG(ERROR) << "Cannot interpret right, height or front as float value in params: " << e.what();
}
-
+
// do we have a position on a circle?
try {
if (params.find("circle") != params.end()) {
@@ -307,24 +314,24 @@ void OpenALInvoker::getPosFromParams(const std::multimap<std::string, std::strin
position[2] = -1 * sinf(rad); // z axis increases to front
position[0] *= 150;
position[2] *= 150;
-
+
}
} catch (boost::bad_lexical_cast& e) {
LOG(ERROR) << "Cannot interpret circle as float value in params: " << e.what();
}
-
+
// position[0] = position[0] / _maxPos[0];
// position[1] = position[1] / _maxPos[1];
// position[2] = position[2] / _maxPos[2];
// std::cout << _pos[0] << ":" << _pos[1] << ":" << _pos[2] << std::endl;
-
+
}
float OpenALInvoker::posToRadian(const std::string& pos) {
-
+
std::string trimmedPos = boost::trim_copy(pos);
float rad = 0;
-
+
if (trimmedPos.size() > 3 && boost::iequals("deg", trimmedPos.substr(trimmedPos.length() - 3, 3))) {
rad = boost::lexical_cast<float>(trimmedPos.substr(0, trimmedPos.size() - 3));
rad = fmodf(rad, 360); // into range [0-360]
diff --git a/src/uscxml/plugins/invoker/audio/OpenALInvoker.h b/src/uscxml/plugins/invoker/audio/OpenALInvoker.h
index c0ed842..086bfe8 100644
--- a/src/uscxml/plugins/invoker/audio/OpenALInvoker.h
+++ b/src/uscxml/plugins/invoker/audio/OpenALInvoker.h
@@ -24,7 +24,7 @@ class OpenALSource {
public:
OpenALSource();
~OpenALSource();
-
+
OpenALPlayer* player;
char buffer[ALPLAY_AUDIO_BUFFER_SIZE];
bool loop;
@@ -35,7 +35,7 @@ public:
URL file;
PCMConverter* transform;
};
-
+
class OpenALInvoker : public InvokerImpl {
public:
OpenALInvoker();
@@ -49,7 +49,7 @@ public:
names.insert("http://uscxml.tk.informatik.tu-darmstadt.de/#openal");
return names;
}
-
+
virtual Data getDataModelVariables();
virtual void send(const SendRequest& req);
virtual void cancel(const std::string sendId);
@@ -59,20 +59,20 @@ protected:
std::map<std::string, OpenALSource*> _sources;
ALCcontext* _alContext;
ALCdevice* _alDevice;
-
+
tthread::recursive_mutex _mutex;
tthread::thread* _thread;
tthread::condition_variable _sourcesAvailable;
bool _isStarted;
bool _isRunning;
-
+
static void fillBuffers(void* userdata);
void start();
void notifyOfEnd(OpenALSource*);
void notifyOfLoop(OpenALSource*);
-
+
float posToRadian(const std::string& pos);
void getPosFromParams(const std::multimap<std::string, std::string>& params, float* position);
diff --git a/src/uscxml/plugins/invoker/audio/OpenALPlayer.cpp b/src/uscxml/plugins/invoker/audio/OpenALPlayer.cpp
index 4266f79..a5f90b8 100644
--- a/src/uscxml/plugins/invoker/audio/OpenALPlayer.cpp
+++ b/src/uscxml/plugins/invoker/audio/OpenALPlayer.cpp
@@ -17,11 +17,11 @@ OpenALPlayer::OpenALPlayer(ALCcontext* context, OpenALPlayerCallback* audioCallb
_nrBuffers = 0;
_thread = NULL;
_alId = 0;
-
+
_position[0] = _position[1] = _position[2] = 0;
_velocity[0] = _velocity[1] = _velocity[2] = 0;
_direction[0] = _direction[1] = _direction[2] = 0;
-
+
tthread::lock_guard<tthread::recursive_mutex> lock(_alMutex);
if (context == NULL) {
// this is in essence alutInit() from freealut.
@@ -143,7 +143,7 @@ void OpenALPlayer::init() {
// get available buffer ids
tthread::lock_guard<tthread::recursive_mutex> lock(_alMutex);
-
+
if (!alcMakeContextCurrent (_context)) {
throw std::runtime_error("openal error make context current");
}
@@ -153,7 +153,7 @@ void OpenALPlayer::init() {
// get new source id from openAL
alGenSources(1, &_alId);
-
+
checkOpenALError(__LINE__);
if (!alIsSource(_alId)) {
throw std::runtime_error("openal source id not valid");
@@ -254,7 +254,7 @@ int OpenALPlayer::write(char* buffer, int size, int* repollAt, bool blocking) {
if (!alcMakeContextCurrent (_context)) {
throw std::runtime_error("openal error make context current");
}
-
+
// try to enqueue the given buffer data
for (;;) {
// do we have an empty buffer in the OpenAL queue?
@@ -264,7 +264,7 @@ int OpenALPlayer::write(char* buffer, int size, int* repollAt, bool blocking) {
// if (!isPlaying())
// std::cout << "-";
-
+
if (processed > 0) {
// std::cout << "P" << processed;
ALuint bufferId = 0;
@@ -308,7 +308,7 @@ int OpenALPlayer::write(char* buffer, int size, int* repollAt, bool blocking) {
// there was a free buffer, repoll immediately to try to write more
if (repollAt)
*repollAt = 0;
-
+
break;
} else {
// std::cout << "X";
@@ -330,7 +330,7 @@ int OpenALPlayer::write(char* buffer, int size, int* repollAt, bool blocking) {
checkOpenALError(__LINE__);
_isStarted = true;
}
-
+
return size;
}
diff --git a/src/uscxml/plugins/invoker/audio/PCMConverter.h b/src/uscxml/plugins/invoker/audio/PCMConverter.h
index 6036af2..df367f8 100644
--- a/src/uscxml/plugins/invoker/audio/PCMConverter.h
+++ b/src/uscxml/plugins/invoker/audio/PCMConverter.h
@@ -18,7 +18,7 @@ public:
virtual ~PCMConverter() {}
virtual void seek(unsigned int pos) = 0;
virtual int read(char* buffer, unsigned int size) = 0;
-
+
virtual void setOutFormat(const PCMFormat& format) = 0;
virtual PCMFormat getInFormat() = 0;
protected:
diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp
index 5900cc8..0f6b776 100644
--- a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp
+++ b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp
@@ -28,13 +28,18 @@ DirMonInvoker::DirMonInvoker() :
_reportExisting(true),
_reportHidden(false),
_recurse(false),
- _thread(NULL) {
+ _thread(NULL),
+ _watcher(NULL) {
}
DirMonInvoker::~DirMonInvoker() {
_isRunning = false;
- if (_thread)
+ if (_thread) {
_thread->join();
+ delete _thread;
+ }
+ if (_watcher)
+ delete(_watcher);
};
boost::shared_ptr<InvokerImpl> DirMonInvoker::create(InterpreterImpl* interpreter) {
@@ -218,6 +223,15 @@ void DirMonInvoker::handleChanges(DirectoryWatch::Action action, const std::stri
returnEvent(event);
}
+DirectoryWatch::~DirectoryWatch() {
+ std::map<std::string, DirectoryWatch*>::iterator dirIter = _knownDirs.begin();
+ while(dirIter != _knownDirs.end()) {
+ delete(dirIter->second);
+ dirIter++;
+ }
+
+}
+
void DirectoryWatch::reportAsDeleted() {
std::map<std::string, struct stat>::iterator fileIter = _knownEntries.begin();
while(fileIter != _knownEntries.end()) {
diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.h b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.h
index 611106b..59eee81 100644
--- a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.h
+++ b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.h
@@ -1,6 +1,7 @@
#ifndef DIRMONINVOKER_H_W09J90F0
#define DIRMONINVOKER_H_W09J90F0
+#include <uscxml/config.h>
#include <uscxml/Interpreter.h>
#include <map>
#include <sys/stat.h>
@@ -23,6 +24,7 @@ public:
};
DirectoryWatch(const std::string& dir, bool recurse = false) : _dir(dir), _recurse(recurse), _lastChecked(0) {}
+ ~DirectoryWatch();
void addMonitor(DirectoryWatchMonitor* monitor) {
_monitors.insert(monitor);
@@ -33,6 +35,24 @@ public:
void updateEntries(bool reportAsExisting = false);
void reportAsDeleted();
+ std::map<std::string, struct stat> getAllEntries() {
+ std::map<std::string, struct stat> entries;
+ entries.insert(_knownEntries.begin(), _knownEntries.end());
+
+ std::map<std::string, DirectoryWatch*>::iterator dirIter = _knownDirs.begin();
+ while(dirIter != _knownDirs.end()) {
+ std::map<std::string, struct stat> dirEntries = dirIter->second->getAllEntries();
+ std::map<std::string, struct stat>::iterator dirEntryIter = dirEntries.begin();
+ while(dirEntryIter != dirEntries.end()) {
+ entries[dirIter->first + PATH_SEPERATOR + dirEntryIter->first] = dirEntryIter->second;
+ dirEntryIter++;
+ }
+ dirIter++;
+ }
+
+ return entries;
+ }
+
protected:
DirectoryWatch(const std::string& dir, const std::string& relDir) : _dir(dir), _relDir(relDir), _recurse(true), _lastChecked(0) {}
diff --git a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp
index bbfdabd..a70be38 100644
--- a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp
+++ b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp
@@ -21,14 +21,14 @@ UmundoInvoker::UmundoInvoker() : _pub(NULL), _sub(NULL) {
UmundoInvoker::~UmundoInvoker() {
if (_node) {
- if (_sub) {
- _node->removeSubscriber(*_sub);
- delete _sub;
- }
- if (_pub) {
- _node->removePublisher(*_pub);
- delete _pub;
- }
+// if (_sub) {
+// _node->removeSubscriber(*_sub);
+// delete _sub;
+// }
+// if (_pub) {
+// _node->removePublisher(*_pub);
+// delete _pub;
+// }
}
};
diff --git a/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp b/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp
index b2a6824..a612ee6 100644
--- a/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp
+++ b/src/uscxml/plugins/ioprocessor/basichttp/BasicHTTPIOProcessor.cpp
@@ -80,8 +80,14 @@ bool BasicHTTPIOProcessor::httpRecvRequest(const HTTPServer::Request& req) {
while(std::getline(ss, term, '&')) {
size_t split = term.find_first_of("=");
if (split != std::string::npos) {
- std::string key = evhttp_decode_uri(term.substr(0, split).c_str());
- std::string value = evhttp_decode_uri(term.substr(split + 1).c_str());
+
+ char* keyCStr = evhttp_decode_uri(term.substr(0, split).c_str());
+ char* valueCStr = evhttp_decode_uri(term.substr(split + 1).c_str());
+ std::string key = keyCStr;
+ std::string value = valueCStr;
+ free(keyCStr);
+ free(valueCStr);
+
if (boost::iequals(key, "_scxmleventname")) {
reqEvent.name = value;
} else if (boost::iequals(key, "content")) {
@@ -92,22 +98,30 @@ bool BasicHTTPIOProcessor::httpRecvRequest(const HTTPServer::Request& req) {
}
} else {
// this is most likely wrong
- reqEvent.content = evhttp_decode_uri(term.c_str());
+ char* contentCStr = evhttp_decode_uri(term.c_str());
+ reqEvent.content = contentCStr;
+ free(contentCStr);
}
}
} else {
if (reqEvent.data.compound["header"].compound.find("_scxmleventstruct") != reqEvent.data.compound["header"].compound.end()) {
// TODO: this looses all other information
- reqEvent = Event::fromXML(evhttp_decode_uri(reqEvent.data.compound["header"].compound["_scxmleventstruct"].atom.c_str()));
+ char* scxmlStructCStr = evhttp_decode_uri(reqEvent.data.compound["header"].compound["_scxmleventstruct"].atom.c_str());
+ reqEvent = Event::fromXML(scxmlStructCStr);
+ free(scxmlStructCStr);
scxmlStructFound = true;
}
if (reqEvent.data.compound["header"].compound.find("_scxmleventname") != reqEvent.data.compound["header"].compound.end()) {
- reqEvent.name = evhttp_decode_uri(reqEvent.data.compound["header"].compound["_scxmleventname"].atom.c_str());
+ char* evNameCStr = evhttp_decode_uri(reqEvent.data.compound["header"].compound["_scxmleventname"].atom.c_str());
+ reqEvent.name = evNameCStr;
+ free(evNameCStr);
}
}
std::map<std::string, Data>::iterator headerIter = reqEvent.data.compound["header"].compound.begin();
while(headerIter != reqEvent.data.compound["header"].compound.end()) {
- reqEvent.data.compound[headerIter->first] = Data(evhttp_decode_uri(headerIter->second.atom.c_str()), Data::VERBATIM);
+ char* headerCStr = evhttp_decode_uri(headerIter->second.atom.c_str());
+ reqEvent.data.compound[headerIter->first] = Data(headerCStr, Data::VERBATIM);
+ free(headerCStr);
headerIter++;
}
@@ -162,8 +176,12 @@ void BasicHTTPIOProcessor::send(const SendRequest& req) {
// event name
if (req.name.size() > 0) {
- kvps << kvpSeperator << evhttp_encode_uri("_scxmleventname") << "=" << evhttp_encode_uri(req.name.c_str());
+ char* eventNameCStr = evhttp_encode_uri("_scxmleventname");
+ char* eventValueCStr = evhttp_encode_uri(req.name.c_str());
+ kvps << kvpSeperator << eventNameCStr << "=" << eventValueCStr;
kvpSeperator = "&";
+ free(eventNameCStr);
+ free(eventValueCStr);
// targetURL.addOutHeader("_scxmleventname", evhttp_encode_uri(req.name.c_str()));
}
@@ -171,7 +189,11 @@ void BasicHTTPIOProcessor::send(const SendRequest& req) {
if (req.namelist.size() > 0) {
std::map<std::string, std::string>::const_iterator namelistIter = req.namelist.begin();
while (namelistIter != req.namelist.end()) {
- kvps << kvpSeperator << evhttp_encode_uri(namelistIter->first.c_str()) << "=" << evhttp_encode_uri(namelistIter->second.c_str());
+ char* keyCStr = evhttp_encode_uri(namelistIter->first.c_str());
+ char* valueCStr = evhttp_encode_uri(namelistIter->second.c_str());
+ kvps << kvpSeperator << keyCStr << "=" << valueCStr;
+ free(keyCStr);
+ free(valueCStr);
kvpSeperator = "&";
// targetURL.addOutHeader(namelistIter->first, namelistIter->second);
namelistIter++;
@@ -182,7 +204,11 @@ void BasicHTTPIOProcessor::send(const SendRequest& req) {
if (req.params.size() > 0) {
std::multimap<std::string, std::string>::const_iterator paramIter = req.params.begin();
while (paramIter != req.params.end()) {
- kvps << kvpSeperator << evhttp_encode_uri(paramIter->first.c_str()) << "=" << evhttp_encode_uri(paramIter->second.c_str());
+ char* keyCStr = evhttp_encode_uri(paramIter->first.c_str());
+ char* valueCStr = evhttp_encode_uri(paramIter->second.c_str());
+ kvps << kvpSeperator << keyCStr << "=" << valueCStr;
+ free(keyCStr);
+ free(valueCStr);
kvpSeperator = "&";
// targetURL.addOutHeader(paramIter->first, paramIter->second);
paramIter++;
@@ -192,13 +218,21 @@ void BasicHTTPIOProcessor::send(const SendRequest& req) {
// content
if (req.content.size() > 0) {
- kvps << kvpSeperator << evhttp_encode_uri("content") << "=" << evhttp_encode_uri(req.content.c_str());
+ char* keyCStr = evhttp_encode_uri("content");
+ char* valueCStr = evhttp_encode_uri(req.content.c_str());
+ kvps << kvpSeperator << keyCStr << "=" << valueCStr;
+ free(keyCStr);
+ free(valueCStr);
kvpSeperator = "&";
}
if (req.dom) {
std::stringstream xmlStream;
xmlStream << req.dom;
- kvps << kvpSeperator << evhttp_encode_uri("content") << "=" << evhttp_encode_uri(xmlStream.str().c_str());
+ char* keyCStr = evhttp_encode_uri("content");
+ char* valueCStr = evhttp_encode_uri(xmlStream.str().c_str());
+ kvps << kvpSeperator << keyCStr << "=" << valueCStr;
+ free(keyCStr);
+ free(valueCStr);
kvpSeperator = "&";
}
targetURL.setOutContent(kvps.str());
diff --git a/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp b/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp
index 288bfb7..98d98e1 100644
--- a/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp
+++ b/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp
@@ -138,6 +138,9 @@ void SCXMLIOProcessor::send(const SendRequest& req) {
tthread::lock_guard<tthread::recursive_mutex> lock(_interpreter->_mutex);
try {
_interpreter->_invokers[invokeId].send(reqCopy);
+ } catch(Event e) {
+ // Is this the right thing to do?
+ _interpreter->receive(e);
} catch(...) {
LOG(ERROR) << "Exception caught while sending event to invoker " << invokeId;
}