diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-08-21 15:16:52 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-08-21 15:16:52 (GMT) |
commit | bd45c688b3d3aad5d62b85457ce943eaadf989ae (patch) | |
tree | 831d54da85c85f3e998be70241f8ffc3fed7f924 /src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore | |
parent | a52fb3364968e31a1a15c85ac45b68d9f531687b (diff) | |
download | uscxml-bd45c688b3d3aad5d62b85457ce943eaadf989ae.zip uscxml-bd45c688b3d3aad5d62b85457ce943eaadf989ae.tar.gz uscxml-bd45c688b3d3aad5d62b85457ce943eaadf989ae.tar.bz2 |
Added WebStorage object to document
Some refinements to DotWriter
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore')
31 files changed, 286 insertions, 320 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.cpp index 1b5aaef..f2c3a8e 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.cpp @@ -5,11 +5,14 @@ namespace DOM { JSCDOM::JSCDOM() { xpath = NULL; + storage = NULL; } JSCDOM::~JSCDOM() { if (xpath) delete(xpath); + if (storage) + delete(storage); } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h index bffeab8..e88851e 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h @@ -4,6 +4,7 @@ #include "uscxml/Interpreter.h" #include <JavaScriptCore/JavaScriptCore.h> #include <XPath/XPath.hpp> +#include "../Storage.h" #define JSC_DESTRUCTOR(type) \ static void jsDestructor(JSObjectRef object) { \ @@ -28,7 +29,7 @@ class JSCDOM { public: JSCDOM(); virtual ~JSCDOM(); - + uscxml::Storage* storage; Arabica::XPath::XPath<std::string>* xpath; }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp index 7f6a9e7..712799c 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp @@ -1,6 +1,7 @@ #include "uscxml/Common.h" +#include "uscxml/config.h" #include "JSCDataModel.h" -#include "dom/JSCDOM.h" +#include "JSCDOM.h" #include "dom/JSCDocument.h" #include "dom/JSCSCXMLEvent.h" @@ -77,6 +78,7 @@ boost::shared_ptr<DataModelImpl> JSCDataModel::create(InterpreterImpl* interpret dm->_dom = new JSCDOM(); dm->_dom->xpath = new XPath<std::string>(); dm->_dom->xpath->setNamespaceContext(interpreter->getNSContext()); + dm->_dom->storage = new Storage(URL::getResourceDir() + PATH_SEPERATOR + interpreter->getName() + ".storage"); // introduce global functions as objects for private data JSClassRef jsInClassRef = JSClassCreate(&jsInClassDef); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h index c5e9587..f7360d4 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h @@ -4,7 +4,7 @@ #include "uscxml/Interpreter.h" #include <list> #include <JavaScriptCore/JavaScriptCore.h> -#include "dom/JSCDOM.h" +#include "JSCDOM.h" #ifdef BUILD_AS_PLUGINS #include "uscxml/plugins/Plugins.h" diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h index 01628a6..3e98cab 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h @@ -25,7 +25,7 @@ #include "DOM/Node.hpp" #include "JSCNode.h" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h index 9fe225b..f0ec864 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h @@ -25,7 +25,7 @@ #include "DOM/Node.hpp" #include "JSCText.h" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h index 0bdca74..1155a0a 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h @@ -25,7 +25,7 @@ #include "DOM/Node.hpp" #include "JSCNode.h" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h index 7c4e96f..63bf840 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h @@ -25,7 +25,7 @@ #include "DOM/Node.hpp" #include "JSCCharacterData.h" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.h index 551c2fe..9169604 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.h @@ -24,7 +24,7 @@ #include <string> #include "DOM/Node.hpp" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp index 4fae6c9..a7f170f 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp @@ -21,6 +21,7 @@ JSStaticValue JSCDocument::staticValues[] = { { "doctype", doctypeAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, { "implementation", implementationAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, { "documentElement", documentElementAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "localStorage", localStorageCustomAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, { 0, 0, 0, 0 } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h index 6657f3b..7663d98 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h @@ -25,7 +25,7 @@ #include "DOM/Node.hpp" #include "JSCNode.h" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { @@ -58,6 +58,7 @@ public: static JSValueRef doctypeAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); static JSValueRef implementationAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); static JSValueRef documentElementAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef localStorageCustomAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); static JSStaticValue staticValues[]; diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp index c6fdce1..52d6a88 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentCustom.cpp @@ -1,4 +1,5 @@ #include "JSCDocument.h" +#include "JSCStorage.h" #include "JSCXPathResult.h" #include "JSCNode.h" #include <XPath/XPath.hpp> @@ -6,6 +7,23 @@ namespace Arabica { namespace DOM { +JSValueRef JSCDocument::localStorageCustomAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) { + struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(object); + + if (!privData->dom->storage) { + return JSValueMakeUndefined(ctx); + } + + JSClassRef retClass = JSCStorage::getTmpl(); + struct JSCStorage::JSCStoragePrivate* retPrivData = new JSCStorage::JSCStoragePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retPrivData->dom->storage; + + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, retClass, retPrivData); + return arbaicaRetObj; + +} + JSValueRef JSCDocument::evaluateCustomCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef object, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(object); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h index 3a9d8d6..fbe47e9 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h @@ -25,7 +25,7 @@ #include "DOM/Node.hpp" #include "JSCNode.h" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h index 3dc46f4..635f78d 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h @@ -25,7 +25,7 @@ #include "DOM/Node.hpp" #include "JSCNode.h" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h index 9520a8b..43df02d 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h @@ -25,7 +25,7 @@ #include "DOM/Node.hpp" #include "JSCNode.h" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h index 69f54a3..b952750 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h @@ -25,7 +25,7 @@ #include "DOM/Node.hpp" #include "JSCNode.h" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h index 428274f..2dddf57 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h @@ -25,7 +25,7 @@ #include "DOM/Node.hpp" #include "JSCNode.h" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.h index c82bfdd..251ab72 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.h @@ -24,7 +24,7 @@ #include <string> #include "DOM/Node.hpp" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp.old b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp.old deleted file mode 100644 index 7d38f9f..0000000 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp.old +++ /dev/null @@ -1,60 +0,0 @@ -#include "JSCNode.h" -#include <DOM/Node.hpp> - -namespace uscxml { - -using namespace Arabica::DOM; - -JSStaticValue JSCNode::staticValues[] = { - { "nodeName", nodeNameAttrGetter, nodeValueAttrSetter, kJSPropertyAttributeDontDelete }, - { "nodeValue", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "nodeType", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "parentNode", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "childNodes", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "firstChild", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "lastChild", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "previousSibling", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "nextSibling", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "attributes", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "ownerDocument", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "namespaceURI", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "prefix", nodeValueAttrGetter, prefixAttrSetter, kJSPropertyAttributeDontDelete }, - { "localName", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "baseURI", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "textContent", nodeValueAttrGetter, textContentAttrSetter, kJSPropertyAttributeDontDelete }, - { "parentElement", nodeValueAttrGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "ELEMENT_NODE", ELEMENT_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "ATTRIBUTE_NODE", ATTRIBUTE_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "TEXT_NODE", TEXT_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "CDATA_SECTION_NODE", CDATA_SECTION_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "ENTITY_REFERENCE_NODE", ENTITY_REFERENCE_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "ENTITY_NODE", ENTITY_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "PROCESSING_INSTRUCTION_NODE", PROCESSING_INSTRUCTION_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "COMMENT_NODE", COMMENT_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "DOCUMENT_NODE", DOCUMENT_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "DOCUMENT_TYPE_NODE", DOCUMENT_TYPE_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "DOCUMENT_FRAGMENT_NODE", DOCUMENT_FRAGMENT_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "NOTATION_NODE", NOTATION_NODEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { "MAX_TYPE", MAX_TYPEConstGetter, NULL, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, - { 0, 0, 0, 0 } -}; - -JSStaticFunction JSCNode::staticFunctions[] = { - { "insertBefore", insertBeforeCallback, kJSPropertyAttributeDontDelete }, - { "replaceChild", replaceChildCallback, kJSPropertyAttributeDontDelete }, - { "removeChild", removeChildCallback, kJSPropertyAttributeDontDelete }, - { "appendChild", appendChildCallback, kJSPropertyAttributeDontDelete }, - { "hasChildNodes", hasChildNodesCallback, kJSPropertyAttributeDontDelete }, - { "cloneNode", cloneNodeCallback, kJSPropertyAttributeDontDelete }, - { "normalize", normalizeCallback, kJSPropertyAttributeDontDelete }, - { "isSupported", isSupportedCallback, kJSPropertyAttributeDontDelete }, - { "hasAttributes", hasAttributesCallback, kJSPropertyAttributeDontDelete }, - { "lookupPrefix", lookupPrefixCallback, kJSPropertyAttributeDontDelete }, - { "isDefaultNamespace", isDefaultNamespaceCallback, kJSPropertyAttributeDontDelete }, - { "lookupNamespaceURI", lookupNamespaceURICallback, kJSPropertyAttributeDontDelete }, - { "addEventListener", addEventListenerCallback, kJSPropertyAttributeDontDelete }, - { "removeEventListener", removeEventListenerCallback, kJSPropertyAttributeDontDelete }, - { 0, 0, 0 } -}; - -}
\ No newline at end of file diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h index d833ecb..9849d72 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h @@ -24,7 +24,7 @@ #include <string> #include "DOM/Node.hpp" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h.old b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h.old deleted file mode 100644 index 677a63b..0000000 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h.old +++ /dev/null @@ -1,223 +0,0 @@ -#ifndef JSCNODE_H_6BAK1S3C -#define JSCNODE_H_6BAK1S3C - -#include "JSCDOM.h" - -namespace uscxml { - -class JSCNode { -public: - static JSValueRef nodeNameAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef nodeValueAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef nodeTypeAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef parentNodeAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef childNodesAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef firstChildAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef lastChildAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef previousSiblingAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef nextSiblingAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef attributesAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef ownerDocumentAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef namespaceURIAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef prefixAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef localNameAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef baseURIAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef textContentAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef parentElementAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - - static bool nodeValueAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { - return false; - } - static bool prefixAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { - return false; - } - static bool textContentAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { - return false; - } - - static JSValueRef insertBeforeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef replaceChildCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef removeChildCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef appendChildCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef hasChildNodesCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef cloneNodeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef normalizeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef isSupportedCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef hasAttributesCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef lookupPrefixCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef isDefaultNamespaceCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef lookupNamespaceURICallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef addEventListenerCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - static JSValueRef removeEventListenerCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - assert(false); - return JSValueMakeUndefined(ctx); - } - - static JSValueRef ELEMENT_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::ELEMENT_NODE); - } - static JSValueRef ATTRIBUTE_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::ATTRIBUTE_NODE); - } - static JSValueRef TEXT_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::TEXT_NODE); - } - static JSValueRef CDATA_SECTION_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::CDATA_SECTION_NODE); - } - static JSValueRef ENTITY_REFERENCE_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::ENTITY_REFERENCE_NODE); - } - static JSValueRef ENTITY_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::ENTITY_NODE); - } - static JSValueRef PROCESSING_INSTRUCTION_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::PROCESSING_INSTRUCTION_NODE); - } - static JSValueRef COMMENT_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::COMMENT_NODE); - } - static JSValueRef DOCUMENT_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::DOCUMENT_NODE); - } - static JSValueRef DOCUMENT_TYPE_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::DOCUMENT_TYPE_NODE); - } - static JSValueRef DOCUMENT_FRAGMENT_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::DOCUMENT_FRAGMENT_NODE); - } - static JSValueRef NOTATION_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::NOTATION_NODE); - } - static JSValueRef MAX_TYPEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - assert(false); - return JSValueMakeNumber(ctx, Arabica::DOM::Node_base::MAX_TYPE); - } - - JSC_DESTRUCTOR(Arabica::DOM::Node<std::string>); - - static JSStaticValue staticValues[]; - static JSStaticFunction staticFunctions[]; - - static JSClassRef Tmpl; - static JSClassRef getTmpl() { - if (Tmpl == NULL) { - JSClassDefinition classDef = kJSClassDefinitionEmpty; - classDef.staticValues = staticValues; - classDef.staticFunctions = staticFunctions; - classDef.finalize = jsDestructor; - - Tmpl = JSClassCreate(&classDef); - JSClassRetain(Tmpl); - } - return Tmpl; - } - -}; - -} - - -#endif /* end of include guard: JSCNODE_H_6BAK1S3C */ diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeCustom.cpp index 82965ad..159ff56 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeCustom.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeCustom.cpp @@ -5,28 +5,23 @@ namespace Arabica { namespace DOM { JSValueRef JSCNode::attributesCustomAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { -#if 0 - v8::Local<v8::Object> self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr<V8NodePrivate >(self->GetInternalField(0)); + + struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(thisObj); if (!privData->nativeObj->hasAttributes()) { - return v8::Undefined(); + return JSValueMakeUndefined(ctx); } - Arabica::DOM::NamedNodeMap<std::string>* arbaicaRet = new Arabica::DOM::NamedNodeMap<std::string>(privData->nativeObj->getAttributes()); - - v8::Handle<v8::Function> arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance()); + Arabica::DOM::NamedNodeMap<std::string>* retVal = new Arabica::DOM::NamedNodeMap<std::string>(privData->nativeObj->getAttributes()); + JSClassRef retClass = JSCNamedNodeMap::getTmpl(); - struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate(); + struct JSCNamedNodeMap::JSCNamedNodeMapPrivate* retPrivData = new JSCNamedNodeMap::JSCNamedNodeMapPrivate(); retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + retPrivData->nativeObj = retVal; - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor); - return arbaicaRetObj; + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); -#endif + return retObj; } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h index fca81b8..feb9be5 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h @@ -24,7 +24,7 @@ #include <string> #include "DOM/Node.hpp" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h index b38d04e..5db3af8 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h @@ -24,7 +24,7 @@ #include <string> #include "DOM/Node.hpp" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h index bb84c50..b043d14 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h @@ -25,7 +25,7 @@ #include "DOM/Node.hpp" #include "JSCNode.h" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h index fc8c44b..4ebdefb 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h @@ -25,7 +25,7 @@ #include "DOM/Node.hpp" #include "JSCNode.h" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEvent.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEvent.h index 8e00401..d3a25d5 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEvent.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEvent.h @@ -24,7 +24,7 @@ #include <string> #include "DOM/Node.hpp" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.cpp new file mode 100644 index 0000000..f3c709b --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.cpp @@ -0,0 +1,155 @@ +#include "JSCStorage.h" + +namespace Arabica { +namespace DOM { + +JSClassRef JSCStorage::Tmpl; + +JSStaticValue JSCStorage::staticValues[] = { + { "length", lengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCStorage::staticFunctions[] = { + { "key", keyCallback, kJSPropertyAttributeDontDelete }, + { "getItem", getItemCallback, kJSPropertyAttributeDontDelete }, + { "setItem", setItemCallback, kJSPropertyAttributeDontDelete }, + { "removeItem", removeItemCallback, kJSPropertyAttributeDontDelete }, + { "clear", clearCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCStorage::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { + struct JSCStoragePrivate* privData = (struct JSCStoragePrivate*)JSObjectGetPrivate(object); + + return JSValueMakeNumber(ctx, privData->nativeObj->getLength()); +} + +JSValueRef JSCStorage::keyCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 1) { + std::string errorMsg = "Wrong number of arguments in key"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCStoragePrivate* privData = (struct JSCStoragePrivate*)JSObjectGetPrivate(thisObj); + + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + + std::string retVal = privData->nativeObj->key(localIndex); + + JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); + JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); + JSStringRelease(jscString); + return jscRetVal; +} + +JSValueRef JSCStorage::getItemCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 1) { + std::string errorMsg = "Wrong number of arguments in getItem"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCStoragePrivate* privData = (struct JSCStoragePrivate*)JSObjectGetPrivate(thisObj); + + JSStringRef stringReflocalKey = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localKeyMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalKey); + char* localKeyBuffer = new char[localKeyMaxSize]; + JSStringGetUTF8CString(stringReflocalKey, localKeyBuffer, localKeyMaxSize); + std::string localKey(localKeyBuffer); + JSStringRelease(stringReflocalKey); + free(localKeyBuffer); + + + std::string retVal = privData->nativeObj->getItem(localKey); + + JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); + JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); + JSStringRelease(jscString); + return jscRetVal; +} + +JSValueRef JSCStorage::setItemCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 2) { + std::string errorMsg = "Wrong number of arguments in setItem"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCStoragePrivate* privData = (struct JSCStoragePrivate*)JSObjectGetPrivate(thisObj); + + JSStringRef stringReflocalKey = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localKeyMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalKey); + char* localKeyBuffer = new char[localKeyMaxSize]; + JSStringGetUTF8CString(stringReflocalKey, localKeyBuffer, localKeyMaxSize); + std::string localKey(localKeyBuffer); + JSStringRelease(stringReflocalKey); + free(localKeyBuffer); + + JSStringRef stringReflocalValue = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localValueMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalValue); + char* localValueBuffer = new char[localValueMaxSize]; + JSStringGetUTF8CString(stringReflocalValue, localValueBuffer, localValueMaxSize); + std::string localValue(localValueBuffer); + JSStringRelease(stringReflocalValue); + free(localValueBuffer); + + + privData->nativeObj->setItem(localKey, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCStorage::removeItemCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + if (argumentCount < 1) { + std::string errorMsg = "Wrong number of arguments in removeItem"; + JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); + JSValueRef exceptionString =JSValueMakeString(ctx, string); + JSStringRelease(string); + *exception = JSValueToObject(ctx, exceptionString, NULL); + return NULL; + } + + struct JSCStoragePrivate* privData = (struct JSCStoragePrivate*)JSObjectGetPrivate(thisObj); + + JSStringRef stringReflocalKey = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localKeyMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalKey); + char* localKeyBuffer = new char[localKeyMaxSize]; + JSStringGetUTF8CString(stringReflocalKey, localKeyBuffer, localKeyMaxSize); + std::string localKey(localKeyBuffer); + JSStringRelease(stringReflocalKey); + free(localKeyBuffer); + + + privData->nativeObj->removeItem(localKey); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + +JSValueRef JSCStorage::clearCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + + struct JSCStoragePrivate* privData = (struct JSCStoragePrivate*)JSObjectGetPrivate(thisObj); + + + privData->nativeObj->clear(); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; +} + + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.h new file mode 100644 index 0000000..afb9714 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.h @@ -0,0 +1,73 @@ +/* + This file is part of the Wrapper open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef JSCStorage_h +#define JSCStorage_h + +#include <string> +#include "DOM/Node.hpp" +#include <JavaScriptCore/JavaScriptCore.h> +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCStorage { +public: + struct JSCStoragePrivate { + JSCDOM* dom; + uscxml::Storage* nativeObj; + }; + + JSC_DESTRUCTOR_KEEP_WRAPPED(JSCStoragePrivate); + + static JSValueRef keyCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef getItemCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setItemCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef removeItemCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef clearCallback(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 JSStaticValue staticValues[]; + static JSStaticFunction staticFunctions[]; + + static JSClassRef Tmpl; + static JSClassRef getTmpl() { + if (Tmpl == NULL) { + JSClassDefinition classDef = kJSClassDefinitionEmpty; + classDef.staticValues = staticValues; + classDef.staticFunctions = staticFunctions; + classDef.finalize = jsDestructor; + + Tmpl = JSClassCreate(&classDef); + JSClassRetain(Tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // JSCStorage_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h index 786df27..663124f 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h @@ -25,7 +25,7 @@ #include "DOM/Node.hpp" #include "JSCCharacterData.h" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.h index cd6ead7..9686a2c 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.h @@ -24,7 +24,7 @@ #include <string> #include "DOM/Node.hpp" #include <JavaScriptCore/JavaScriptCore.h> -#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" namespace Arabica { namespace DOM { |