From 3be96d1aa3024c1acc129e587f5d3165c9434e48 Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Tue, 22 Jan 2013 00:47:54 +0100 Subject: See detailed commitlog - Started DirectoryMonitor invoker - Refactored Invoker / IOProcessor interface - Started with JavaScriptCore bindings - Embedding applications can now use setParentQueue to receive events sent to #_parent --- CMakeLists.txt | 40 +- config.h.in | 1 + contrib/dom/idl/SCXMLEvent.idl | 18 + contrib/dom/scripts/CodeGeneratorArabicaJSC.pm | 786 +++++++++++++++++++++ contrib/dom/scripts/CodeGeneratorArabicaV8.pm | 89 ++- contrib/dom/scripts/make_jsc.sh | 1 + src/uscxml/Factory.cpp | 30 + src/uscxml/Factory.h | 36 +- src/uscxml/Interpreter.cpp | 15 +- src/uscxml/Interpreter.h | 11 +- src/uscxml/Message.h | 6 +- src/uscxml/concurrency/BlockingQueue.h | 6 +- src/uscxml/debug/SCXMLDotWriter.h | 1 - .../ecmascript/JavaScriptCore/JSCDataModel.cpp | 138 +++- .../ecmascript/JavaScriptCore/JSCDataModel.h | 6 +- .../ecmascript/JavaScriptCore/dom/JSCAttr.cpp | 60 ++ .../ecmascript/JavaScriptCore/dom/JSCAttr.h | 72 ++ .../JavaScriptCore/dom/JSCCDATASection.cpp | 18 + .../JavaScriptCore/dom/JSCCDATASection.h | 67 ++ .../JavaScriptCore/dom/JSCCharacterData.cpp | 40 ++ .../JavaScriptCore/dom/JSCCharacterData.h | 75 ++ .../ecmascript/JavaScriptCore/dom/JSCComment.cpp | 18 + .../ecmascript/JavaScriptCore/dom/JSCComment.h | 67 ++ .../ecmascript/JavaScriptCore/dom/JSCDOM.cpp | 4 +- .../ecmascript/JavaScriptCore/dom/JSCDOM.h | 7 +- .../JavaScriptCore/dom/JSCDOMImplementation.cpp | 20 + .../JavaScriptCore/dom/JSCDOMImplementation.h | 69 ++ .../ecmascript/JavaScriptCore/dom/JSCDocument.cpp | 78 ++ .../ecmascript/JavaScriptCore/dom/JSCDocument.h | 85 +++ .../JavaScriptCore/dom/JSCDocumentFragment.cpp | 18 + .../JavaScriptCore/dom/JSCDocumentFragment.h | 67 ++ .../JavaScriptCore/dom/JSCDocumentType.cpp | 87 +++ .../JavaScriptCore/dom/JSCDocumentType.h | 73 ++ .../ecmascript/JavaScriptCore/dom/JSCElement.cpp | 43 ++ .../ecmascript/JavaScriptCore/dom/JSCElement.h | 83 +++ .../ecmascript/JavaScriptCore/dom/JSCEntity.cpp | 48 ++ .../ecmascript/JavaScriptCore/dom/JSCEntity.h | 70 ++ .../JavaScriptCore/dom/JSCEntityReference.cpp | 18 + .../JavaScriptCore/dom/JSCEntityReference.h | 67 ++ .../JavaScriptCore/dom/JSCNamedNodeMap.cpp | 31 + .../JavaScriptCore/dom/JSCNamedNodeMap.h | 74 ++ .../ecmascript/JavaScriptCore/dom/JSCNode.cpp | 228 +++++- .../ecmascript/JavaScriptCore/dom/JSCNode.cpp.old | 60 ++ .../ecmascript/JavaScriptCore/dom/JSCNode.h | 264 ++----- .../ecmascript/JavaScriptCore/dom/JSCNode.h.old | 223 ++++++ .../ecmascript/JavaScriptCore/dom/JSCNodeList.cpp | 25 + .../ecmascript/JavaScriptCore/dom/JSCNodeList.h | 68 ++ .../ecmascript/JavaScriptCore/dom/JSCNodeSet.cpp | 32 + .../ecmascript/JavaScriptCore/dom/JSCNodeSet.h | 69 ++ .../ecmascript/JavaScriptCore/dom/JSCNotation.cpp | 38 + .../ecmascript/JavaScriptCore/dom/JSCNotation.h | 69 ++ .../dom/JSCProcessingInstruction.cpp | 38 + .../JavaScriptCore/dom/JSCProcessingInstruction.h | 70 ++ .../ecmascript/JavaScriptCore/dom/JSCText.cpp | 19 + .../ecmascript/JavaScriptCore/dom/JSCText.h | 68 ++ .../JavaScriptCore/dom/JSCXPathResult.cpp | 46 ++ .../ecmascript/JavaScriptCore/dom/JSCXPathResult.h | 74 ++ .../datamodel/ecmascript/v8/V8DataModel.cpp | 125 +--- .../plugins/datamodel/ecmascript/v8/V8DataModel.h | 22 +- .../plugins/datamodel/ecmascript/v8/dom/V8Attr.cpp | 14 +- .../plugins/datamodel/ecmascript/v8/dom/V8Attr.h | 4 +- .../datamodel/ecmascript/v8/dom/V8CDATASection.h | 4 +- .../ecmascript/v8/dom/V8CharacterData.cpp | 16 +- .../datamodel/ecmascript/v8/dom/V8CharacterData.h | 4 +- .../datamodel/ecmascript/v8/dom/V8Comment.h | 4 +- .../plugins/datamodel/ecmascript/v8/dom/V8DOM.h | 11 +- .../ecmascript/v8/dom/V8DOMImplementation.cpp | 12 +- .../ecmascript/v8/dom/V8DOMImplementation.h | 4 +- .../datamodel/ecmascript/v8/dom/V8Document.cpp | 76 +- .../datamodel/ecmascript/v8/dom/V8Document.h | 4 +- .../ecmascript/v8/dom/V8DocumentCustom.cpp | 4 +- .../ecmascript/v8/dom/V8DocumentFragment.h | 4 +- .../datamodel/ecmascript/v8/dom/V8DocumentType.cpp | 20 +- .../datamodel/ecmascript/v8/dom/V8DocumentType.h | 4 +- .../datamodel/ecmascript/v8/dom/V8Element.cpp | 52 +- .../datamodel/ecmascript/v8/dom/V8Element.h | 4 +- .../datamodel/ecmascript/v8/dom/V8Entity.cpp | 6 +- .../plugins/datamodel/ecmascript/v8/dom/V8Entity.h | 4 +- .../ecmascript/v8/dom/V8EntityReference.h | 4 +- .../datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp | 34 +- .../datamodel/ecmascript/v8/dom/V8NamedNodeMap.h | 4 +- .../plugins/datamodel/ecmascript/v8/dom/V8Node.cpp | 104 +-- .../plugins/datamodel/ecmascript/v8/dom/V8Node.h | 52 +- .../datamodel/ecmascript/v8/dom/V8NodeList.cpp | 6 +- .../datamodel/ecmascript/v8/dom/V8NodeList.h | 4 +- .../datamodel/ecmascript/v8/dom/V8NodeSet.cpp | 6 +- .../datamodel/ecmascript/v8/dom/V8NodeSet.h | 4 +- .../ecmascript/v8/dom/V8NodeSetCustom.cpp | 12 +- .../datamodel/ecmascript/v8/dom/V8Notation.cpp | 4 +- .../datamodel/ecmascript/v8/dom/V8Notation.h | 4 +- .../ecmascript/v8/dom/V8ProcessingInstruction.cpp | 6 +- .../ecmascript/v8/dom/V8ProcessingInstruction.h | 4 +- .../datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp | 76 ++ .../datamodel/ecmascript/v8/dom/V8SCXMLEvent.h | 95 +++ .../plugins/datamodel/ecmascript/v8/dom/V8Text.cpp | 4 +- .../plugins/datamodel/ecmascript/v8/dom/V8Text.h | 4 +- .../datamodel/ecmascript/v8/dom/V8XPathResult.cpp | 16 +- .../datamodel/ecmascript/v8/dom/V8XPathResult.h | 4 +- .../ecmascript/v8/dom/V8XPathResultCustom.cpp | 4 +- .../plugins/datamodel/prolog/swi/SWIDataModel.h | 5 - .../invoker/filesystem/dirmon/DirMonInvoker.cpp | 197 ++++++ .../invoker/filesystem/dirmon/DirMonInvoker.h | 58 ++ .../filesystem/dirmon/FileWatcher/FileWatcher.cpp | 75 ++ .../filesystem/dirmon/FileWatcher/FileWatcher.h | 141 ++++ .../dirmon/FileWatcher/FileWatcherImpl.h | 77 ++ .../dirmon/FileWatcher/FileWatcherLinux.cpp | 165 +++++ .../dirmon/FileWatcher/FileWatcherLinux.h | 89 +++ .../dirmon/FileWatcher/FileWatcherOSX.cpp | 364 ++++++++++ .../filesystem/dirmon/FileWatcher/FileWatcherOSX.h | 87 +++ .../dirmon/FileWatcher/FileWatcherWin32.cpp | 244 +++++++ .../dirmon/FileWatcher/FileWatcherWin32.h | 83 +++ .../invoker/graphics/openscenegraph/OSGInvoker.cpp | 3 - .../invoker/graphics/openscenegraph/OSGInvoker.h | 2 - .../plugins/invoker/heartbeat/HeartbeatInvoker.cpp | 6 +- .../plugins/invoker/heartbeat/HeartbeatInvoker.h | 4 +- .../plugins/invoker/sample/SampleInvoker.cpp | 12 +- src/uscxml/plugins/invoker/sample/SampleInvoker.h | 10 +- src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp | 14 +- src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h | 12 +- .../plugins/invoker/umundo/UmundoInvoker.cpp | 14 +- src/uscxml/plugins/invoker/umundo/UmundoInvoker.h | 2 - .../basichttp/libevent/EventIOProcessor.cpp | 2 +- .../basichttp/libevent/EventIOProcessor.h | 1 - test/samples/uscxml/demos/3d-file-server.scxml | 7 + test/samples/uscxml/test-dirmon.scxml | 16 + test/samples/uscxml/test-umundo-s11n.scxml | 22 +- 126 files changed, 5760 insertions(+), 735 deletions(-) create mode 100644 contrib/dom/idl/SCXMLEvent.idl create mode 100644 contrib/dom/scripts/CodeGeneratorArabicaJSC.pm create mode 100644 contrib/dom/scripts/make_jsc.sh create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp.old create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h.old create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.h create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp create mode 100644 src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h create mode 100644 src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp create mode 100644 src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.h create mode 100644 src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcher.cpp create mode 100644 src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcher.h create mode 100644 src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherImpl.h create mode 100644 src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherLinux.cpp create mode 100644 src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherLinux.h create mode 100644 src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherOSX.cpp create mode 100644 src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherOSX.h create mode 100644 src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherWin32.cpp create mode 100644 src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherWin32.h create mode 100644 test/samples/uscxml/demos/3d-file-server.scxml create mode 100644 test/samples/uscxml/test-dirmon.scxml diff --git a/CMakeLists.txt b/CMakeLists.txt index 3004fac..b6fe9ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -409,6 +409,23 @@ endif() ################################################# # optional libraries we can build as plugins +# sample invoker - include to make sure it compiles +file(GLOB_RECURSE SAMPLE_INVOKER + src/uscxml/plugins/invoker/sample/*.cpp + src/uscxml/plugins/invoker/sample/*.h +) +source_group("Invoker" FILES ${SAMPLE_INVOKER}) +if (BUILD_AS_PLUGINS) + add_library( + invoker_sample SHARED + ${SAMPLE_INVOKER}) + target_link_libraries(invoker_sample uscxml) + set_target_properties(invoker_sample PROPERTIES FOLDER "Plugin Invoker") +else() + list (APPEND USCXML_FILES ${SAMPLE_INVOKER}) +endif() + + # LIBEVENT basichttp ioprocessor - this one is already required above file(GLOB_RECURSE LIBEVENT_IOPROCESSOR @@ -426,9 +443,30 @@ else() list (APPEND USCXML_FILES ${LIBEVENT_IOPROCESSOR}) endif() + +# DirMon invoker to watch for filesystem changes + +file(GLOB_RECURSE DIRMON_INVOKER + src/uscxml/plugins/invoker/filesystem/dirmon/*.cpp + src/uscxml/plugins/invoker/filesystem/dirmon/*.h +) +source_group("Invoker" FILES ${DIRMON_INVOKER}) +include_directories(${PROJECT_SOURCE_DIR}/src/uscxml/plugins/invoker/filesystem/dirmon/) +if (BUILD_AS_PLUGINS) + add_library( + invoker_dirmon SHARED + ${DIRMON_INVOKER}) + target_link_libraries(invoker_dirmon uscxml) + set_target_properties(invoker_dirmon PROPERTIES FOLDER "Plugin Invoker") +else() + list (APPEND USCXML_FILES ${DIRMON_INVOKER}) +endif() + + # JavaScriptCore ecmascript datamodel -if (APPLE AND IOS) +if (APPLE AND IOS AND OFF) FIND_LIBRARY(JSC_LIBRARY JavaScriptCore) + set(JSC_FOUND ON) file(GLOB JSC_DATAMODEL src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/*.cpp src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/*.h diff --git a/config.h.in b/config.h.in index 1bef782..f7d4ec7 100644 --- a/config.h.in +++ b/config.h.in @@ -54,6 +54,7 @@ #cmakedefine UMUNDO_FOUND #cmakedefine MILES_FOUND #cmakedefine V8_FOUND +#cmakedefine JSC_FOUND #cmakedefine SWI_FOUND #cmakedefine OPENSCENEGRAPH_FOUND diff --git a/contrib/dom/idl/SCXMLEvent.idl b/contrib/dom/idl/SCXMLEvent.idl new file mode 100644 index 0000000..f70c4d4 --- /dev/null +++ b/contrib/dom/idl/SCXMLEvent.idl @@ -0,0 +1,18 @@ +[ + AttributesArePublic, + DontDestroyWrapped +] interface SCXMLEvent { + + // NodeType + const unsigned short INTERNAL = 1; + const unsigned short EXTERNAL = 2; + const unsigned short PLATFORM = 3; + + readonly attribute unsigned short type; + readonly attribute DOMString name; + readonly attribute DOMString origin; + readonly attribute DOMString origintype; + readonly attribute Node dom; + readonly attribute DOMString sendid; + readonly attribute DOMString invokeid; +}; diff --git a/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm b/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm new file mode 100644 index 0000000..affa51f --- /dev/null +++ b/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm @@ -0,0 +1,786 @@ +# Copyright (C) 2005, 2006 Nikolas Zimmermann +# Copyright (C) 2006 Anders Carlsson +# Copyright (C) 2006 Samuel Weinig +# Copyright (C) 2006 Alexey Proskuryakov +# Copyright (C) 2006 Apple Computer, Inc. +# Copyright (C) 2007, 2008, 2009, 2012 Google Inc. +# Copyright (C) 2009 Cameron McCormack +# Copyright (C) Research In Motion Limited 2010. All rights reserved. +# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) +# Copyright (C) 2012 Ericsson AB. All rights reserved. +# Copyright (C) 2013 Stefan Radomski +# +# 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. +# + +package CodeGeneratorArabicaJSC; + +use strict; +use Data::Dumper; +use Carp qw/longmess cluck confess/; + +use constant FileNamePrefix => "JSC"; + +my $codeGenerator; + + +my @headerContent = (); +my @implContentHeader = (); +my @implContent = (); +my @implContentDecls = (); +my %implIncludes = (); +my %headerIncludes = (); + +# Default .h template +my $headerTemplate = << "EOF"; +/* + This file is part of the Arabica 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. +*/ +EOF + +# Default constructor +sub new +{ + my $object = shift; + my $reference = { }; + + $codeGenerator = shift; + + bless($reference, $object); + return $reference; +} + +sub GenerateInterface +{ + my $object = shift; + my $interface = shift; + + # Start actual generation + if ($interface->extendedAttributes->{"Callback"}) { + die(); + $object->GenerateCallbackHeader($interface); + $object->GenerateCallbackImplementation($interface); + } else { + $object->GenerateHeader($interface); + $object->GenerateImplementation($interface); + } +} + +sub AddToImplIncludes +{ + my $header = shift; + my $conditional = shift; + + if ($header eq "JSCbool.h") { + confess(); + } + + if (not $conditional) { + $implIncludes{$header} = 1; + } elsif (not exists($implIncludes{$header})) { + $implIncludes{$header} = $conditional; + } else { + my $oldValue = $implIncludes{$header}; + if ($oldValue ne 1) { + my %newValue = (); + $newValue{$conditional} = 1; + foreach my $condition (split(/\|/, $oldValue)) { + $newValue{$condition} = 1; + } + $implIncludes{$header} = join("|", sort keys %newValue); + } + } +} + +sub GenerateHeader +{ + my $object = shift; + my $interface = shift; + my $interfaceName = $interface->name; + my $extensions = $interface->extendedAttributes; +# print Dumper($extensions); + + # Copy contents of parent interfaces except the first parent. + my @parents; + $codeGenerator->AddMethodsConstantsAndAttributesFromParentInterfaces($interface, \@parents, 1); + $codeGenerator->LinkOverloadedFunctions($interface); + + # - Add default header template + push(@headerContent, GenerateHeaderContentHeader($interface)); + + $headerIncludes{"uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h"} = 1; + $headerIncludes{"DOM/Node.hpp"} = 1; + $headerIncludes{"JavaScriptCore/JavaScriptCore.h"} = 1; + + foreach (@{$interface->parents}) { + my $parent = $_; + $headerIncludes{"JSC${parent}.h"} = 1; + } + + foreach my $headerInclude (sort keys(%headerIncludes)) { + if ($headerInclude =~ /wtf|JavaScriptCore\/JavaScriptCore\.h/) { + push(@headerContent, "#include \<${headerInclude}\>\n"); + } else { + push(@headerContent, "#include \"${headerInclude}\"\n"); + } + } + + push(@headerContent, ""); + push(@headerContent, "\nnamespace Arabica {"); + push(@headerContent, "\nnamespace DOM {\n"); + + push(@headerContent, "\nclass JSC${interfaceName} {"); + push(@headerContent, "\npublic:"); + + my $arabicaType = IdlToArabicaType($interfaceName); + push(@headerContent, <functions}) { + my $name = $function->signature->name; + my $attrExt = $function->signature->extendedAttributes; + my $custom = ($attrExt->{'Custom'} ? "Custom" : ""); + push(@headerContent, "\n static JSValueRef ${name}${custom}Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception);"); + } + push(@headerContent, "\n"); + + # attribute getter and setters + foreach my $attribute (@{$interface->attributes}) { + my $name = $attribute->signature->name; + my $attrExt = $attribute->signature->extendedAttributes; + my $customGetter = ($attrExt->{'CustomGetter'} ? "Custom" : ""); + my $customSetter = ($attrExt->{'CustomSetter'} ? "Custom" : ""); + push(@headerContent, "\n static JSValueRef ${name}${customGetter}AttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception);"); + if (!IsReadonly($attribute)) { + push(@headerContent, "\n static bool ${name}${customSetter}AttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);"); + } + } + + push(@headerContent, "\n"); + # constant getters + foreach my $constant (@{$interface->constants}) { + my $name = $constant->name; + push(@headerContent, "\n static JSValueRef ${name}ConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception);"); + } + + # if ($extensions->{'CustomIndexedGetter'}) { + # push(@headerContent, "\n static v8::Handle indexedPropertyCustomGetter(uint32_t, const v8::AccessorInfo&);"); + # } + # if ($extensions->{'CustomIndexedSetter'}) { + # push(@headerContent, "\n static v8::Handle indexedPropertyCustomSetter(uint32_t, v8::Local, const v8::AccessorInfo&);"); + # } + # push(@headerContent, "\n"); + +# GenerateClassPrototypeHeader($interface); + + push(@headerContent, <name; + my $extensions = $interface->extendedAttributes; + + push(@implContent, "\nJSStaticValue JSC${interfaceName}::staticValues[] = {"); + foreach my $attribute (@{$interface->attributes}) { + my $name = $attribute->signature->name; + my $attrExt = $attribute->signature->extendedAttributes; + my $customGetter = ($attrExt->{'CustomGetter'} ? "Custom" : ""); + my $customSetter = ($attrExt->{'CustomSetter'} ? "Custom" : ""); + my $getter = "${name}${customGetter}AttrGetter"; + my $setter = (IsReadonly($attribute) ? "0" : "${name}${customSetter}AttrSetter"); + my $flags = "kJSPropertyAttributeDontDelete"; + $flags .= " | kJSPropertyAttributeReadOnly" if (IsReadonly($attribute)); + push(@implContent, "\n { \"${name}\", ${getter}, ${setter}, ${flags} },"); + + } + + push(@implContent, "\n"); + foreach my $constant (@{$interface->constants}) { + my $name = $constant->name; + my $value = $constant->value; + my $getter = "${name}ConstGetter"; + my $flags = "kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly"; + push(@implContent, "\n { \"${name}\", ${getter}, 0, ${flags} },"); + } + + push(@implContent, "\n { 0, 0, 0, 0 }"); + push(@implContent, "\n};\n"); + + push(@implContent, "\nJSStaticFunction JSC${interfaceName}::staticFunctions[] = {"); + foreach my $function (@{$interface->functions}) { + my $name = $function->signature->name; + my $attrExt = $function->signature->extendedAttributes; + my $custom = ($attrExt->{'Custom'} ? "Custom" : ""); + my $callback = ${name}.${custom}."Callback"; + my $flags = "kJSPropertyAttributeDontDelete"; + push(@implContent, "\n { \"${name}\", ${callback}, ${flags} },"); + + } + push(@implContent, "\n { 0, 0, 0 }"); + push(@implContent, "\n};\n"); + +} + +sub GenerateImplementationAttributes +{ + my $interface = shift; + my $interfaceName = $interface->name; + + # Generate property accessors for attributes. + for (my $index = 0; $index < @{$interface->attributes}; $index++) { + my $attribute = @{$interface->attributes}[$index]; + my $attrType = $attribute->signature->type; + my $attrName = $attribute->signature->name; + my $attrExt = $attribute->signature->extendedAttributes; + + my $arabicaRetType = IdlToArabicaType($attrType); + my $arabicaType = IdlToArabicaType($interfaceName); + my $arabicaGetter = IdlToArabicaAttrGetter($interface, $attribute); + + next if ($attrExt->{'Custom'}); + + # getter + if (!$attrExt->{'CustomGetter'}) { + push(@implContent, <(JSObjectGetPrivate(thisObj)); +END + if (IsWrapperType($attrType)) { + AddToImplIncludes("JSC".$attrType.".h"); + push(@implContent, <arabicaThis->${arabicaGetter}()); + + struct JSC${attrType}::JSC${attrType}Private* retPrivData = new JSC${attrType}::JSC${attrType}Private(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = arbaicaRet; + + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, JSC${attrType}::getTmpl(), retPrivData); + return arbaicaRetObj; +END + } else { + my $jscType = IdlToJSCType($attrType); + if ($attrType eq "DOMString") { + push(@implContent, <arabicaThis->${arabicaGetter}().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; +END + } else { + push(@implContent, "\n return ${jscType}(ctx, privData->arabicaThis->${arabicaGetter}());"); + } + } + push(@implContent, "\n}\n"); + } + + if (!$attrExt->{'CustomSetter'}) { + # setter + if (!IsReadonly($attribute) && 0) { + my $arabicaSetter = IdlToArabicaAttrSetter($attrName); + push(@implContent, "\n void JSC${interfaceName}::${attrName}AttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) {"); + push(@implContent, "\n v8::Local self = info.Holder();"); + push(@implContent, "\n struct JSC${interfaceName}Private* privData = JSCDOM::toClassPtr(self->GetInternalField(0));"); + + my ($handle, $deref) = IdlToArgHandle($attribute->signature->type, "local".ucfirst($attribute->signature->name), "value"); + + push(@implContent, "\n $handle"); + push(@implContent, "\n privData->arabicaThis->${arabicaSetter}(${deref});"); + push(@implContent, "\n }\n"); + + } + } + } +} + +sub GenerateImplementationFunctionCallbacks +{ + my $interface = shift; + my $interfaceName = $interface->name; + my $arabicaType = IdlToArabicaType($interfaceName); + + # Generate methods for functions. + foreach my $function (@{$interface->functions}) { + my $name = $function->signature->name; + my $attrExt = $function->signature->extendedAttributes; + my $retType = $function->signature->type; + my $arabicaRetType = IdlToArabicaType($retType); + + next if ($attrExt->{'Custom'}); + + # signature + push(@implContent, < JSC${interfaceName}::${name}Callback(const v8::Arguments& args) { +END + + # arguments count and type checking + push(@implContent, GenerateArgumentsCountCheck($function, $interface)); + my $argCheckExpr = GenerateArgumentsTypeCheck($function, $interface); + + push(@implContent, < self = args.Holder();"); + push(@implContent, "\n struct JSC${interfaceName}Private* privData = JSCDOM::toClassPtr(self->GetInternalField(0));"); + + # arguments to local handles + my $parameterIndex = 0; + my @argList; + foreach my $parameter (@{$function->parameters}) { + my $value = "args[$parameterIndex]"; + my $type = $parameter->type; + AddToImplIncludes("JSC".$type.".h") if (IsWrapperType($type)); + + my ($handle, $deref) = IdlToArgHandle($parameter->type, "local".ucfirst($parameter->name), "args[${parameterIndex}]"); + push(@implContent, "\n ${handle}"); + push(@argList, $deref); + + $parameterIndex++; + } + + # invoke native function with argument handles + my $retNativeType = IdlToNativeType($retType); + my $arabicaFunctionName = IdlToArabicaFunction($interface, $function); + if (IsWrapperType($retType)) { + push(@implContent, "\n\n ${retNativeType}* retVal = new $arabicaRetType(privData->arabicaThis->${arabicaFunctionName}(" . join(", ", @argList) . "));\n"); + } elsif ($retNativeType eq "void") { + push(@implContent, "\n\n privData->arabicaThis->${arabicaFunctionName}(" . join(", ", @argList) . ");\n"); + } else { + push(@implContent, "\n\n ${retNativeType} retVal = privData->arabicaThis->${arabicaFunctionName}(" . join(", ", @argList) . ");\n"); + } + + # wrap return type if needed + if (IsWrapperType($retType)) { + AddToImplIncludes("JSC".$retType.".h"); + + push(@implContent, < retCtor = JSC${retType}::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + + struct JSC${retType}::JSC${retType}Private* retPrivData = new JSC${retType}::JSC${retType}Private(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = retVal; + + retObj->SetInternalField(0, JSCDOM::toExternal(retPrivData)); + + retObj.MakeWeak(0, JSC${retType}::jsDestructor); + return retObj; +END + } else { + my $toHandleString = NativeToHandle($retNativeType, "retVal"); + push(@implContent, "\n return ${toHandleString};"); + } + + push(@implContent, "\n }\n\n"); + } + +} + +sub GenerateImplementation +{ + my $object = shift; + my $interface = shift; + my $interfaceName = $interface->name; + my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interface); + my $v8InterfaceName = "JSC$interfaceName"; + my $arabicaType = IdlToArabicaType($interfaceName); + + AddToImplIncludes("JSC${interfaceName}.h"); + + # Find the super descriptor. + my $parentClass = ""; + my $parentClassTemplate = ""; + foreach (@{$interface->parents}) { + my $parent = $_; + AddToImplIncludes("JSC${parent}.h"); + $parentClass = "JSC" . $parent; + last; + } + push(@implContent, "namespace Arabica {\n"); + push(@implContent, "namespace DOM {\n\n"); + + GenerateClassDefStatics($interface); + GenerateImplementationAttributes($interface); +# GenerateImplementationFunctionCallbacks($interface); + + push(@implContent, <name; + my $prefix = FileNamePrefix; + my $headerFileName = "$outputHeadersDir/$prefix$name.h"; + my $implFileName = "$outputDir/$prefix$name.cpp"; + + # print "WriteData\n"; + # print Dumper($interface); + # exit(); + + # Update a .cpp file if the contents are changed. + my $contents = join "", @implContentHeader; + + my @includes = (); + my %implIncludeConditions = (); + foreach my $include (keys %implIncludes) { + my $condition = $implIncludes{$include}; + my $checkType = $include; + $checkType =~ s/\.h//; + next if $codeGenerator->IsSVGAnimatedType($checkType); + + if ($include =~ /wtf/) { + $include = "\<$include\>"; + } else { + $include = "\"$include\""; + } + + if ($condition eq 1) { + push @includes, $include; + } else { + push @{$implIncludeConditions{$condition}}, $include; + } + } + foreach my $include (sort @includes) { + $contents .= "#include $include\n"; + } + foreach my $condition (sort keys %implIncludeConditions) { + $contents .= "\n#if " . $codeGenerator->GenerateConditionalStringFromAttributeValue($condition) . "\n"; + foreach my $include (sort @{$implIncludeConditions{$condition}}) { + $contents .= "#include $include\n"; + } + $contents .= "#endif\n"; + } + + $contents .= "\n"; + $contents .= join "", @implContentDecls, @implContent; + $codeGenerator->UpdateFile($implFileName, $contents); + + %implIncludes = (); + @implContentHeader = (); + @implContentDecls = (); + @implContent = (); + + # Update a .h file if the contents are changed. + $contents = join "", @headerContent; + $codeGenerator->UpdateFile($headerFileName, $contents); + + @headerContent = (); +} + +sub IdlToJSCType +{ + my $idlType = shift; + return "JSValueMakeNumber" if ($idlType eq "unsigned short"); + return "JSValueMakeNumber" if ($idlType eq "short"); + return "JSValueMakeNumber" if ($idlType eq "unsigned long"); + return "JSValueMakeNumber" if ($idlType eq "long"); + return "JSValueMakeString" if ($idlType eq "DOMString"); + return "JSValueMakeBoolean" if ($idlType eq "boolean"); + return "JSValueMakeNumber" if ($idlType eq "double"); + die($idlType); +} + +sub IdlToNativeType +{ + my $idlType = shift; + + return IdlToArabicaType($idlType) if (IsWrapperType($idlType)); + + return "std::string" if ($idlType eq "DOMString"); + return "bool" if ($idlType eq "boolean"); + return "void" if ($idlType eq "void"); + return "double" if ($idlType eq "double"); + die(${idlType}); +} + +sub NativeToHandle +{ + my $nativeType = shift; + my $nativeName = shift; + + return ("v8::Boolean::New(${nativeName})") if ($nativeType eq "bool"); + return ("v8::Number::New(${nativeName})") if ($nativeType eq "double"); + return ("v8::String::New(${nativeName}.c_str())") if ($nativeType eq "std::string"); + return ("v8::Undefined()") if ($nativeType eq "void"); + + die($nativeType); +} + +sub IdlToArabicaType +{ + my $idlType = shift; + return "Arabica::XPath::XPathValue" if ($idlType eq "XPathResult"); + return "Arabica::XPath::NodeSet" if ($idlType eq "NodeSet"); + return "Arabica::DOM::Node" if ($idlType eq "Node"); + return "Arabica::DOM::Element" if ($idlType eq "Element"); + return "Arabica::DOM::${idlType}"; +} + +sub IdlToArgHandle +{ + my $type = shift; + my $localName = shift; + my $paramName = shift; + + return ("v8::String::AsciiValue ${localName}(${paramName});", "*${localName}") if ($type eq "DOMString"); + return ("unsigned long ${localName} = ${paramName}->ToNumber()->Uint32Value();", ${localName}) if ($type eq "unsigned long"); + return ("unsigned short ${localName} = ${paramName}->ToNumber()->Uint32Value();", ${localName}) if ($type eq "unsigned short"); + return ("bool ${localName} = ${paramName}->ToBoolean()->BooleanValue();", ${localName}) if ($type eq "boolean"); + + if (IsWrapperType($type)) { + my $arabicaType = IdlToArabicaType($type); + return ("${arabicaType}* ${localName} = JSCDOM::toClassPtr(${paramName}->ToObject()->GetInternalField(0))->arabicaThis;", "*${localName}"); + } + + print $type."\n"; + die(); +} + +sub IdlToArabicaAttrGetter +{ + my $interface = shift; + my $attribute = shift; + + return $attribute->signature->name if ($interface->name eq "NodeSet" && $attribute->signature->name eq "size"); + return $attribute->signature->name if ($interface->name eq "NodeSet" && $attribute->signature->name eq "empty"); + return "asString" if ($interface->name eq "XPathResult" && $attribute->signature->name eq "stringValue"); + return "asBool" if ($interface->name eq "XPathResult" && $attribute->signature->name eq "booleanValue"); + return "asNumber" if ($interface->name eq "XPathResult" && $attribute->signature->name eq "numberValue"); + + return "get" . ucfirst($attribute->signature->name); +} + +sub IdlToArabicaFunction +{ + my $interface = shift; + my $function = shift; + + # if ($interface->name eq "NodeSet" && $function->signature->name eq "toDocumentOrder") { + # print Dumper($interface); + # print Dumper($function); + # } + + return "to_document_order" if ($interface->name eq "NodeSet" && $function->signature->name eq "toDocumentOrder"); + + return $function->signature->name; + +} + +sub IdlToArabicaAttrSetter +{ + my $idlAttr = shift; + return "set" . ucfirst($idlAttr); +} + + +sub IsReadonly +{ + my $attribute = shift; + my $attrExt = $attribute->signature->extendedAttributes; + return ($attribute->type =~ /readonly/ || $attrExt->{"JSCReadOnly"}) && !$attrExt->{"Replaceable"}; +} + + +sub GenerateArgumentsCountCheck +{ + my $function = shift; + my $interface = shift; + + my $numMandatoryParams = 0; + my $allowNonOptional = 1; + foreach my $param (@{$function->parameters}) { + if ($param->extendedAttributes->{"Optional"} or $param->isVariadic) { + $allowNonOptional = 0; + } else { + die "An argument must not be declared to be optional unless all subsequent arguments to the operation are also optional." if !$allowNonOptional; + $numMandatoryParams++; + } + } + + my $argumentsCountCheckString = ""; + if ($numMandatoryParams >= 1) { + $argumentsCountCheckString .= " if (args.Length() < $numMandatoryParams)\n"; + $argumentsCountCheckString .= " throw JSCException(\"Wrong number of arguments in " . $function->signature->name . "\");\n"; + } + return $argumentsCountCheckString; +} + +sub GenerateArgumentsTypeCheck +{ + my $function = shift; + my $interface = shift; + + my @andExpression = (); + + my $parameterIndex = 0; + foreach my $parameter (@{$function->parameters}) { + my $value = "args[$parameterIndex]"; + my $type = $parameter->type; + + # Only DOMString or wrapper types are checked. + # For DOMString with StrictTypeChecking only Null, Undefined and Object + # are accepted for compatibility. Otherwise, no restrictions are made to + # match the non-overloaded behavior. + # FIXME: Implement WebIDL overload resolution algorithm. + if ($codeGenerator->IsStringType($type)) { + if ($parameter->extendedAttributes->{"StrictTypeChecking"}) { + push(@andExpression, "(${value}->IsNull() || ${value}->IsUndefined() || ${value}->IsString() || ${value}->IsObject())"); + } + } elsif ($parameter->extendedAttributes->{"Callback"}) { + # For Callbacks only checks if the value is null or object. + push(@andExpression, "(${value}->IsNull() || ${value}->IsFunction())"); + } elsif ($codeGenerator->IsArrayType($type) || $codeGenerator->GetSequenceType($type)) { + if ($parameter->isNullable) { + push(@andExpression, "(${value}->IsNull() || ${value}->IsArray())"); + } else { + push(@andExpression, "(${value}->IsArray())"); + } + } elsif (IsWrapperType($type)) { + if ($parameter->isNullable) { + push(@andExpression, "(${value}->IsNull() || JSC${type}::hasInstance($value))"); + } else { + push(@andExpression, "(JSC${type}::hasInstance($value))"); + } + } + + $parameterIndex++; + } + my $res = join(" && ", @andExpression); + $res = "($res)" if @andExpression > 1; + return $res; +} + + +my %non_wrapper_types = ( + 'CompareHow' => 1, + 'DOMObject' => 1, + 'DOMString' => 1, + 'DOMString[]' => 1, + 'DOMTimeStamp' => 1, + 'Date' => 1, + 'Dictionary' => 1, + 'EventListener' => 1, + # FIXME: When EventTarget is an interface and not a mixin, fix this so that + # EventTarget is treated as a wrapper type. + 'EventTarget' => 1, + 'IDBKey' => 1, + 'JSObject' => 1, + 'MediaQueryListListener' => 1, + 'NodeFilter' => 1, + 'SerializedScriptValue' => 1, + 'any' => 1, + 'boolean' => 1, + 'double' => 1, + 'float' => 1, + 'int' => 1, + 'long long' => 1, + 'long' => 1, + 'short' => 1, + 'void' => 1, + 'unsigned int' => 1, + 'unsigned long long' => 1, + 'unsigned long' => 1, + 'unsigned short' => 1 +); + +sub IsWrapperType +{ + my $type = shift; + return !($non_wrapper_types{$type}); +} + +sub GenerateHeaderContentHeader +{ + my $interface = shift; + my $v8InterfaceName = "JSC" . $interface->name; + my $conditionalString = $codeGenerator->GenerateConditionalString($interface); + + my @headerContentHeader = split("\r", $headerTemplate); + + push(@headerContentHeader, "\n#if ${conditionalString}\n") if $conditionalString; + push(@headerContentHeader, "\n#ifndef ${v8InterfaceName}" . "_h"); + push(@headerContentHeader, "\n#define ${v8InterfaceName}" . "_h\n\n"); + return @headerContentHeader; +} + +1; diff --git a/contrib/dom/scripts/CodeGeneratorArabicaV8.pm b/contrib/dom/scripts/CodeGeneratorArabicaV8.pm index 3382c24..738e981 100644 --- a/contrib/dom/scripts/CodeGeneratorArabicaV8.pm +++ b/contrib/dom/scripts/CodeGeneratorArabicaV8.pm @@ -47,7 +47,7 @@ my %headerIncludes = (); # Default .h template my $headerTemplate = << "EOF"; /* - This file is part of the Arabica open source project. + 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 @@ -161,16 +161,20 @@ sub GenerateHeader push(@headerContent, "\nclass V8${interfaceName} {"); push(@headerContent, "\npublic:"); - my $arabicaType = IdlToArabicaType($interfaceName); + my $wrapperType = IdlToWrapperType($interfaceName); push(@headerContent, <{'DontDestroyWrapped'}) { + push(@headerContent, "\n V8_DESTRUCTOR_KEEP_WRAPPED(V8${interfaceName}Private);"); + } else { + push(@headerContent, "\n V8_DESTRUCTOR(V8${interfaceName}Private);"); + } push(@headerContent, "\n static bool hasInstance(v8::Handle);"); push(@headerContent, "\n"); @@ -270,8 +274,8 @@ END my $value = $constant->value; my $type = IdlToV8Type($constant->type); push(@headerContent, <Set(v8::String::NewSymbol("${name}"), ${type}::New(${value}), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("${name}"), ${type}::New(${value}), v8::ReadOnly); + tmpl->Set(v8::String::NewSymbol("${name}"), ${type}::New(${value}), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("${name}"), ${type}::New(${value}), static_cast(v8::ReadOnly | v8::DontEnum)); END } @@ -294,6 +298,7 @@ sub GenerateImplementationAttributes { my $interface = shift; my $interfaceName = $interface->name; + my $extensions = $interface->extendedAttributes; # Generate property accessors for attributes. for (my $index = 0; $index < @{$interface->attributes}; $index++) { @@ -302,11 +307,16 @@ sub GenerateImplementationAttributes my $attrName = $attribute->signature->name; my $attrExt = $attribute->signature->extendedAttributes; - my $arabicaRetType = IdlToArabicaType($attrType); - my $arabicaType = IdlToArabicaType($interfaceName); - my $arabicaGetter = IdlToArabicaAttrGetter($interface, $attribute); - - next if ($attrExt->{'Custom'}); + my $wrapperRetType = IdlToWrapperType($attrType); + my $wrapperType = IdlToWrapperType($interfaceName); + my $wrapperGetter; + + if ($attrExt->{'AttributeIsPublic'} || $extensions->{'AttributesArePublic'}) { + $wrapperGetter = $attrName; + } else { + $wrapperGetter = IdlToWrapperAttrGetter($interface, $attribute)."()"; + + } # getter if (!$attrExt->{'CustomGetter'}) { @@ -318,15 +328,18 @@ sub GenerateImplementationAttributes END if (IsWrapperType($attrType)) { AddToImplIncludes("V8".$attrType.".h"); + push(@implContent, "\n ".GenerateConditionalUndefReturn($interface, $attribute, "privData->nativeObj->${wrapperGetter}")); + push(@implContent, <arabicaThis->${arabicaGetter}()); + + ${wrapperRetType}* arbaicaRet = new ${wrapperRetType}(privData->nativeObj->${wrapperGetter}); v8::Handle arbaicaRetCtor = V8${attrType}::getTmpl()->GetFunction(); v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); struct V8${attrType}::V8${attrType}Private* retPrivData = new V8${attrType}::V8${attrType}Private(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = arbaicaRet; + retPrivData->nativeObj = arbaicaRet; arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); arbaicaRetObj.MakeWeak(0, V8${attrType}::jsDestructor); @@ -335,9 +348,9 @@ END } else { my $v8Type = IdlToV8Type($attrType); if ($attrType eq "DOMString") { - push(@implContent, "\n return ${v8Type}::New(privData->arabicaThis->${arabicaGetter}().c_str());"); + push(@implContent, "\n return ${v8Type}::New(privData->nativeObj->${wrapperGetter}.c_str());"); } else { - push(@implContent, "\n return ${v8Type}::New(privData->arabicaThis->${arabicaGetter}());"); + push(@implContent, "\n return ${v8Type}::New(privData->nativeObj->${wrapperGetter});"); } } push(@implContent, "\n }\n"); @@ -346,7 +359,7 @@ END if (!$attrExt->{'CustomSetter'}) { # setter if (!IsReadonly($attribute)) { - my $arabicaSetter = IdlToArabicaAttrSetter($attrName); + my $wrapperSetter = IdlToWrapperAttrSetter($attrName); push(@implContent, "\n void V8${interfaceName}::${attrName}AttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) {"); push(@implContent, "\n v8::Local self = info.Holder();"); push(@implContent, "\n struct V8${interfaceName}Private* privData = V8DOM::toClassPtr(self->GetInternalField(0));"); @@ -354,7 +367,7 @@ END my ($handle, $deref) = IdlToArgHandle($attribute->signature->type, "local".ucfirst($attribute->signature->name), "value"); push(@implContent, "\n $handle"); - push(@implContent, "\n privData->arabicaThis->${arabicaSetter}(${deref});"); + push(@implContent, "\n privData->nativeObj->${wrapperSetter}(${deref});"); push(@implContent, "\n }\n"); } @@ -362,18 +375,29 @@ END } } +sub GenerateConditionalUndefReturn +{ + my $interface = shift; + my $attribute = shift; + my $getterExpression = shift; + + return "" if ($attribute->signature->type eq "NamedNodeMap"); + return "" if ($attribute->signature->type eq "NodeList"); + return "if (!$getterExpression) return v8::Undefined();"; +} + sub GenerateImplementationFunctionCallbacks { my $interface = shift; my $interfaceName = $interface->name; - my $arabicaType = IdlToArabicaType($interfaceName); + my $wrapperType = IdlToWrapperType($interfaceName); # Generate methods for functions. foreach my $function (@{$interface->functions}) { my $name = $function->signature->name; my $attrExt = $function->signature->extendedAttributes; my $retType = $function->signature->type; - my $arabicaRetType = IdlToArabicaType($retType); + my $wrapperRetType = IdlToWrapperType($retType); next if ($attrExt->{'Custom'}); @@ -412,13 +436,13 @@ END # invoke native function with argument handles my $retNativeType = IdlToNativeType($retType); - my $arabicaFunctionName = IdlToArabicaFunction($interface, $function); + my $wrapperFunctionName = IdlToWrapperFunction($interface, $function); if (IsWrapperType($retType)) { - push(@implContent, "\n\n ${retNativeType}* retVal = new $arabicaRetType(privData->arabicaThis->${arabicaFunctionName}(" . join(", ", @argList) . "));\n"); + push(@implContent, "\n\n ${retNativeType}* retVal = new $wrapperRetType(privData->nativeObj->${wrapperFunctionName}(" . join(", ", @argList) . "));\n"); } elsif ($retNativeType eq "void") { - push(@implContent, "\n\n privData->arabicaThis->${arabicaFunctionName}(" . join(", ", @argList) . ");\n"); + push(@implContent, "\n\n privData->nativeObj->${wrapperFunctionName}(" . join(", ", @argList) . ");\n"); } else { - push(@implContent, "\n\n ${retNativeType} retVal = privData->arabicaThis->${arabicaFunctionName}(" . join(", ", @argList) . ");\n"); + push(@implContent, "\n\n ${retNativeType} retVal = privData->nativeObj->${wrapperFunctionName}(" . join(", ", @argList) . ");\n"); } # wrap return type if needed @@ -431,7 +455,7 @@ END struct V8${retType}::V8${retType}Private* retPrivData = new V8${retType}::V8${retType}Private(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -455,7 +479,7 @@ sub GenerateImplementation my $interfaceName = $interface->name; my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interface); my $v8InterfaceName = "V8$interfaceName"; - my $arabicaType = IdlToArabicaType($interfaceName); + my $wrapperType = IdlToWrapperType($interfaceName); AddToImplIncludes("V8${interfaceName}.h"); @@ -572,7 +596,7 @@ sub IdlToNativeType { my $idlType = shift; - return IdlToArabicaType($idlType) if (IsWrapperType($idlType)); + return IdlToWrapperType($idlType) if (IsWrapperType($idlType)); return "std::string" if ($idlType eq "DOMString"); return "bool" if ($idlType eq "boolean"); @@ -594,13 +618,14 @@ sub NativeToHandle die($nativeType); } -sub IdlToArabicaType +sub IdlToWrapperType { my $idlType = shift; return "Arabica::XPath::XPathValue" if ($idlType eq "XPathResult"); return "Arabica::XPath::NodeSet" if ($idlType eq "NodeSet"); return "Arabica::DOM::Node" if ($idlType eq "Node"); return "Arabica::DOM::Element" if ($idlType eq "Element"); + return "uscxml::Event" if ($idlType eq "SCXMLEvent"); return "Arabica::DOM::${idlType}"; } @@ -616,15 +641,15 @@ sub IdlToArgHandle return ("bool ${localName} = ${paramName}->ToBoolean()->BooleanValue();", ${localName}) if ($type eq "boolean"); if (IsWrapperType($type)) { - my $arabicaType = IdlToArabicaType($type); - return ("${arabicaType}* ${localName} = V8DOM::toClassPtr(${paramName}->ToObject()->GetInternalField(0))->arabicaThis;", "*${localName}"); + my $wrapperType = IdlToWrapperType($type); + return ("${wrapperType}* ${localName} = V8DOM::toClassPtr(${paramName}->ToObject()->GetInternalField(0))->nativeObj;", "*${localName}"); } print $type."\n"; die(); } -sub IdlToArabicaAttrGetter +sub IdlToWrapperAttrGetter { my $interface = shift; my $attribute = shift; @@ -638,7 +663,7 @@ sub IdlToArabicaAttrGetter return "get" . ucfirst($attribute->signature->name); } -sub IdlToArabicaFunction +sub IdlToWrapperFunction { my $interface = shift; my $function = shift; @@ -654,7 +679,7 @@ sub IdlToArabicaFunction } -sub IdlToArabicaAttrSetter +sub IdlToWrapperAttrSetter { my $idlAttr = shift; return "set" . ucfirst($idlAttr); diff --git a/contrib/dom/scripts/make_jsc.sh b/contrib/dom/scripts/make_jsc.sh new file mode 100644 index 0000000..97ced82 --- /dev/null +++ b/contrib/dom/scripts/make_jsc.sh @@ -0,0 +1 @@ +find ../idl/ -name *.idl -exec ./generate-bindings.pl --outputDir=/Users/sradomski/Documents/TK/Code/uscxml/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom --include=../idl/ --generator=ArabicaJSC {} \; diff --git a/src/uscxml/Factory.cpp b/src/uscxml/Factory.cpp index b65f088..623dbaf 100644 --- a/src/uscxml/Factory.cpp +++ b/src/uscxml/Factory.cpp @@ -12,6 +12,7 @@ # include "uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h" # include "uscxml/plugins/invoker/scxml/USCXMLInvoker.h" # include "uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h" +# include "uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.h" # ifdef UMUNDO_FOUND # include "uscxml/plugins/invoker/umundo/UmundoInvoker.h" @@ -29,6 +30,10 @@ # include "uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h" # endif +# ifdef JSC_FOUND +# include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h" +# endif + # ifdef SWI_FOUND # include "uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h" # endif @@ -99,6 +104,13 @@ Factory::Factory() { } #endif +#ifdef JSC_FOUND + { + JSCDataModel* dataModel = new JSCDataModel(); + registerDataModel(dataModel); + } +#endif + #ifdef SWI_FOUND { SWIDataModel* dataModel = new SWIDataModel(); @@ -116,9 +128,14 @@ Factory::Factory() { registerInvoker(invoker); } { + DirMonInvoker* invoker = new DirMonInvoker(); + registerInvoker(invoker); + } + { EventIOProcessor* ioProcessor = new EventIOProcessor(); registerIOProcessor(ioProcessor); } + #endif } @@ -223,6 +240,19 @@ Factory* Factory::getInstance() { return _instance; } +void IOProcessorImpl::returnEvent(Event& event) { + if (event.invokeid.length() == 0) + event.invokeid = _invokeId; + if (event.type == 0) + event.type = Event::EXTERNAL; + if (event.origin.length() == 0) + event.origin = "#_" + _invokeId; + if (event.origintype.length() == 0) + event.origintype = _type; + + _interpreter->receive(event); +} + Factory* Factory::_instance = NULL; std::string Factory::pluginPath; } \ No newline at end of file diff --git a/src/uscxml/Factory.h b/src/uscxml/Factory.h index e1aebea..8004366 100644 --- a/src/uscxml/Factory.h +++ b/src/uscxml/Factory.h @@ -27,6 +27,12 @@ template T strTo(std::string tmp) { return output; } +inline bool isNumeric( const char* pszInput, int nNumberBase) { + std::string base = "0123456789ABCDEF"; + std::string input = pszInput; + return (input.find_first_not_of(base.substr(0, nNumberBase)) == std::string::npos); +} + class Interpreter; #if 0 @@ -47,14 +53,24 @@ public: virtual void setInterpreter(Interpreter* interpreter) { _interpreter = interpreter; } + void setInvokeId(const std::string& invokeId) { + _invokeId = invokeId; + } + void setType(const std::string& type) { + _type = type; + } virtual Data getDataModelVariables() = 0; virtual void send(const SendRequest& req) = 0; virtual void runOnMainThread() {}; + void returnEvent(Event& event); + protected: Interpreter* _interpreter; + std::string _invokeId; + std::string _type; }; class IOProcessor { @@ -91,6 +107,16 @@ public: return _impl->runOnMainThread(); } + void setInterpreter(Interpreter* interpreter) { + _impl->setInterpreter(interpreter); + } + void setInvokeId(const std::string& invokeId) { + _impl->setInvokeId(invokeId); + } + void setType(const std::string& type) { + _impl->setType(type); + } + protected: boost::shared_ptr _impl; }; @@ -98,7 +124,6 @@ protected: class InvokerImpl : public IOProcessorImpl { public: virtual void invoke(const InvokeRequest& req) = 0; - virtual void sendToParent(const SendRequest& req) = 0; virtual boost::shared_ptr create(Interpreter* interpreter) = 0; }; @@ -130,9 +155,6 @@ public: virtual void invoke(InvokeRequest& req) { _impl->invoke(req); } - virtual void sendToParent(SendRequest& req) { - _impl->sendToParent(req); - } protected: boost::shared_ptr _impl; @@ -160,6 +182,12 @@ public: virtual bool evalAsBool(const std::string& expr) = 0; virtual void assign(const std::string& location, const std::string& expr) = 0; virtual void assign(const std::string& location, const Data& data) = 0; + +protected: + Interpreter* _interpreter; + std::string _sessionId; + std::string _name; + }; class DataModel { diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index 5000498..6e34e07 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -32,6 +32,7 @@ Interpreter::Interpreter() : Arabica::SAX2DOM::Parser() { _lastRunOnMainThread = 0; _thread = NULL; _sendQueue = NULL; + _parentQueue = NULL; _running = false; _done = false; @@ -164,7 +165,8 @@ void Interpreter::init() { Interpreter::~Interpreter() { if (_thread) { _running = false; - _externalQueue.push(Event()); + Event event; + _externalQueue.push(event); _thread->join(); delete(_thread); } @@ -445,6 +447,7 @@ void Interpreter::mainEventLoop() { } Event externalEvent = _externalQueue.pop(); + externalEvent.type = Event::EXTERNAL; // make sure it is set to external if (!_running) exitInterpreter(); @@ -679,8 +682,8 @@ void Interpreter::delayedSend(void* userdata, std::string eventName) { if (boost::iequals(sendReq.target, "#_parent")) { // send to parent scxml session - if (INSTANCE->_invoker) { - INSTANCE->_invoker.sendToParent(sendReq); + if (INSTANCE->_parentQueue != NULL) { + INSTANCE->_parentQueue->push(sendReq); } else { LOG(ERROR) << "Can not send to parent, we were not invoked" << std::endl; } @@ -794,6 +797,9 @@ void Interpreter::invoke(const Arabica::DOM::Node& element) { Invoker invoker(Factory::createInvoker(invokeReq.type, this)); if (invoker) { tthread::lock_guard lock(_mutex); + invoker.setInvokeId(invokeReq.invokeid); + invoker.setType(invokeReq.type); + invoker.setInterpreter(this); _invokers[invokeReq.invokeid] = invoker; LOG(INFO) << "Added invoker " << invokeReq.type << " at " << invokeReq.invokeid; invoker.invoke(invokeReq); @@ -1827,6 +1833,9 @@ void Interpreter::setupIOProcessors() { std::map::iterator ioProcIter = Factory::getInstance()->_ioProcessors.begin(); while(ioProcIter != Factory::getInstance()->_ioProcessors.end()) { _ioProcessors[ioProcIter->first] = Factory::createIOProcessor(ioProcIter->first, this); + _ioProcessors[ioProcIter->first].setType(ioProcIter->first); + _ioProcessors[ioProcIter->first].setInterpreter(this); + if (_dataModel) { try { _dataModel.registerIOProcessor(ioProcIter->first, _ioProcessors[ioProcIter->first]); diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h index 96667c4..61d09e0 100644 --- a/src/uscxml/Interpreter.h +++ b/src/uscxml/Interpreter.h @@ -82,15 +82,13 @@ public: URL getBaseURI() { return _baseURI; } + bool toAbsoluteURI(URL& uri); DataModel getDataModel() { return _dataModel; } - Invoker getInvoker() { - return _invoker; - } - void setInvoker(const Invoker& invoker) { - _invoker = invoker; + void setParentQueue(uscxml::concurrency::BlockingQueue* parentQueue) { + _parentQueue = parentQueue; } std::string getNSPrefix() { return _nsPrefix; @@ -181,11 +179,10 @@ protected: std::list _internalQueue; uscxml::concurrency::BlockingQueue _externalQueue; + uscxml::concurrency::BlockingQueue* _parentQueue; DelayedEventQueue* _sendQueue; - Invoker _invoker; static URL toBaseURI(const URL& url); - bool toAbsoluteURI(URL& uri); void microstep(const Arabica::XPath::NodeSet& enabledTransitions); void exitStates(const Arabica::XPath::NodeSet& enabledTransitions); diff --git a/src/uscxml/Message.h b/src/uscxml/Message.h index c241b78..a006ff6 100644 --- a/src/uscxml/Message.h +++ b/src/uscxml/Message.h @@ -54,9 +54,9 @@ protected: class Event : public Data { public: enum Type { - PLATFORM, - INTERNAL, - EXTERNAL + INTERNAL = 1, + EXTERNAL = 2, + PLATFORM = 3 }; Event() : type(INTERNAL) {} diff --git a/src/uscxml/concurrency/BlockingQueue.h b/src/uscxml/concurrency/BlockingQueue.h index 3d45720..f318ccf 100644 --- a/src/uscxml/concurrency/BlockingQueue.h +++ b/src/uscxml/concurrency/BlockingQueue.h @@ -14,13 +14,13 @@ public: virtual ~BlockingQueue() { } - void push(T elem) { + virtual void push(T& elem) { tthread::lock_guard lock(_mutex); _queue.push_back(elem); _cond.notify_all(); } - T pop() { + virtual T pop() { tthread::lock_guard lock(_mutex); while (_queue.empty()) { _cond.wait(_mutex); @@ -30,7 +30,7 @@ public: return ret; } - bool isEmpty() { + virtual bool isEmpty() { tthread::lock_guard lock(_mutex); return _queue.empty(); } diff --git a/src/uscxml/debug/SCXMLDotWriter.h b/src/uscxml/debug/SCXMLDotWriter.h index 0a3c2dc..e6e2215 100644 --- a/src/uscxml/debug/SCXMLDotWriter.h +++ b/src/uscxml/debug/SCXMLDotWriter.h @@ -35,7 +35,6 @@ public: static std::string getPrefix(); static std::string dotEscape(const std::string& text); - Interpreter* _interpreter; std::set _knownIds; static int _indentation; }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp index 303b7d1..4c6c23e 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp @@ -1,5 +1,8 @@ #include "uscxml/Common.h" #include "JSCDataModel.h" +#include "dom/JSCDOM.h" +#include "dom/JSCDocument.h" + #include "uscxml/Message.h" #include @@ -22,14 +25,27 @@ JSCDataModel::JSCDataModel() { boost::shared_ptr JSCDataModel::create(Interpreter* interpreter) { boost::shared_ptr dm = boost::shared_ptr(new JSCDataModel()); + + dm->_ctx = JSGlobalContextCreate(NULL); dm->_interpreter = interpreter; + Arabica::DOM::JSCDOM* dom = new Arabica::DOM::JSCDOM(); + // dom->interpreter = interpreter; + dom->xpath = new Arabica::XPath::XPath(); + dom->xpath->setNamespaceContext(interpreter->getNSContext()); + + dm->setName(interpreter->getName()); dm->setSessionId(interpreter->getSessionId()); dm->eval("_ioprocessors = {};"); - dm->_ctx = JSGlobalContextCreate(NULL); + Arabica::DOM::JSCDocument::JSCDocumentPrivate* privData = new Arabica::DOM::JSCDocument::JSCDocumentPrivate(); + privData->arabicaThis = new Arabica::DOM::Document(interpreter->getDocument()); + privData->dom = dom; + + JSObjectRef documentObject = JSObjectMake(dm->_ctx, Arabica::DOM::JSCDocument::getTmpl(), privData); JSObjectRef globalObject = JSContextGetGlobalObject(dm->_ctx); + JSObjectSetProperty(dm->_ctx, globalObject, JSStringCreateWithUTF8CString("document"), documentObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, NULL); return dm; } @@ -47,7 +63,7 @@ void JSCDataModel::setName(const std::string& name) { } JSCDataModel::~JSCDataModel() { -// JSGlobalContextRelease(_ctx); + JSGlobalContextRelease(_ctx); } void JSCDataModel::pushContext() { @@ -60,9 +76,84 @@ void JSCDataModel::initialize() { } void JSCDataModel::setEvent(const Event& event) { + LOG(ERROR) << "setEvent not implemented in JSC"; } Data JSCDataModel::getStringAsData(const std::string& content) { + JSValueRef result = evalAsValue(content); + Data data = getValueAsData(result); + return data; +} + +Data JSCDataModel::getValueAsData(const JSValueRef value) { + Data data; + JSValueRef exception = NULL; + switch(JSValueGetType(_ctx, value)) { + case kJSTypeUndefined: + LOG(ERROR) << "IsUndefined is unimplemented"; + break; + case kJSTypeNull: + LOG(ERROR) << "IsNull is unimplemented"; + break; + case kJSTypeBoolean: + data.atom = (JSValueToBoolean(_ctx, value) ? "true" : "false"); + break; + case kJSTypeNumber: + data.atom = toStr(JSValueToNumber(_ctx, value, &exception)); + if (exception) + handleException(exception); + break; + case kJSTypeString: { + JSStringRef stringValue = JSValueToStringCopy( _ctx, value, &exception); + if (exception) + handleException(exception); + + char* buf = (char*)malloc(JSStringGetMaximumUTF8CStringSize(stringValue)); + JSStringGetUTF8CString(stringValue, buf, sizeof(buf)); + data.atom = std::string(buf, sizeof(buf)); + free(buf); + break; + } + case kJSTypeObject: { + JSObjectRef objValue = JSValueToObject(_ctx, value, &exception); + if (exception) + handleException(exception); + std::set propertySet; + JSPropertyNameArrayRef properties = JSObjectCopyPropertyNames(_ctx, objValue); + size_t paramCount = JSPropertyNameArrayGetCount(properties); + bool isArray = true; + for (size_t i = 0; i < paramCount; i++) { + JSStringRef stringValue = JSPropertyNameArrayGetNameAtIndex(properties, i); + char* buf = (char*)malloc(JSStringGetMaximumUTF8CStringSize(stringValue)); + JSStringGetUTF8CString(stringValue, buf, sizeof(buf)); + std::string property(buf, sizeof(buf)); + if (!isNumeric(property.c_str(), 10)) + isArray = false; + propertySet.insert(property); + free(buf); + } + std::set::iterator propIter = propertySet.begin(); + while(propIter != propertySet.end()) { + if (isArray) { + JSValueRef nestedValue = JSObjectGetPropertyAtIndex(_ctx, objValue, strTo(*propIter), &exception); + if (exception) + handleException(exception); + data.array.push_back(getValueAsData(nestedValue)); + } else { + JSStringRef jsString = JSStringCreateWithUTF8CString(propIter->c_str()); + JSValueRef nestedValue = JSObjectGetProperty(_ctx, objValue, jsString, &exception); + JSStringRelease(jsString); + if (exception) + handleException(exception); + data.compound[*propIter] = getValueAsData(nestedValue); + } + propIter++; + } + + break; + } + } + return data; } bool JSCDataModel::validate(const std::string& location, const std::string& schema) { @@ -70,21 +161,64 @@ bool JSCDataModel::validate(const std::string& location, const std::string& sche } uint32_t JSCDataModel::getLength(const std::string& expr) { + LOG(ERROR) << "I am not sure whether getLength() works :("; + JSValueRef result = evalAsValue(expr); + JSValueRef exception = NULL; + double length = JSValueToNumber(_ctx, result, &exception); + if (exception) + handleException(exception); + + return (uint32_t)length; } void JSCDataModel::eval(const std::string& expr) { + evalAsValue(expr); } bool JSCDataModel::evalAsBool(const std::string& expr) { + JSValueRef result = evalAsValue(expr); + return JSValueToBoolean(_ctx, result); } std::string JSCDataModel::evalAsString(const std::string& expr) { + JSValueRef result = evalAsValue(expr); + JSValueRef exception = NULL; + JSStringRef stringValue = JSValueToStringCopy( _ctx, result, &exception); + if (exception) + handleException(exception); + + char* data = (char*)malloc(JSStringGetMaximumUTF8CStringSize(stringValue)); + JSStringGetUTF8CString(stringValue, data, sizeof(data)); + std::string retString(data, sizeof(data)); + + JSStringRelease(stringValue); + free(data); + return retString; +} + +JSValueRef JSCDataModel::evalAsValue(const std::string& expr) { + JSStringRef scriptJS = JSStringCreateWithUTF8CString(expr.c_str()); + JSValueRef exception = NULL; + JSValueRef result = JSEvaluateScript(_ctx, scriptJS, NULL, NULL, 0, &exception); + if (exception) + handleException(exception); + + JSStringRelease(scriptJS); + return result; } void JSCDataModel::assign(const std::string& location, const Data& data) { + std::stringstream ssJSON; + ssJSON << data; + assign(location, ssJSON.str()); } void JSCDataModel::assign(const std::string& location, const std::string& expr) { + evalAsValue(location + " = " + expr); +} + +void JSCDataModel::handleException(JSValueRef exception) { + assert(false); } } \ No newline at end of file diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h index c223d4f..5662d42 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h @@ -46,19 +46,23 @@ public: virtual void assign(const std::string& location, const Data& data); virtual Data getStringAsData(const std::string& content); + virtual Data getValueAsData(const JSValueRef value); virtual std::string evalAsString(const std::string& expr); virtual bool evalAsBool(const std::string& expr); + virtual JSValueRef evalAsValue(const std::string& expr); protected: + void handleException(JSValueRef exception); + Interpreter* _interpreter; std::string _sessionId; std::string _name; Event _event; - JSContextRef _ctx; + JSGlobalContextRef _ctx; }; #ifdef BUILD_AS_PLUGINS diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp new file mode 100644 index 0000000..4259b86 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp @@ -0,0 +1,60 @@ +#include "JSCAttr.h" +#include "JSCElement.h" +#include "JSCNode.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCAttr::staticValues[] = { + { "name", nameAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "specified", specifiedAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "value", valueAttrGetter, valueAttrSetter, kJSPropertyAttributeDontDelete }, + { "ownerElement", ownerElementAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCAttr::staticFunctions[] = { + { 0, 0, 0 } +}; + +JSValueRef JSCAttr::nameAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCAttrPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getName().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +JSValueRef JSCAttr::specifiedAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCAttrPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + + return JSValueMakeBoolean(ctx, privData->arabicaThis->getSpecified()); +} + +JSValueRef JSCAttr::valueAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCAttrPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getValue().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +JSValueRef JSCAttr::ownerElementAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCAttrPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + Arabica::DOM::Element* arbaicaRet = new Arabica::DOM::Element(privData->arabicaThis->getOwnerElement()); + + struct JSCElement::JSCElementPrivate* retPrivData = new JSCElement::JSCElementPrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = arbaicaRet; + + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, JSCElement::getTmpl(), retPrivData); + return arbaicaRetObj; + +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h new file mode 100644 index 0000000..f7c3fec --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.h @@ -0,0 +1,72 @@ +/* + This file is part of the Arabica 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 JSCAttr_h +#define JSCAttr_h + +#include "DOM/Node.hpp" +#include "JSCNode.h" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCAttr { +public: + struct JSCAttrPrivate { + JSCDOM* dom; + Arabica::DOM::Attr* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCAttrPrivate); + + + static JSValueRef nameAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef specifiedAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef valueAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static bool valueAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); + static JSValueRef ownerElementAttrGetter(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 // JSCAttr_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.cpp new file mode 100644 index 0000000..c735084 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.cpp @@ -0,0 +1,18 @@ +#include "JSCCDATASection.h" +#include "JSCText.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCCDATASection::staticValues[] = { + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCCDATASection::staticFunctions[] = { + { 0, 0, 0 } +}; + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h new file mode 100644 index 0000000..b4cd391 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCDATASection.h @@ -0,0 +1,67 @@ +/* + This file is part of the Arabica 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 JSCCDATASection_h +#define JSCCDATASection_h + +#include "DOM/Node.hpp" +#include "JSCText.h" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCCDATASection { +public: + struct JSCCDATASectionPrivate { + JSCDOM* dom; + Arabica::DOM::CDATASection* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCCDATASectionPrivate); + + + + + 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 // JSCCDATASection_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp new file mode 100644 index 0000000..5108625 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp @@ -0,0 +1,40 @@ +#include "JSCCharacterData.h" +#include "JSCNode.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCCharacterData::staticValues[] = { + { "data", dataAttrGetter, dataAttrSetter, kJSPropertyAttributeDontDelete }, + { "length", lengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCCharacterData::staticFunctions[] = { + { "substringData", substringDataCallback, kJSPropertyAttributeDontDelete }, + { "appendData", appendDataCallback, kJSPropertyAttributeDontDelete }, + { "insertData", insertDataCallback, kJSPropertyAttributeDontDelete }, + { "deleteData", deleteDataCallback, kJSPropertyAttributeDontDelete }, + { "replaceData", replaceDataCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCCharacterData::dataAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCCharacterDataPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getData().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +JSValueRef JSCCharacterData::lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCCharacterDataPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + + return JSValueMakeNumber(ctx, privData->arabicaThis->getLength()); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h new file mode 100644 index 0000000..1289143 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.h @@ -0,0 +1,75 @@ +/* + This file is part of the Arabica 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 JSCCharacterData_h +#define JSCCharacterData_h + +#include "DOM/Node.hpp" +#include "JSCNode.h" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCCharacterData { +public: + struct JSCCharacterDataPrivate { + JSCDOM* dom; + Arabica::DOM::CharacterData* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCCharacterDataPrivate); + + static JSValueRef substringDataCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef appendDataCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef insertDataCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef deleteDataCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef replaceDataCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + static JSValueRef dataAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static bool dataAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, 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 // JSCCharacterData_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.cpp new file mode 100644 index 0000000..b9aa25c --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.cpp @@ -0,0 +1,18 @@ +#include "JSCCharacterData.h" +#include "JSCComment.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCComment::staticValues[] = { + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCComment::staticFunctions[] = { + { 0, 0, 0 } +}; + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h new file mode 100644 index 0000000..c311c49 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCComment.h @@ -0,0 +1,67 @@ +/* + This file is part of the Arabica 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 JSCComment_h +#define JSCComment_h + +#include "DOM/Node.hpp" +#include "JSCCharacterData.h" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCComment { +public: + struct JSCCommentPrivate { + JSCDOM* dom; + Arabica::DOM::Comment* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCCommentPrivate); + + + + + 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 // JSCComment_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.cpp index f42c9bd..bd66f8c 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.cpp @@ -1,9 +1,11 @@ #include "JSCDOM.h" -namespace uscxml { +namespace Arabica { +namespace DOM { JSCDOM::JSCDOM() { } +} } \ No newline at end of file diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h index 248d057..af946a9 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h @@ -7,21 +7,22 @@ #define JSC_DESTRUCTOR(type) \ static void jsDestructor(JSObjectRef object) { \ type* thing = static_cast(JSObjectGetPrivate(object)); \ +delete thing->arabicaThis; \ delete thing; \ } -namespace uscxml { +namespace Arabica { +namespace DOM { class JSCDOM { public: JSCDOM(); virtual ~JSCDOM() { }; - Interpreter* interpreter; Arabica::XPath::XPath* xpath; }; } - +} #endif /* end of include guard: JSCDOM_H_1RC5LCG8 */ diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.cpp new file mode 100644 index 0000000..ee42a3e --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.cpp @@ -0,0 +1,20 @@ +#include "JSCDOMImplementation.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCDOMImplementation::staticValues[] = { + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCDOMImplementation::staticFunctions[] = { + { "hasFeature", hasFeatureCallback, kJSPropertyAttributeDontDelete }, + { "createDocumentType", createDocumentTypeCallback, kJSPropertyAttributeDontDelete }, + { "createDocument", createDocumentCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.h new file mode 100644 index 0000000..033f2c1 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.h @@ -0,0 +1,69 @@ +/* + This file is part of the Arabica 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 JSCDOMImplementation_h +#define JSCDOMImplementation_h + +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCDOMImplementation { +public: + struct JSCDOMImplementationPrivate { + JSCDOM* dom; + Arabica::DOM::DOMImplementation* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCDOMImplementationPrivate); + + static JSValueRef hasFeatureCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef createDocumentTypeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef createDocumentCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + + + static JSStaticValue staticValues[]; + static JSStaticFunction staticFunctions[]; + + static JSClassRef Tmpl; + static JSClassRef getTmpl() { + if (Tmpl == NULL) { + JSClassDefinition classDef = kJSClassDefinitionEmpty; + classDef.staticValues = staticValues; + classDef.staticFunctions = staticFunctions; + classDef.finalize = jsDestructor; + + Tmpl = JSClassCreate(&classDef); + JSClassRetain(Tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // JSCDOMImplementation_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp new file mode 100644 index 0000000..36bb243 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp @@ -0,0 +1,78 @@ +#include "JSCDOMImplementation.h" +#include "JSCDocument.h" +#include "JSCDocumentType.h" +#include "JSCElement.h" +#include "JSCNode.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCDocument::staticValues[] = { + { "doctype", doctypeAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "implementation", implementationAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "documentElement", documentElementAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCDocument::staticFunctions[] = { + { "createElement", createElementCallback, kJSPropertyAttributeDontDelete }, + { "createDocumentFragment", createDocumentFragmentCallback, kJSPropertyAttributeDontDelete }, + { "createTextNode", createTextNodeCallback, kJSPropertyAttributeDontDelete }, + { "createComment", createCommentCallback, kJSPropertyAttributeDontDelete }, + { "createCDATASection", createCDATASectionCallback, kJSPropertyAttributeDontDelete }, + { "createProcessingInstruction", createProcessingInstructionCallback, kJSPropertyAttributeDontDelete }, + { "createAttribute", createAttributeCallback, kJSPropertyAttributeDontDelete }, + { "createEntityReference", createEntityReferenceCallback, kJSPropertyAttributeDontDelete }, + { "getElementsByTagName", getElementsByTagNameCallback, kJSPropertyAttributeDontDelete }, + { "importNode", importNodeCallback, kJSPropertyAttributeDontDelete }, + { "createElementNS", createElementNSCallback, kJSPropertyAttributeDontDelete }, + { "createAttributeNS", createAttributeNSCallback, kJSPropertyAttributeDontDelete }, + { "getElementsByTagNameNS", getElementsByTagNameNSCallback, kJSPropertyAttributeDontDelete }, + { "getElementById", getElementByIdCallback, kJSPropertyAttributeDontDelete }, + { "evaluate", evaluateCustomCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCDocument::doctypeAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCDocumentPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + Arabica::DOM::DocumentType* arbaicaRet = new Arabica::DOM::DocumentType(privData->arabicaThis->getDoctype()); + + struct JSCDocumentType::JSCDocumentTypePrivate* retPrivData = new JSCDocumentType::JSCDocumentTypePrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = arbaicaRet; + + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, JSCDocumentType::getTmpl(), retPrivData); + return arbaicaRetObj; + +} + +JSValueRef JSCDocument::implementationAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCDocumentPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + Arabica::DOM::DOMImplementation* arbaicaRet = new Arabica::DOM::DOMImplementation(privData->arabicaThis->getImplementation()); + + struct JSCDOMImplementation::JSCDOMImplementationPrivate* retPrivData = new JSCDOMImplementation::JSCDOMImplementationPrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = arbaicaRet; + + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, JSCDOMImplementation::getTmpl(), retPrivData); + return arbaicaRetObj; + +} + +JSValueRef JSCDocument::documentElementAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCDocumentPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + Arabica::DOM::Element* arbaicaRet = new Arabica::DOM::Element(privData->arabicaThis->getDocumentElement()); + + struct JSCElement::JSCElementPrivate* retPrivData = new JSCElement::JSCElementPrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = arbaicaRet; + + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, JSCElement::getTmpl(), retPrivData); + return arbaicaRetObj; + +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h new file mode 100644 index 0000000..c1f052e --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.h @@ -0,0 +1,85 @@ +/* + This file is part of the Arabica 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 JSCDocument_h +#define JSCDocument_h + +#include "DOM/Node.hpp" +#include "JSCNode.h" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCDocument { +public: + struct JSCDocumentPrivate { + JSCDOM* dom; + Arabica::DOM::Document* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCDocumentPrivate); + + static JSValueRef createElementCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef createDocumentFragmentCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef createTextNodeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef createCommentCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef createCDATASectionCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef createProcessingInstructionCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef createAttributeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef createEntityReferenceCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef getElementsByTagNameCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef importNodeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef createElementNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef createAttributeNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef getElementsByTagNameNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef getElementByIdCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef evaluateCustomCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + 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 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 // JSCDocument_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.cpp new file mode 100644 index 0000000..77203a7 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.cpp @@ -0,0 +1,18 @@ +#include "JSCDocumentFragment.h" +#include "JSCNode.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCDocumentFragment::staticValues[] = { + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCDocumentFragment::staticFunctions[] = { + { 0, 0, 0 } +}; + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h new file mode 100644 index 0000000..4c6f46e --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentFragment.h @@ -0,0 +1,67 @@ +/* + This file is part of the Arabica 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 JSCDocumentFragment_h +#define JSCDocumentFragment_h + +#include "DOM/Node.hpp" +#include "JSCNode.h" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCDocumentFragment { +public: + struct JSCDocumentFragmentPrivate { + JSCDOM* dom; + Arabica::DOM::DocumentFragment* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCDocumentFragmentPrivate); + + + + + 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 // JSCDocumentFragment_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.cpp new file mode 100644 index 0000000..bbfa35c --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.cpp @@ -0,0 +1,87 @@ +#include "JSCDocumentType.h" +#include "JSCNamedNodeMap.h" +#include "JSCNode.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCDocumentType::staticValues[] = { + { "name", nameAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "entities", entitiesAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "notations", notationsAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "publicId", publicIdAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "systemId", systemIdAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "internalSubset", internalSubsetAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCDocumentType::staticFunctions[] = { + { 0, 0, 0 } +}; + +JSValueRef JSCDocumentType::nameAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCDocumentTypePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getName().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +JSValueRef JSCDocumentType::entitiesAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCDocumentTypePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + Arabica::DOM::NamedNodeMap* arbaicaRet = new Arabica::DOM::NamedNodeMap(privData->arabicaThis->getEntities()); + + struct JSCNamedNodeMap::JSCNamedNodeMapPrivate* retPrivData = new JSCNamedNodeMap::JSCNamedNodeMapPrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = arbaicaRet; + + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, JSCNamedNodeMap::getTmpl(), retPrivData); + return arbaicaRetObj; + +} + +JSValueRef JSCDocumentType::notationsAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCDocumentTypePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + Arabica::DOM::NamedNodeMap* arbaicaRet = new Arabica::DOM::NamedNodeMap(privData->arabicaThis->getNotations()); + + struct JSCNamedNodeMap::JSCNamedNodeMapPrivate* retPrivData = new JSCNamedNodeMap::JSCNamedNodeMapPrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = arbaicaRet; + + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, JSCNamedNodeMap::getTmpl(), retPrivData); + return arbaicaRetObj; + +} + +JSValueRef JSCDocumentType::publicIdAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCDocumentTypePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getPublicId().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +JSValueRef JSCDocumentType::systemIdAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCDocumentTypePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getSystemId().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +JSValueRef JSCDocumentType::internalSubsetAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCDocumentTypePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getInternalSubset().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h new file mode 100644 index 0000000..875b1f7 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.h @@ -0,0 +1,73 @@ +/* + This file is part of the Arabica 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 JSCDocumentType_h +#define JSCDocumentType_h + +#include "DOM/Node.hpp" +#include "JSCNode.h" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCDocumentType { +public: + struct JSCDocumentTypePrivate { + JSCDOM* dom; + Arabica::DOM::DocumentType* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCDocumentTypePrivate); + + + static JSValueRef nameAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef entitiesAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef notationsAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef publicIdAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef systemIdAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef internalSubsetAttrGetter(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 // JSCDocumentType_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.cpp new file mode 100644 index 0000000..2ff24d7 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.cpp @@ -0,0 +1,43 @@ +#include "JSCElement.h" +#include "JSCNode.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCElement::staticValues[] = { + { "tagName", tagNameAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCElement::staticFunctions[] = { + { "getAttribute", getAttributeCallback, kJSPropertyAttributeDontDelete }, + { "setAttribute", setAttributeCallback, kJSPropertyAttributeDontDelete }, + { "removeAttribute", removeAttributeCallback, kJSPropertyAttributeDontDelete }, + { "getAttributeNode", getAttributeNodeCallback, kJSPropertyAttributeDontDelete }, + { "setAttributeNode", setAttributeNodeCallback, kJSPropertyAttributeDontDelete }, + { "removeAttributeNode", removeAttributeNodeCallback, kJSPropertyAttributeDontDelete }, + { "getElementsByTagName", getElementsByTagNameCallback, kJSPropertyAttributeDontDelete }, + { "getAttributeNS", getAttributeNSCallback, kJSPropertyAttributeDontDelete }, + { "setAttributeNS", setAttributeNSCallback, kJSPropertyAttributeDontDelete }, + { "removeAttributeNS", removeAttributeNSCallback, kJSPropertyAttributeDontDelete }, + { "getAttributeNodeNS", getAttributeNodeNSCallback, kJSPropertyAttributeDontDelete }, + { "setAttributeNodeNS", setAttributeNodeNSCallback, kJSPropertyAttributeDontDelete }, + { "getElementsByTagNameNS", getElementsByTagNameNSCallback, kJSPropertyAttributeDontDelete }, + { "hasAttribute", hasAttributeCallback, kJSPropertyAttributeDontDelete }, + { "hasAttributeNS", hasAttributeNSCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCElement::tagNameAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCElementPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getTagName().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h new file mode 100644 index 0000000..01f9f2f --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.h @@ -0,0 +1,83 @@ +/* + This file is part of the Arabica 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 JSCElement_h +#define JSCElement_h + +#include "DOM/Node.hpp" +#include "JSCNode.h" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCElement { +public: + struct JSCElementPrivate { + JSCDOM* dom; + Arabica::DOM::Element* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCElementPrivate); + + static JSValueRef getAttributeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setAttributeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef removeAttributeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef getAttributeNodeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setAttributeNodeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef removeAttributeNodeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef getElementsByTagNameCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef getAttributeNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setAttributeNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef removeAttributeNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef getAttributeNodeNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setAttributeNodeNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef getElementsByTagNameNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef hasAttributeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef hasAttributeNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + static JSValueRef tagNameAttrGetter(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 // JSCElement_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.cpp new file mode 100644 index 0000000..55aee54 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.cpp @@ -0,0 +1,48 @@ +#include "JSCEntity.h" +#include "JSCNode.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCEntity::staticValues[] = { + { "publicId", publicIdAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "systemId", systemIdAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "notationName", notationNameAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCEntity::staticFunctions[] = { + { 0, 0, 0 } +}; + +JSValueRef JSCEntity::publicIdAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCEntityPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getPublicId().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +JSValueRef JSCEntity::systemIdAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCEntityPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getSystemId().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +JSValueRef JSCEntity::notationNameAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCEntityPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getNotationName().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h new file mode 100644 index 0000000..79d8ddf --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntity.h @@ -0,0 +1,70 @@ +/* + This file is part of the Arabica 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 JSCEntity_h +#define JSCEntity_h + +#include "DOM/Node.hpp" +#include "JSCNode.h" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCEntity { +public: + struct JSCEntityPrivate { + JSCDOM* dom; + Arabica::DOM::Entity* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCEntityPrivate); + + + static JSValueRef publicIdAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef systemIdAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef notationNameAttrGetter(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 // JSCEntity_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.cpp new file mode 100644 index 0000000..a8aac23 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.cpp @@ -0,0 +1,18 @@ +#include "JSCEntityReference.h" +#include "JSCNode.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCEntityReference::staticValues[] = { + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCEntityReference::staticFunctions[] = { + { 0, 0, 0 } +}; + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h new file mode 100644 index 0000000..48a660d --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCEntityReference.h @@ -0,0 +1,67 @@ +/* + This file is part of the Arabica 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 JSCEntityReference_h +#define JSCEntityReference_h + +#include "DOM/Node.hpp" +#include "JSCNode.h" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCEntityReference { +public: + struct JSCEntityReferencePrivate { + JSCDOM* dom; + Arabica::DOM::EntityReference* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCEntityReferencePrivate); + + + + + 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 // JSCEntityReference_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.cpp new file mode 100644 index 0000000..49ef0c1 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.cpp @@ -0,0 +1,31 @@ +#include "JSCNamedNodeMap.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCNamedNodeMap::staticValues[] = { + { "length", lengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCNamedNodeMap::staticFunctions[] = { + { "getNamedItem", getNamedItemCallback, kJSPropertyAttributeDontDelete }, + { "setNamedItem", setNamedItemCallback, kJSPropertyAttributeDontDelete }, + { "removeNamedItem", removeNamedItemCallback, kJSPropertyAttributeDontDelete }, + { "item", itemCallback, kJSPropertyAttributeDontDelete }, + { "getNamedItemNS", getNamedItemNSCallback, kJSPropertyAttributeDontDelete }, + { "setNamedItemNS", setNamedItemNSCallback, kJSPropertyAttributeDontDelete }, + { "removeNamedItemNS", removeNamedItemNSCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCNamedNodeMap::lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNamedNodeMapPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + + return JSValueMakeNumber(ctx, privData->arabicaThis->getLength()); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.h new file mode 100644 index 0000000..b95796a --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.h @@ -0,0 +1,74 @@ +/* + This file is part of the Arabica 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 JSCNamedNodeMap_h +#define JSCNamedNodeMap_h + +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCNamedNodeMap { +public: + struct JSCNamedNodeMapPrivate { + JSCDOM* dom; + Arabica::DOM::NamedNodeMap* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCNamedNodeMapPrivate); + + static JSValueRef getNamedItemCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setNamedItemCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef removeNamedItemCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef itemCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef getNamedItemNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef setNamedItemNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef removeNamedItemNSCallback(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 // JSCNamedNodeMap_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp index 7d38f9f..ca1ca41 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp @@ -1,41 +1,40 @@ +#include "JSCDocument.h" +#include "JSCNamedNodeMap.h" #include "JSCNode.h" -#include +#include "JSCNodeList.h" -namespace uscxml { +namespace Arabica { +namespace DOM { -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 }, + { "nodeName", nodeNameAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "nodeValue", nodeValueAttrGetter, nodeValueAttrSetter, kJSPropertyAttributeDontDelete }, + { "nodeType", nodeTypeAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "parentNode", parentNodeAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "childNodes", childNodesAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "firstChild", firstChildAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "lastChild", lastChildAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "previousSibling", previousSiblingAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "nextSibling", nextSiblingAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "attributes", attributesAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "ownerDocument", ownerDocumentAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "namespaceURI", namespaceURIAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "prefix", prefixAttrGetter, prefixAttrSetter, kJSPropertyAttributeDontDelete }, + { "localName", localNameAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { "ELEMENT_NODE", ELEMENT_NODEConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "ATTRIBUTE_NODE", ATTRIBUTE_NODEConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "TEXT_NODE", TEXT_NODEConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "CDATA_SECTION_NODE", CDATA_SECTION_NODEConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "ENTITY_REFERENCE_NODE", ENTITY_REFERENCE_NODEConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "ENTITY_NODE", ENTITY_NODEConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "PROCESSING_INSTRUCTION_NODE", PROCESSING_INSTRUCTION_NODEConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "COMMENT_NODE", COMMENT_NODEConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "DOCUMENT_NODE", DOCUMENT_NODEConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "DOCUMENT_TYPE_NODE", DOCUMENT_TYPE_NODEConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "DOCUMENT_FRAGMENT_NODE", DOCUMENT_FRAGMENT_NODEConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "NOTATION_NODE", NOTATION_NODEConstGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, { 0, 0, 0, 0 } }; @@ -49,12 +48,163 @@ JSStaticFunction JSCNode::staticFunctions[] = { { "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 +JSValueRef JSCNode::nodeNameAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNodePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getNodeName().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +JSValueRef JSCNode::nodeValueAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNodePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getNodeValue().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +JSValueRef JSCNode::nodeTypeAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNodePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + + return JSValueMakeNumber(ctx, privData->arabicaThis->getNodeType()); +} + +JSValueRef JSCNode::parentNodeAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNodePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->arabicaThis->getParentNode()); + + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = arbaicaRet; + + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, JSCNode::getTmpl(), retPrivData); + return arbaicaRetObj; + +} + +JSValueRef JSCNode::childNodesAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNodePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + Arabica::DOM::NodeList* arbaicaRet = new Arabica::DOM::NodeList(privData->arabicaThis->getChildNodes()); + + struct JSCNodeList::JSCNodeListPrivate* retPrivData = new JSCNodeList::JSCNodeListPrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = arbaicaRet; + + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, JSCNodeList::getTmpl(), retPrivData); + return arbaicaRetObj; + +} + +JSValueRef JSCNode::firstChildAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNodePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->arabicaThis->getFirstChild()); + + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = arbaicaRet; + + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, JSCNode::getTmpl(), retPrivData); + return arbaicaRetObj; + +} + +JSValueRef JSCNode::lastChildAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNodePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->arabicaThis->getLastChild()); + + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = arbaicaRet; + + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, JSCNode::getTmpl(), retPrivData); + return arbaicaRetObj; + +} + +JSValueRef JSCNode::previousSiblingAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNodePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->arabicaThis->getPreviousSibling()); + + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = arbaicaRet; + + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, JSCNode::getTmpl(), retPrivData); + return arbaicaRetObj; + +} + +JSValueRef JSCNode::nextSiblingAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNodePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->arabicaThis->getNextSibling()); + + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = arbaicaRet; + + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, JSCNode::getTmpl(), retPrivData); + return arbaicaRetObj; + +} + +JSValueRef JSCNode::attributesAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNodePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + Arabica::DOM::NamedNodeMap* arbaicaRet = new Arabica::DOM::NamedNodeMap(privData->arabicaThis->getAttributes()); + + struct JSCNamedNodeMap::JSCNamedNodeMapPrivate* retPrivData = new JSCNamedNodeMap::JSCNamedNodeMapPrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = arbaicaRet; + + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, JSCNamedNodeMap::getTmpl(), retPrivData); + return arbaicaRetObj; + +} + +JSValueRef JSCNode::ownerDocumentAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNodePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + Arabica::DOM::Document* arbaicaRet = new Arabica::DOM::Document(privData->arabicaThis->getOwnerDocument()); + + struct JSCDocument::JSCDocumentPrivate* retPrivData = new JSCDocument::JSCDocumentPrivate(); + retPrivData->dom = privData->dom; + retPrivData->arabicaThis = arbaicaRet; + + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, JSCDocument::getTmpl(), retPrivData); + return arbaicaRetObj; + +} + +JSValueRef JSCNode::namespaceURIAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNodePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getNamespaceURI().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +JSValueRef JSCNode::prefixAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNodePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getPrefix().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +JSValueRef JSCNode::localNameAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNodePrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getLocalName().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp.old b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp.old new file mode 100644 index 0000000..7d38f9f --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp.old @@ -0,0 +1,60 @@ +#include "JSCNode.h" +#include + +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 677a63b..f99d561 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h @@ -1,202 +1,81 @@ -#ifndef JSCNODE_H_6BAK1S3C -#define JSCNODE_H_6BAK1S3C +/* + This file is part of the Arabica open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! -#include "JSCDOM.h" + 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. -namespace uscxml { + 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 JSCNode_h +#define JSCNode_h + +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { 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); - } + struct JSCNodePrivate { + JSCDOM* dom; + Arabica::DOM::Node* arabicaThis; + }; - 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; - } + JSC_DESTRUCTOR(JSCNodePrivate); - 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 insertBeforeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef replaceChildCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef removeChildCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef appendChildCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef hasChildNodesCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef cloneNodeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef normalizeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef isSupportedCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef hasAttributesCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); - 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); - } + static JSValueRef nodeNameAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef nodeValueAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static bool nodeValueAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); + static JSValueRef nodeTypeAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef parentNodeAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef childNodesAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef firstChildAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef lastChildAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef previousSiblingAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef nextSiblingAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef attributesAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef ownerDocumentAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef namespaceURIAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef prefixAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static bool prefixAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); + static JSValueRef localNameAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); - JSC_DESTRUCTOR(Arabica::DOM::Node); + static JSValueRef ELEMENT_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef ATTRIBUTE_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef TEXT_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef CDATA_SECTION_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef ENTITY_REFERENCE_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef ENTITY_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef PROCESSING_INSTRUCTION_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef COMMENT_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef DOCUMENT_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef DOCUMENT_TYPE_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef DOCUMENT_FRAGMENT_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef NOTATION_NODEConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); static JSStaticValue staticValues[]; static JSStaticFunction staticFunctions[]; @@ -215,9 +94,10 @@ public: return Tmpl; } + }; } +} - -#endif /* end of include guard: JSCNODE_H_6BAK1S3C */ +#endif // JSCNode_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h.old b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h.old new file mode 100644 index 0000000..677a63b --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.h.old @@ -0,0 +1,223 @@ +#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); + + 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/JSCNodeList.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.cpp new file mode 100644 index 0000000..5046dcd --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.cpp @@ -0,0 +1,25 @@ +#include "JSCNodeList.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCNodeList::staticValues[] = { + { "length", lengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCNodeList::staticFunctions[] = { + { "item", itemCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCNodeList::lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNodeListPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + + return JSValueMakeNumber(ctx, privData->arabicaThis->getLength()); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h new file mode 100644 index 0000000..6236deb --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.h @@ -0,0 +1,68 @@ +/* + This file is part of the Arabica 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 JSCNodeList_h +#define JSCNodeList_h + +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCNodeList { +public: + struct JSCNodeListPrivate { + JSCDOM* dom; + Arabica::DOM::NodeList* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCNodeListPrivate); + + 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 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 // JSCNodeList_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.cpp new file mode 100644 index 0000000..7c72faf --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.cpp @@ -0,0 +1,32 @@ +#include "JSCNodeSet.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCNodeSet::staticValues[] = { + { "size", sizeAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "empty", emptyAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCNodeSet::staticFunctions[] = { + { "toDocumentOrder", toDocumentOrderCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCNodeSet::sizeAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNodeSetPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + + return JSValueMakeNumber(ctx, privData->arabicaThis->size()); +} + +JSValueRef JSCNodeSet::emptyAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNodeSetPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + + return JSValueMakeBoolean(ctx, privData->arabicaThis->empty()); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h new file mode 100644 index 0000000..5ee0b9b --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.h @@ -0,0 +1,69 @@ +/* + This file is part of the Arabica 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 JSCNodeSet_h +#define JSCNodeSet_h + +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCNodeSet { +public: + struct JSCNodeSetPrivate { + JSCDOM* dom; + Arabica::XPath::NodeSet* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCNodeSetPrivate); + + static JSValueRef toDocumentOrderCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + static JSValueRef sizeAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef emptyAttrGetter(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 // JSCNodeSet_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.cpp new file mode 100644 index 0000000..04bb8ec --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.cpp @@ -0,0 +1,38 @@ +#include "JSCNode.h" +#include "JSCNotation.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCNotation::staticValues[] = { + { "publicId", publicIdAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "systemId", systemIdAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCNotation::staticFunctions[] = { + { 0, 0, 0 } +}; + +JSValueRef JSCNotation::publicIdAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNotationPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getPublicId().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +JSValueRef JSCNotation::systemIdAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCNotationPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getSystemId().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h new file mode 100644 index 0000000..29e7280 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNotation.h @@ -0,0 +1,69 @@ +/* + This file is part of the Arabica 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 JSCNotation_h +#define JSCNotation_h + +#include "DOM/Node.hpp" +#include "JSCNode.h" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCNotation { +public: + struct JSCNotationPrivate { + JSCDOM* dom; + Arabica::DOM::Notation* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCNotationPrivate); + + + static JSValueRef publicIdAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef systemIdAttrGetter(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 // JSCNotation_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.cpp new file mode 100644 index 0000000..a9e69e6 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.cpp @@ -0,0 +1,38 @@ +#include "JSCNode.h" +#include "JSCProcessingInstruction.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCProcessingInstruction::staticValues[] = { + { "target", targetAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "data", dataAttrGetter, dataAttrSetter, kJSPropertyAttributeDontDelete }, + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCProcessingInstruction::staticFunctions[] = { + { 0, 0, 0 } +}; + +JSValueRef JSCProcessingInstruction::targetAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCProcessingInstructionPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getTarget().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +JSValueRef JSCProcessingInstruction::dataAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCProcessingInstructionPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getData().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h new file mode 100644 index 0000000..835fb2e --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCProcessingInstruction.h @@ -0,0 +1,70 @@ +/* + This file is part of the Arabica 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 JSCProcessingInstruction_h +#define JSCProcessingInstruction_h + +#include "DOM/Node.hpp" +#include "JSCNode.h" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCProcessingInstruction { +public: + struct JSCProcessingInstructionPrivate { + JSCDOM* dom; + Arabica::DOM::ProcessingInstruction* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCProcessingInstructionPrivate); + + + static JSValueRef targetAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef dataAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static bool dataAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, 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 // JSCProcessingInstruction_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.cpp new file mode 100644 index 0000000..a0ba7df --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.cpp @@ -0,0 +1,19 @@ +#include "JSCCharacterData.h" +#include "JSCText.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCText::staticValues[] = { + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCText::staticFunctions[] = { + { "splitText", splitTextCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h new file mode 100644 index 0000000..10aa682 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.h @@ -0,0 +1,68 @@ +/* + This file is part of the Arabica 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 JSCText_h +#define JSCText_h + +#include "DOM/Node.hpp" +#include "JSCCharacterData.h" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCText { +public: + struct JSCTextPrivate { + JSCDOM* dom; + Arabica::DOM::Text* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCTextPrivate); + + static JSValueRef splitTextCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + + + static JSStaticValue staticValues[]; + static JSStaticFunction staticFunctions[]; + + static JSClassRef Tmpl; + static JSClassRef getTmpl() { + if (Tmpl == NULL) { + JSClassDefinition classDef = kJSClassDefinitionEmpty; + classDef.staticValues = staticValues; + classDef.staticFunctions = staticFunctions; + classDef.finalize = jsDestructor; + + Tmpl = JSClassCreate(&classDef); + JSClassRetain(Tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // JSCText_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp new file mode 100644 index 0000000..465e4fd --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp @@ -0,0 +1,46 @@ +#include "JSCXPathResult.h" + +namespace Arabica { +namespace DOM { + + +JSStaticValue JSCXPathResult::staticValues[] = { + { "numberValue", numberValueAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "stringValue", stringValueAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "booleanValue", booleanValueAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + { "singleNodeValue", singleNodeValueCustomAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, + + { 0, 0, 0, 0 } +}; + +JSStaticFunction JSCXPathResult::staticFunctions[] = { + { "asNodeSet", asNodeSetCallback, kJSPropertyAttributeDontDelete }, + { "asBool", asBoolCallback, kJSPropertyAttributeDontDelete }, + { "asString", asStringCallback, kJSPropertyAttributeDontDelete }, + { "asNumber", asNumberCallback, kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +JSValueRef JSCXPathResult::numberValueAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCXPathResultPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + + return JSValueMakeNumber(ctx, privData->arabicaThis->asNumber()); +} + +JSValueRef JSCXPathResult::stringValueAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCXPathResultPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->asString().c_str()); + JSValueRef retObj = JSValueMakeString(ctx, retString); + JSStringRelease(retString); + return retObj; + +} + +JSValueRef JSCXPathResult::booleanValueAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { + struct JSCXPathResultPrivate* privData = static_cast(JSObjectGetPrivate(thisObj)); + + return JSValueMakeBoolean(ctx, privData->arabicaThis->asBool()); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.h new file mode 100644 index 0000000..7eb45e1 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.h @@ -0,0 +1,74 @@ +/* + This file is part of the Arabica 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 JSCXPathResult_h +#define JSCXPathResult_h + +#include "DOM/Node.hpp" +#include +#include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOM.h" + +namespace Arabica { +namespace DOM { + +class JSCXPathResult { +public: + struct JSCXPathResultPrivate { + JSCDOM* dom; + Arabica::XPath::XPathValue* arabicaThis; + }; + + JSC_DESTRUCTOR(JSCXPathResultPrivate); + + static JSValueRef asNodeSetCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef asBoolCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef asStringCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSValueRef asNumberCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + + static JSValueRef numberValueAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef stringValueAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef booleanValueAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static JSValueRef singleNodeValueCustomAttrGetter(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 // JSCXPathResult_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp index ac1fbbd..9f04670 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp @@ -1,7 +1,8 @@ #include "uscxml/Common.h" #include "V8DataModel.h" -#include "dom/V8DOM.h" #include "dom/V8Document.h" +#include "dom/V8SCXMLEvent.h" + #include "uscxml/Message.h" #include @@ -29,10 +30,10 @@ boost::shared_ptr V8DataModel::create(Interpreter* interpreter) { v8::Locker locker; v8::HandleScope scope; - Arabica::DOM::V8DOM* dom = new Arabica::DOM::V8DOM(); + dm->_dom = new Arabica::DOM::V8DOM(); // dom->interpreter = interpreter; - dom->xpath = new Arabica::XPath::XPath(); - dom->xpath->setNamespaceContext(interpreter->getNSContext()); + dm->_dom->xpath = new Arabica::XPath::XPath(); + dm->_dom->xpath->setNamespaceContext(interpreter->getNSContext()); // see http://stackoverflow.com/questions/3171418/v8-functiontemplate-class-instance @@ -49,8 +50,8 @@ boost::shared_ptr V8DataModel::create(Interpreter* interpreter) { v8::Handle docObj = docCtor->NewInstance(); Arabica::DOM::V8Document::V8DocumentPrivate* privData = new Arabica::DOM::V8Document::V8DocumentPrivate(); - privData->arabicaThis = new Arabica::DOM::Document(interpreter->getDocument()); - privData->dom = dom; + privData->nativeObj = new Arabica::DOM::Document(interpreter->getDocument()); + privData->dom = dm->_dom; docObj->SetInternalField(0, Arabica::DOM::V8DOM::toExternal(privData)); context->Global()->Set(v8::String::New("document"), docObj); @@ -72,21 +73,12 @@ void V8DataModel::registerIOProcessor(const std::string& name, const IOProcessor void V8DataModel::setSessionId(const std::string& sessionId) { _sessionId = sessionId; - v8::Locker locker; - v8::HandleScope handleScope; - v8::Context::Scope contextScope(_contexts.front()); - v8::Handle global = _contexts.front()->Global(); - - global->Set(v8::String::New("_sessionid"), v8::String::New(sessionId.c_str())); + assign("_sessionId", "'" + sessionId + "'"); } void V8DataModel::setName(const std::string& name) { _name = name; - v8::HandleScope handleScope; - v8::Context::Scope contextScope(_contexts.front()); - v8::Handle global = _contexts.front()->Global(); - - global->Set(v8::String::New("_name"), v8::String::New(name.c_str())); + assign("_name", "'" + name + "'"); } V8DataModel::~V8DataModel() { @@ -117,25 +109,16 @@ void V8DataModel::setEvent(const Event& event) { v8::Context::Scope contextScope(_contexts.front()); v8::Handle global = _contexts.front()->Global(); - // this is unfortunate - can't we store the template in the object? - if (_eventTemplate.IsEmpty()) { - v8::Handle localEventTemplate = v8::ObjectTemplate::New(); - localEventTemplate->SetInternalFieldCount(1); // we only have a single C++ object - localEventTemplate->SetAccessor(v8::String::New("name"), V8DataModel::jsGetEventName); - localEventTemplate->SetAccessor(v8::String::New("type"), V8DataModel::jsGetEventType); - localEventTemplate->SetAccessor(v8::String::New("sendid"), V8DataModel::jsGetEventSendId); - localEventTemplate->SetAccessor(v8::String::New("origin"), V8DataModel::jsGetEventOrigin); - localEventTemplate->SetAccessor(v8::String::New("origintype"), V8DataModel::jsGetEventOriginType); - localEventTemplate->SetAccessor(v8::String::New("invokeid"), V8DataModel::jsGetEventInvokeId); - _eventTemplate = v8::Persistent::New(localEventTemplate); - } + v8::Handle eventCtor = Arabica::DOM::V8SCXMLEvent::getTmpl()->GetFunction(); + v8::Handle eventObj = eventCtor->NewInstance(); - assert(_eventTemplate->InternalFieldCount() == 1); - v8::Handle eventJS = _eventTemplate->NewInstance(); - eventJS->SetInternalField(0, v8::External::New(&_event)); + Arabica::DOM::V8SCXMLEvent::V8SCXMLEventPrivate* privData = new Arabica::DOM::V8SCXMLEvent::V8SCXMLEventPrivate(); + privData->nativeObj = &_event; + privData->dom = _dom; + eventObj->SetInternalField(0, Arabica::DOM::V8DOM::toExternal(privData)); - eventJS->Set(v8::String::New("data"), getDataAsValue(event)); // set data part of _event - global->Set(v8::String::New("_event"), eventJS); + eventObj->Set(v8::String::New("data"), getDataAsValue(event)); // set data part of _event + global->Set(v8::String::New("_event"), eventObj); } Data V8DataModel::getStringAsData(const std::string& content) { @@ -254,56 +237,6 @@ v8::Handle V8DataModel::jsIn(const v8::Arguments& args) { return v8::Boolean::New(true); } -v8::Handle V8DataModel::jsGetEventName(v8::Local property, - const v8::AccessorInfo &info) { - Event* event = static_cast(v8::Local::Cast(info.Holder()->GetInternalField(0))->Value()); - return v8::String::New(event->name.c_str()); -} - -v8::Handle V8DataModel::jsGetEventType(v8::Local property, - const v8::AccessorInfo &info) { - Event* event = static_cast(v8::Local::Cast(info.Holder()->GetInternalField(0))->Value()); - switch (event->type) { - case Event::PLATFORM: - return v8::String::New("platform"); - break; - case Event::INTERNAL: - return v8::String::New("internal"); - break; - case Event::EXTERNAL: - return v8::String::New("external"); - break; - default: - return v8::String::New(""); - break; - } -} - -v8::Handle V8DataModel::jsGetEventSendId(v8::Local property, - const v8::AccessorInfo &info) { - Event* event = static_cast(v8::Local::Cast(info.Holder()->GetInternalField(0))->Value()); - return v8::String::New(event->sendid.c_str()); - -} - -v8::Handle V8DataModel::jsGetEventOrigin(v8::Local property, - const v8::AccessorInfo &info) { - Event* event = static_cast(v8::Local::Cast(info.Holder()->GetInternalField(0))->Value()); - return v8::String::New(event->origin.c_str()); -} - -v8::Handle V8DataModel::jsGetEventOriginType(v8::Local property, - const v8::AccessorInfo &info) { - Event* event = static_cast(v8::Local::Cast(info.Holder()->GetInternalField(0))->Value()); - return v8::String::New(event->origintype.c_str()); -} - -v8::Handle V8DataModel::jsGetEventInvokeId(v8::Local property, - const v8::AccessorInfo &info) { - Event* event = static_cast(v8::Local::Cast(info.Holder()->GetInternalField(0))->Value()); - return v8::String::New(event->invokeid.c_str()); -} - bool V8DataModel::validate(const std::string& location, const std::string& schema) { return true; } @@ -348,35 +281,13 @@ void V8DataModel::assign(const std::string& location, const Data& data) { std::stringstream ssJSON; ssJSON << data; assign(location, ssJSON.str()); -// v8::Handle variable = evalAsValue(location).As(); -// assert(!variable.IsEmpty()); -// if (data.compound.size() > 0) { -// std::map::const_iterator compoundIter = data.compound.begin(); -// while(compoundIter != data.compound.end()) { -// variable->Set(v8::String::New(compoundIter->first.c_str()), getDataAsValue(compoundIter->second)); -// compoundIter++; -// } -// return; -// } else if (data.array.size() > 0) { -// std::list::const_iterator arrayIter = data.array.begin(); -// uint32_t index = 0; -// while(arrayIter != data.array.end()) { -// variable->Set(index++, getDataAsValue(*arrayIter)); -// arrayIter++; -// } -// } else if (data.type == Data::VERBATIM) { -// assign(location, "'" + data.atom + "'"); -// } else { -// assign(location, data.atom); -// } - } void V8DataModel::assign(const std::string& location, const std::string& expr) { v8::Locker locker; v8::HandleScope handleScope; v8::Context::Scope contextScope(_contexts.back()); - evalAsValue((location + " = " + expr).c_str()); + evalAsValue(location + " = " + expr); } v8::Handle V8DataModel::evalAsValue(const std::string& expr) { diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h index bcc9052..b99392f 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h @@ -4,6 +4,7 @@ #include "uscxml/Interpreter.h" #include #include +#include "dom/V8DOM.h" #ifdef BUILD_AS_PLUGINS #include "uscxml/plugins/Plugins.h" @@ -52,33 +53,14 @@ public: virtual std::string evalAsString(const std::string& expr); virtual bool evalAsBool(const std::string& expr); - static v8::Handle jsGetEventName(v8::Local property, - const v8::AccessorInfo &info); - static v8::Handle jsGetEventType(v8::Local property, - const v8::AccessorInfo &info); - static v8::Handle jsGetEventSendId(v8::Local property, - const v8::AccessorInfo &info); - static v8::Handle jsGetEventOrigin(v8::Local property, - const v8::AccessorInfo &info); - static v8::Handle jsGetEventOriginType(v8::Local property, - const v8::AccessorInfo &info); - static v8::Handle jsGetEventInvokeId(v8::Local property, - const v8::AccessorInfo &info); - static v8::Handle jsIn(const v8::Arguments& args); static v8::Handle jsPrint(const v8::Arguments& args); - protected: std::list > _contexts; - Interpreter* _interpreter; - - std::string _sessionId; - std::string _name; Event _event; - v8::Persistent _globalTemplate; - v8::Persistent _eventTemplate; + Arabica::DOM::V8DOM* _dom; v8::Handle evalAsValue(const std::string& expr); virtual v8::Handle getDataAsValue(const Data& data); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.cpp index dd11694..bee6042 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.cpp @@ -12,41 +12,43 @@ v8::Handle V8Attr::nameAttrGetter(v8::Local property, con v8::Local self = info.Holder(); struct V8AttrPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getName().c_str()); + return v8::String::New(privData->nativeObj->getName().c_str()); } v8::Handle V8Attr::specifiedAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8AttrPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Boolean::New(privData->arabicaThis->getSpecified()); + return v8::Boolean::New(privData->nativeObj->getSpecified()); } v8::Handle V8Attr::valueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8AttrPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getValue().c_str()); + return v8::String::New(privData->nativeObj->getValue().c_str()); } void V8Attr::valueAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8AttrPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localValue(value); - privData->arabicaThis->setValue(*localValue); + privData->nativeObj->setValue(*localValue); } v8::Handle V8Attr::ownerElementAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8AttrPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Element* arbaicaRet = new Arabica::DOM::Element(privData->arabicaThis->getOwnerElement()); + + if (!privData->nativeObj->getOwnerElement()) return v8::Undefined(); + Arabica::DOM::Element* arbaicaRet = new Arabica::DOM::Element(privData->nativeObj->getOwnerElement()); v8::Handle arbaicaRetCtor = V8Element::getTmpl()->GetFunction(); v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = arbaicaRet; + retPrivData->nativeObj = arbaicaRet; arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); arbaicaRetObj.MakeWeak(0, V8Element::jsDestructor); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h index 5cd4831..e290415 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -33,7 +33,7 @@ class V8Attr { public: struct V8AttrPrivate { V8DOM* dom; - Arabica::DOM::Attr* arabicaThis; + Arabica::DOM::Attr* nativeObj; }; V8_DESTRUCTOR(V8AttrPrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h index d2543c1..a0b5ced 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -33,7 +33,7 @@ class V8CDATASection { public: struct V8CDATASectionPrivate { V8DOM* dom; - Arabica::DOM::CDATASection* arabicaThis; + Arabica::DOM::CDATASection* nativeObj; }; V8_DESTRUCTOR(V8CDATASectionPrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.cpp index 13c582a..459cf96 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.cpp @@ -11,21 +11,21 @@ v8::Handle V8CharacterData::dataAttrGetter(v8::Local prop v8::Local self = info.Holder(); struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getData().c_str()); + return v8::String::New(privData->nativeObj->getData().c_str()); } void V8CharacterData::dataAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localData(value); - privData->arabicaThis->setData(*localData); + privData->nativeObj->setData(*localData); } v8::Handle V8CharacterData::lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Integer::New(privData->arabicaThis->getLength()); + return v8::Integer::New(privData->nativeObj->getLength()); } v8::Handle V8CharacterData::substringDataCallback(const v8::Arguments& args) { if (args.Length() < 2) @@ -36,7 +36,7 @@ v8::Handle V8CharacterData::substringDataCallback(const v8::Arguments unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); unsigned long localCount = args[1]->ToNumber()->Uint32Value(); - std::string retVal = privData->arabicaThis->substringData(localOffset, localCount); + std::string retVal = privData->nativeObj->substringData(localOffset, localCount); return v8::String::New(retVal.c_str()); } @@ -49,7 +49,7 @@ v8::Handle V8CharacterData::appendDataCallback(const v8::Arguments& a struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localArg(args[0]); - privData->arabicaThis->appendData(*localArg); + privData->nativeObj->appendData(*localArg); return v8::Undefined(); } @@ -63,7 +63,7 @@ v8::Handle V8CharacterData::insertDataCallback(const v8::Arguments& a unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); v8::String::AsciiValue localArg(args[1]); - privData->arabicaThis->insertData(localOffset, *localArg); + privData->nativeObj->insertData(localOffset, *localArg); return v8::Undefined(); } @@ -77,7 +77,7 @@ v8::Handle V8CharacterData::deleteDataCallback(const v8::Arguments& a unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); unsigned long localCount = args[1]->ToNumber()->Uint32Value(); - privData->arabicaThis->deleteData(localOffset, localCount); + privData->nativeObj->deleteData(localOffset, localCount); return v8::Undefined(); } @@ -92,7 +92,7 @@ v8::Handle V8CharacterData::replaceDataCallback(const v8::Arguments& unsigned long localCount = args[1]->ToNumber()->Uint32Value(); v8::String::AsciiValue localArg(args[2]); - privData->arabicaThis->replaceData(localOffset, localCount, *localArg); + privData->nativeObj->replaceData(localOffset, localCount, *localArg); return v8::Undefined(); } diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h index d9808a3..a86519b 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -33,7 +33,7 @@ class V8CharacterData { public: struct V8CharacterDataPrivate { V8DOM* dom; - Arabica::DOM::CharacterData* arabicaThis; + Arabica::DOM::CharacterData* nativeObj; }; V8_DESTRUCTOR(V8CharacterDataPrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h index 8ff626e..b07bf19 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -33,7 +33,7 @@ class V8Comment { public: struct V8CommentPrivate { V8DOM* dom; - Arabica::DOM::Comment* arabicaThis; + Arabica::DOM::Comment* nativeObj; }; V8_DESTRUCTOR(V8CommentPrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h index 122a457..10528e8 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h @@ -9,12 +9,21 @@ static void jsDestructor(v8::Persistent object, void* data) { \ v8::HandleScope handleScope; \ type* thing = static_cast(v8::Local::Cast(object->ToObject()->GetInternalField(0))->Value()); \ - delete thing->arabicaThis; \ + delete thing->nativeObj; \ delete thing; \ object.Dispose(); \ object.Clear(); \ } +#define V8_DESTRUCTOR_KEEP_WRAPPED(type) \ +static void jsDestructor(v8::Persistent object, void* data) { \ +v8::HandleScope handleScope; \ +type* thing = static_cast(v8::Local::Cast(object->ToObject()->GetInternalField(0))->Value()); \ +delete thing; \ +object.Dispose(); \ +object.Clear(); \ +} + namespace Arabica { namespace DOM { diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.cpp index 6d26cee..f7a7575 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.cpp @@ -16,7 +16,7 @@ v8::Handle V8DOMImplementation::hasFeatureCallback(const v8::Argument v8::String::AsciiValue localFeature(args[0]); v8::String::AsciiValue localVersion(args[1]); - bool retVal = privData->arabicaThis->hasFeature(*localFeature, *localVersion); + bool retVal = privData->nativeObj->hasFeature(*localFeature, *localVersion); return v8::Boolean::New(retVal); } @@ -31,13 +31,13 @@ v8::Handle V8DOMImplementation::createDocumentTypeCallback(const v8:: v8::String::AsciiValue localPublicId(args[1]); v8::String::AsciiValue localSystemId(args[2]); - Arabica::DOM::DocumentType* retVal = new Arabica::DOM::DocumentType(privData->arabicaThis->createDocumentType(*localQualifiedName, *localPublicId, *localSystemId)); + Arabica::DOM::DocumentType* retVal = new Arabica::DOM::DocumentType(privData->nativeObj->createDocumentType(*localQualifiedName, *localPublicId, *localSystemId)); v8::Handle retCtor = V8DocumentType::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8DocumentType::V8DocumentTypePrivate* retPrivData = new V8DocumentType::V8DocumentTypePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -56,15 +56,15 @@ v8::Handle V8DOMImplementation::createDocumentCallback(const v8::Argu struct V8DOMImplementationPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localNamespaceURI(args[0]); v8::String::AsciiValue localQualifiedName(args[1]); - Arabica::DOM::DocumentType* localDoctype = V8DOM::toClassPtr(args[2]->ToObject()->GetInternalField(0))->arabicaThis; + Arabica::DOM::DocumentType* localDoctype = V8DOM::toClassPtr(args[2]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Document* retVal = new Arabica::DOM::Document(privData->arabicaThis->createDocument(*localNamespaceURI, *localQualifiedName, *localDoctype)); + Arabica::DOM::Document* retVal = new Arabica::DOM::Document(privData->nativeObj->createDocument(*localNamespaceURI, *localQualifiedName, *localDoctype)); v8::Handle retCtor = V8Document::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Document::V8DocumentPrivate* retPrivData = new V8Document::V8DocumentPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h index f14a39b..5a4c9d3 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -32,7 +32,7 @@ class V8DOMImplementation { public: struct V8DOMImplementationPrivate { V8DOM* dom; - Arabica::DOM::DOMImplementation* arabicaThis; + Arabica::DOM::DOMImplementation* nativeObj; }; V8_DESTRUCTOR(V8DOMImplementationPrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp index 2bad2dd..06191ea 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp @@ -21,14 +21,16 @@ v8::Persistent V8Document::Tmpl; v8::Handle V8Document::doctypeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::DocumentType* arbaicaRet = new Arabica::DOM::DocumentType(privData->arabicaThis->getDoctype()); + + if (!privData->nativeObj->getDoctype()) return v8::Undefined(); + Arabica::DOM::DocumentType* arbaicaRet = new Arabica::DOM::DocumentType(privData->nativeObj->getDoctype()); v8::Handle arbaicaRetCtor = V8DocumentType::getTmpl()->GetFunction(); v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); struct V8DocumentType::V8DocumentTypePrivate* retPrivData = new V8DocumentType::V8DocumentTypePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = arbaicaRet; + retPrivData->nativeObj = arbaicaRet; arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); arbaicaRetObj.MakeWeak(0, V8DocumentType::jsDestructor); @@ -39,14 +41,16 @@ v8::Handle V8Document::doctypeAttrGetter(v8::Local proper v8::Handle V8Document::implementationAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::DOMImplementation* arbaicaRet = new Arabica::DOM::DOMImplementation(privData->arabicaThis->getImplementation()); + + if (!privData->nativeObj->getImplementation()) return v8::Undefined(); + Arabica::DOM::DOMImplementation* arbaicaRet = new Arabica::DOM::DOMImplementation(privData->nativeObj->getImplementation()); v8::Handle arbaicaRetCtor = V8DOMImplementation::getTmpl()->GetFunction(); v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); struct V8DOMImplementation::V8DOMImplementationPrivate* retPrivData = new V8DOMImplementation::V8DOMImplementationPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = arbaicaRet; + retPrivData->nativeObj = arbaicaRet; arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); arbaicaRetObj.MakeWeak(0, V8DOMImplementation::jsDestructor); @@ -57,14 +61,16 @@ v8::Handle V8Document::implementationAttrGetter(v8::Local v8::Handle V8Document::documentElementAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Element* arbaicaRet = new Arabica::DOM::Element(privData->arabicaThis->getDocumentElement()); + + if (!privData->nativeObj->getDocumentElement()) return v8::Undefined(); + Arabica::DOM::Element* arbaicaRet = new Arabica::DOM::Element(privData->nativeObj->getDocumentElement()); v8::Handle arbaicaRetCtor = V8Element::getTmpl()->GetFunction(); v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = arbaicaRet; + retPrivData->nativeObj = arbaicaRet; arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); arbaicaRetObj.MakeWeak(0, V8Element::jsDestructor); @@ -79,13 +85,13 @@ v8::Handle V8Document::createElementCallback(const v8::Arguments& arg struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localTagName(args[0]); - Arabica::DOM::Element* retVal = new Arabica::DOM::Element(privData->arabicaThis->createElement(*localTagName)); + Arabica::DOM::Element* retVal = new Arabica::DOM::Element(privData->nativeObj->createElement(*localTagName)); v8::Handle retCtor = V8Element::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -99,13 +105,13 @@ v8::Handle V8Document::createDocumentFragmentCallback(const v8::Argum v8::Local self = args.Holder(); struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::DocumentFragment* retVal = new Arabica::DOM::DocumentFragment(privData->arabicaThis->createDocumentFragment()); + Arabica::DOM::DocumentFragment* retVal = new Arabica::DOM::DocumentFragment(privData->nativeObj->createDocumentFragment()); v8::Handle retCtor = V8DocumentFragment::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8DocumentFragment::V8DocumentFragmentPrivate* retPrivData = new V8DocumentFragment::V8DocumentFragmentPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -122,13 +128,13 @@ v8::Handle V8Document::createTextNodeCallback(const v8::Arguments& ar struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localData(args[0]); - Arabica::DOM::Text* retVal = new Arabica::DOM::Text(privData->arabicaThis->createTextNode(*localData)); + Arabica::DOM::Text* retVal = new Arabica::DOM::Text(privData->nativeObj->createTextNode(*localData)); v8::Handle retCtor = V8Text::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Text::V8TextPrivate* retPrivData = new V8Text::V8TextPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -145,13 +151,13 @@ v8::Handle V8Document::createCommentCallback(const v8::Arguments& arg struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localData(args[0]); - Arabica::DOM::Comment* retVal = new Arabica::DOM::Comment(privData->arabicaThis->createComment(*localData)); + Arabica::DOM::Comment* retVal = new Arabica::DOM::Comment(privData->nativeObj->createComment(*localData)); v8::Handle retCtor = V8Comment::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Comment::V8CommentPrivate* retPrivData = new V8Comment::V8CommentPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -168,13 +174,13 @@ v8::Handle V8Document::createCDATASectionCallback(const v8::Arguments struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localData(args[0]); - Arabica::DOM::CDATASection* retVal = new Arabica::DOM::CDATASection(privData->arabicaThis->createCDATASection(*localData)); + Arabica::DOM::CDATASection* retVal = new Arabica::DOM::CDATASection(privData->nativeObj->createCDATASection(*localData)); v8::Handle retCtor = V8CDATASection::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8CDATASection::V8CDATASectionPrivate* retPrivData = new V8CDATASection::V8CDATASectionPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -192,13 +198,13 @@ v8::Handle V8Document::createProcessingInstructionCallback(const v8:: v8::String::AsciiValue localTarget(args[0]); v8::String::AsciiValue localData(args[1]); - Arabica::DOM::ProcessingInstruction* retVal = new Arabica::DOM::ProcessingInstruction(privData->arabicaThis->createProcessingInstruction(*localTarget, *localData)); + Arabica::DOM::ProcessingInstruction* retVal = new Arabica::DOM::ProcessingInstruction(privData->nativeObj->createProcessingInstruction(*localTarget, *localData)); v8::Handle retCtor = V8ProcessingInstruction::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8ProcessingInstruction::V8ProcessingInstructionPrivate* retPrivData = new V8ProcessingInstruction::V8ProcessingInstructionPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -215,13 +221,13 @@ v8::Handle V8Document::createAttributeCallback(const v8::Arguments& a struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localName(args[0]); - Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->arabicaThis->createAttribute(*localName)); + Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->createAttribute(*localName)); v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -238,13 +244,13 @@ v8::Handle V8Document::createEntityReferenceCallback(const v8::Argume struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localName(args[0]); - Arabica::DOM::EntityReference* retVal = new Arabica::DOM::EntityReference(privData->arabicaThis->createEntityReference(*localName)); + Arabica::DOM::EntityReference* retVal = new Arabica::DOM::EntityReference(privData->nativeObj->createEntityReference(*localName)); v8::Handle retCtor = V8EntityReference::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8EntityReference::V8EntityReferencePrivate* retPrivData = new V8EntityReference::V8EntityReferencePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -261,13 +267,13 @@ v8::Handle V8Document::getElementsByTagNameCallback(const v8::Argumen struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localTagname(args[0]); - Arabica::DOM::NodeList* retVal = new Arabica::DOM::NodeList(privData->arabicaThis->getElementsByTagName(*localTagname)); + Arabica::DOM::NodeList* retVal = new Arabica::DOM::NodeList(privData->nativeObj->getElementsByTagName(*localTagname)); v8::Handle retCtor = V8NodeList::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -284,16 +290,16 @@ v8::Handle V8Document::importNodeCallback(const v8::Arguments& args) v8::Local self = args.Holder(); struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* localImportedNode = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->arabicaThis; + Arabica::DOM::Node* localImportedNode = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; bool localDeep = args[1]->ToBoolean()->BooleanValue(); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->arabicaThis->importNode(*localImportedNode, localDeep)); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->importNode(*localImportedNode, localDeep)); v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -311,13 +317,13 @@ v8::Handle V8Document::createElementNSCallback(const v8::Arguments& a v8::String::AsciiValue localNamespaceURI(args[0]); v8::String::AsciiValue localQualifiedName(args[1]); - Arabica::DOM::Element* retVal = new Arabica::DOM::Element(privData->arabicaThis->createElementNS(*localNamespaceURI, *localQualifiedName)); + Arabica::DOM::Element* retVal = new Arabica::DOM::Element(privData->nativeObj->createElementNS(*localNamespaceURI, *localQualifiedName)); v8::Handle retCtor = V8Element::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -335,13 +341,13 @@ v8::Handle V8Document::createAttributeNSCallback(const v8::Arguments& v8::String::AsciiValue localNamespaceURI(args[0]); v8::String::AsciiValue localQualifiedName(args[1]); - Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->arabicaThis->createAttributeNS(*localNamespaceURI, *localQualifiedName)); + Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->createAttributeNS(*localNamespaceURI, *localQualifiedName)); v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -359,13 +365,13 @@ v8::Handle V8Document::getElementsByTagNameNSCallback(const v8::Argum v8::String::AsciiValue localNamespaceURI(args[0]); v8::String::AsciiValue localLocalName(args[1]); - Arabica::DOM::NodeList* retVal = new Arabica::DOM::NodeList(privData->arabicaThis->getElementsByTagNameNS(*localNamespaceURI, *localLocalName)); + Arabica::DOM::NodeList* retVal = new Arabica::DOM::NodeList(privData->nativeObj->getElementsByTagNameNS(*localNamespaceURI, *localLocalName)); v8::Handle retCtor = V8NodeList::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -382,13 +388,13 @@ v8::Handle V8Document::getElementByIdCallback(const v8::Arguments& ar struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localElementId(args[0]); - Arabica::DOM::Element* retVal = new Arabica::DOM::Element(privData->arabicaThis->getElementById(*localElementId)); + Arabica::DOM::Element* retVal = new Arabica::DOM::Element(privData->nativeObj->getElementById(*localElementId)); v8::Handle retCtor = V8Element::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h index 22d2713..da61876 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -33,7 +33,7 @@ class V8Document { public: struct V8DocumentPrivate { V8DOM* dom; - Arabica::DOM::Document* arabicaThis; + Arabica::DOM::Document* nativeObj; }; V8_DESTRUCTOR(V8DocumentPrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp index 2756287..be9b05c 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentCustom.cpp @@ -21,7 +21,7 @@ v8::Handle V8Document::evaluateCustomCallback(const v8::Arguments& ar Arabica::DOM::Node* localContextNode = V8DOM::toClassPtr >(args[1]->ToObject()->GetInternalField(0)); retVal = new XPath::XPathValue(privData->dom->xpath->evaluate(*localExpression, *localContextNode)); } else { - retVal = new XPath::XPathValue(privData->dom->xpath->evaluate(*localExpression, *privData->arabicaThis)); + retVal = new XPath::XPathValue(privData->dom->xpath->evaluate(*localExpression, *privData->nativeObj)); } v8::Handle retCtor = V8XPathResult::getTmpl()->GetFunction(); @@ -29,7 +29,7 @@ v8::Handle V8Document::evaluateCustomCallback(const v8::Arguments& ar V8XPathResult::V8XPathResultPrivate* retPrivData = new V8XPathResult::V8XPathResultPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h index 2340eb7..62dc58d 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -33,7 +33,7 @@ class V8DocumentFragment { public: struct V8DocumentFragmentPrivate { V8DOM* dom; - Arabica::DOM::DocumentFragment* arabicaThis; + Arabica::DOM::DocumentFragment* nativeObj; }; V8_DESTRUCTOR(V8DocumentFragmentPrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.cpp index cd7e2a5..6b9a7b0 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.cpp @@ -12,20 +12,22 @@ v8::Handle V8DocumentType::nameAttrGetter(v8::Local prope v8::Local self = info.Holder(); struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getName().c_str()); + return v8::String::New(privData->nativeObj->getName().c_str()); } v8::Handle V8DocumentType::entitiesAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::NamedNodeMap* arbaicaRet = new Arabica::DOM::NamedNodeMap(privData->arabicaThis->getEntities()); + + + Arabica::DOM::NamedNodeMap* arbaicaRet = new Arabica::DOM::NamedNodeMap(privData->nativeObj->getEntities()); v8::Handle arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction(); v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = arbaicaRet; + retPrivData->nativeObj = arbaicaRet; arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor); @@ -36,14 +38,16 @@ v8::Handle V8DocumentType::entitiesAttrGetter(v8::Local p v8::Handle V8DocumentType::notationsAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::NamedNodeMap* arbaicaRet = new Arabica::DOM::NamedNodeMap(privData->arabicaThis->getNotations()); + + + Arabica::DOM::NamedNodeMap* arbaicaRet = new Arabica::DOM::NamedNodeMap(privData->nativeObj->getNotations()); v8::Handle arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction(); v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = arbaicaRet; + retPrivData->nativeObj = arbaicaRet; arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor); @@ -55,21 +59,21 @@ v8::Handle V8DocumentType::publicIdAttrGetter(v8::Local p v8::Local self = info.Holder(); struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getPublicId().c_str()); + return v8::String::New(privData->nativeObj->getPublicId().c_str()); } v8::Handle V8DocumentType::systemIdAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getSystemId().c_str()); + return v8::String::New(privData->nativeObj->getSystemId().c_str()); } v8::Handle V8DocumentType::internalSubsetAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getInternalSubset().c_str()); + return v8::String::New(privData->nativeObj->getInternalSubset().c_str()); } bool V8DocumentType::hasInstance(v8::Handle value) { return getTmpl()->HasInstance(value); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h index 462cec9..f4d0c15 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -33,7 +33,7 @@ class V8DocumentType { public: struct V8DocumentTypePrivate { V8DOM* dom; - Arabica::DOM::DocumentType* arabicaThis; + Arabica::DOM::DocumentType* nativeObj; }; V8_DESTRUCTOR(V8DocumentTypePrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp index 3c7d7da..680dd5e 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp @@ -13,7 +13,7 @@ v8::Handle V8Element::tagNameAttrGetter(v8::Local propert v8::Local self = info.Holder(); struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getTagName().c_str()); + return v8::String::New(privData->nativeObj->getTagName().c_str()); } v8::Handle V8Element::getAttributeCallback(const v8::Arguments& args) { if (args.Length() < 1) @@ -23,7 +23,7 @@ v8::Handle V8Element::getAttributeCallback(const v8::Arguments& args) struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localName(args[0]); - std::string retVal = privData->arabicaThis->getAttribute(*localName); + std::string retVal = privData->nativeObj->getAttribute(*localName); return v8::String::New(retVal.c_str()); } @@ -37,7 +37,7 @@ v8::Handle V8Element::setAttributeCallback(const v8::Arguments& args) v8::String::AsciiValue localName(args[0]); v8::String::AsciiValue localValue(args[1]); - privData->arabicaThis->setAttribute(*localName, *localValue); + privData->nativeObj->setAttribute(*localName, *localValue); return v8::Undefined(); } @@ -50,7 +50,7 @@ v8::Handle V8Element::removeAttributeCallback(const v8::Arguments& ar struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localName(args[0]); - privData->arabicaThis->removeAttribute(*localName); + privData->nativeObj->removeAttribute(*localName); return v8::Undefined(); } @@ -63,13 +63,13 @@ v8::Handle V8Element::getAttributeNodeCallback(const v8::Arguments& a struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localName(args[0]); - Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->arabicaThis->getAttributeNode(*localName)); + Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->getAttributeNode(*localName)); v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -86,15 +86,15 @@ v8::Handle V8Element::setAttributeNodeCallback(const v8::Arguments& a v8::Local self = args.Holder(); struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Attr* localNewAttr = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->arabicaThis; + Arabica::DOM::Attr* localNewAttr = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->arabicaThis->setAttributeNode(*localNewAttr)); + Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->setAttributeNode(*localNewAttr)); v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -111,15 +111,15 @@ v8::Handle V8Element::removeAttributeNodeCallback(const v8::Arguments v8::Local self = args.Holder(); struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Attr* localOldAttr = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->arabicaThis; + Arabica::DOM::Attr* localOldAttr = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->arabicaThis->removeAttributeNode(*localOldAttr)); + Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->removeAttributeNode(*localOldAttr)); v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -136,13 +136,13 @@ v8::Handle V8Element::getElementsByTagNameCallback(const v8::Argument struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localName(args[0]); - Arabica::DOM::NodeList* retVal = new Arabica::DOM::NodeList(privData->arabicaThis->getElementsByTagName(*localName)); + Arabica::DOM::NodeList* retVal = new Arabica::DOM::NodeList(privData->nativeObj->getElementsByTagName(*localName)); v8::Handle retCtor = V8NodeList::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -160,7 +160,7 @@ v8::Handle V8Element::getAttributeNSCallback(const v8::Arguments& arg v8::String::AsciiValue localNamespaceURI(args[0]); v8::String::AsciiValue localLocalName(args[1]); - std::string retVal = privData->arabicaThis->getAttributeNS(*localNamespaceURI, *localLocalName); + std::string retVal = privData->nativeObj->getAttributeNS(*localNamespaceURI, *localLocalName); return v8::String::New(retVal.c_str()); } @@ -175,7 +175,7 @@ v8::Handle V8Element::setAttributeNSCallback(const v8::Arguments& arg v8::String::AsciiValue localQualifiedName(args[1]); v8::String::AsciiValue localValue(args[2]); - privData->arabicaThis->setAttributeNS(*localNamespaceURI, *localQualifiedName, *localValue); + privData->nativeObj->setAttributeNS(*localNamespaceURI, *localQualifiedName, *localValue); return v8::Undefined(); } @@ -189,7 +189,7 @@ v8::Handle V8Element::removeAttributeNSCallback(const v8::Arguments& v8::String::AsciiValue localNamespaceURI(args[0]); v8::String::AsciiValue localLocalName(args[1]); - privData->arabicaThis->removeAttributeNS(*localNamespaceURI, *localLocalName); + privData->nativeObj->removeAttributeNS(*localNamespaceURI, *localLocalName); return v8::Undefined(); } @@ -203,13 +203,13 @@ v8::Handle V8Element::getAttributeNodeNSCallback(const v8::Arguments& v8::String::AsciiValue localNamespaceURI(args[0]); v8::String::AsciiValue localLocalName(args[1]); - Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->arabicaThis->getAttributeNodeNS(*localNamespaceURI, *localLocalName)); + Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->getAttributeNodeNS(*localNamespaceURI, *localLocalName)); v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -226,15 +226,15 @@ v8::Handle V8Element::setAttributeNodeNSCallback(const v8::Arguments& v8::Local self = args.Holder(); struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Attr* localNewAttr = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->arabicaThis; + Arabica::DOM::Attr* localNewAttr = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->arabicaThis->setAttributeNodeNS(*localNewAttr)); + Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->setAttributeNodeNS(*localNewAttr)); v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -252,13 +252,13 @@ v8::Handle V8Element::getElementsByTagNameNSCallback(const v8::Argume v8::String::AsciiValue localNamespaceURI(args[0]); v8::String::AsciiValue localLocalName(args[1]); - Arabica::DOM::NodeList* retVal = new Arabica::DOM::NodeList(privData->arabicaThis->getElementsByTagNameNS(*localNamespaceURI, *localLocalName)); + Arabica::DOM::NodeList* retVal = new Arabica::DOM::NodeList(privData->nativeObj->getElementsByTagNameNS(*localNamespaceURI, *localLocalName)); v8::Handle retCtor = V8NodeList::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -275,7 +275,7 @@ v8::Handle V8Element::hasAttributeCallback(const v8::Arguments& args) struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localName(args[0]); - bool retVal = privData->arabicaThis->hasAttribute(*localName); + bool retVal = privData->nativeObj->hasAttribute(*localName); return v8::Boolean::New(retVal); } @@ -289,7 +289,7 @@ v8::Handle V8Element::hasAttributeNSCallback(const v8::Arguments& arg v8::String::AsciiValue localNamespaceURI(args[0]); v8::String::AsciiValue localLocalName(args[1]); - bool retVal = privData->arabicaThis->hasAttributeNS(*localNamespaceURI, *localLocalName); + bool retVal = privData->nativeObj->hasAttributeNS(*localNamespaceURI, *localLocalName); return v8::Boolean::New(retVal); } diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h index 5a824b3..338c249 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -33,7 +33,7 @@ class V8Element { public: struct V8ElementPrivate { V8DOM* dom; - Arabica::DOM::Element* arabicaThis; + Arabica::DOM::Element* nativeObj; }; V8_DESTRUCTOR(V8ElementPrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.cpp index 8bdd57c..f3ce21d 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.cpp @@ -11,21 +11,21 @@ v8::Handle V8Entity::publicIdAttrGetter(v8::Local propert v8::Local self = info.Holder(); struct V8EntityPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getPublicId().c_str()); + return v8::String::New(privData->nativeObj->getPublicId().c_str()); } v8::Handle V8Entity::systemIdAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8EntityPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getSystemId().c_str()); + return v8::String::New(privData->nativeObj->getSystemId().c_str()); } v8::Handle V8Entity::notationNameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8EntityPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getNotationName().c_str()); + return v8::String::New(privData->nativeObj->getNotationName().c_str()); } bool V8Entity::hasInstance(v8::Handle value) { return getTmpl()->HasInstance(value); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h index 6c22e3a..c8e0eaf 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -33,7 +33,7 @@ class V8Entity { public: struct V8EntityPrivate { V8DOM* dom; - Arabica::DOM::Entity* arabicaThis; + Arabica::DOM::Entity* nativeObj; }; V8_DESTRUCTOR(V8EntityPrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h index d99c7ab..85cc7cc 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -33,7 +33,7 @@ class V8EntityReference { public: struct V8EntityReferencePrivate { V8DOM* dom; - Arabica::DOM::EntityReference* arabicaThis; + Arabica::DOM::EntityReference* nativeObj; }; V8_DESTRUCTOR(V8EntityReferencePrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp index 4608ea1..037d651 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp @@ -11,7 +11,7 @@ v8::Handle V8NamedNodeMap::lengthAttrGetter(v8::Local pro v8::Local self = info.Holder(); struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Integer::New(privData->arabicaThis->getLength()); + return v8::Integer::New(privData->nativeObj->getLength()); } v8::Handle V8NamedNodeMap::getNamedItemCallback(const v8::Arguments& args) { if (args.Length() < 1) @@ -21,13 +21,13 @@ v8::Handle V8NamedNodeMap::getNamedItemCallback(const v8::Arguments& struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localName(args[0]); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->arabicaThis->getNamedItem(*localName)); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->getNamedItem(*localName)); v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -44,15 +44,15 @@ v8::Handle V8NamedNodeMap::setNamedItemCallback(const v8::Arguments& v8::Local self = args.Holder(); struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* localArg = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->arabicaThis; + Arabica::DOM::Node* localArg = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->arabicaThis->setNamedItem(*localArg)); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->setNamedItem(*localArg)); v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -69,13 +69,13 @@ v8::Handle V8NamedNodeMap::removeNamedItemCallback(const v8::Argument struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localName(args[0]); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->arabicaThis->removeNamedItem(*localName)); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->removeNamedItem(*localName)); v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -92,13 +92,13 @@ v8::Handle V8NamedNodeMap::itemCallback(const v8::Arguments& args) { struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->arabicaThis->item(localIndex)); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->item(localIndex)); v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -116,13 +116,13 @@ v8::Handle V8NamedNodeMap::getNamedItemNSCallback(const v8::Arguments v8::String::AsciiValue localNamespaceURI(args[0]); v8::String::AsciiValue localLocalName(args[1]); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->arabicaThis->getNamedItemNS(*localNamespaceURI, *localLocalName)); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->getNamedItemNS(*localNamespaceURI, *localLocalName)); v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -139,15 +139,15 @@ v8::Handle V8NamedNodeMap::setNamedItemNSCallback(const v8::Arguments v8::Local self = args.Holder(); struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* localArg = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->arabicaThis; + Arabica::DOM::Node* localArg = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->arabicaThis->setNamedItemNS(*localArg)); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->setNamedItemNS(*localArg)); v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -165,13 +165,13 @@ v8::Handle V8NamedNodeMap::removeNamedItemNSCallback(const v8::Argume v8::String::AsciiValue localNamespaceURI(args[0]); v8::String::AsciiValue localLocalName(args[1]); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->arabicaThis->removeNamedItemNS(*localNamespaceURI, *localLocalName)); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->removeNamedItemNS(*localNamespaceURI, *localLocalName)); v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h index 52e6c54..b8bc873 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -32,7 +32,7 @@ class V8NamedNodeMap { public: struct V8NamedNodeMapPrivate { V8DOM* dom; - Arabica::DOM::NamedNodeMap* arabicaThis; + Arabica::DOM::NamedNodeMap* nativeObj; }; V8_DESTRUCTOR(V8NamedNodeMapPrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp index 52ff3ec..b77f38e 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp @@ -13,41 +13,43 @@ v8::Handle V8Node::nodeNameAttrGetter(v8::Local property, v8::Local self = info.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getNodeName().c_str()); + return v8::String::New(privData->nativeObj->getNodeName().c_str()); } v8::Handle V8Node::nodeValueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getNodeValue().c_str()); + return v8::String::New(privData->nativeObj->getNodeValue().c_str()); } void V8Node::nodeValueAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localNodeValue(value); - privData->arabicaThis->setNodeValue(*localNodeValue); + privData->nativeObj->setNodeValue(*localNodeValue); } v8::Handle V8Node::nodeTypeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Integer::New(privData->arabicaThis->getNodeType()); + return v8::Integer::New(privData->nativeObj->getNodeType()); } v8::Handle V8Node::parentNodeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->arabicaThis->getParentNode()); + + if (!privData->nativeObj->getParentNode()) return v8::Undefined(); + Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->getParentNode()); v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = arbaicaRet; + retPrivData->nativeObj = arbaicaRet; arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); @@ -58,14 +60,16 @@ v8::Handle V8Node::parentNodeAttrGetter(v8::Local propert v8::Handle V8Node::childNodesAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::NodeList* arbaicaRet = new Arabica::DOM::NodeList(privData->arabicaThis->getChildNodes()); + + + Arabica::DOM::NodeList* arbaicaRet = new Arabica::DOM::NodeList(privData->nativeObj->getChildNodes()); v8::Handle arbaicaRetCtor = V8NodeList::getTmpl()->GetFunction(); v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = arbaicaRet; + retPrivData->nativeObj = arbaicaRet; arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); arbaicaRetObj.MakeWeak(0, V8NodeList::jsDestructor); @@ -76,14 +80,16 @@ v8::Handle V8Node::childNodesAttrGetter(v8::Local propert v8::Handle V8Node::firstChildAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->arabicaThis->getFirstChild()); + + if (!privData->nativeObj->getFirstChild()) return v8::Undefined(); + Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->getFirstChild()); v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = arbaicaRet; + retPrivData->nativeObj = arbaicaRet; arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); @@ -94,14 +100,16 @@ v8::Handle V8Node::firstChildAttrGetter(v8::Local propert v8::Handle V8Node::lastChildAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->arabicaThis->getLastChild()); + + if (!privData->nativeObj->getLastChild()) return v8::Undefined(); + Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->getLastChild()); v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = arbaicaRet; + retPrivData->nativeObj = arbaicaRet; arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); @@ -112,14 +120,16 @@ v8::Handle V8Node::lastChildAttrGetter(v8::Local property v8::Handle V8Node::previousSiblingAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->arabicaThis->getPreviousSibling()); + + if (!privData->nativeObj->getPreviousSibling()) return v8::Undefined(); + Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->getPreviousSibling()); v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = arbaicaRet; + retPrivData->nativeObj = arbaicaRet; arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); @@ -130,14 +140,16 @@ v8::Handle V8Node::previousSiblingAttrGetter(v8::Local pr v8::Handle V8Node::nextSiblingAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->arabicaThis->getNextSibling()); + + if (!privData->nativeObj->getNextSibling()) return v8::Undefined(); + Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->getNextSibling()); v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = arbaicaRet; + retPrivData->nativeObj = arbaicaRet; arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); @@ -148,14 +160,16 @@ v8::Handle V8Node::nextSiblingAttrGetter(v8::Local proper v8::Handle V8Node::attributesAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::NamedNodeMap* arbaicaRet = new Arabica::DOM::NamedNodeMap(privData->arabicaThis->getAttributes()); + + + Arabica::DOM::NamedNodeMap* arbaicaRet = new Arabica::DOM::NamedNodeMap(privData->nativeObj->getAttributes()); v8::Handle arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction(); v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = arbaicaRet; + retPrivData->nativeObj = arbaicaRet; arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor); @@ -166,14 +180,16 @@ v8::Handle V8Node::attributesAttrGetter(v8::Local propert v8::Handle V8Node::ownerDocumentAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Document* arbaicaRet = new Arabica::DOM::Document(privData->arabicaThis->getOwnerDocument()); + + if (!privData->nativeObj->getOwnerDocument()) return v8::Undefined(); + Arabica::DOM::Document* arbaicaRet = new Arabica::DOM::Document(privData->nativeObj->getOwnerDocument()); v8::Handle arbaicaRetCtor = V8Document::getTmpl()->GetFunction(); v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); struct V8Document::V8DocumentPrivate* retPrivData = new V8Document::V8DocumentPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = arbaicaRet; + retPrivData->nativeObj = arbaicaRet; arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); arbaicaRetObj.MakeWeak(0, V8Document::jsDestructor); @@ -185,28 +201,28 @@ v8::Handle V8Node::namespaceURIAttrGetter(v8::Local prope v8::Local self = info.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getNamespaceURI().c_str()); + return v8::String::New(privData->nativeObj->getNamespaceURI().c_str()); } v8::Handle V8Node::prefixAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getPrefix().c_str()); + return v8::String::New(privData->nativeObj->getPrefix().c_str()); } void V8Node::prefixAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localPrefix(value); - privData->arabicaThis->setPrefix(*localPrefix); + privData->nativeObj->setPrefix(*localPrefix); } v8::Handle V8Node::localNameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getLocalName().c_str()); + return v8::String::New(privData->nativeObj->getLocalName().c_str()); } v8::Handle V8Node::insertBeforeCallback(const v8::Arguments& args) { if (args.Length() < 2) @@ -216,16 +232,16 @@ v8::Handle V8Node::insertBeforeCallback(const v8::Arguments& args) { v8::Local self = args.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* localNewChild = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->arabicaThis; - Arabica::DOM::Node* localRefChild = V8DOM::toClassPtr(args[1]->ToObject()->GetInternalField(0))->arabicaThis; + Arabica::DOM::Node* localNewChild = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; + Arabica::DOM::Node* localRefChild = V8DOM::toClassPtr(args[1]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->arabicaThis->insertBefore(*localNewChild, *localRefChild)); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->insertBefore(*localNewChild, *localRefChild)); v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -242,16 +258,16 @@ v8::Handle V8Node::replaceChildCallback(const v8::Arguments& args) { v8::Local self = args.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* localNewChild = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->arabicaThis; - Arabica::DOM::Node* localOldChild = V8DOM::toClassPtr(args[1]->ToObject()->GetInternalField(0))->arabicaThis; + Arabica::DOM::Node* localNewChild = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; + Arabica::DOM::Node* localOldChild = V8DOM::toClassPtr(args[1]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->arabicaThis->replaceChild(*localNewChild, *localOldChild)); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->replaceChild(*localNewChild, *localOldChild)); v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -268,15 +284,15 @@ v8::Handle V8Node::removeChildCallback(const v8::Arguments& args) { v8::Local self = args.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* localOldChild = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->arabicaThis; + Arabica::DOM::Node* localOldChild = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->arabicaThis->removeChild(*localOldChild)); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->removeChild(*localOldChild)); v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -293,15 +309,15 @@ v8::Handle V8Node::appendChildCallback(const v8::Arguments& args) { v8::Local self = args.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* localNewChild = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->arabicaThis; + Arabica::DOM::Node* localNewChild = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->arabicaThis->appendChild(*localNewChild)); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->appendChild(*localNewChild)); v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -315,7 +331,7 @@ v8::Handle V8Node::hasChildNodesCallback(const v8::Arguments& args) { v8::Local self = args.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - bool retVal = privData->arabicaThis->hasChildNodes(); + bool retVal = privData->nativeObj->hasChildNodes(); return v8::Boolean::New(retVal); } @@ -328,13 +344,13 @@ v8::Handle V8Node::cloneNodeCallback(const v8::Arguments& args) { struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); bool localDeep = args[0]->ToBoolean()->BooleanValue(); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->arabicaThis->cloneNode(localDeep)); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->cloneNode(localDeep)); v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -348,7 +364,7 @@ v8::Handle V8Node::normalizeCallback(const v8::Arguments& args) { v8::Local self = args.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - privData->arabicaThis->normalize(); + privData->nativeObj->normalize(); return v8::Undefined(); } @@ -362,7 +378,7 @@ v8::Handle V8Node::isSupportedCallback(const v8::Arguments& args) { v8::String::AsciiValue localFeature(args[0]); v8::String::AsciiValue localVersion(args[1]); - bool retVal = privData->arabicaThis->isSupported(*localFeature, *localVersion); + bool retVal = privData->nativeObj->isSupported(*localFeature, *localVersion); return v8::Boolean::New(retVal); } @@ -372,7 +388,7 @@ v8::Handle V8Node::hasAttributesCallback(const v8::Arguments& args) { v8::Local self = args.Holder(); struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - bool retVal = privData->arabicaThis->hasAttributes(); + bool retVal = privData->nativeObj->hasAttributes(); return v8::Boolean::New(retVal); } diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h index ee14dc9..a15a676 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -32,7 +32,7 @@ class V8Node { public: struct V8NodePrivate { V8DOM* dom; - Arabica::DOM::Node* arabicaThis; + Arabica::DOM::Node* nativeObj; }; V8_DESTRUCTOR(V8NodePrivate); @@ -124,30 +124,30 @@ public: prototype->Set(v8::String::NewSymbol("hasAttributes"), v8::FunctionTemplate::New(V8Node::hasAttributesCallback, v8::Undefined()), static_cast(v8::DontDelete)); - tmpl->Set(v8::String::NewSymbol("ELEMENT_NODE"), v8::Integer::New(1), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("ELEMENT_NODE"), v8::Integer::New(1), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("ATTRIBUTE_NODE"), v8::Integer::New(2), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("ATTRIBUTE_NODE"), v8::Integer::New(2), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("TEXT_NODE"), v8::Integer::New(3), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("TEXT_NODE"), v8::Integer::New(3), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("CDATA_SECTION_NODE"), v8::Integer::New(4), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("CDATA_SECTION_NODE"), v8::Integer::New(4), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("ENTITY_REFERENCE_NODE"), v8::Integer::New(5), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("ENTITY_REFERENCE_NODE"), v8::Integer::New(5), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("ENTITY_NODE"), v8::Integer::New(6), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("ENTITY_NODE"), v8::Integer::New(6), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("PROCESSING_INSTRUCTION_NODE"), v8::Integer::New(7), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("PROCESSING_INSTRUCTION_NODE"), v8::Integer::New(7), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("COMMENT_NODE"), v8::Integer::New(8), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("COMMENT_NODE"), v8::Integer::New(8), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("DOCUMENT_NODE"), v8::Integer::New(9), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("DOCUMENT_NODE"), v8::Integer::New(9), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("DOCUMENT_TYPE_NODE"), v8::Integer::New(10), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("DOCUMENT_TYPE_NODE"), v8::Integer::New(10), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("DOCUMENT_FRAGMENT_NODE"), v8::Integer::New(11), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("DOCUMENT_FRAGMENT_NODE"), v8::Integer::New(11), v8::ReadOnly); - tmpl->Set(v8::String::NewSymbol("NOTATION_NODE"), v8::Integer::New(12), v8::ReadOnly); - prototype->Set(v8::String::NewSymbol("NOTATION_NODE"), v8::Integer::New(12), v8::ReadOnly); + tmpl->Set(v8::String::NewSymbol("ELEMENT_NODE"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("ELEMENT_NODE"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("ATTRIBUTE_NODE"), v8::Integer::New(2), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("ATTRIBUTE_NODE"), v8::Integer::New(2), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("TEXT_NODE"), v8::Integer::New(3), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("TEXT_NODE"), v8::Integer::New(3), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("CDATA_SECTION_NODE"), v8::Integer::New(4), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("CDATA_SECTION_NODE"), v8::Integer::New(4), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("ENTITY_REFERENCE_NODE"), v8::Integer::New(5), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("ENTITY_REFERENCE_NODE"), v8::Integer::New(5), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("ENTITY_NODE"), v8::Integer::New(6), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("ENTITY_NODE"), v8::Integer::New(6), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("PROCESSING_INSTRUCTION_NODE"), v8::Integer::New(7), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("PROCESSING_INSTRUCTION_NODE"), v8::Integer::New(7), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("COMMENT_NODE"), v8::Integer::New(8), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("COMMENT_NODE"), v8::Integer::New(8), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("DOCUMENT_NODE"), v8::Integer::New(9), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("DOCUMENT_NODE"), v8::Integer::New(9), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("DOCUMENT_TYPE_NODE"), v8::Integer::New(10), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("DOCUMENT_TYPE_NODE"), v8::Integer::New(10), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("DOCUMENT_FRAGMENT_NODE"), v8::Integer::New(11), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("DOCUMENT_FRAGMENT_NODE"), v8::Integer::New(11), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("NOTATION_NODE"), v8::Integer::New(12), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("NOTATION_NODE"), v8::Integer::New(12), static_cast(v8::ReadOnly | v8::DontEnum)); Tmpl = v8::Persistent::New(tmpl); } diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.cpp index 1f6b368..bee706e 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.cpp @@ -11,7 +11,7 @@ v8::Handle V8NodeList::lengthAttrGetter(v8::Local propert v8::Local self = info.Holder(); struct V8NodeListPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Integer::New(privData->arabicaThis->getLength()); + return v8::Integer::New(privData->nativeObj->getLength()); } v8::Handle V8NodeList::itemCallback(const v8::Arguments& args) { if (args.Length() < 1) @@ -21,13 +21,13 @@ v8::Handle V8NodeList::itemCallback(const v8::Arguments& args) { struct V8NodeListPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->arabicaThis->item(localIndex)); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->item(localIndex)); v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h index fefc084..771d82c 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -32,7 +32,7 @@ class V8NodeList { public: struct V8NodeListPrivate { V8DOM* dom; - Arabica::DOM::NodeList* arabicaThis; + Arabica::DOM::NodeList* nativeObj; }; V8_DESTRUCTOR(V8NodeListPrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp index 2b051f1..fade729 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp @@ -10,21 +10,21 @@ v8::Handle V8NodeSet::sizeAttrGetter(v8::Local property, v8::Local self = info.Holder(); struct V8NodeSetPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Integer::New(privData->arabicaThis->size()); + return v8::Integer::New(privData->nativeObj->size()); } v8::Handle V8NodeSet::emptyAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8NodeSetPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Boolean::New(privData->arabicaThis->empty()); + return v8::Boolean::New(privData->nativeObj->empty()); } v8::Handle V8NodeSet::toDocumentOrderCallback(const v8::Arguments& args) { v8::Local self = args.Holder(); struct V8NodeSetPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - privData->arabicaThis->to_document_order(); + privData->nativeObj->to_document_order(); return v8::Undefined(); } diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h index 583c1b9..294d851 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -32,7 +32,7 @@ class V8NodeSet { public: struct V8NodeSetPrivate { V8DOM* dom; - Arabica::XPath::NodeSet* arabicaThis; + Arabica::XPath::NodeSet* nativeObj; }; V8_DESTRUCTOR(V8NodeSetPrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSetCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSetCustom.cpp index 61f5947..ba84b75 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSetCustom.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSetCustom.cpp @@ -9,17 +9,17 @@ v8::Handle V8NodeSet::indexedPropertyCustomGetter(uint32_t index, con v8::Local self = info.Holder(); V8NodeSetPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - if (privData->arabicaThis->size() >= index) { - switch((*privData->arabicaThis)[index].getNodeType()) { + if (privData->nativeObj->size() >= index) { + switch((*privData->nativeObj)[index].getNodeType()) { case Node_base::ELEMENT_NODE: { - Arabica::DOM::Element* retVal = new Arabica::DOM::Element((*privData->arabicaThis)[index]); + Arabica::DOM::Element* retVal = new Arabica::DOM::Element((*privData->nativeObj)[index]); v8::Handle retCtor = V8Element::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -27,14 +27,14 @@ v8::Handle V8NodeSet::indexedPropertyCustomGetter(uint32_t index, con return retObj; } default: { - Arabica::DOM::Node* retVal = new Arabica::DOM::Node((*privData->arabicaThis)[index]); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node((*privData->nativeObj)[index]); v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.cpp index e210491..129563d 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.cpp @@ -11,14 +11,14 @@ v8::Handle V8Notation::publicIdAttrGetter(v8::Local prope v8::Local self = info.Holder(); struct V8NotationPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getPublicId().c_str()); + return v8::String::New(privData->nativeObj->getPublicId().c_str()); } v8::Handle V8Notation::systemIdAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8NotationPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getSystemId().c_str()); + return v8::String::New(privData->nativeObj->getSystemId().c_str()); } bool V8Notation::hasInstance(v8::Handle value) { return getTmpl()->HasInstance(value); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h index f29d1fe..ba90056 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -33,7 +33,7 @@ class V8Notation { public: struct V8NotationPrivate { V8DOM* dom; - Arabica::DOM::Notation* arabicaThis; + Arabica::DOM::Notation* nativeObj; }; V8_DESTRUCTOR(V8NotationPrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.cpp index c299d76..c6d2b28 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.cpp @@ -11,21 +11,21 @@ v8::Handle V8ProcessingInstruction::targetAttrGetter(v8::Local self = info.Holder(); struct V8ProcessingInstructionPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getTarget().c_str()); + return v8::String::New(privData->nativeObj->getTarget().c_str()); } v8::Handle V8ProcessingInstruction::dataAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8ProcessingInstructionPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->getData().c_str()); + return v8::String::New(privData->nativeObj->getData().c_str()); } void V8ProcessingInstruction::dataAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8ProcessingInstructionPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); v8::String::AsciiValue localData(value); - privData->arabicaThis->setData(*localData); + privData->nativeObj->setData(*localData); } bool V8ProcessingInstruction::hasInstance(v8::Handle value) { return getTmpl()->HasInstance(value); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h index 61eaa2e..995d066 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -33,7 +33,7 @@ class V8ProcessingInstruction { public: struct V8ProcessingInstructionPrivate { V8DOM* dom; - Arabica::DOM::ProcessingInstruction* arabicaThis; + Arabica::DOM::ProcessingInstruction* nativeObj; }; V8_DESTRUCTOR(V8ProcessingInstructionPrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp new file mode 100644 index 0000000..ed6133a --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp @@ -0,0 +1,76 @@ +#include "V8Node.h" +#include "V8SCXMLEvent.h" + +namespace Arabica { +namespace DOM { + +v8::Persistent V8SCXMLEvent::Tmpl; + + +v8::Handle V8SCXMLEvent::typeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::Integer::New(privData->nativeObj->type); +} + +v8::Handle V8SCXMLEvent::nameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::String::New(privData->nativeObj->name.c_str()); +} + +v8::Handle V8SCXMLEvent::originAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::String::New(privData->nativeObj->origin.c_str()); +} + +v8::Handle V8SCXMLEvent::origintypeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::String::New(privData->nativeObj->origintype.c_str()); +} + +v8::Handle V8SCXMLEvent::domAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + if (!privData->nativeObj->dom) return v8::Undefined(); + Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->dom); + + v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); + return arbaicaRetObj; + +} + +v8::Handle V8SCXMLEvent::sendidAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::String::New(privData->nativeObj->sendid.c_str()); +} + +v8::Handle V8SCXMLEvent::invokeidAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + return v8::String::New(privData->nativeObj->invokeid.c_str()); +} +bool V8SCXMLEvent::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); +} + +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h new file mode 100644 index 0000000..26ac8b6 --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h @@ -0,0 +1,95 @@ +/* + 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 V8SCXMLEvent_h +#define V8SCXMLEvent_h + +#include "DOM/Node.hpp" +#include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" +#include + +namespace Arabica { +namespace DOM { + +class V8SCXMLEvent { +public: + struct V8SCXMLEventPrivate { + V8DOM* dom; + uscxml::Event* nativeObj; + }; + + V8_DESTRUCTOR_KEEP_WRAPPED(V8SCXMLEventPrivate); + static bool hasInstance(v8::Handle); + + + static v8::Handle typeAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle nameAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle originAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle origintypeAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle domAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle sendidAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle invokeidAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("SCXMLEvent")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("type"), V8SCXMLEvent::typeAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("name"), V8SCXMLEvent::nameAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("origin"), V8SCXMLEvent::originAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("origintype"), V8SCXMLEvent::origintypeAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("dom"), V8SCXMLEvent::domAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("sendid"), V8SCXMLEvent::sendidAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("invokeid"), V8SCXMLEvent::invokeidAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + + + tmpl->Set(v8::String::NewSymbol("INTERNAL"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("INTERNAL"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("EXTERNAL"), v8::Integer::New(2), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("EXTERNAL"), v8::Integer::New(2), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("PLATFORM"), v8::Integer::New(3), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("PLATFORM"), v8::Integer::New(3), static_cast(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } + + +}; + +} +} + +#endif // V8SCXMLEvent_h diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.cpp index fd9f6a3..42b298a 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.cpp @@ -14,13 +14,13 @@ v8::Handle V8Text::splitTextCallback(const v8::Arguments& args) { struct V8TextPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); - Arabica::DOM::Text* retVal = new Arabica::DOM::Text(privData->arabicaThis->splitText(localOffset)); + Arabica::DOM::Text* retVal = new Arabica::DOM::Text(privData->nativeObj->splitText(localOffset)); v8::Handle retCtor = V8Text::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Text::V8TextPrivate* retPrivData = new V8Text::V8TextPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h index fdabf6e..4861dc8 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -33,7 +33,7 @@ class V8Text { public: struct V8TextPrivate { V8DOM* dom; - Arabica::DOM::Text* arabicaThis; + Arabica::DOM::Text* nativeObj; }; V8_DESTRUCTOR(V8TextPrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp index 0d6210f..968e53d 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp @@ -11,34 +11,34 @@ v8::Handle V8XPathResult::numberValueAttrGetter(v8::Local v8::Local self = info.Holder(); struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Number::New(privData->arabicaThis->asNumber()); + return v8::Number::New(privData->nativeObj->asNumber()); } v8::Handle V8XPathResult::stringValueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->arabicaThis->asString().c_str()); + return v8::String::New(privData->nativeObj->asString().c_str()); } v8::Handle V8XPathResult::booleanValueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { v8::Local self = info.Holder(); struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Boolean::New(privData->arabicaThis->asBool()); + return v8::Boolean::New(privData->nativeObj->asBool()); } v8::Handle V8XPathResult::asNodeSetCallback(const v8::Arguments& args) { v8::Local self = args.Holder(); struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::XPath::NodeSet* retVal = new Arabica::XPath::NodeSet(privData->arabicaThis->asNodeSet()); + Arabica::XPath::NodeSet* retVal = new Arabica::XPath::NodeSet(privData->nativeObj->asNodeSet()); v8::Handle retCtor = V8NodeSet::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8NodeSet::V8NodeSetPrivate* retPrivData = new V8NodeSet::V8NodeSetPrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); @@ -52,7 +52,7 @@ v8::Handle V8XPathResult::asBoolCallback(const v8::Arguments& args) { v8::Local self = args.Holder(); struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - bool retVal = privData->arabicaThis->asBool(); + bool retVal = privData->nativeObj->asBool(); return v8::Boolean::New(retVal); } @@ -62,7 +62,7 @@ v8::Handle V8XPathResult::asStringCallback(const v8::Arguments& args) v8::Local self = args.Holder(); struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - std::string retVal = privData->arabicaThis->asString(); + std::string retVal = privData->nativeObj->asString(); return v8::String::New(retVal.c_str()); } @@ -72,7 +72,7 @@ v8::Handle V8XPathResult::asNumberCallback(const v8::Arguments& args) v8::Local self = args.Holder(); struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - double retVal = privData->arabicaThis->asNumber(); + double retVal = privData->nativeObj->asNumber(); return v8::Number::New(retVal); } diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h index 96410df..9a3bf4d 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h @@ -1,5 +1,5 @@ /* - This file is part of the Arabica open source project. + 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 @@ -32,7 +32,7 @@ class V8XPathResult { public: struct V8XPathResultPrivate { V8DOM* dom; - Arabica::XPath::XPathValue* arabicaThis; + Arabica::XPath::XPathValue* nativeObj; }; V8_DESTRUCTOR(V8XPathResultPrivate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResultCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResultCustom.cpp index 38b2cb5..6accfc7 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResultCustom.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResultCustom.cpp @@ -8,14 +8,14 @@ v8::Handle V8XPathResult::singleNodeValueCustomAttrGetter(v8::Local self = info.Holder(); V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->arabicaThis->asNodeSet()[0]); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->asNodeSet()[0]); v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); retPrivData->dom = privData->dom; - retPrivData->arabicaThis = retVal; + retPrivData->nativeObj = retVal; retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h index 9a10dc7..63300dd 100644 --- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h +++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h @@ -47,11 +47,6 @@ public: protected: - Interpreter* _interpreter; - - std::string _sessionId; - std::string _name; - Event _event; PlEngine* _plEngine; diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp new file mode 100644 index 0000000..8489d1d --- /dev/null +++ b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp @@ -0,0 +1,197 @@ +#include "DirMonInvoker.h" +#include + +#ifdef BUILD_AS_PLUGINS +#include +#endif + +#include +#ifndef WIN32 +#include +#else +#include +#endif + +namespace uscxml { + +#ifdef BUILD_AS_PLUGINS +PLUMA_CONNECTOR +bool connect(pluma::Host& host) { + host.add( new DirMonInvokerProvider() ); + return true; +} +#endif + +DirMonInvoker::DirMonInvoker() : _reportExisting(false), _recurse(false), _thread(NULL) { +} + +DirMonInvoker::~DirMonInvoker() { + _isRunning = false; + if (_thread) + _thread->join(); +}; + +boost::shared_ptr DirMonInvoker::create(Interpreter* interpreter) { + boost::shared_ptr invoker = boost::shared_ptr(new DirMonInvoker()); + invoker->_interpreter = interpreter; + return invoker; +} + +Data DirMonInvoker::getDataModelVariables() { + Data data; + return data; +} + +void DirMonInvoker::send(const SendRequest& req) { +} + +void DirMonInvoker::cancel(const std::string sendId) { +} + +void DirMonInvoker::invoke(const InvokeRequest& req) { + if (req.params.find("dir") != req.params.end() && boost::iequals(req.params.find("reportexisting")->second, "true")) + _reportExisting = true; + if (req.params.find("recurse") != req.params.end() && boost::iequals(req.params.find("recurse")->second, "true")) + _recurse = true; + if (req.params.find("suffix") != req.params.end()) + _suffix = req.params.find("suffix")->second; + + std::multimap::const_iterator dirIter = req.params.find("dir"); + while(dirIter != req.params.upper_bound("dir")) { + URL url(dirIter->second); + if (!_interpreter->toAbsoluteURI(url) || !boost::iequals(url.scheme(), "file")) { + LOG(ERROR) << "Given directory '" << dirIter->second << "' cannot be transformed to absolute path"; + } else { + _watchIds.insert(std::make_pair(url.path(), _fileWatcher.addWatch(url.path(), this, _recurse))); + } + dirIter++; + } + _isRunning = true; + _thread = new tthread::thread(DirMonInvoker::run, this); +} + +void DirMonInvoker::run(void* instance) { + if (((DirMonInvoker*)instance)->_reportExisting) + ((DirMonInvoker*)instance)->reportExisting(); + + while(((DirMonInvoker*)instance)->_isRunning) + ((DirMonInvoker*)instance)->_fileWatcher.update(); +} + +void DirMonInvoker::reportExisting() { + std::multimap::iterator watchIter = _watchIds.begin(); + while(watchIter != _watchIds.end()) { + reportExistingIn(watchIter->first, watchIter->second); + watchIter++; + } +} + +void DirMonInvoker::handleFileAction(FW::WatchID watchid, const FW::String& dir, const FW::String& filename, FW::Action action) { + if (!boost::algorithm::ends_with(filename, _suffix)) + return; + + struct stat fileStat; + if (stat(filename.c_str(), &fileStat) != 0) { + LOG(ERROR) << "Error with stat on directory entry " << filename << ": " << strerror(errno); + return; + } + + Event event; + event.invokeid = _invokeId; + switch (action) { + case FW::Actions::Existing: + event.name = "file.existing"; + break; + case FW::Actions::Add: + event.name = "file.added"; + break; + case FW::Actions::Delete: + event.name = "file.deleted"; + break; + case FW::Actions::Modified: + event.name = "file.modified"; + break; + + default: + break; + } + + event.compound["file"].compound["name"] = Data(filename, Data::VERBATIM); + event.compound["file"].compound["dir"] = Data(dir, Data::VERBATIM); + + event.compound["file"].compound["mtime"] = toStr(fileStat.st_mtime); + event.compound["file"].compound["ctime"] = toStr(fileStat.st_ctime); + event.compound["file"].compound["atime"] = toStr(fileStat.st_atime); + event.compound["file"].compound["size"] = toStr(fileStat.st_size); + + returnEvent(event); +} + +bool DirMonInvoker::filter(const std::string filename) { + return true; +} + +void DirMonInvoker::reportExistingIn(const std::string dir, FW::WatchID watchid) { +#ifndef WIN32 + DIR *dp; + dp = opendir(dir.c_str()); + if (dp == NULL) { + LOG(ERROR) << "Error opening directory " << dir << ": " << strerror(errno); + return; + } + // iterate all entries and see what changed + struct dirent* entry; + while((entry = readdir(dp))) { + std::string dname = entry->d_name; +#else + WIN32_FIND_DATA ffd; + HANDLE hFind = INVALID_HANDLE_VALUE; + TCHAR szDir[MAX_PATH]; + StringCchCopy(szDir, MAX_PATH, dir.c_str()); + StringCchCat(szDir, MAX_PATH, TEXT("\\*")); + + hFind = FindFirstFile(szDir, &ffd); + do { + std::string dname = ffd.cFileName; +#endif + + if (boost::iequals(dname, ".") || boost::iequals(dname, "..")) + continue; + + char* filename; + asprintf(&filename, "%s/%s", dir.c_str(), dname.c_str()); + + struct stat fileStat; + if (stat(filename, &fileStat) != 0) { + LOG(ERROR) << "Error with stat on directory entry " << filename << ": " << strerror(errno); + free(filename); + continue; + } + + if (fileStat.st_mode & S_IFDIR) { + if (_recurse) { + reportExistingIn(filename, watchid); + } else { + free(filename); + continue; + } + } + + if (!filter(dname)) { + free(filename); + continue; + } + + handleFileAction(watchid, dir, filename, FW::Actions::Existing); +#ifndef WIN32 + } + closedir(dp); +#else + } + while (FindNextFile(hFind, &ffd) != 0); + FindClose(hFind); +#endif + +} + +} \ No newline at end of file diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.h b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.h new file mode 100644 index 0000000..1437759 --- /dev/null +++ b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.h @@ -0,0 +1,58 @@ +#ifndef DIRMONINVOKER_H_W09J90F0 +#define DIRMONINVOKER_H_W09J90F0 + +#include +#include "FileWatcher/FileWatcher.h" +#include + +#ifdef BUILD_AS_PLUGINS +#include "uscxml/plugins/Plugins.h" +#endif + +namespace uscxml { + +class DirMonInvoker : public InvokerImpl, public FW::FileWatchListener { +public: + DirMonInvoker(); + virtual ~DirMonInvoker(); + virtual boost::shared_ptr create(Interpreter* interpreter); + + virtual std::set getNames() { + std::set names; + names.insert("dirmon"); + names.insert("DirectoryMonitor"); + names.insert("http://uscxml.tk.informatik.tu-darmstadt.de/#dirmon"); + return names; + } + + virtual Data getDataModelVariables(); + virtual void send(const SendRequest& req); + virtual void cancel(const std::string sendId); + virtual void invoke(const InvokeRequest& req); + + void handleFileAction(FW::WatchID watchid, const FW::String& dir, const FW::String& filename, FW::Action action); + void reportExisting(); + void reportExistingIn(const std::string dir, FW::WatchID watchid); + virtual bool filter(const std::string filename); + + static void run(void* instance); + +protected: + bool _reportExisting; + bool _recurse; + std::string _suffix; + + bool _isRunning; + tthread::thread* _thread; + FW::FileWatcher _fileWatcher; + std::multimap _watchIds; +}; + +#ifdef BUILD_AS_PLUGINS +PLUMA_INHERIT_PROVIDER(DirMonInvoker, Invoker); +#endif + +} + + +#endif /* end of include guard: DIRMONINVOKER_H_W09J90F0 */ diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcher.cpp b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcher.cpp new file mode 100644 index 0000000..9399495 --- /dev/null +++ b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcher.cpp @@ -0,0 +1,75 @@ +/** + Copyright (c) 2009 James Wynn (james@jameswynn.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#include +#include + +#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_WIN32 +# include +# define FILEWATCHER_IMPL FileWatcherWin32 +#elif FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_KQUEUE +# include +# define FILEWATCHER_IMPL FileWatcherOSX +#elif FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_LINUX +# include +# define FILEWATCHER_IMPL FileWatcherLinux +#endif + +namespace FW { + +//-------- +FileWatcher::FileWatcher() { + mImpl = new FILEWATCHER_IMPL(); +} + +//-------- +FileWatcher::~FileWatcher() { + delete mImpl; + mImpl = 0; +} + +//-------- +WatchID FileWatcher::addWatch(const String& directory, FileWatchListener* watcher) { + return mImpl->addWatch(directory, watcher, false); +} + +//-------- +WatchID FileWatcher::addWatch(const String& directory, FileWatchListener* watcher, bool recursive) { + return mImpl->addWatch(directory, watcher, recursive); +} + +//-------- +void FileWatcher::removeWatch(const String& directory) { + mImpl->removeWatch(directory); +} + +//-------- +void FileWatcher::removeWatch(WatchID watchid) { + mImpl->removeWatch(watchid); +} + +//-------- +void FileWatcher::update() { + mImpl->update(); +} + +};//namespace FW diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcher.h b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcher.h new file mode 100644 index 0000000..0e659b6 --- /dev/null +++ b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcher.h @@ -0,0 +1,141 @@ +/** + Main header for the FileWatcher class. Declares all implementation + classes to reduce compilation overhead. + + @author James Wynn + @date 4/15/2009 + + Copyright (c) 2009 James Wynn (james@jameswynn.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#ifndef _FW_FILEWATCHER_H_ +#define _FW_FILEWATCHER_H_ +#pragma once + +#include +#include + +namespace FW { +/// Type for a string +typedef std::string String; +/// Type for a watch id +typedef unsigned long WatchID; + +// forward declarations +class FileWatcherImpl; +class FileWatchListener; + +/// Base exception class +/// @class Exception +class Exception : public std::runtime_error { +public: + Exception(const String& message) + : std::runtime_error(message) + {} +}; + +/// Exception thrown when a file is not found. +/// @class FileNotFoundException +class FileNotFoundException : public Exception { +public: + FileNotFoundException() + : Exception("File not found") + {} + + FileNotFoundException(const String& filename) + : Exception("File not found (" + filename + ")") + {} +}; + +/// Actions to listen for. Rename will send two events, one for +/// the deletion of the old file, and one for the creation of the +/// new file. +namespace Actions { +enum Action { + /// Sent when a file is created or renamed + Add = 1, + /// Sent when a file is deleted or renamed + Delete = 2, + /// Sent when a file is modified + Modified = 4, + /// Sent when an existing file is reported + Existing = 8 +}; +}; +typedef Actions::Action Action; + +/// Listens to files and directories and dispatches events +/// to notify the parent program of the changes. +/// @class FileWatcher +class FileWatcher { +public: + /// + /// + FileWatcher(); + + /// + /// + virtual ~FileWatcher(); + + /// Add a directory watch. Same as the other addWatch, but doesn't have recursive option. + /// For backwards compatibility. + /// @exception FileNotFoundException Thrown when the requested directory does not exist + WatchID addWatch(const String& directory, FileWatchListener* watcher); + + /// Add a directory watch + /// @exception FileNotFoundException Thrown when the requested directory does not exist + WatchID addWatch(const String& directory, FileWatchListener* watcher, bool recursive); + + /// Remove a directory watch. This is a brute force search O(nlogn). + void removeWatch(const String& directory); + + /// Remove a directory watch. This is a map lookup O(logn). + void removeWatch(WatchID watchid); + + /// Updates the watcher. Must be called often. + void update(); + +private: + /// The implementation + FileWatcherImpl* mImpl; + +};//end FileWatcher + + +/// Basic interface for listening for file events. +/// @class FileWatchListener +class FileWatchListener { +public: + FileWatchListener() {} + virtual ~FileWatchListener() {} + + /// Handles the action file action + /// @param watchid The watch id for the directory + /// @param dir The directory + /// @param filename The filename that was accessed (not full path) + /// @param action Action that was performed + virtual void handleFileAction(WatchID watchid, const String& dir, const String& filename, Action action) = 0; + +};//class FileWatchListener + +};//namespace FW + +#endif//_FW_FILEWATCHER_H_ diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherImpl.h b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherImpl.h new file mode 100644 index 0000000..08cfed1 --- /dev/null +++ b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherImpl.h @@ -0,0 +1,77 @@ +/** + Basic interface for the FileWatcher backend. + + @author James Wynn + @date 5/11/2009 + + Copyright (c) 2009 James Wynn (james@jameswynn.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ +#ifndef _FW_FILEWATCHERIMPL_H_ +#define _FW_FILEWATCHERIMPL_H_ +#pragma once + +#include "FileWatcher.h" + +#define FILEWATCHER_PLATFORM_WIN32 1 +#define FILEWATCHER_PLATFORM_LINUX 2 +#define FILEWATCHER_PLATFORM_KQUEUE 3 + +#if defined(_WIN32) +# define FILEWATCHER_PLATFORM FILEWATCHER_PLATFORM_WIN32 +#elif defined(__APPLE_CC__) || defined(BSD) +# define FILEWATCHER_PLATFORM FILEWATCHER_PLATFORM_KQUEUE +#elif defined(__linux__) +# define FILEWATCHER_PLATFORM FILEWATCHER_PLATFORM_LINUX +#endif + +namespace FW { +struct WatchStruct; + +class FileWatcherImpl { +public: + /// + /// + FileWatcherImpl() {} + + /// + /// + virtual ~FileWatcherImpl() {} + + /// Add a directory watch + /// @exception FileNotFoundException Thrown when the requested directory does not exist + virtual WatchID addWatch(const String& directory, FileWatchListener* watcher, bool recursive) = 0; + + /// Remove a directory watch. This is a brute force lazy search O(nlogn). + virtual void removeWatch(const String& directory) = 0; + + /// Remove a directory watch. This is a map lookup O(logn). + virtual void removeWatch(WatchID watchid) = 0; + + /// Updates the watcher. Must be called often. + virtual void update() = 0; + + /// Handles the action + virtual void handleAction(WatchStruct* watch, const String& filename, unsigned long action) = 0; + +};//end FileWatcherImpl +};//namespace FW + +#endif//_FW_FILEWATCHERIMPL_H_ diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherLinux.cpp b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherLinux.cpp new file mode 100644 index 0000000..ecbaa32 --- /dev/null +++ b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherLinux.cpp @@ -0,0 +1,165 @@ +/** + Copyright (c) 2009 James Wynn (james@jameswynn.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + + James Wynn james@jameswynn.com +*/ + +#include + +#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_LINUX + +#include +#include +#include +#include +#include +#include + +#define BUFF_SIZE ((sizeof(struct inotify_event)+FILENAME_MAX)*1024) + +namespace FW { + +struct WatchStruct { + WatchID mWatchID; + String mDirName; + FileWatchListener* mListener; +}; + +//-------- +FileWatcherLinux::FileWatcherLinux() { + mFD = inotify_init(); + if (mFD < 0) + fprintf (stderr, "Error: %s\n", strerror(errno)); + + mTimeOut.tv_sec = 0; + mTimeOut.tv_usec = 0; + + FD_ZERO(&mDescriptorSet); +} + +//-------- +FileWatcherLinux::~FileWatcherLinux() { + WatchMap::iterator iter = mWatches.begin(); + WatchMap::iterator end = mWatches.end(); + for(; iter != end; ++iter) { + delete iter->second; + } + mWatches.clear(); +} + +//-------- +WatchID FileWatcherLinux::addWatch(const String& directory, FileWatchListener* watcher, bool recursive) { + int wd = inotify_add_watch (mFD, directory.c_str(), + IN_CLOSE_WRITE | IN_MOVED_TO | IN_CREATE | IN_MOVED_FROM | IN_DELETE); + if (wd < 0) { + if(errno == ENOENT) + throw FileNotFoundException(directory); + else + throw Exception(strerror(errno)); + +// fprintf (stderr, "Error: %s\n", strerror(errno)); +// return -1; + } + + WatchStruct* pWatch = new WatchStruct(); + pWatch->mListener = watcher; + pWatch->mWatchID = wd; + pWatch->mDirName = directory; + + mWatches.insert(std::make_pair(wd, pWatch)); + + return wd; +} + +//-------- +void FileWatcherLinux::removeWatch(const String& directory) { + WatchMap::iterator iter = mWatches.begin(); + WatchMap::iterator end = mWatches.end(); + for(; iter != end; ++iter) { + if(directory == iter->second->mDirName) { + removeWatch(iter->first); + return; + } + } +} + +//-------- +void FileWatcherLinux::removeWatch(WatchID watchid) { + WatchMap::iterator iter = mWatches.find(watchid); + + if(iter == mWatches.end()) + return; + + WatchStruct* watch = iter->second; + mWatches.erase(iter); + + inotify_rm_watch(mFD, watchid); + + delete watch; + watch = 0; +} + +//-------- +void FileWatcherLinux::update() { + FD_SET(mFD, &mDescriptorSet); + + int ret = select(mFD + 1, &mDescriptorSet, NULL, NULL, &mTimeOut); + if(ret < 0) { + perror("select"); + } else if(FD_ISSET(mFD, &mDescriptorSet)) { + ssize_t len, i = 0; + char action[81+FILENAME_MAX] = {0}; + char buff[BUFF_SIZE] = {0}; + + len = read (mFD, buff, BUFF_SIZE); + + while (i < len) { + struct inotify_event *pevent = (struct inotify_event *)&buff[i]; + + WatchStruct* watch = mWatches[pevent->wd]; + handleAction(watch, pevent->name, pevent->mask); + i += sizeof(struct inotify_event) + pevent->len; + } + } +} + +//-------- +void FileWatcherLinux::handleAction(WatchStruct* watch, const String& filename, unsigned long action) { + if(!watch->mListener) + return; + + if(IN_CLOSE_WRITE & action) { + watch->mListener->handleFileAction(watch->mWatchID, watch->mDirName, filename, + Actions::Modified); + } + if(IN_MOVED_TO & action || IN_CREATE & action) { + watch->mListener->handleFileAction(watch->mWatchID, watch->mDirName, filename, + Actions::Add); + } + if(IN_MOVED_FROM & action || IN_DELETE & action) { + watch->mListener->handleFileAction(watch->mWatchID, watch->mDirName, filename, + Actions::Delete); + } +} + +};//namespace FW + +#endif//FILEWATCHER_PLATFORM_LINUX diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherLinux.h b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherLinux.h new file mode 100644 index 0000000..b681e52 --- /dev/null +++ b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherLinux.h @@ -0,0 +1,89 @@ +/** + Implementation header file for Linux based on inotify. + + @author James Wynn + @date 4/15/2009 + + Copyright (c) 2009 James Wynn (james@jameswynn.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ +#ifndef _FW_FILEWATCHERLINUX_H_ +#define _FW_FILEWATCHERLINUX_H_ +#pragma once + +#include "FileWatcherImpl.h" + +#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_LINUX + +#include +#include + +namespace FW { +/// Implementation for Linux based on inotify. +/// @class FileWatcherLinux +class FileWatcherLinux : public FileWatcherImpl { +public: + /// type for a map from WatchID to WatchStruct pointer + typedef std::map WatchMap; + +public: + /// + /// + FileWatcherLinux(); + + /// + /// + virtual ~FileWatcherLinux(); + + /// Add a directory watch + /// @exception FileNotFoundException Thrown when the requested directory does not exist + WatchID addWatch(const String& directory, FileWatchListener* watcher, bool recursive); + + /// Remove a directory watch. This is a brute force lazy search O(nlogn). + void removeWatch(const String& directory); + + /// Remove a directory watch. This is a map lookup O(logn). + void removeWatch(WatchID watchid); + + /// Updates the watcher. Must be called often. + void update(); + + /// Handles the action + void handleAction(WatchStruct* watch, const String& filename, unsigned long action); + +private: + /// Map of WatchID to WatchStruct pointers + WatchMap mWatches; + /// The last watchid + WatchID mLastWatchID; + /// inotify file descriptor + int mFD; + /// time out data + struct timeval mTimeOut; + /// File descriptor set + fd_set mDescriptorSet; + +};//end FileWatcherLinux + +};//namespace FW + +#endif//FILEWATCHER_PLATFORM_LINUX + +#endif//_FW_FILEWATCHERLINUX_H_ diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherOSX.cpp b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherOSX.cpp new file mode 100644 index 0000000..e1634b0 --- /dev/null +++ b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherOSX.cpp @@ -0,0 +1,364 @@ +/** + Copyright (c) 2009 James Wynn (james@jameswynn.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + + James Wynn james@jameswynn.com +*/ + +#include + +#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_KQUEUE + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// this is more suited: +// https://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/FSEvents_ProgGuide/UsingtheFSEventsFramework/UsingtheFSEventsFramework.html + +namespace FW { + +#define MAX_CHANGE_EVENT_SIZE 2000 + +typedef struct kevent KEvent; + +struct EntryStruct { + EntryStruct(const char* filename, time_t mtime = 0) + : mFilename(filename), mModifiedTime(mtime) { + } + ~EntryStruct() { + delete[] mFilename; + } + const char* mFilename; + time_t mModifiedTime; +}; + +int comparator(const void* ke1, const void* ke2) { + /*KEvent* kevent1 = (KEvent*) ke1; + KEvent* kevent2 = (KEvent*) ke2; + + EntryStruct* event1 = (EntryStruct*)kevent1->udata; + EntryStruct* event2 = (EntryStruct*)kevent2->udata; + return strcmp(event1->mFilename, event2->mFilename); + */ + return strcmp(((EntryStruct*)(((KEvent*)(ke1))->udata))->mFilename, ((EntryStruct*)(((KEvent*)(ke2))->udata))->mFilename); +} + +struct WatchStruct { + WatchID mWatchID; + String mDirName; + FileWatchListener* mListener; + + // index 0 is always the directory + KEvent mChangeList[MAX_CHANGE_EVENT_SIZE]; + size_t mChangeListCount; + + WatchStruct(WatchID watchid, const String& dirname, FileWatchListener* listener) + : mWatchID(watchid), mDirName(dirname), mListener(listener) { + mChangeListCount = 0; + addAll(); + } + + void addFile(const String& name, bool imitEvents = true) { + //fprintf(stderr, "ADDED: %s\n", name.c_str()); + + // create entry + struct stat attrib; + stat(name.c_str(), &attrib); + + int fd = open(name.c_str(), O_RDONLY); + + if(fd == -1) + throw FileNotFoundException(name); + + ++mChangeListCount; + + char* namecopy = new char[name.length() + 1]; + strncpy(namecopy, name.c_str(), name.length()); + namecopy[name.length()] = 0; + EntryStruct* entry = new EntryStruct(namecopy, attrib.st_mtime); + + // set the event data at the end of the list + EV_SET(&mChangeList[mChangeListCount], fd, EVFILT_VNODE, + EV_ADD | EV_ENABLE | EV_ONESHOT, + NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_ATTRIB, + 0, (void*)entry); + + // qsort + qsort(mChangeList + 1, mChangeListCount, sizeof(KEvent), comparator); + + // handle action + if(imitEvents) + handleAction(name, Actions::Add); + } + + void removeFile(const String& name, bool imitEvents = true) { + // bsearch + KEvent target; + EntryStruct tempEntry(name.c_str(), 0); + target.udata = &tempEntry; + KEvent* ke = (KEvent*)bsearch(&target, &mChangeList, mChangeListCount + 1, sizeof(KEvent), comparator); + if(!ke) + throw FileNotFoundException(name); + + tempEntry.mFilename = 0; + + // delete + close(ke->ident); + delete((EntryStruct*)ke->udata); + memset(ke, 0, sizeof(KEvent)); + + // move end to current + memcpy(ke, &mChangeList[mChangeListCount], sizeof(KEvent)); + memset(&mChangeList[mChangeListCount], 0, sizeof(KEvent)); + --mChangeListCount; + + // qsort + qsort(mChangeList + 1, mChangeListCount, sizeof(KEvent), comparator); + + // handle action + if(imitEvents) + handleAction(name, Actions::Delete); + } + + // called when the directory is actually changed + // means a file has been added or removed + // rescans the watched directory adding/removing files and sending notices + void rescan() { + // if new file, call addFile + // if missing file, call removeFile + // if timestamp modified, call handleAction(filename, ACTION_MODIFIED); + DIR* dir = opendir(mDirName.c_str()); + if(!dir) + return; + + struct dirent* dentry; + KEvent* ke = &mChangeList[1]; + EntryStruct* entry = 0; + struct stat attrib; + + while((dentry = readdir(dir)) != NULL) { + String fname = mDirName + "/" + dentry->d_name; + stat(fname.c_str(), &attrib); + if(!S_ISREG(attrib.st_mode)) + continue; + + if(ke <= &mChangeList[mChangeListCount]) { + entry = (EntryStruct*)ke->udata; + int result = strcmp(entry->mFilename, fname.c_str()); + //fprintf(stderr, "[%s cmp %s]\n", entry->mFilename, fname.c_str()); + if(result == 0) { + stat(entry->mFilename, &attrib); + time_t timestamp = attrib.st_mtime; + + if(entry->mModifiedTime != timestamp) { + entry->mModifiedTime = timestamp; + handleAction(entry->mFilename, Actions::Modified); + } + ke++; + } else if(result < 0) { + // f1 was deleted + removeFile(entry->mFilename); + ke++; + } else { + // f2 was created + addFile(fname); + ke++; + } + } else { + // just add + addFile(fname); + ke++; + } + }//end while + + closedir(dir); + }; + + void handleAction(const String& filename, FW::Action action) { + mListener->handleFileAction(mWatchID, mDirName, filename, action); + } + + void addAll() { + // add base dir + int fd = open(mDirName.c_str(), O_RDONLY); + EV_SET(&mChangeList[0], fd, EVFILT_VNODE, + EV_ADD | EV_ENABLE | EV_ONESHOT, + NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_ATTRIB, + 0, 0); + + //fprintf(stderr, "ADDED: %s\n", mDirName.c_str()); + + // scan directory and call addFile(name, false) on each file + DIR* dir = opendir(mDirName.c_str()); + if(!dir) + throw FileNotFoundException(mDirName); + + struct dirent* entry; + struct stat attrib; + while((entry = readdir(dir)) != NULL) { + String fname = (mDirName + "/" + String(entry->d_name)); + stat(fname.c_str(), &attrib); + if(S_ISREG(attrib.st_mode)) + addFile(fname, false); + //else + // fprintf(stderr, "NOT ADDED: %s (%d)\n", fname.c_str(), attrib.st_mode); + + }//end while + + closedir(dir); + } + + void removeAll() { + KEvent* ke = NULL; + + // go through list removing each file and sending an event + for(int i = 0; i < mChangeListCount; ++i) { + ke = &mChangeList[i]; + //handleAction(name, Action::Delete); + EntryStruct* entry = (EntryStruct*)ke->udata; + + handleAction(entry->mFilename, Actions::Delete); + + // delete + close(ke->ident); + delete((EntryStruct*)ke->udata); + } + } +}; + +void FileWatcherOSX::update() { + int nev = 0; + struct kevent event; + + WatchMap::iterator iter = mWatches.begin(); + WatchMap::iterator end = mWatches.end(); + for(; iter != end; ++iter) { + WatchStruct* watch = iter->second; + + while((nev = kevent(mDescriptor, (KEvent*)&(watch->mChangeList), watch->mChangeListCount + 1, &event, 1, &mTimeOut)) != 0) { + if(nev == -1) + perror("kevent"); + else { + EntryStruct* entry = 0; + if((entry = (EntryStruct*)event.udata) != 0) { + //fprintf(stderr, "File: %s -- ", (char*)entry->mFilename); + + if(event.fflags & NOTE_DELETE) { + //fprintf(stderr, "File deleted\n"); + //watch->handleAction(entry->mFilename, Action::Delete); + watch->removeFile(entry->mFilename); + } + if(event.fflags & NOTE_EXTEND || + event.fflags & NOTE_WRITE || + event.fflags & NOTE_ATTRIB) { + //fprintf(stderr, "modified\n"); + //watch->rescan(); + struct stat attrib; + stat(entry->mFilename, &attrib); + entry->mModifiedTime = attrib.st_mtime; + watch->handleAction(entry->mFilename, FW::Actions::Modified); + } + } else { + //fprintf(stderr, "Dir: %s -- rescanning\n", watch->mDirName.c_str()); + watch->rescan(); + } + } + } + } +} + +//-------- +FileWatcherOSX::FileWatcherOSX() { + mDescriptor = kqueue(); + mTimeOut.tv_sec = 0; + mTimeOut.tv_nsec = 2000000; +} + +//-------- +FileWatcherOSX::~FileWatcherOSX() { + WatchMap::iterator iter = mWatches.begin(); + WatchMap::iterator end = mWatches.end(); + for(; iter != end; ++iter) { + delete iter->second; + } + mWatches.clear(); + + close(mDescriptor); +} + +//-------- +WatchID FileWatcherOSX::addWatch(const String& directory, FileWatchListener* watcher, bool recursive) { + /* int fd = open(directory.c_str(), O_RDONLY); + if(fd == -1) + perror("open"); + + EV_SET(&change, fd, EVFILT_VNODE, + EV_ADD | EV_ENABLE | EV_ONESHOT, + NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_ATTRIB, + 0, (void*)"testing"); + */ + + WatchStruct* watch = new WatchStruct(++mLastWatchID, directory, watcher); + mWatches.insert(std::make_pair(mLastWatchID, watch)); + return mLastWatchID; +} + +//-------- +void FileWatcherOSX::removeWatch(const String& directory) { + WatchMap::iterator iter = mWatches.begin(); + WatchMap::iterator end = mWatches.end(); + for(; iter != end; ++iter) { + if(directory == iter->second->mDirName) { + removeWatch(iter->first); + return; + } + } +} + +//-------- +void FileWatcherOSX::removeWatch(WatchID watchid) { + WatchMap::iterator iter = mWatches.find(watchid); + + if(iter == mWatches.end()) + return; + + WatchStruct* watch = iter->second; + mWatches.erase(iter); + + //inotify_rm_watch(mFD, watchid); + + delete watch; + watch = 0; +} + +//-------- +void FileWatcherOSX::handleAction(WatchStruct* watch, const String& filename, unsigned long action) { +} + +};//namespace FW + +#endif//FILEWATCHER_PLATFORM_KQUEUE diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherOSX.h b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherOSX.h new file mode 100644 index 0000000..39f411c --- /dev/null +++ b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherOSX.h @@ -0,0 +1,87 @@ +/** + Implementation header file for OSX based on KEvent. + + @author James Wynn + @date 4/15/2009 + + Copyright (c) 2009 James Wynn (james@jameswynn.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ +#ifndef _FW_FILEWATCHEROSX_H_ +#define _FW_FILEWATCHEROSX_H_ +#pragma once + +#include "FileWatcherImpl.h" + +#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_KQUEUE + +#include +#include + +namespace FW { +/// Implementation for OSX based on kqueue. +/// @class FileWatcherOSX +class FileWatcherOSX : public FileWatcherImpl { +public: + /// type for a map from WatchID to WatchStruct pointer + typedef std::map WatchMap; + +public: + /// + /// + FileWatcherOSX(); + + /// + /// + virtual ~FileWatcherOSX(); + + /// Add a directory watch + /// @exception FileNotFoundException Thrown when the requested directory does not exist + WatchID addWatch(const String& directory, FileWatchListener* watcher, bool recursive); + + /// Remove a directory watch. This is a brute force lazy search O(nlogn). + void removeWatch(const String& directory); + + /// Remove a directory watch. This is a map lookup O(logn). + void removeWatch(WatchID watchid); + + /// Updates the watcher. Must be called often. + void update(); + + /// Handles the action + void handleAction(WatchStruct* watch, const String& filename, unsigned long action); + +private: + /// Map of WatchID to WatchStruct pointers + WatchMap mWatches; + /// The descriptor for the kqueue + int mDescriptor; + /// time out data + struct timespec mTimeOut; + /// WatchID allocator + int mLastWatchID; + +};//end FileWatcherOSX + +};//namespace FW + +#endif//__APPLE_CC__ + +#endif//_FW_FILEWATCHEROSX_H_ diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherWin32.cpp b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherWin32.cpp new file mode 100644 index 0000000..ee5de7e --- /dev/null +++ b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherWin32.cpp @@ -0,0 +1,244 @@ +/** + Copyright (c) 2009 James Wynn (james@jameswynn.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#include + +#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_WIN32 + +#define _WIN32_WINNT 0x0550 +#include + +#if defined(_MSC_VER) +#pragma comment(lib, "comctl32.lib") +#pragma comment(lib, "user32.lib") +#pragma comment(lib, "ole32.lib") + +// disable secure warnings +#pragma warning (disable: 4996) +#endif + +namespace FW { +/// Internal watch data +struct WatchStruct { + OVERLAPPED mOverlapped; + HANDLE mDirHandle; + BYTE mBuffer[32 * 1024]; + LPARAM lParam; + DWORD mNotifyFilter; + bool mStopNow; + FileWatcherImpl* mFileWatcher; + FileWatchListener* mFileWatchListener; + char* mDirName; + WatchID mWatchid; + bool mIsRecursive; +}; + +#pragma region Internal Functions + +// forward decl +bool RefreshWatch(WatchStruct* pWatch, bool _clear = false); + +/// Unpacks events and passes them to a user defined callback. +void CALLBACK WatchCallback(DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped) { + TCHAR szFile[MAX_PATH]; + PFILE_NOTIFY_INFORMATION pNotify; + WatchStruct* pWatch = (WatchStruct*) lpOverlapped; + size_t offset = 0; + + if(dwNumberOfBytesTransfered == 0) + return; + + if (dwErrorCode == ERROR_SUCCESS) { + do { + pNotify = (PFILE_NOTIFY_INFORMATION) &pWatch->mBuffer[offset]; + offset += pNotify->NextEntryOffset; + +# if defined(UNICODE) + { + lstrcpynW(szFile, pNotify->FileName, + min(MAX_PATH, pNotify->FileNameLength / sizeof(WCHAR) + 1)); + } +# else + { + int count = WideCharToMultiByte(CP_ACP, 0, pNotify->FileName, + pNotify->FileNameLength / sizeof(WCHAR), + szFile, MAX_PATH - 1, NULL, NULL); + szFile[count] = TEXT('\0'); + } +# endif + + pWatch->mFileWatcher->handleAction(pWatch, szFile, pNotify->Action); + + } while (pNotify->NextEntryOffset != 0); + } + + if (!pWatch->mStopNow) { + RefreshWatch(pWatch); + } +} + +/// Refreshes the directory monitoring. +bool RefreshWatch(WatchStruct* pWatch, bool _clear) { + return ReadDirectoryChangesW( + pWatch->mDirHandle, pWatch->mBuffer, sizeof(pWatch->mBuffer), pWatch->mIsRecursive, + pWatch->mNotifyFilter, NULL, &pWatch->mOverlapped, _clear ? 0 : WatchCallback) != 0; +} + +/// Stops monitoring a directory. +void DestroyWatch(WatchStruct* pWatch) { + if (pWatch) { + pWatch->mStopNow = TRUE; + + CancelIo(pWatch->mDirHandle); + + RefreshWatch(pWatch, true); + + if (!HasOverlappedIoCompleted(&pWatch->mOverlapped)) { + SleepEx(5, TRUE); + } + + CloseHandle(pWatch->mOverlapped.hEvent); + CloseHandle(pWatch->mDirHandle); + delete pWatch->mDirName; + HeapFree(GetProcessHeap(), 0, pWatch); + } +} + +/// Starts monitoring a directory. +WatchStruct* CreateWatch(LPCTSTR szDirectory, bool recursive, DWORD mNotifyFilter) { + WatchStruct* pWatch; + size_t ptrsize = sizeof(*pWatch); + pWatch = static_cast(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ptrsize)); + + pWatch->mDirHandle = CreateFile(szDirectory, FILE_LIST_DIRECTORY, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, NULL); + + if (pWatch->mDirHandle != INVALID_HANDLE_VALUE) { + pWatch->mOverlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + pWatch->mNotifyFilter = mNotifyFilter; + pWatch->mIsRecursive = recursive; + + if (RefreshWatch(pWatch)) { + return pWatch; + } else { + CloseHandle(pWatch->mOverlapped.hEvent); + CloseHandle(pWatch->mDirHandle); + } + } + + HeapFree(GetProcessHeap(), 0, pWatch); + return NULL; +} + +#pragma endregion + +//-------- +FileWatcherWin32::FileWatcherWin32() + : mLastWatchID(0) { +} + +//-------- +FileWatcherWin32::~FileWatcherWin32() { + WatchMap::iterator iter = mWatches.begin(); + WatchMap::iterator end = mWatches.end(); + for(; iter != end; ++iter) { + DestroyWatch(iter->second); + } + mWatches.clear(); +} + +//-------- +WatchID FileWatcherWin32::addWatch(const String& directory, FileWatchListener* watcher, bool recursive) { + WatchID watchid = ++mLastWatchID; + + WatchStruct* watch = CreateWatch(directory.c_str(), recursive, + FILE_NOTIFY_CHANGE_CREATION | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_FILE_NAME); + + if(!watch) + throw FileNotFoundException(directory); + + watch->mWatchid = watchid; + watch->mFileWatcher = this; + watch->mFileWatchListener = watcher; + watch->mDirName = new char[directory.length()+1]; + strcpy(watch->mDirName, directory.c_str()); + + mWatches.insert(std::make_pair(watchid, watch)); + + return watchid; +} + +//-------- +void FileWatcherWin32::removeWatch(const String& directory) { + WatchMap::iterator iter = mWatches.begin(); + WatchMap::iterator end = mWatches.end(); + for(; iter != end; ++iter) { + if(directory == iter->second->mDirName) { + removeWatch(iter->first); + return; + } + } +} + +//-------- +void FileWatcherWin32::removeWatch(WatchID watchid) { + WatchMap::iterator iter = mWatches.find(watchid); + + if(iter == mWatches.end()) + return; + + WatchStruct* watch = iter->second; + mWatches.erase(iter); + + DestroyWatch(watch); +} + +//-------- +void FileWatcherWin32::update() { + MsgWaitForMultipleObjectsEx(0, NULL, 0, QS_ALLINPUT, MWMO_ALERTABLE); +} + +//-------- +void FileWatcherWin32::handleAction(WatchStruct* watch, const String& filename, unsigned long action) { + Action fwAction; + + switch(action) { + case FILE_ACTION_RENAMED_NEW_NAME: + case FILE_ACTION_ADDED: + fwAction = Actions::Add; + break; + case FILE_ACTION_RENAMED_OLD_NAME: + case FILE_ACTION_REMOVED: + fwAction = Actions::Delete; + break; + case FILE_ACTION_MODIFIED: + fwAction = Actions::Modified; + break; + }; + + watch->mFileWatchListener->handleFileAction(watch->mWatchid, watch->mDirName, filename, fwAction); +} + +};//namespace FW + +#endif//_WIN32 diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherWin32.h b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherWin32.h new file mode 100644 index 0000000..d1626b0 --- /dev/null +++ b/src/uscxml/plugins/invoker/filesystem/dirmon/FileWatcher/FileWatcherWin32.h @@ -0,0 +1,83 @@ +/** + Implementation for Windows. Uses ReadDirectoryChangesW to watch for + file system changes. + + @author James Wynn + @date 4/15/2009 + + Copyright (c) 2009 James Wynn (james@jameswynn.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ +#ifndef _FW_FILEWATCHERWIN32_H_ +#define _FW_FILEWATCHERWIN32_H_ +#pragma once + +#include "FileWatcherImpl.h" + +#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_WIN32 + +#include + +namespace FW { +/// Implementation for Win32 based on ReadDirectoryChangesW. +/// @class FileWatcherWin32 +class FileWatcherWin32 : public FileWatcherImpl { +public: + /// type for a map from WatchID to WatchStruct pointer + typedef std::map WatchMap; + +public: + /// + /// + FileWatcherWin32(); + + /// + /// + virtual ~FileWatcherWin32(); + + /// Add a directory watch + /// @exception FileNotFoundException Thrown when the requested directory does not exist + WatchID addWatch(const String& directory, FileWatchListener* watcher, bool recursive); + + /// Remove a directory watch. This is a brute force lazy search O(nlogn). + void removeWatch(const String& directory); + + /// Remove a directory watch. This is a map lookup O(logn). + void removeWatch(WatchID watchid); + + /// Updates the watcher. Must be called often. + void update(); + + /// Handles the action + void handleAction(WatchStruct* watch, const String& filename, unsigned long action); + +private: + /// Map of WatchID to WatchStruct pointers + WatchMap mWatches; + /// The last watchid + WatchID mLastWatchID; + +};//end FileWatcherWin32 + +};//namespace FW + +#endif//FILEWATCHER_PLATFORM_WIN32 + +#endif//_FW_FILEWATCHERWIN32_H_ diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp index 9e584c3..3b1a828 100644 --- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp +++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp @@ -39,9 +39,6 @@ void OSGInvoker::send(const SendRequest& req) { void OSGInvoker::cancel(const std::string sendId) { } -void OSGInvoker::sendToParent(const SendRequest& req) { -} - void OSGInvoker::invoke(const InvokeRequest& req) { tthread::lock_guard lock(_mutex); diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h index e65bff8..acfa55c 100644 --- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h +++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h @@ -34,7 +34,6 @@ public: virtual void send(const SendRequest& req); virtual void cancel(const std::string sendId); virtual void invoke(const InvokeRequest& req); - virtual void sendToParent(const SendRequest& req); virtual void handleEvent(Arabica::DOM::Events::Event& event); virtual void runOnMainThread(); @@ -95,7 +94,6 @@ protected: typedef std::map, osg::Node*> _nodes_t; tthread::recursive_mutex _mutex; - std::string _invokeId; }; #ifdef BUILD_AS_PLUGINS diff --git a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp index a983d58..1f08378 100644 --- a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp +++ b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp @@ -39,11 +39,7 @@ void HeartbeatInvoker::cancel(const std::string sendId) { HeartbeatDispatcher::getInstance()->cancelEvent(toStr(this)); } -void HeartbeatInvoker::sendToParent(const SendRequest& req) { -} - void HeartbeatInvoker::invoke(const InvokeRequest& req) { - _invokeId = req.invokeid; _event.invokeid = _invokeId; std::string intervalStr; double interval = 0; @@ -78,7 +74,7 @@ void HeartbeatInvoker::invoke(const InvokeRequest& req) { void HeartbeatInvoker::dispatch(void* instance, std::string name) { HeartbeatInvoker* invoker = (HeartbeatInvoker*)instance; - invoker->_interpreter->receive(invoker->_event); + invoker->returnEvent(invoker->_event); } HeartbeatDispatcher* HeartbeatDispatcher::_instance = NULL; diff --git a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h index a7f3cbd..11be295 100644 --- a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h +++ b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h @@ -18,7 +18,7 @@ public: virtual std::set getNames() { std::set names; names.insert("heartbeat"); - names.insert("http://uscxml.tk.informatik.tu-darmstadt.de/#heartbaet"); + names.insert("http://uscxml.tk.informatik.tu-darmstadt.de/#heartbeat"); return names; } @@ -26,12 +26,10 @@ public: virtual void send(const SendRequest& req); virtual void cancel(const std::string sendId); virtual void invoke(const InvokeRequest& req); - virtual void sendToParent(const SendRequest& req); static void dispatch(void* instance, std::string name); protected: - std::string _invokeId; Event _event; }; diff --git a/src/uscxml/plugins/invoker/sample/SampleInvoker.cpp b/src/uscxml/plugins/invoker/sample/SampleInvoker.cpp index 3678cc3..e7c2e10 100644 --- a/src/uscxml/plugins/invoker/sample/SampleInvoker.cpp +++ b/src/uscxml/plugins/invoker/sample/SampleInvoker.cpp @@ -21,8 +21,8 @@ SampleInvoker::SampleInvoker() { SampleInvoker::~SampleInvoker() { }; -Invoker* SampleInvoker::create(Interpreter* interpreter) { - SampleInvoker* invoker = new SampleInvoker(); +boost::shared_ptr SampleInvoker::create(Interpreter* interpreter) { + boost::shared_ptr invoker = boost::shared_ptr(new SampleInvoker()); invoker->_interpreter = interpreter; return invoker; } @@ -32,17 +32,13 @@ Data SampleInvoker::getDataModelVariables() { return data; } -void SampleInvoker::send(SendRequest& req) { +void SampleInvoker::send(const SendRequest& req) { } void SampleInvoker::cancel(const std::string sendId) { } -void SampleInvoker::sendToParent(SendRequest& req) { -} - -void SampleInvoker::invoke(InvokeRequest& req) { - _invokeId = req.invokeid; +void SampleInvoker::invoke(const InvokeRequest& req) { } } \ No newline at end of file diff --git a/src/uscxml/plugins/invoker/sample/SampleInvoker.h b/src/uscxml/plugins/invoker/sample/SampleInvoker.h index 1f30324..018dfc5 100644 --- a/src/uscxml/plugins/invoker/sample/SampleInvoker.h +++ b/src/uscxml/plugins/invoker/sample/SampleInvoker.h @@ -9,11 +9,11 @@ namespace uscxml { -class SampleInvoker : public Invoker { +class SampleInvoker : public InvokerImpl { public: SampleInvoker(); virtual ~SampleInvoker(); - virtual Invoker* create(Interpreter* interpreter); + virtual boost::shared_ptr create(Interpreter* interpreter); virtual std::set getNames() { std::set names; @@ -23,13 +23,11 @@ public: } virtual Data getDataModelVariables(); - virtual void send(SendRequest& req); + virtual void send(const SendRequest& req); virtual void cancel(const std::string sendId); - virtual void invoke(InvokeRequest& req); - virtual void sendToParent(SendRequest& req); + virtual void invoke(const InvokeRequest& req); protected: - std::string _invokeId; }; #ifdef BUILD_AS_PLUGINS diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp index bcdf2d4..4f7d61d 100644 --- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp +++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp @@ -42,23 +42,21 @@ void USCXMLInvoker::cancel(const std::string sendId) { assert(false); } -void USCXMLInvoker::sendToParent(const SendRequest& req) { - SendRequest parentReq = req; - parentReq.invokeid = _invokeId; - _parentInterpreter->receive(parentReq); -} - void USCXMLInvoker::invoke(const InvokeRequest& req) { - _invokeId = req.invokeid; _invokedInterpreter = Interpreter::fromURI(req.src); DataModel dataModel(_invokedInterpreter->getDataModel()); if (dataModel) { } if (_invokedInterpreter) { - _invokedInterpreter->setInvoker(boost::static_pointer_cast(shared_from_this())); + _invokedInterpreter->setParentQueue(this); _invokedInterpreter->start(); } } +void USCXMLInvoker::push(Event& event) { + event.invokeid = _invokeId; + _parentInterpreter->receive(event); +} + } \ No newline at end of file diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h index 62851e3..792cc5d 100644 --- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h +++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h @@ -2,7 +2,8 @@ #define USCXMLINVOKER_H_OQFA21IO #include -#include +#include +#include "uscxml/concurrency/BlockingQueue.h" #ifdef BUILD_AS_PLUGINS #include "uscxml/plugins/Plugins.h" @@ -12,7 +13,10 @@ namespace uscxml { class Interpreter; -class USCXMLInvoker : public InvokerImpl, public boost::enable_shared_from_this { +class USCXMLInvoker : + public InvokerImpl, + public uscxml::concurrency::BlockingQueue, + public boost::enable_shared_from_this { public: USCXMLInvoker(); virtual ~USCXMLInvoker(); @@ -29,10 +33,10 @@ public: virtual void send(const SendRequest& req); virtual void cancel(const std::string sendId); virtual void invoke(const InvokeRequest& req); - virtual void sendToParent(const SendRequest& req); + + virtual void push(Event& event); protected: - std::string _invokeId; Interpreter* _invokedInterpreter; Interpreter* _parentInterpreter; }; diff --git a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp index c269869..1e15865 100644 --- a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp +++ b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp @@ -80,12 +80,11 @@ void UmundoInvoker::send(const SendRequest& req) { protobufToData(event, *(const google::protobuf::Message*)rv); event.name = _invokeId + ".reply." + req.name; - event.invokeid = _invokeId; event.origin = msg->getMeta("um.channel"); event.origintype = "umundo"; event.type = Event::EXTERNAL; - _interpreter->receive(event); + returnEvent(event); svcIter++; } } @@ -105,12 +104,7 @@ void UmundoInvoker::cancel(const std::string sendId) { assert(false); } -void UmundoInvoker::sendToParent(const SendRequest& req) { - assert(false); -} - void UmundoInvoker::invoke(const InvokeRequest& req) { - _invokeId = req.invokeid; std::string domain; std::string channelName; @@ -201,7 +195,7 @@ void UmundoInvoker::receive(void* object, umundo::Message* msg) { metaIter++; } - _interpreter->receive(event); + returnEvent(event); } void UmundoInvoker::added(umundo::ServiceDescription desc) { @@ -223,7 +217,7 @@ void UmundoInvoker::added(umundo::ServiceDescription desc) { propIter++; } - _interpreter->receive(addedEvent); + returnEvent(addedEvent); } void UmundoInvoker::removed(umundo::ServiceDescription desc) { @@ -249,7 +243,7 @@ void UmundoInvoker::removed(umundo::ServiceDescription desc) { propIter++; } - _interpreter->receive(addedEvent); + returnEvent(addedEvent); } void UmundoInvoker::changed(umundo::ServiceDescription desc) { diff --git a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h index 58fa5d8..f03006b 100644 --- a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h +++ b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h @@ -34,7 +34,6 @@ public: virtual void send(const SendRequest& req); virtual void cancel(const std::string sendId); virtual void invoke(const InvokeRequest& req); - virtual void sendToParent(const SendRequest& req); virtual void receive(void* object, umundo::Message* msg); @@ -43,7 +42,6 @@ public: virtual void changed(umundo::ServiceDescription); protected: - std::string _invokeId; bool _isService; bool dataToProtobuf(google::protobuf::Message* msg, Data& data); diff --git a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp index eb5d77b..b051310 100644 --- a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp +++ b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp @@ -243,7 +243,7 @@ void EventIOProcessor::httpRecvReq(struct evhttp_request *req, void *arg) { } EventIOProcessor* INSTANCE = (EventIOProcessor*)arg; - INSTANCE->_interpreter->receive(reqEvent); + INSTANCE->returnEvent(reqEvent); evhttp_send_reply(req, 200, "OK", NULL); } diff --git a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h index d07bab5..3afe463 100644 --- a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h +++ b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h @@ -57,7 +57,6 @@ protected: std::string _url; uscxml::DelayedEventQueue _asyncQueue; - uscxml::Interpreter* _interpreter; std::map _httpConnections; std::map _httpRequests; struct evdns_base* _dns; diff --git a/test/samples/uscxml/demos/3d-file-server.scxml b/test/samples/uscxml/demos/3d-file-server.scxml new file mode 100644 index 0000000..4823127 --- /dev/null +++ b/test/samples/uscxml/demos/3d-file-server.scxml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/test/samples/uscxml/test-dirmon.scxml b/test/samples/uscxml/test-dirmon.scxml new file mode 100644 index 0000000..872757f --- /dev/null +++ b/test/samples/uscxml/test-dirmon.scxml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/test/samples/uscxml/test-umundo-s11n.scxml b/test/samples/uscxml/test-umundo-s11n.scxml index 001d72e..f4a9a02 100644 --- a/test/samples/uscxml/test-umundo-s11n.scxml +++ b/test/samples/uscxml/test-umundo-s11n.scxml @@ -1,25 +1,25 @@